|
| 1 | +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'; |
| 2 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 3 | +import _import from 'eslint-plugin-import'; |
| 4 | +import jest from 'eslint-plugin-jest'; |
| 5 | +import prettier from 'eslint-plugin-prettier'; |
| 6 | +import tsParser from '@typescript-eslint/parser'; |
| 7 | +import path from 'node:path'; |
| 8 | +import { fileURLToPath } from 'node:url'; |
| 9 | +import js from '@eslint/js'; |
| 10 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 11 | + |
| 12 | +const __filename = fileURLToPath(import.meta.url); |
| 13 | +const __dirname = path.dirname(__filename); |
| 14 | +const compat = new FlatCompat({ |
| 15 | + baseDirectory: __dirname, |
| 16 | + recommendedConfig: js.configs.recommended, |
| 17 | + allConfig: js.configs.all |
| 18 | +}); |
| 19 | + |
| 20 | +export default [ |
| 21 | + { |
| 22 | + ignores: ['**/coverage', '**/dist', '**/node_modules', '**/*.js'] |
| 23 | + }, |
| 24 | + ...fixupConfigRules( |
| 25 | + compat.extends( |
| 26 | + 'eslint:recommended', |
| 27 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 28 | + 'plugin:@typescript-eslint/recommended', |
| 29 | + 'plugin:@typescript-eslint/recommended-type-checked', |
| 30 | + 'plugin:@typescript-eslint/stylistic-type-checked', |
| 31 | + 'airbnb-base', |
| 32 | + 'prettier', |
| 33 | + 'plugin:import/recommended', |
| 34 | + 'plugin:import/errors', |
| 35 | + 'plugin:import/warnings', |
| 36 | + 'plugin:jest/all' |
| 37 | + ) |
| 38 | + ), |
| 39 | + { |
| 40 | + plugins: { |
| 41 | + '@typescript-eslint': fixupPluginRules(typescriptEslint), |
| 42 | + import: fixupPluginRules(_import), |
| 43 | + jest: fixupPluginRules(jest), |
| 44 | + prettier |
| 45 | + }, |
| 46 | + |
| 47 | + languageOptions: { |
| 48 | + parser: tsParser, |
| 49 | + ecmaVersion: 5, |
| 50 | + sourceType: 'script', |
| 51 | + |
| 52 | + parserOptions: { |
| 53 | + project: true |
| 54 | + } |
| 55 | + }, |
| 56 | + |
| 57 | + settings: { |
| 58 | + 'import/parsers': { |
| 59 | + '@typescript-eslint/parser': ['.ts', '.tsx'] |
| 60 | + }, |
| 61 | + |
| 62 | + 'import/resolver': { |
| 63 | + typescript: { |
| 64 | + alwaysTryTypes: true, |
| 65 | + project: '.' |
| 66 | + } |
| 67 | + } |
| 68 | + }, |
| 69 | + |
| 70 | + rules: { |
| 71 | + 'prettier/prettier': ['error'], |
| 72 | + |
| 73 | + 'import/extensions': [ |
| 74 | + 'error', |
| 75 | + 'always', |
| 76 | + { |
| 77 | + pattern: { |
| 78 | + ts: 'never' |
| 79 | + } |
| 80 | + } |
| 81 | + ], |
| 82 | + |
| 83 | + 'no-restricted-syntax': 0, |
| 84 | + 'no-console': 'off', |
| 85 | + 'no-underscore-dangle': 0, |
| 86 | + |
| 87 | + 'no-plusplus': [ |
| 88 | + 'error', |
| 89 | + { |
| 90 | + allowForLoopAfterthoughts: true |
| 91 | + } |
| 92 | + ], |
| 93 | + |
| 94 | + 'no-shadow': 'off', |
| 95 | + '@typescript-eslint/no-shadow': 'error', |
| 96 | + 'no-unused-vars': 'off', |
| 97 | + '@typescript-eslint/no-unused-vars': 'error', |
| 98 | + 'no-use-before-define': 'off', |
| 99 | + '@typescript-eslint/no-use-before-define': 'error' |
| 100 | + } |
| 101 | + }, |
| 102 | + { |
| 103 | + files: ['**/*.ts', '**/*.mts', '**/*.cts', '**/*.tsx'], |
| 104 | + |
| 105 | + rules: { |
| 106 | + '@typescript-eslint/explicit-function-return-type': 'error' |
| 107 | + } |
| 108 | + }, |
| 109 | + { |
| 110 | + ignores: ["dist/*", "coverage/*", "node_modules/*", "eslint.config.mjs"] |
| 111 | + } |
| 112 | +]; |
0 commit comments