|
| 1 | +const tsParser = require('@typescript-eslint/parser'); |
| 2 | +const tsPlugin = require('@typescript-eslint/eslint-plugin'); |
| 3 | +const importPlugin = require('eslint-plugin-import'); |
| 4 | +const eslintJs = require('@eslint/js'); |
| 5 | +const globals = require('globals'); |
| 6 | + |
| 7 | +module.exports = [ |
| 8 | + // Ignored paths (replaces .eslintignore) |
| 9 | + { |
| 10 | + ignores: ['node_modules', 'lib', 'examples', 'docs'], |
| 11 | + }, |
| 12 | + |
| 13 | + // Base JavaScript recommended rules |
| 14 | + eslintJs.configs.recommended, |
| 15 | + |
| 16 | + // Project rules for JS/TS files |
| 17 | + { |
| 18 | + files: ['**/*.{ts,js}'], |
| 19 | + languageOptions: { |
| 20 | + parser: tsParser, |
| 21 | + ecmaVersion: 2021, |
| 22 | + sourceType: 'module', |
| 23 | + globals: { |
| 24 | + ...globals.es2021, |
| 25 | + ...globals.node, |
| 26 | + }, |
| 27 | + }, |
| 28 | + plugins: { |
| 29 | + '@typescript-eslint': tsPlugin, |
| 30 | + import: importPlugin, |
| 31 | + }, |
| 32 | + settings: { |
| 33 | + 'import/extensions': ['.js'], |
| 34 | + }, |
| 35 | + rules: { |
| 36 | + 'no-console': ['error', { allow: ['warn', 'error', 'time'] }], |
| 37 | + '@typescript-eslint/no-var-requires': 'off', |
| 38 | + // Use the TS version of this rule; base rule disabled for TS below |
| 39 | + '@typescript-eslint/no-unused-vars': [ |
| 40 | + 'error', |
| 41 | + { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, |
| 42 | + ], |
| 43 | + '@typescript-eslint/no-empty-function': 'off', |
| 44 | + '@typescript-eslint/no-explicit-any': 'off', |
| 45 | + 'import/extensions': ['error', 'ignorePackages'], |
| 46 | + }, |
| 47 | + }, |
| 48 | + |
| 49 | + // TypeScript-specific overrides to avoid false positives from base rules |
| 50 | + { |
| 51 | + files: ['**/*.ts'], |
| 52 | + rules: { |
| 53 | + 'no-undef': 'off', |
| 54 | + 'no-unused-vars': 'off', |
| 55 | + }, |
| 56 | + }, |
| 57 | + |
| 58 | + // Test-specific tweaks |
| 59 | + { |
| 60 | + files: ['*.spec.ts', '*.test.ts', 'tests/**/*.ts'], |
| 61 | + languageOptions: { |
| 62 | + globals: { |
| 63 | + ...globals.jest, |
| 64 | + }, |
| 65 | + }, |
| 66 | + rules: { |
| 67 | + 'import/extensions': 'off', |
| 68 | + }, |
| 69 | + }, |
| 70 | +]; |
| 71 | + |
| 72 | + |
0 commit comments