npm i prettier eslint eslint-config-prettier eslint-config-standard eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-tailwindcss @typescript-eslint/eslint-plugin @typescript-eslint/parser -D
.eslintrc.js
:
module.exports = {
env: {
browser: true,
es2021: true,
jest: true,
},
extends: [
"standard",
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:tailwindcss/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: "latest",
sourceType: "module",
plugins: ["jsx-a11y", "@typescript-eslint"],
rules: {
"prettier/prettier": [
"error",
{
printWidth: 80,
tabWidth: 2,
singleQuote: true,
trailingComma: "all",
arrowParens: "always",
semi: true,
endOfLine: "auto",
},
],
"jsx-a11y/alt-text": [
"warn",
{
elements: ["img"],
img: ["Image"],
},
],
"jsx-a11y/aria-props": "warn",
"jsx-a11y/aria-proptypes": "warn",
"jsx-a11y/aria-unsupported-elements": "warn",
"jsx-a11y/role-has-required-aria-props": "warn",
"jsx-a11y/role-supports-aria-props": "warn",
},
settings: {
react: {
version: "detect",
},
"import/parsers": {
[require.resolve("@typescript-eslint/parser")]: [
".ts",
".tsx",
".d.ts",
],
},
},
},
};
package.json
:
"scripts": {
"lint": "npx eslint ./src --ext .ts",
"lint:fix": "npx eslint ./src --ext .ts --fix"
}
.vsconfig/settings.json
:
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
}
}
npm i prettier eslint eslint-config-prettier eslint-config-standard eslint-plugin-import eslint-plugin-prettier @typescript-eslint/eslint-plugin @typescript-eslint/parser -D
.eslintrc.js
:
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
'standard',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
rules: {
'prettier/prettier': [
'error',
{
printWidth: 80,
tabWidth: 2,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'always',
semi: false,
},
],
},
settings: {
'import/parsers': {
[require.resolve('@typescript-eslint/parser')]: ['.ts', '.tsx', '.d.ts'],
},
},
}