|
| 1 | +import js from '@eslint/js'; |
| 2 | +import gitignore from 'eslint-config-flat-gitignore'; |
| 3 | +import prettierConfig from 'eslint-config-prettier'; |
| 4 | +import reactPlugin from 'eslint-plugin-react'; |
| 5 | +import reactHooks from 'eslint-plugin-react-hooks'; |
| 6 | +import globals from 'globals'; |
| 7 | +import tseslint from 'typescript-eslint'; |
| 8 | + |
| 9 | +export default tseslint.config( |
| 10 | + gitignore(), |
| 11 | + js.configs.recommended, |
| 12 | + tseslint.configs.recommendedTypeChecked, |
| 13 | + { |
| 14 | + languageOptions: { |
| 15 | + parserOptions: { |
| 16 | + projectService: true, |
| 17 | + tsconfigRootDir: import.meta.dirname, |
| 18 | + }, |
| 19 | + globals: { ...globals.browser, ...globals.node, ...globals.es2020 }, |
| 20 | + }, |
| 21 | + rules: { |
| 22 | + eqeqeq: 'error', |
| 23 | + 'no-param-reassign': 'error', |
| 24 | + 'object-shorthand': ['error', 'always'], |
| 25 | + 'prefer-template': 'error', |
| 26 | + '@typescript-eslint/consistent-type-imports': 'error', |
| 27 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 28 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 29 | + '@typescript-eslint/no-explicit-any': 'error', |
| 30 | + '@typescript-eslint/explicit-function-return-type': 'error', |
| 31 | + '@typescript-eslint/no-unnecessary-condition': 'error', |
| 32 | + complexity: ['error', 5], |
| 33 | + 'max-depth': ['error', 2], |
| 34 | + 'max-nested-callbacks': ['error', 3], |
| 35 | + 'max-lines': ['error', 200], |
| 36 | + 'func-style': ['error', 'declaration', { allowArrowFunctions: false }], |
| 37 | + '@typescript-eslint/no-unused-vars': [ |
| 38 | + 'error', |
| 39 | + { |
| 40 | + argsIgnorePattern: '^_', |
| 41 | + varsIgnorePattern: '^_', |
| 42 | + caughtErrorsIgnorePattern: '^_', |
| 43 | + destructuredArrayIgnorePattern: '^_', |
| 44 | + }, |
| 45 | + ], |
| 46 | + }, |
| 47 | + }, |
| 48 | + { |
| 49 | + files: ['**/*.tsx'], |
| 50 | + plugins: { |
| 51 | + react: reactPlugin, |
| 52 | + 'react-hooks': reactHooks, |
| 53 | + }, |
| 54 | + settings: { |
| 55 | + react: { version: 'detect' }, |
| 56 | + }, |
| 57 | + rules: { |
| 58 | + 'react/react-in-jsx-scope': 'off', |
| 59 | + 'react/jsx-uses-react': 'off', |
| 60 | + 'react/prop-types': 'off', |
| 61 | + '@typescript-eslint/no-misused-promises': 'off', |
| 62 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 63 | + 'react/self-closing-comp': 'error', |
| 64 | + 'react-hooks/rules-of-hooks': 'error', |
| 65 | + 'react-hooks/exhaustive-deps': 'error', |
| 66 | + }, |
| 67 | + }, |
| 68 | + { |
| 69 | + files: ['src/app/**/route.ts'], |
| 70 | + rules: { '@typescript-eslint/require-await': 'off' }, |
| 71 | + }, |
| 72 | + { |
| 73 | + files: ['tests/**/*.{ts,tsx}', '**/*.test.{ts,tsx}'], |
| 74 | + rules: { |
| 75 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 76 | + '@typescript-eslint/require-await': 'off', |
| 77 | + 'no-restricted-syntax': [ |
| 78 | + 'error', |
| 79 | + { selector: 'OptionalChain', message: 'Optional chaining (?.) is not allowed.' }, |
| 80 | + ], |
| 81 | + }, |
| 82 | + }, |
| 83 | + prettierConfig, |
| 84 | +); |
0 commit comments