|
| 1 | +import eslintJs from '@eslint/js' |
| 2 | +import pluginJest from 'eslint-plugin-jest' |
| 3 | +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' |
| 4 | +import reactPlugin from 'eslint-plugin-react' |
| 5 | +import hooksPlugin from 'eslint-plugin-react-hooks' |
| 6 | +import simpleImportSort from 'eslint-plugin-simple-import-sort' |
| 7 | +import globals from 'globals' |
| 8 | +import tseslint from 'typescript-eslint' |
| 9 | + |
| 10 | +export default tseslint.config( |
| 11 | + { |
| 12 | + ignores: ['.swc/**', 'dist/**'], |
| 13 | + }, |
| 14 | + { |
| 15 | + languageOptions: { |
| 16 | + parserOptions: { |
| 17 | + project: './tsconfig.json', |
| 18 | + tsconfigRootDir: import.meta.dirname, |
| 19 | + }, |
| 20 | + globals: { |
| 21 | + ...globals.browser, |
| 22 | + ...globals.node, |
| 23 | + }, |
| 24 | + }, |
| 25 | + settings: { |
| 26 | + react: { |
| 27 | + version: 'detect', |
| 28 | + }, |
| 29 | + }, |
| 30 | + }, |
| 31 | + eslintJs.configs.recommended, |
| 32 | + reactPlugin.configs.flat.recommended, |
| 33 | + tseslint.configs.eslintRecommended, |
| 34 | + ...tseslint.configs.recommendedTypeChecked, |
| 35 | + ...tseslint.configs.stylisticTypeChecked, |
| 36 | + eslintPluginPrettierRecommended, |
| 37 | + { |
| 38 | + plugins: { |
| 39 | + /** "eslint-plugin-react-hooks" doesn't work with TypeScript */ |
| 40 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
| 41 | + 'react-hooks': hooksPlugin, |
| 42 | + 'simple-import-sort': simpleImportSort, |
| 43 | + }, |
| 44 | + /** "eslint-plugin-react-hooks" doesn't work with TypeScript */ |
| 45 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
| 46 | + rules: { |
| 47 | + /** "eslint-plugin-react-hooks" doesn't work with TypeScript */ |
| 48 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access |
| 49 | + ...hooksPlugin.configs.recommended.rules, |
| 50 | + '@typescript-eslint/consistent-type-definitions': 'off', |
| 51 | + '@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }], |
| 52 | + '@typescript-eslint/prefer-nullish-coalescing': 'off', |
| 53 | + 'react/react-in-jsx-scope': 'off', |
| 54 | + 'simple-import-sort/imports': 'error', |
| 55 | + 'simple-import-sort/exports': 'error', |
| 56 | + }, |
| 57 | + }, |
| 58 | + { |
| 59 | + files: ['tests/**/*.(spec|test).*'], |
| 60 | + plugins: { |
| 61 | + jest: pluginJest, |
| 62 | + }, |
| 63 | + languageOptions: { |
| 64 | + globals: pluginJest.environments.globals.globals, |
| 65 | + }, |
| 66 | + rules: { |
| 67 | + 'jest/no-disabled-tests': 'warn', |
| 68 | + 'jest/no-focused-tests': 'error', |
| 69 | + 'jest/no-identical-title': 'error', |
| 70 | + 'jest/prefer-to-have-length': 'warn', |
| 71 | + 'jest/valid-expect': 'error', |
| 72 | + }, |
| 73 | + }, |
| 74 | +) |
0 commit comments