Skip to content

Commit

Permalink
chore(eslint): replace eslint-config-react-app with less and relate…
Browse files Browse the repository at this point in the history
…d plugins

- install package @typescript-eslint/eslint-plugin@5.26.0
- install package eslint-plugin-playwright@0.11.1
- install package eslint-plugin-react@7.30.0
- install package eslint-plugin-react-hooks@4.5.0
- uninstall package eslint-config-react-app@7.0.1
- update eslint configuration
  • Loading branch information
SimonGolms committed Aug 31, 2022
1 parent a997b2d commit bcd9a40
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 20 deletions.
43 changes: 32 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
module.exports = {
env: {
browser: true,
es2022: true,
node: true,
worker: true,
},
extends: [
'react-app',
'react-app/jest',
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/jsx-runtime',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:jsx-a11y/recommended',
'plugin:playwright/playwright-test',
'plugin:sonarjs/recommended',
'plugin:typescript-sort-keys/recommended',
// HINT: prettier must be the last extension to work
'plugin:prettier/recommended',
],
ignorePatterns: ['build', 'docker', 'node_modules', 'openshift', 'public'],
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
'no-undef': 'off',
'no-unused-vars': 'off',
},
},
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
Expand All @@ -26,6 +44,14 @@ module.exports = {
'prettier',
],
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/sort-type-union-intersection-members': 'error',
camelcase: 'warn',
curly: 'error',
Expand Down Expand Up @@ -64,15 +90,8 @@ module.exports = {
],
'import/prefer-default-export': 'off',
'no-console': ['warn', { allow: ['warn', 'error'] }],
'no-restricted-imports': [
'error',
{
patterns: ['@mui/*/*/*', '!@mui/material/test-utils/*'],
},
],
'no-type-assertion/no-type-assertion': 'error',
'prettier/prettier': 'error',
'react/display-name': 'off',
'react/jsx-sort-default-props': 'error',
'react/jsx-sort-props': [
'error',
Expand All @@ -85,8 +104,7 @@ module.exports = {
shorthandLast: false,
},
],
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off', // do not overeager and inferred the type
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
'sort-imports': [
Expand All @@ -113,5 +131,8 @@ module.exports = {
alwaysTryTypes: true,
},
},
react: {
version: 'detect',
},
},
};
4 changes: 2 additions & 2 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
'*.css': ['stylelint --fix', 'git add --force'],
'*.{js,jsx,ts,tsx}': [
// Extend rule set of .eslintrc.js with 'no-console' and 'no-unused-vars'
"eslint --fix --rule 'no-console: [error, { allow: [warn, error] }]' --rule 'no-unused-vars: error'",
// Extend rule levels based on .eslintrc.js
"eslint --fix --rule '@typescript-eslint/no-unused-vars: error' --rule 'no-console: error'",
'git add --force',
],
'*.json': ['prettier --write', 'git add --force'],
Expand Down
35 changes: 29 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,23 @@
"@types/react-dom": "18.0.6",
"@types/react-router": "5.1.18",
"@types/react-router-dom": "5.3.3",
"@typescript-eslint/eslint-plugin": "5.26.0",
"@typescript-eslint/parser": "5.36.1",
"@vitejs/plugin-react": "2.0.1",
"conventional-changelog-conventionalcommits": "5.0.0",
"eslint": "8.23.0",
"eslint-config-prettier": "8.5.0",
"eslint-config-react-app": "7.0.1",
"eslint-import-resolver-typescript": "3.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-plugin-no-type-assertion": "1.3.0",
"eslint-plugin-playwright": "0.11.1",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-sonarjs": "0.15.0",
"eslint-plugin-sort-keys-fix": "1.1.2",
"eslint-plugin-typescript-sort-keys": "2.1.0",
"eslint-plugin-react": "7.30.0",
"eslint-plugin-react-hooks": "4.5.0",
"husky": "8.0.1",
"lint-staged": "13.0.3",
"prettier": "2.7.1",
Expand Down

0 comments on commit bcd9a40

Please sign in to comment.