|
| 1 | +import { defineConfig } from 'eslint/config'; |
| 2 | +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'; |
| 3 | +import prettier from 'eslint-plugin-prettier'; |
| 4 | +import react from 'eslint-plugin-react'; |
| 5 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 6 | +import globals from 'globals'; |
| 7 | +import tsParser from '@typescript-eslint/parser'; |
| 8 | +import path from 'node:path'; |
| 9 | +import { fileURLToPath } from 'node:url'; |
| 10 | +import js from '@eslint/js'; |
| 11 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 12 | + |
| 13 | +const __filename = fileURLToPath(import.meta.url); |
| 14 | +const __dirname = path.dirname(__filename); |
| 15 | +const compat = new FlatCompat({ |
| 16 | + baseDirectory: __dirname, |
| 17 | + recommendedConfig: js.configs.recommended, |
| 18 | + allConfig: js.configs.all, |
| 19 | +}); |
| 20 | + |
| 21 | +export default defineConfig([ |
| 22 | + { |
| 23 | + extends: fixupConfigRules( |
| 24 | + compat.extends( |
| 25 | + 'eslint:recommended', |
| 26 | + 'plugin:react/recommended', |
| 27 | + 'plugin:react-hooks/recommended', |
| 28 | + 'plugin:@typescript-eslint/recommended', |
| 29 | + 'plugin:react/jsx-runtime', |
| 30 | + 'prettier', |
| 31 | + ), |
| 32 | + ), |
| 33 | + |
| 34 | + plugins: { |
| 35 | + prettier, |
| 36 | + react: fixupPluginRules(react as any), |
| 37 | + '@typescript-eslint': fixupPluginRules(typescriptEslint as any), |
| 38 | + }, |
| 39 | + |
| 40 | + languageOptions: { |
| 41 | + globals: { |
| 42 | + ...globals.browser, |
| 43 | + }, |
| 44 | + |
| 45 | + parser: tsParser, |
| 46 | + ecmaVersion: 2021, |
| 47 | + sourceType: 'module', |
| 48 | + |
| 49 | + parserOptions: { |
| 50 | + ecmaFeatures: { |
| 51 | + jsx: true, |
| 52 | + }, |
| 53 | + }, |
| 54 | + }, |
| 55 | + |
| 56 | + settings: { |
| 57 | + react: { |
| 58 | + version: 'detect', |
| 59 | + }, |
| 60 | + }, |
| 61 | + |
| 62 | + rules: { |
| 63 | + 'prettier/prettier': ['error'], |
| 64 | + |
| 65 | + 'max-len': [ |
| 66 | + 'error', |
| 67 | + { |
| 68 | + code: 100, |
| 69 | + ignoreStrings: true, |
| 70 | + ignoreUrls: true, |
| 71 | + }, |
| 72 | + ], |
| 73 | + |
| 74 | + 'no-console': ['error'], |
| 75 | + 'react/display-name': 'off', |
| 76 | + 'react/prop-types': 'off', |
| 77 | + 'react-hooks/set-state-in-effect': 'off', |
| 78 | + 'react-hooks/set-state-in-render': 'off', |
| 79 | + 'react-hooks/incompatible-library': 'off', |
| 80 | + '@typescript-eslint/no-explicit-any': 'off', |
| 81 | + }, |
| 82 | + }, |
| 83 | +]); |
0 commit comments