|
| 1 | +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat' |
| 2 | +import react from 'eslint-plugin-react' |
| 3 | +import _import from 'eslint-plugin-import' |
| 4 | +import simpleImportSort from 'eslint-plugin-simple-import-sort' |
| 5 | +import n from 'eslint-plugin-n' |
| 6 | +import typescriptEslint from '@typescript-eslint/eslint-plugin' |
| 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 | + ...fixupConfigRules( |
| 24 | + compat.extends( |
| 25 | + 'eslint:recommended', |
| 26 | + 'plugin:react/recommended', |
| 27 | + 'plugin:react-hooks/recommended', |
| 28 | + 'plugin:import/typescript', |
| 29 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 30 | + 'plugin:@typescript-eslint/recommended' |
| 31 | + ) |
| 32 | + ), |
| 33 | + { |
| 34 | + plugins: { |
| 35 | + react: fixupPluginRules(react), |
| 36 | + import: fixupPluginRules(_import), |
| 37 | + 'simple-import-sort': simpleImportSort, |
| 38 | + n, |
| 39 | + '@typescript-eslint': fixupPluginRules(typescriptEslint), |
| 40 | + }, |
| 41 | + |
| 42 | + languageOptions: { |
| 43 | + globals: { |
| 44 | + ...globals.browser, |
| 45 | + ...globals.node, |
| 46 | + }, |
| 47 | + |
| 48 | + parser: tsParser, |
| 49 | + ecmaVersion: 5, |
| 50 | + sourceType: 'module', |
| 51 | + |
| 52 | + parserOptions: { |
| 53 | + project: 'tsconfig.json', |
| 54 | + }, |
| 55 | + }, |
| 56 | + |
| 57 | + settings: { |
| 58 | + react: { |
| 59 | + pragma: 'React', |
| 60 | + version: 'detect', |
| 61 | + }, |
| 62 | + }, |
| 63 | + |
| 64 | + rules: { |
| 65 | + 'import/no-cycle': 'error', |
| 66 | + 'n/no-extraneous-import': 'error', |
| 67 | + 'n/file-extension-in-import': 'error', |
| 68 | + '@typescript-eslint/ban-ts-ignore': 'off', |
| 69 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 70 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 71 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 72 | + '@typescript-eslint/no-unused-expressions': 'off', |
| 73 | + '@typescript-eslint/no-unused-vars': [ |
| 74 | + 'error', |
| 75 | + { |
| 76 | + args: 'all', |
| 77 | + argsIgnorePattern: '^_', |
| 78 | + caughtErrors: 'all', |
| 79 | + caughtErrorsIgnorePattern: '^_', |
| 80 | + destructuredArrayIgnorePattern: '^_', |
| 81 | + varsIgnorePattern: '^_', |
| 82 | + ignoreRestSiblings: true, |
| 83 | + }, |
| 84 | + ], |
| 85 | + '@typescript-eslint/no-use-before-define': 'off', |
| 86 | + '@typescript-eslint/interface-name-prefix': 'off', |
| 87 | + '@typescript-eslint/member-delimiter-style': 'off', |
| 88 | + '@typescript-eslint/no-explicit-any': 'error', |
| 89 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 90 | + 'simple-import-sort/imports': 'error', |
| 91 | + 'simple-import-sort/exports': 'error', |
| 92 | + 'react/prop-types': 'off', |
| 93 | + }, |
| 94 | + }, |
| 95 | + { |
| 96 | + files: ['src/**/*.spec.*'], |
| 97 | + |
| 98 | + rules: { |
| 99 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 100 | + }, |
| 101 | + }, |
| 102 | +] |
0 commit comments