|
| 1 | +import js from '@eslint/js'; |
| 2 | +import prettier from 'eslint-config-prettier'; |
| 3 | +import importPlugin from 'eslint-plugin-import'; |
| 4 | +import tseslint from 'typescript-eslint'; |
| 5 | + |
| 6 | +export default tseslint.config( |
| 7 | + // Base JavaScript configuration for all files |
| 8 | + js.configs.recommended, |
| 9 | + |
| 10 | + // TypeScript configuration for .ts files only |
| 11 | + { |
| 12 | + files: ['src/**/*.ts'], |
| 13 | + extends: [...tseslint.configs.recommended, ...tseslint.configs.recommendedTypeChecked], |
| 14 | + plugins: { |
| 15 | + import: importPlugin, |
| 16 | + }, |
| 17 | + languageOptions: { |
| 18 | + parserOptions: { |
| 19 | + ecmaVersion: 2022, |
| 20 | + sourceType: 'module', |
| 21 | + project: './tsconfig.node.json', |
| 22 | + tsconfigRootDir: import.meta.dirname, |
| 23 | + }, |
| 24 | + }, |
| 25 | + settings: { |
| 26 | + 'import/resolver': { |
| 27 | + typescript: { |
| 28 | + alwaysTryTypes: true, |
| 29 | + project: './tsconfig.node.json', |
| 30 | + }, |
| 31 | + }, |
| 32 | + }, |
| 33 | + rules: { |
| 34 | + 'no-debugger': 'off', |
| 35 | + // Import ordering and organization rules |
| 36 | + 'import/order': [ |
| 37 | + 'error', |
| 38 | + { |
| 39 | + groups: [ |
| 40 | + 'builtin', // Node.js built-in modules |
| 41 | + 'external', // npm packages |
| 42 | + 'internal', // Internal modules (configured with path mapping) |
| 43 | + 'parent', // ../ |
| 44 | + 'sibling', // ./ |
| 45 | + 'index', // ./index |
| 46 | + ], |
| 47 | + 'newlines-between': 'never', |
| 48 | + alphabetize: { |
| 49 | + order: 'asc', |
| 50 | + caseInsensitive: true, |
| 51 | + }, |
| 52 | + }, |
| 53 | + ], |
| 54 | + 'import/first': 'error', |
| 55 | + 'import/no-duplicates': 'error', |
| 56 | + 'import/no-unresolved': 'off', // TypeScript handles this |
| 57 | + 'import/extensions': ['error', 'ignorePackages', { ts: 'never' }], |
| 58 | + |
| 59 | + // TypeScript import rules |
| 60 | + '@typescript-eslint/consistent-type-imports': [ |
| 61 | + 'error', |
| 62 | + { |
| 63 | + prefer: 'type-imports', |
| 64 | + disallowTypeAnnotations: false, |
| 65 | + fixStyle: 'separate-type-imports', |
| 66 | + }, |
| 67 | + ], |
| 68 | + '@typescript-eslint/consistent-type-exports': [ |
| 69 | + 'error', |
| 70 | + { |
| 71 | + fixMixedExportsWithInlineTypeSpecifier: true, |
| 72 | + }, |
| 73 | + ], |
| 74 | + |
| 75 | + // Custom rules - balanced approach for development |
| 76 | + '@typescript-eslint/await-thenable': 'error', |
| 77 | + '@typescript-eslint/no-base-to-string': 'off', // Common pattern in VS Code |
| 78 | + '@typescript-eslint/no-duplicate-type-constituents': 'off', // False positives |
| 79 | + '@typescript-eslint/no-explicit-any': 'off', // Allowing any for flexibility... for now |
| 80 | + '@typescript-eslint/no-floating-promises': 'off', // Too strict for VS Code extension patterns |
| 81 | + '@typescript-eslint/no-misused-promises': 'off', // Common in VS Code APIs |
| 82 | + '@typescript-eslint/no-redundant-type-constituents': 'off', // False positives |
| 83 | + '@typescript-eslint/no-unused-vars': [ |
| 84 | + 'warn', |
| 85 | + { |
| 86 | + args: 'all', |
| 87 | + argsIgnorePattern: '^_', |
| 88 | + caughtErrors: 'all', |
| 89 | + caughtErrorsIgnorePattern: '^_', |
| 90 | + destructuredArrayIgnorePattern: '^_', |
| 91 | + varsIgnorePattern: '^_', |
| 92 | + ignoreRestSiblings: true, |
| 93 | + }, |
| 94 | + ], |
| 95 | + '@typescript-eslint/no-unsafe-assignment': 'off', // Too strict for dynamic APIs |
| 96 | + '@typescript-eslint/no-unsafe-member-access': 'off', // Too strict for dynamic APIs |
| 97 | + '@typescript-eslint/no-unsafe-argument': 'off', // Too strict for dynamic APIs |
| 98 | + '@typescript-eslint/no-unsafe-return': 'off', // Too strict for dynamic APIs |
| 99 | + '@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false }], |
| 100 | + '@typescript-eslint/prefer-optional-chain': 'warn', |
| 101 | + '@typescript-eslint/prefer-promise-reject-errors': ['error', { allowEmptyReject: true }], |
| 102 | + '@typescript-eslint/restrict-template-expressions': 'off', // Too strict for logging |
| 103 | + '@typescript-eslint/unbound-method': 'off', // Too strict for VS Code APIs |
| 104 | + }, |
| 105 | + }, |
| 106 | + { |
| 107 | + ignores: [ |
| 108 | + 'dist/', |
| 109 | + 'node_modules/', |
| 110 | + '*.js', |
| 111 | + 'webpack.config.mjs', |
| 112 | + 'scripts/', |
| 113 | + '.vscode-test/', |
| 114 | + '.vscode-test-web/', |
| 115 | + 'LICENSE', |
| 116 | + 'ThirdPartyNotices.txt', |
| 117 | + ], |
| 118 | + }, |
| 119 | + prettier, |
| 120 | +); |
0 commit comments