|
1 | 1 | module.exports = {
|
| 2 | + parser: '@typescript-eslint/parser', |
| 3 | + parserOptions: { |
| 4 | + sourceType: 'module', |
| 5 | + project: './tsconfig.json', |
| 6 | + }, |
2 | 7 | env: {
|
3 | 8 | browser: true,
|
4 |
| - es6: true, |
5 | 9 | node: true,
|
6 |
| - jest: true, |
7 | 10 | },
|
8 |
| - ignorePatterns: ['setupTests.tsx', '*.test.ts*', '*.stories.tsx'], |
| 11 | + plugins: ['import'], |
9 | 12 | extends: [
|
10 |
| - // non-ts recommended rules |
11 | 13 | 'eslint:recommended',
|
12 |
| - // remove non-ts rules covered by typescript-eslint |
13 |
| - 'plugin:@typescript-eslint/eslint-recommended', |
14 |
| - // ts recommended rules |
15 |
| - // can be slow |
| 14 | + 'plugin:import/errors', |
| 15 | + 'plugin:import/warnings', |
| 16 | + 'plugin:import/typescript', |
| 17 | + 'plugin:react/recommended', |
| 18 | + 'plugin:react-hooks/recommended', |
| 19 | + 'plugin:jsx-a11y/recommended', |
| 20 | + 'plugin:jest/recommended', |
| 21 | + 'plugin:jest/style', |
| 22 | + 'plugin:jest-dom/recommended', |
16 | 23 | 'plugin:@typescript-eslint/recommended',
|
17 |
| - // ts recommended rules that require tsconfig.json to be specified in parserOptions.project |
18 |
| - // can be slow |
19 | 24 | 'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
20 |
| - 'prettier/@typescript-eslint', |
21 |
| - |
22 |
| - 'plugin:react/recommended', |
23 |
| - 'plugin:security/recommended', |
24 |
| - // remove rules covered by prettier |
25 |
| - 'prettier/@typescript-eslint', |
26 |
| - 'plugin:prettier/recommended', |
| 25 | + 'prettier', |
| 26 | + 'plugin:storybook/recommended', |
27 | 27 | ],
|
28 |
| - globals: { |
29 |
| - Atomics: 'readonly', |
30 |
| - SharedArrayBuffer: 'readonly', |
31 |
| - }, |
32 |
| - parser: '@typescript-eslint/parser', |
33 |
| - parserOptions: { |
34 |
| - ecmaFeatures: { |
35 |
| - jsx: true, |
36 |
| - modules: true, |
| 28 | + settings: { |
| 29 | + react: { |
| 30 | + // to indicate latest version |
| 31 | + // https://github.com/yannickcr/eslint-plugin-react/blob/b8e91a571bc6b58cc3c78e9e62e8b60ecb45e233/lib/util/version.js#L48 |
| 32 | + version: '999.999.999', |
| 33 | + }, |
| 34 | + 'import/parsers': { |
| 35 | + '@typescript-eslint/parser': ['.ts', '.tsx'], |
| 36 | + }, |
| 37 | + 'import/resolver': { |
| 38 | + typescript: { |
| 39 | + alwaysTryTypes: true, |
| 40 | + }, |
37 | 41 | },
|
38 |
| - ecmaVersion: 2018, |
39 |
| - sourceType: 'module', |
40 |
| - project: ['./tsconfig.json'], |
41 | 42 | },
|
42 |
| - plugins: ['react', '@typescript-eslint'], |
43 | 43 | rules: {
|
44 |
| - '@typescript-eslint/ban-ts-ignore': 'off', |
45 |
| - '@typescript-eslint/ban-types': 'warn', |
46 |
| - '@typescript-eslint/interface-name-prefix': 'off', |
47 |
| - '@typescript-eslint/naming-convention': [ |
48 |
| - 'warn', |
49 |
| - { |
50 |
| - selector: 'function', |
51 |
| - format: ['camelCase', 'PascalCase'], |
52 |
| - }, |
53 |
| - ], |
54 |
| - '@typescript-eslint/no-base-to-string': 'warn', |
55 |
| - '@typescript-eslint/no-empty-function': 'warn', |
| 44 | + 'import/default': 'off', |
| 45 | + 'import/no-default-export': 'off', |
| 46 | + 'react/display-name': 'off', |
| 47 | + 'import/no-named-as-default-member': 'warn', |
| 48 | + // see for rational https://basarat.gitbook.io/typescript/main-1/defaultisbad |
| 49 | + 'import/no-default-export': 'error', |
| 50 | + '@typescript-eslint/restrict-template-expressions': 'off', |
| 51 | + '@typescript-eslint/ban-ts-comment': 'warn', |
56 | 52 | '@typescript-eslint/no-explicit-any': 'warn',
|
57 |
| - '@typescript-eslint/no-floating-promises': 'error', |
58 |
| - '@typescript-eslint/no-implied-eval': 'warn', |
59 |
| - '@typescript-eslint/no-inferrable-types': 'warn', |
60 |
| - '@typescript-eslint/no-misused-promises': 'error', |
61 |
| - '@typescript-eslint/no-non-null-assertion': 'warn', |
62 |
| - '@typescript-eslint/no-throw-literal': 'warn', |
63 |
| - '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn', |
64 |
| - '@typescript-eslint/no-unnecessary-condition': 'warn', |
65 |
| - '@typescript-eslint/no-unnecessary-qualifier': 'warn', |
66 |
| - '@typescript-eslint/no-unnecessary-type-arguments': 'warn', |
67 |
| - '@typescript-eslint/no-unnecessary-type-assertion': 'warn', |
68 | 53 | '@typescript-eslint/no-unsafe-assignment': 'warn',
|
69 | 54 | '@typescript-eslint/no-unsafe-call': 'warn',
|
70 | 55 | '@typescript-eslint/no-unsafe-member-access': 'warn',
|
71 | 56 | '@typescript-eslint/no-unsafe-return': 'warn',
|
72 |
| - '@typescript-eslint/no-unused-vars-experimental': 'off', |
73 |
| - '@typescript-eslint/prefer-nullish-coalescing': 'warn', |
74 |
| - '@typescript-eslint/prefer-readonly': 'warn', |
75 |
| - // Ideally this would be on, but it has too many false positives. Should apply to arrays but seems to apply to everything, potentially a bug |
76 |
| - '@typescript-eslint/prefer-readonly-parameter-types': 'off', |
77 |
| - '@typescript-eslint/prefer-reduce-type-parameter': 'warn', |
78 |
| - '@typescript-eslint/prefer-regexp-exec': 'warn', |
79 |
| - '@typescript-eslint/promise-function-async': 'error', |
80 |
| - '@typescript-eslint/promise-function-async': 'error', |
81 |
| - '@typescript-eslint/require-array-sort-compare': 'warn', |
82 |
| - // require-await is incompatible with promise-function-async |
83 |
| - '@typescript-eslint/require-await': 'off', |
84 |
| - '@typescript-eslint/restrict-plus-operands': 'warn', |
85 |
| - '@typescript-eslint/restrict-template-expressions': [ |
86 |
| - 'warn', |
87 |
| - { |
88 |
| - allowNumber: true, |
89 |
| - allowBoolean: true, |
90 |
| - allowNullable: false, |
| 57 | + '@typescript-eslint/no-this-alias': 'warn', |
| 58 | + }, |
| 59 | + overrides: [ |
| 60 | + { |
| 61 | + // required because of https://github.com/yannickcr/eslint-plugin-react/issues/2353 |
| 62 | + // otherwise get missing prop-types error in tsx files |
| 63 | + files: ['**/*.tsx'], |
| 64 | + rules: { |
| 65 | + 'react/prop-types': 'off', |
91 | 66 | },
|
92 |
| - ], |
93 |
| - '@typescript-eslint/strict-boolean-expressions': 'warn', |
94 |
| - '@typescript-eslint/switch-exhaustiveness-check': 'warn', |
95 |
| - // TODO: We use this in mocks in .spec.ts, perhaps syntax is incorrect? |
96 |
| - '@typescript-eslint/unbound-method': 'off', |
97 |
| - 'react/jsx-pascal-case': [ |
98 |
| - 'warn', |
99 |
| - { |
100 |
| - ignore: [ |
101 |
| - 'h1', |
102 |
| - 'h2', |
103 |
| - 'h3', |
104 |
| - 'h4', |
105 |
| - 'h5', |
106 |
| - 'h6', |
107 |
| - 'd1', |
108 |
| - 'd2', |
109 |
| - 'd3', |
110 |
| - 'd4', |
111 |
| - 'd5', |
112 |
| - 'd6', |
113 |
| - ], |
| 67 | + }, |
| 68 | + { |
| 69 | + // allow node_module mocks to have default exports |
| 70 | + files: ['__mocks__/**/*'], |
| 71 | + rules: { |
| 72 | + 'import/no-default-export': 'off', |
114 | 73 | },
|
115 |
| - ], |
116 |
| - }, |
| 74 | + }, |
| 75 | + ], |
| 76 | + ignorePatterns: [ |
| 77 | + 'dist', |
| 78 | + 'docs', |
| 79 | + 'example', |
| 80 | + 'node_modules', |
| 81 | + '**/*.stories.tsx', |
| 82 | + '**/*.test.ts', |
| 83 | + ], |
117 | 84 | }
|
0 commit comments