|
| 1 | +import { fixupPluginRules } from '@eslint/compat'; |
| 2 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 3 | +import js from '@eslint/js'; |
| 4 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 5 | +import tsParser from '@typescript-eslint/parser'; |
| 6 | +import reactHooks from 'eslint-plugin-react-hooks'; |
| 7 | +import globals from 'globals'; |
| 8 | +import path from 'node:path'; |
| 9 | +import { fileURLToPath } from 'node:url'; |
| 10 | + |
| 11 | +const __filename = fileURLToPath(import.meta.url); |
| 12 | +const __dirname = path.dirname(__filename); |
| 13 | +const compat = new FlatCompat({ |
| 14 | + baseDirectory: __dirname, |
| 15 | + recommendedConfig: js.configs.recommended, |
| 16 | + allConfig: js.configs.all, |
| 17 | +}); |
| 18 | + |
| 19 | +export default [ |
| 20 | + ...compat.extends('airbnb', 'plugin:@typescript-eslint/recommended', 'prettier'), |
| 21 | + { |
| 22 | + plugins: { |
| 23 | + '@typescript-eslint': typescriptEslint, |
| 24 | + 'react-hooks': fixupPluginRules(reactHooks), |
| 25 | + }, |
| 26 | + |
| 27 | + languageOptions: { |
| 28 | + globals: { |
| 29 | + ...globals.browser, |
| 30 | + }, |
| 31 | + |
| 32 | + parser: tsParser, |
| 33 | + ecmaVersion: 5, |
| 34 | + sourceType: 'module', |
| 35 | + |
| 36 | + parserOptions: { |
| 37 | + ecmaFeatures: { |
| 38 | + ecmaVersion: 8, |
| 39 | + jsx: true, |
| 40 | + impliedStrict: true, |
| 41 | + }, |
| 42 | + }, |
| 43 | + }, |
| 44 | + |
| 45 | + settings: { |
| 46 | + 'import/resolver': { |
| 47 | + typescript: {}, |
| 48 | + |
| 49 | + node: { |
| 50 | + extensions: ['.js', '.jsx', '.ts', '.tsx', '.less', '.scss'], |
| 51 | + moduleDirectory: ['node_modules', 'src/'], |
| 52 | + }, |
| 53 | + }, |
| 54 | + }, |
| 55 | + |
| 56 | + rules: { |
| 57 | + 'import/no-extraneous-dependencies': 0, |
| 58 | + |
| 59 | + 'import/no-unused-modules': [ |
| 60 | + 1, |
| 61 | + { |
| 62 | + unusedExports: true, |
| 63 | + missingExports: true, |
| 64 | + ignoreExports: [], |
| 65 | + }, |
| 66 | + ], |
| 67 | + |
| 68 | + 'import/no-unresolved': 'error', |
| 69 | + '@typescript-eslint/no-unused-vars': 'warn', |
| 70 | + '@typescript-eslint/no-use-before-define': 'error', |
| 71 | + '@typescript-eslint/no-shadow': 'error', |
| 72 | + |
| 73 | + 'react/jsx-filename-extension': [ |
| 74 | + 1, |
| 75 | + { |
| 76 | + extensions: ['.js', '.jsx', '.ts', '.tsx'], |
| 77 | + }, |
| 78 | + ], |
| 79 | + |
| 80 | + 'no-shadow': 'off', |
| 81 | + 'max-len': [1, 160], |
| 82 | + 'react/jsx-props-no-spreading': 'off', |
| 83 | + 'react/destructuring-assignment': 'off', |
| 84 | + 'jsx-a11y/control-has-associated-label': 'off', |
| 85 | + 'react/function-component-definition': 'off', |
| 86 | + 'implicit-arrow-linebreak': 'off', |
| 87 | + 'function-paren-newline': 'off', |
| 88 | + 'arrow-parens': 'off', |
| 89 | + 'object-curly-newline': 'off', |
| 90 | + 'react/require-default-props': 'off', |
| 91 | + 'react/prop-types': 'off', |
| 92 | + 'import/prefer-default-export': 'off', |
| 93 | + 'import/extensions': 'off', |
| 94 | + }, |
| 95 | + }, |
| 96 | + { |
| 97 | + files: ['**/*.spec.ts', '**/*.spec.tsx'], |
| 98 | + |
| 99 | + rules: { |
| 100 | + '@typescript-eslint/no-explicit-any': 0, |
| 101 | + 'import/no-unused-modules': 0, |
| 102 | + }, |
| 103 | + }, |
| 104 | +]; |
0 commit comments