|
| 1 | +import js from '@eslint/js' |
| 2 | +import { defineConfig } from 'eslint/config' |
| 3 | +import pluginPrettier from 'eslint-plugin-prettier' |
| 4 | +import pluginExpectType from 'eslint-plugin-expect-type/configs/recommended' |
| 5 | +import globals from 'globals' |
| 6 | +import tseslint from 'typescript-eslint' |
| 7 | + |
| 8 | +export default defineConfig( |
| 9 | + // Base ESLint recommended rules |
| 10 | + js.configs.recommended, |
| 11 | + // TypeScript-ESLint recommended rules with type checking |
| 12 | + ...tseslint.configs.strict, |
| 13 | + ...tseslint.configs.stylistic, |
| 14 | + // Enable type-aware linting for TypeScript files only |
| 15 | + { |
| 16 | + files: ['**/*.ts'], |
| 17 | + languageOptions: { |
| 18 | + parserOptions: { |
| 19 | + project: './tsconfig.all.json', |
| 20 | + }, |
| 21 | + }, |
| 22 | + }, |
| 23 | + // Project-wide rules and plugins |
| 24 | + { |
| 25 | + plugins: { |
| 26 | + prettier: pluginPrettier, |
| 27 | + 'expect-type': pluginExpectType, |
| 28 | + }, |
| 29 | + rules: { |
| 30 | + 'prettier/prettier': 'error', |
| 31 | + '@typescript-eslint/no-floating-promises': 'error', |
| 32 | + eqeqeq: 'error', |
| 33 | + 'no-console': 'error', |
| 34 | + // Keep some rules relaxed until addressed in dedicated PRs |
| 35 | + '@typescript-eslint/no-explicit-any': 'off', |
| 36 | + '@typescript-eslint/consistent-type-imports': 'warn', |
| 37 | + '@typescript-eslint/array-type': 'off', |
| 38 | + }, |
| 39 | + }, |
| 40 | + // Test files overrides |
| 41 | + { |
| 42 | + files: ['./**/__tests__/**/*.ts'], |
| 43 | + rules: { |
| 44 | + '@typescript-eslint/no-explicit-any': 'off', |
| 45 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 46 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 47 | + 'no-constant-condition': 'off', |
| 48 | + 'no-console': 'off', |
| 49 | + }, |
| 50 | + }, |
| 51 | + // Examples and benchmarks overrides |
| 52 | + { |
| 53 | + files: [ |
| 54 | + './**/examples/**/*.ts', |
| 55 | + './**/benchmarks/**/*.ts', |
| 56 | + '.build/*.ts', |
| 57 | + '.scripts/*.ts', |
| 58 | + ], |
| 59 | + rules: { |
| 60 | + 'no-console': 'off', |
| 61 | + }, |
| 62 | + }, |
| 63 | + // Root-level config files (ESM in Node) |
| 64 | + { |
| 65 | + files: ['*.mjs', '**/*.mjs'], |
| 66 | + languageOptions: { |
| 67 | + sourceType: 'module', |
| 68 | + ecmaVersion: 'latest', |
| 69 | + globals: globals.node, |
| 70 | + parserOptions: { |
| 71 | + projectService: false, |
| 72 | + }, |
| 73 | + }, |
| 74 | + rules: { |
| 75 | + '@typescript-eslint/no-floating-promises': 'off', |
| 76 | + '@typescript-eslint/consistent-type-imports': 'off', |
| 77 | + 'no-console': 'off', |
| 78 | + }, |
| 79 | + }, |
| 80 | + // Ignore build artifacts and externals |
| 81 | + { |
| 82 | + ignores: ['out', 'dist', 'node_modules', 'webpack'], |
| 83 | + }, |
| 84 | +) |
0 commit comments