|
| 1 | +import js from '@eslint/js'; |
| 2 | +import { defineConfig } from 'eslint/config'; |
| 3 | +import { dirname } from 'node:path'; |
| 4 | +import { fileURLToPath } from 'node:url'; |
| 5 | +import prettier from 'eslint-config-prettier'; |
| 6 | +import jest from 'eslint-plugin-jest'; |
| 7 | +import react from 'eslint-plugin-react'; |
| 8 | +import reactHooks from 'eslint-plugin-react-hooks'; |
| 9 | +import globals from 'globals'; |
| 10 | +import tseslint from 'typescript-eslint'; |
| 11 | + |
| 12 | +const tsconfigRootDir = dirname(fileURLToPath(import.meta.url)); |
| 13 | + |
| 14 | +export default defineConfig([ |
| 15 | + { |
| 16 | + plugins: { |
| 17 | + '@typescript-eslint': tseslint.plugin, |
| 18 | + }, |
| 19 | + }, |
| 20 | + { |
| 21 | + linterOptions: { |
| 22 | + reportUnusedDisableDirectives: 'warn', |
| 23 | + }, |
| 24 | + }, |
| 25 | + { |
| 26 | + ignores: [ |
| 27 | + 'node_modules/', |
| 28 | + 'coverage/', |
| 29 | + 'es/', |
| 30 | + 'lib/', |
| 31 | + 'dist/', |
| 32 | + 'docs-dist/', |
| 33 | + '.docs-dist/', |
| 34 | + '.dumi/', |
| 35 | + '.doc/', |
| 36 | + '.vercel/', |
| 37 | + ], |
| 38 | + }, |
| 39 | + { |
| 40 | + files: ['**/*.{js,jsx,ts,tsx}'], |
| 41 | + extends: [ |
| 42 | + js.configs.recommended, |
| 43 | + react.configs.flat.recommended, |
| 44 | + react.configs.flat['jsx-runtime'], |
| 45 | + prettier, |
| 46 | + ], |
| 47 | + plugins: { |
| 48 | + 'react-hooks': reactHooks, |
| 49 | + }, |
| 50 | + languageOptions: { |
| 51 | + globals: { |
| 52 | + ...globals.browser, |
| 53 | + ...globals.node, |
| 54 | + }, |
| 55 | + }, |
| 56 | + settings: { |
| 57 | + react: { |
| 58 | + version: 'detect', |
| 59 | + }, |
| 60 | + }, |
| 61 | + rules: { |
| 62 | + 'no-async-promise-executor': 'off', |
| 63 | + 'no-empty-pattern': 'off', |
| 64 | + 'no-irregular-whitespace': 'off', |
| 65 | + 'no-prototype-builtins': 'off', |
| 66 | + 'no-useless-escape': 'off', |
| 67 | + 'no-extra-boolean-cast': 'off', |
| 68 | + 'no-undef': 'off', |
| 69 | + 'no-unused-vars': 'off', |
| 70 | + 'react/no-find-dom-node': 'off', |
| 71 | + 'react/display-name': 'off', |
| 72 | + 'react/no-unknown-property': 'off', |
| 73 | + 'react/prop-types': 'off', |
| 74 | + 'react-hooks/exhaustive-deps': 'warn', |
| 75 | + 'react-hooks/rules-of-hooks': 'error', |
| 76 | + }, |
| 77 | + }, |
| 78 | + { |
| 79 | + files: ['**/*.{ts,tsx}'], |
| 80 | + extends: [...tseslint.configs.recommended], |
| 81 | + rules: { |
| 82 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 83 | + '@typescript-eslint/no-empty-object-type': 'off', |
| 84 | + '@typescript-eslint/no-explicit-any': 'off', |
| 85 | + '@typescript-eslint/no-unsafe-function-type': 'off', |
| 86 | + '@typescript-eslint/no-unnecessary-type-constraint': 'off', |
| 87 | + '@typescript-eslint/no-unused-vars': 'off', |
| 88 | + }, |
| 89 | + }, |
| 90 | + { |
| 91 | + files: ['src/**/*.{ts,tsx}'], |
| 92 | + languageOptions: { |
| 93 | + parserOptions: { |
| 94 | + projectService: true, |
| 95 | + tsconfigRootDir, |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + { |
| 100 | + files: ['tests/**/*.{js,jsx,ts,tsx}', '**/*.{test,spec}.{js,jsx,ts,tsx}'], |
| 101 | + extends: [jest.configs['flat/recommended']], |
| 102 | + rules: { |
| 103 | + 'jest/no-disabled-tests': 'off', |
| 104 | + 'jest/no-done-callback': 'off', |
| 105 | + 'jest/no-identical-title': 'off', |
| 106 | + 'jest/expect-expect': 'off', |
| 107 | + 'jest/no-alias-methods': 'off', |
| 108 | + 'jest/no-conditional-expect': 'off', |
| 109 | + 'jest/no-export': 'off', |
| 110 | + 'jest/no-standalone-expect': 'off', |
| 111 | + 'jest/valid-expect': 'off', |
| 112 | + 'jest/valid-title': 'off', |
| 113 | + }, |
| 114 | + }, |
| 115 | +]); |
0 commit comments