|
| 1 | +const baseConfig = { |
| 2 | + env: { node: true }, |
| 3 | + plugins: ['import'], |
| 4 | + parser: '@typescript-eslint/parser', |
| 5 | + parserOptions: { |
| 6 | + project: ['./tsconfig.eslint.json'], |
| 7 | + }, |
| 8 | + extends: [ |
| 9 | + 'airbnb', |
| 10 | + 'airbnb/hooks', |
| 11 | + 'plugin:import/recommended', |
| 12 | + ], |
| 13 | + rules: { |
| 14 | + 'max-len': [ |
| 15 | + 'warn', |
| 16 | + { |
| 17 | + code: 80, |
| 18 | + tabWidth: 2, |
| 19 | + ignoreComments: true, |
| 20 | + }, |
| 21 | + ], |
| 22 | + 'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], |
| 23 | + 'import/order': [ |
| 24 | + 'error', |
| 25 | + { alphabetize: { order: 'asc' } }, |
| 26 | + ], |
| 27 | + }, |
| 28 | +}; |
| 29 | + |
| 30 | +const tsConfig = { |
| 31 | + files: ['*.ts', '*.tsx'], |
| 32 | + excludedFiles: ['*.spec.ts', '*.spec.tsx', '*.test.ts', '*.test.tsx'], |
| 33 | + plugins: [ |
| 34 | + ...baseConfig.plugins, |
| 35 | + '@typescript-eslint', |
| 36 | + ], |
| 37 | + extends: [ |
| 38 | + ...baseConfig.extends, |
| 39 | + 'airbnb-typescript', |
| 40 | + 'plugin:import/typescript', |
| 41 | + 'plugin:@typescript-eslint/recommended', |
| 42 | + 'plugin:@typescript-eslint/recommended-requiring-type-checking', |
| 43 | + ], |
| 44 | + rules: { |
| 45 | + ...baseConfig.rules, |
| 46 | + // disable rules covered by TypesScript compiler |
| 47 | + 'import/default': 'off', |
| 48 | + 'import/named': 'off', |
| 49 | + 'import/namespace': 'off', |
| 50 | + 'import/no-named-as-default-member': 'off', |
| 51 | + // disable rules for better local performance |
| 52 | + 'import/no-cycle': 'off', |
| 53 | + 'import/no-deprecated': 'off', |
| 54 | + 'import/no-named-as-default': 'off', |
| 55 | + 'import/no-unused-modules': 'off', |
| 56 | + }, |
| 57 | + settings: { |
| 58 | + 'import/parsers': { '@typescript-eslint/parser': ['.ts', '.tsx'] }, |
| 59 | + 'import/resolver': { |
| 60 | + typescript: { |
| 61 | + alwaysTryTypes: true, |
| 62 | + project: ['./tsconfig.eslint.json'], |
| 63 | + }, |
| 64 | + }, |
| 65 | + }, |
| 66 | +}; |
| 67 | + |
| 68 | +const jestConfig = { |
| 69 | + files: ['*.spec.ts', '*.spec.tsx', '*.test.ts', '*.test.tsx'], |
| 70 | + env: { node: true, 'jest/globals': true }, |
| 71 | + plugins: [ |
| 72 | + ...tsConfig.plugins, |
| 73 | + 'jest', |
| 74 | + ], |
| 75 | + extends: [ |
| 76 | + ...tsConfig.extends, |
| 77 | + 'plugin:jest/recommended', |
| 78 | + 'plugin:jest/style', |
| 79 | + ], |
| 80 | + rules: { |
| 81 | + ...tsConfig.rules, |
| 82 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 83 | + }, |
| 84 | + settings: tsConfig.settings, |
| 85 | +}; |
| 86 | + |
| 87 | +const specialConfig = { |
| 88 | + files: ['**/*.config.js', '**/*.config.*.js'], |
| 89 | + rules: { |
| 90 | + ...baseConfig.rules, |
| 91 | + 'import/no-extraneous-dependencies': 'off', |
| 92 | + }, |
| 93 | +}; |
| 94 | + |
| 95 | +module.exports = { |
| 96 | + root: true, |
| 97 | + ...baseConfig, |
| 98 | + overrides: [ |
| 99 | + tsConfig, |
| 100 | + jestConfig, |
| 101 | + specialConfig, |
| 102 | + ], |
| 103 | +}; |
0 commit comments