|
| 1 | +import path from 'node:path' |
| 2 | + |
| 3 | +import js from '@eslint/js' |
| 4 | +import prettierConfig from 'eslint-config-prettier' |
| 5 | +import importPlugin from 'eslint-plugin-import' |
| 6 | +import reactPlugin from 'eslint-plugin-react' |
| 7 | +import reactHooksPlugin from 'eslint-plugin-react-hooks' |
| 8 | +import globals from 'globals' |
| 9 | +import ts from 'typescript-eslint' |
| 10 | + |
| 11 | +/** @type {import("eslint").Linter.Config[]} */ |
| 12 | +export default [ |
| 13 | + { |
| 14 | + ignores: ['.*.js', '.*.ts', 'node_modules/', 'dist/', '.next/', 'public/', 'out/'], |
| 15 | + }, |
| 16 | + { |
| 17 | + languageOptions: { |
| 18 | + globals: { ...globals.browser, ...globals.node, ...globals.serviceworker }, |
| 19 | + }, |
| 20 | + }, |
| 21 | + prettierConfig, |
| 22 | + js.configs.recommended, |
| 23 | + ...ts.configs.strict, |
| 24 | + ...ts.configs.stylistic, |
| 25 | + { |
| 26 | + files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'], |
| 27 | + ...importPlugin.flatConfigs.recommended, |
| 28 | + rules: { |
| 29 | + // turn on errors for missing imports |
| 30 | + 'import/no-unresolved': 'error', |
| 31 | + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^React$' }], |
| 32 | + }, |
| 33 | + settings: { |
| 34 | + 'import/parsers': { |
| 35 | + '@typescript-eslint/parser': ['.ts', '.tsx'], |
| 36 | + }, |
| 37 | + 'import/resolver': { |
| 38 | + typescript: { |
| 39 | + project: path.resolve(process.cwd(), 'tsconfig.json'), |
| 40 | + }, |
| 41 | + }, |
| 42 | + }, |
| 43 | + }, |
| 44 | + { |
| 45 | + files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'], |
| 46 | + ...reactPlugin.configs.flat.recommended, |
| 47 | + plugins: { |
| 48 | + ...reactPlugin.configs.flat.recommended.plugins, |
| 49 | + react: reactPlugin, |
| 50 | + 'react-hooks': reactHooksPlugin, |
| 51 | + }, |
| 52 | + rules: { |
| 53 | + ...reactPlugin.configs.flat.recommended.rules, |
| 54 | + ...reactPlugin.configs['jsx-runtime'].rules, |
| 55 | + ...reactHooksPlugin.configs.recommended.rules, |
| 56 | + }, |
| 57 | + }, |
| 58 | +] |
0 commit comments