|
1 | 1 | module.exports = { |
2 | 2 | root: true, |
| 3 | + ignorePatterns: ['*.config.js', '*.config.cjs', 'tools/ci-scripts/**/*'], |
3 | 4 | parser: '@typescript-eslint/parser', |
4 | 5 | parserOptions: { |
5 | 6 | ecmaVersion: 2020, |
6 | 7 | sourceType: 'module', |
| 8 | + project: './tsconfig.json', |
7 | 9 | }, |
8 | | - plugins: ['@typescript-eslint', 'prettier'], |
| 10 | + plugins: ['@typescript-eslint', 'prettier', 'import', 'security'], |
9 | 11 | extends: [ |
10 | 12 | 'eslint:recommended', |
11 | 13 | 'plugin:@typescript-eslint/recommended', |
| 14 | + 'plugin:import/recommended', |
| 15 | + 'plugin:import/typescript', |
12 | 16 | 'plugin:prettier/recommended', |
13 | 17 | ], |
| 18 | + settings: { |
| 19 | + // Removed problematic import resolver for now |
| 20 | + }, |
14 | 21 | env: { |
15 | 22 | node: true, |
16 | 23 | es6: true, |
17 | 24 | }, |
| 25 | + ignorePatterns: ['*.config.js', '*.config.ts', 'webpack.config.js', 'webpack.config.ts', 'tools/ci-scripts/**/*'], |
| 26 | + rules: { |
| 27 | + // Prettier integration |
| 28 | + 'prettier/prettier': 'error', |
| 29 | + |
| 30 | + // TypeScript strict rules |
| 31 | + '@typescript-eslint/no-explicit-any': 'error', |
| 32 | + '@typescript-eslint/no-non-null-assertion': 'warn', |
| 33 | + '@typescript-eslint/no-unnecessary-condition': 'error', |
| 34 | + '@typescript-eslint/strict-boolean-expressions': 'error', |
| 35 | + '@typescript-eslint/no-confusing-void-expression': 'error', |
| 36 | + '@typescript-eslint/prefer-readonly': 'error', |
| 37 | + '@typescript-eslint/prefer-readonly-parameter-types': 'off', // Too strict for current codebase |
| 38 | + |
| 39 | + 'import/no-unresolved': 'error', |
| 40 | + // 'import/no-cycle': 'error', |
| 41 | + 'import/no-self-import': 'error', |
| 42 | + // 'import/no-absolute-path': 'error', |
| 43 | + // 'import/no-unused-modules': 'error', |
| 44 | + 'import/no-deprecated': 'warn', |
| 45 | + 'import/order': [ |
| 46 | + 'error', |
| 47 | + { |
| 48 | + groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], |
| 49 | + 'newlines-between': 'always', |
| 50 | + }, |
| 51 | + ], |
| 52 | + |
| 53 | + // Sorting and ordering rules |
| 54 | + 'sort-keys': ['warn', 'asc', { caseSensitive: false, natural: true }], |
| 55 | + 'sort-vars': 'error', |
| 56 | + '@typescript-eslint/member-ordering': [ |
| 57 | + 'error', |
| 58 | + { |
| 59 | + default: ['signature', 'field', 'constructor', 'method'], |
| 60 | + }, |
| 61 | + ], |
| 62 | + |
| 63 | + // Security rules |
| 64 | + 'security/detect-object-injection': 'warn', |
| 65 | + 'security/detect-non-literal-fs-filename': 'warn', |
| 66 | + 'security/detect-unsafe-regex': 'error', |
| 67 | + |
| 68 | + // General code quality |
| 69 | + 'no-unused-vars': 'off', // Use @typescript-eslint/no-unused-vars instead |
| 70 | + '@typescript-eslint/no-unused-vars': [ |
| 71 | + 'error', |
| 72 | + { |
| 73 | + argsIgnorePattern: '^_', |
| 74 | + varsIgnorePattern: '^_', |
| 75 | + ignoreRestSiblings: true, |
| 76 | + args: 'after-used', |
| 77 | + caughtErrorsIgnorePattern: '^_', |
| 78 | + }, |
| 79 | + ], |
| 80 | + |
| 81 | + // Enforce consistent coding style |
| 82 | + eqeqeq: ['error', 'always', { null: 'ignore' }], |
| 83 | + 'consistent-return': 'error', |
| 84 | + 'no-implicit-coercion': 'error', |
| 85 | + yoda: 'error', |
| 86 | + 'no-bitwise': 'warn', |
| 87 | + 'no-lone-blocks': 'error', |
| 88 | + 'no-multi-assign': 'error', |
| 89 | + 'no-new-object': 'error', |
| 90 | + 'no-array-constructor': 'error', |
| 91 | + 'no-new-wrappers': 'error', |
| 92 | + 'no-extend-native': 'error', |
| 93 | + 'no-implicit-globals': 'error', |
| 94 | + 'no-invalid-this': 'error', |
| 95 | + 'no-shadow': 'off', // Disabled in favor of @typescript-eslint/no-shadow |
| 96 | + '@typescript-eslint/no-shadow': 'error', |
| 97 | + 'no-undef': 'error', |
| 98 | + 'no-undefined': 'error', |
| 99 | + 'no-use-before-define': 'error', |
| 100 | + '@typescript-eslint/no-use-before-define': 'error', |
| 101 | + |
| 102 | + // Code complexity and maintainability |
| 103 | + 'max-lines-per-function': ['error', 50], |
| 104 | + 'max-params': ['error', 4], |
| 105 | + 'max-depth': ['error', 4], |
| 106 | + 'max-nested-callbacks': ['error', 3], |
| 107 | + complexity: ['error', 10], |
| 108 | + 'max-lines': ['error', 300], |
| 109 | + |
| 110 | + // Security rules (additional to plugin) |
| 111 | + 'no-eval': 'error', |
| 112 | + 'no-implied-eval': 'error', |
| 113 | + 'no-new-func': 'error', |
| 114 | + 'no-script-url': 'error', |
| 115 | + |
| 116 | + // Performance rules |
| 117 | + 'no-loop-func': 'error', |
| 118 | + |
| 119 | + // Best practices |
| 120 | + 'no-else-return': 'error', |
| 121 | + 'no-lonely-if': 'error', |
| 122 | + 'no-unneeded-ternary': 'error', |
| 123 | + 'no-useless-computed-key': 'error', |
| 124 | + 'no-useless-rename': 'error', |
| 125 | + 'prefer-object-spread': 'error', |
| 126 | + 'default-case': 'error', |
| 127 | + 'default-case-last': 'error', |
| 128 | + 'no-fallthrough': 'error', |
| 129 | + 'no-case-declarations': 'error', |
| 130 | + 'no-constructor-return': 'error', |
| 131 | + 'no-duplicate-case': 'error', |
| 132 | + 'no-self-compare': 'error', |
| 133 | + 'no-template-curly-in-string': 'error', |
| 134 | + 'no-unreachable-loop': 'error', |
| 135 | + 'require-atomic-updates': 'error', |
| 136 | + 'no-param-reassign': 'error', |
| 137 | + 'no-return-assign': 'error', |
| 138 | + 'no-return-await': 'error', |
| 139 | + 'require-await': 'error', |
| 140 | + 'no-async-promise-executor': 'error', |
| 141 | + 'no-await-in-loop': 'warn', |
| 142 | + 'no-promise-executor-return': 'error', |
| 143 | + }, |
18 | 144 | overrides: [ |
19 | 145 | { |
20 | | - files: ['test/**/*.js', 'test/**/*.ts'], |
| 146 | + files: ['**/*.test.ts', '**/*.spec.ts', '**/__tests__/**/*'], |
| 147 | + parserOptions: { |
| 148 | + project: './tsconfig.test.json', |
| 149 | + }, |
21 | 150 | env: { |
22 | 151 | jest: true, |
23 | 152 | }, |
24 | | - }, |
25 | | - { |
26 | | - files: ['src/types/**/*.ts', 'src/validation/**/*.ts', 'src/core/**/*.ts'], |
27 | 153 | rules: { |
28 | | - '@typescript-eslint/no-unused-vars': [ |
29 | | - 'warn', |
30 | | - { |
31 | | - argsIgnorePattern: '^_', |
32 | | - varsIgnorePattern: '^_', |
33 | | - ignoreRestSiblings: true, |
34 | | - args: 'none', |
35 | | - caughtErrorsIgnorePattern: '^_', |
36 | | - }, |
37 | | - ], |
| 154 | + '@typescript-eslint/no-explicit-any': 'off', |
| 155 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 156 | + '@typescript-eslint/no-unused-vars': 'off', |
| 157 | + '@typescript-eslint/no-unnecessary-condition': 'off', |
| 158 | + '@typescript-eslint/strict-boolean-expressions': 'off', |
| 159 | + 'no-unused-vars': 'off', |
| 160 | + 'max-lines-per-function': 'off', |
| 161 | + complexity: 'off', |
38 | 162 | }, |
39 | 163 | }, |
40 | 164 | { |
41 | | - files: ['src/commands/**/*.ts'], |
| 165 | + files: ['src/types/**/*.ts'], |
42 | 166 | rules: { |
43 | 167 | '@typescript-eslint/no-unused-vars': [ |
44 | 168 | 'warn', |
45 | 169 | { |
46 | | - argsIgnorePattern: 'options', |
| 170 | + argsIgnorePattern: '^_', |
47 | 171 | varsIgnorePattern: '^_', |
48 | 172 | ignoreRestSiblings: true, |
49 | | - args: 'after-used', |
50 | | - caughtErrorsIgnorePattern: '^_', |
51 | 173 | }, |
52 | 174 | ], |
53 | 175 | }, |
54 | 176 | }, |
55 | 177 | ], |
56 | | - rules: { |
57 | | - 'prettier/prettier': 'error', |
58 | | - '@typescript-eslint/no-explicit-any': 'error', |
59 | | - 'no-unused-vars': 'warn', |
60 | | - '@typescript-eslint/no-unused-vars': [ |
61 | | - 'warn', |
62 | | - { |
63 | | - argsIgnorePattern: 'options', |
64 | | - varsIgnorePattern: '^_', |
65 | | - ignoreRestSiblings: true, |
66 | | - args: 'after-used', |
67 | | - caughtErrorsIgnorePattern: '^_', |
68 | | - }, |
69 | | - ], |
70 | | - eqeqeq: ['error', 'always'], |
71 | | - 'consistent-return': 'error', |
72 | | - 'no-implicit-coercion': 'warn', |
73 | | - '@typescript-eslint/explicit-module-boundary-types': 'warn', |
74 | | - }, |
75 | 178 | }; |
0 commit comments