|
| 1 | +import { defineConfig } from 'eslint/config'; |
| 2 | +import eslint from '@eslint/js'; |
| 3 | +import eslintConfigPrettier from 'eslint-config-prettier'; |
| 4 | +import tseslint from 'typescript-eslint'; |
| 5 | + |
| 6 | +export default defineConfig( |
| 7 | + // Apply to all TypeScript and JavaScript files |
| 8 | + { |
| 9 | + files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.mjs', '**/*.cjs'], |
| 10 | + }, |
| 11 | + |
| 12 | + // Ignore patterns |
| 13 | + { |
| 14 | + ignores: [ |
| 15 | + '**/node_modules/**', |
| 16 | + '**/dist/**', |
| 17 | + '**/build/**', |
| 18 | + '**/.git/**', |
| 19 | + '**/coverage/**', |
| 20 | + '**/*.min.js', |
| 21 | + ], |
| 22 | + }, |
| 23 | + |
| 24 | + // Base ESLint recommended rules |
| 25 | + eslint.configs.recommended, |
| 26 | + |
| 27 | + // TypeScript ESLint recommended rules with type checking |
| 28 | + ...tseslint.configs.recommendedTypeChecked, |
| 29 | + |
| 30 | + // TypeScript specific configuration |
| 31 | + { |
| 32 | + languageOptions: { |
| 33 | + parserOptions: { |
| 34 | + projectService: { |
| 35 | + allowDefaultProject: ['*.js', '*.mjs', '*.cjs'], |
| 36 | + defaultProject: './tsconfig.json', |
| 37 | + }, |
| 38 | + tsconfigRootDir: import.meta.dirname, |
| 39 | + }, |
| 40 | + }, |
| 41 | + }, |
| 42 | + |
| 43 | + // Rules for JavaScript files (without type checking) |
| 44 | + { |
| 45 | + files: ['**/*.js', '**/*.mjs', '**/*.cjs'], |
| 46 | + ...tseslint.configs.disableTypeChecked, |
| 47 | + }, |
| 48 | + |
| 49 | + // Custom TypeScript rule overrides |
| 50 | + { |
| 51 | + rules: { |
| 52 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 53 | + '@typescript-eslint/strict-boolean-expressions': 'off', |
| 54 | + '@typescript-eslint/restrict-template-expressions': 'off', |
| 55 | + '@typescript-eslint/method-signature-style': 'off', |
| 56 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 57 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 58 | + '@typescript-eslint/no-unsafe-argument': 'off', |
| 59 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 60 | + '@typescript-eslint/no-explicit-any': 'off', |
| 61 | + '@typescript-eslint/require-await': 'off', |
| 62 | + // allow unused variables if they start with _ |
| 63 | + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], |
| 64 | + 'no-undef': 'off', |
| 65 | + }, |
| 66 | + }, |
| 67 | + |
| 68 | + // Prettier config (must be last to override conflicting rules) |
| 69 | + eslintConfigPrettier, |
| 70 | +); |
0 commit comments