|
11 | 11 | // See the License for the specific language governing permissions and |
12 | 12 | // limitations under the License. |
13 | 13 |
|
| 14 | +// Base eslint configuration for typescript projects |
14 | 15 | module.exports = { |
15 | 16 | extends: [ |
16 | 17 | 'eslint:recommended', |
17 | 18 | 'plugin:react/recommended', |
18 | | - 'plugin:react-hooks/recommended', |
| 19 | + 'plugin:react-hooks/recommended-legacy', |
19 | 20 | 'plugin:jsx-a11y/recommended', |
20 | 21 | 'plugin:@typescript-eslint/recommended', |
21 | 22 | 'plugin:prettier/recommended', |
@@ -48,30 +49,73 @@ module.exports = { |
48 | 49 | }, |
49 | 50 |
|
50 | 51 | rules: { |
51 | | - 'prettier/prettier': 'error', |
52 | | - '@typescript-eslint/explicit-function-return-type': 'off', |
53 | | - '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 52 | + '@typescript-eslint/explicit-function-return-type': 'error', |
| 53 | + '@typescript-eslint/explicit-module-boundary-types': 'error', |
54 | 54 | '@typescript-eslint/array-type': [ |
55 | 55 | 'error', |
56 | 56 | { |
57 | 57 | default: 'array-simple', |
58 | 58 | }, |
59 | 59 | ], |
60 | | - 'import/order': 'error', |
| 60 | + '@typescript-eslint/no-unused-vars': [ |
| 61 | + 'error', |
| 62 | + { |
| 63 | + argsIgnorePattern: '^_', |
| 64 | + varsIgnorePattern: '^_', |
| 65 | + caughtErrorsIgnorePattern: '^_', |
| 66 | + }, |
| 67 | + ], |
61 | 68 | // you must disable the base rule as it can report incorrect errors |
62 | 69 | 'no-unused-vars': 'off', |
63 | | - '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], |
64 | 70 |
|
65 | | - 'react/prop-types': 'off', |
66 | | - 'react-hooks/exhaustive-deps': 'error', |
67 | | - // Not necessary in React 17 |
68 | | - 'react/react-in-jsx-scope': 'off', |
69 | | - 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never', propElementValues: 'always' }], |
| 71 | + 'prettier/prettier': 'error', |
| 72 | + |
| 73 | + eqeqeq: ['error', 'always'], |
70 | 74 |
|
71 | 75 | // We use this rule instead of the core eslint `no-duplicate-imports` |
72 | 76 | // because it avoids false errors on cases where we have a regular |
73 | | - // import and an `import type`. |
| 77 | + // import and an `import type` |
74 | 78 | 'import/no-duplicates': 'error', |
| 79 | + 'import/order': 'error', |
| 80 | + |
| 81 | + // Not necessary in React 17 |
| 82 | + 'react/react-in-jsx-scope': 'off', |
| 83 | + 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never', propElementValues: 'always' }], |
| 84 | + 'react-hooks/exhaustive-deps': 'error', |
| 85 | + 'react-hooks/error-boundaries': 'error', |
| 86 | + 'react-hooks/globals': 'error', |
| 87 | + 'react-hooks/immutability': 'error', |
| 88 | + 'react-hooks/purity': 'error', |
| 89 | + 'react-hooks/refs': 'error', |
| 90 | + 'react-hooks/set-state-in-effect': 'error', |
| 91 | + 'react-hooks/set-state-in-render': 'error', |
| 92 | + 'react-hooks/static-components': 'error', |
| 93 | + 'react-hooks/unsupported-syntax': 'error', |
| 94 | + 'react-hooks/use-memo': 'error', |
| 95 | + |
| 96 | + 'no-restricted-imports': [ |
| 97 | + 'error', |
| 98 | + { |
| 99 | + patterns: [ |
| 100 | + { |
| 101 | + /** |
| 102 | + * This library is gigantic and named imports end up slowing down builds/blowing out bundle sizes, |
| 103 | + * so this prevents that style of import. |
| 104 | + */ |
| 105 | + group: ['mdi-material-ui', '!mdi-material-ui/'], |
| 106 | + message: ` |
| 107 | +Please use the default import from the icon file directly rather than using a named import. |
| 108 | +
|
| 109 | +Good: |
| 110 | +import IconName from 'mdi-material-ui/IconName'; |
| 111 | +
|
| 112 | +Bad: |
| 113 | +import { IconName } from 'mdi-material-ui'; |
| 114 | +`, |
| 115 | + }, |
| 116 | + ], |
| 117 | + }, |
| 118 | + ], |
75 | 119 | }, |
76 | 120 |
|
77 | 121 | ignorePatterns: ['**/dist'], |
|
0 commit comments