|
| 1 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 2 | +import react from 'eslint-plugin-react'; |
| 3 | +import jest from 'eslint-plugin-jest'; |
| 4 | +import prettier from 'eslint-plugin-prettier'; |
| 5 | +import reactHooks from 'eslint-plugin-react-hooks'; |
| 6 | +import { fixupPluginRules } from '@eslint/compat'; |
| 7 | +import globals from 'globals'; |
| 8 | +import tsParser from '@typescript-eslint/parser'; |
| 9 | +import path from 'node:path'; |
| 10 | +import { fileURLToPath } from 'node:url'; |
| 11 | +import js from '@eslint/js'; |
| 12 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 13 | + |
| 14 | +const __filename = fileURLToPath(import.meta.url); |
| 15 | +const __dirname = path.dirname(__filename); |
| 16 | +const compat = new FlatCompat({ |
| 17 | + baseDirectory: __dirname, |
| 18 | + recommendedConfig: js.configs.recommended, |
| 19 | + allConfig: js.configs.all, |
| 20 | +}); |
| 21 | + |
| 22 | +export default [ |
| 23 | + { |
| 24 | + ignores: ['dist/', 'eslint.config.mjs'], |
| 25 | + }, |
| 26 | + ...compat.extends( |
| 27 | + 'eslint:recommended', |
| 28 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 29 | + 'plugin:jest/recommended', |
| 30 | + 'prettier', |
| 31 | + 'plugin:prettier/recommended', |
| 32 | + 'plugin:react/recommended' |
| 33 | + ), |
| 34 | + { |
| 35 | + plugins: { |
| 36 | + '@typescript-eslint': typescriptEslint, |
| 37 | + react, |
| 38 | + jest, |
| 39 | + prettier, |
| 40 | + 'react-hooks': fixupPluginRules(reactHooks), |
| 41 | + }, |
| 42 | + |
| 43 | + languageOptions: { |
| 44 | + globals: { |
| 45 | + ...globals.browser, |
| 46 | + ...jest.environments.globals.globals, |
| 47 | + ...globals.mocha, |
| 48 | + ...globals.node, |
| 49 | + }, |
| 50 | + |
| 51 | + parser: tsParser, |
| 52 | + ecmaVersion: 6, |
| 53 | + sourceType: 'module', |
| 54 | + |
| 55 | + parserOptions: { |
| 56 | + ecmaFeatures: { |
| 57 | + jsx: true, |
| 58 | + }, |
| 59 | + }, |
| 60 | + }, |
| 61 | + |
| 62 | + settings: { |
| 63 | + react: { |
| 64 | + version: 'detect', |
| 65 | + }, |
| 66 | + }, |
| 67 | + |
| 68 | + rules: { |
| 69 | + eqeqeq: ['error', 'always'], |
| 70 | + 'no-console': 'warn', |
| 71 | + 'no-lonely-if': 'error', |
| 72 | + 'no-shadow': 'warn', |
| 73 | + 'no-spaced-func': 'error', |
| 74 | + |
| 75 | + 'prettier/prettier': [ |
| 76 | + 'error', |
| 77 | + { |
| 78 | + singleQuote: true, |
| 79 | + }, |
| 80 | + ], |
| 81 | + |
| 82 | + 'react/display-name': 'warn', |
| 83 | + 'react/no-deprecated': 'warn', |
| 84 | + 'react/no-string-refs': 'warn', |
| 85 | + 'react/prop-types': 'off', |
| 86 | + 'vars-on-top': 'error', |
| 87 | + }, |
| 88 | + }, |
| 89 | + { |
| 90 | + files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], |
| 91 | + |
| 92 | + rules: { |
| 93 | + 'no-unused-vars': 'off', |
| 94 | + }, |
| 95 | + }, |
| 96 | +]; |
0 commit comments