-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy patheslint.config.js
More file actions
196 lines (184 loc) · 5.06 KB
/
eslint.config.js
File metadata and controls
196 lines (184 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import globals from 'globals';
import { createRequire } from 'module';
// Load custom local rules
const require = createRequire(import.meta.url);
const localRules = require('./eslint-local-rules.cjs');
export default [
// Base configurations
js.configs.recommended,
...tseslint.configs.recommended,
// Global settings for all files
{
languageOptions: {
ecmaVersion: 2025,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
},
},
plugins: {
'@typescript-eslint': tseslint.plugin,
'local': {
rules: localRules,
},
},
rules: {
// Base rules for all files
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'no-console': ['warn', { allow: ['warn', 'error'] }],
// Custom rule: enforce test ID constants
'local/no-hardcoded-testid': 'warn',
},
},
// Test files - disable strict checks
{
files: [
'**/tests/**/*.ts',
'**/tests/**/*.tsx',
'**/*.test.ts',
'**/*.test.tsx',
'**/test-*.ts',
'**/test-*.tsx',
'**/*.spec.ts',
'**/*.spec.tsx',
'**/*.extended.test.tsx',
'**/*.comprehensive.test.tsx',
'**/*.enhanced.test.tsx',
'**/*.darkmode.test.tsx',
],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-console': 'off',
'local/no-hardcoded-testid': 'off', // Allow hardcoded test IDs in tests
},
},
// Mock files - be more lenient
{
files: [
'**/__mocks__/**',
'**/mocks/**',
'**/*.mock.ts',
'**/*.mock.tsx',
'**/testMocks.ts',
'**/testMocks/**',
'**/testUtils/**',
'**/mockFactory.ts',
],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
// Type definition files - special handling
{
files: ['**/*.d.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
// Empty interfaces extending supertypes are common in declaration merging
'@typescript-eslint/no-empty-object-type': 'off',
// Triple-slash references are standard in .d.ts files
'@typescript-eslint/triple-slash-reference': 'off',
},
},
// Service and utility files
{
files: ['**/services/**', '**/utils/**'],
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
// Component files - relax unused vars rules for props destructuring
{
files: ['**/components/**/*.tsx', '**/components/**/*.ts'],
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_|^props$|^e$|^event$|^component$',
varsIgnorePattern:
'^_|^React$|options$|Level$|className$|color$|description$|container$|rerender$|totalScore$|compact$|show|span$',
ignoreRestSiblings: true,
},
],
},
},
// Widget files - have complex prop patterns
{
files: ['**/widgets/**/*.tsx'],
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern:
'^_|.*Level$|^roi.*|^options$|^break.*$|^total.*$|^.*Estimate$',
ignoreRestSiblings: true,
},
],
},
},
// Hook files and their tests
{
files: ['**/hooks/**/*.ts', '**/hooks/**/*.tsx'],
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_|^use.*$|^render.*$',
ignoreRestSiblings: true,
},
],
},
},
// Cypress files - allow idiomatic patterns
{
files: [
'cypress/**/*.ts',
'cypress/**/*.js',
'cypress.config.ts',
],
rules: {
// Cypress uses global namespace augmentation for custom commands
'@typescript-eslint/no-namespace': 'off',
// Cypress support files use require() to control load order
'@typescript-eslint/no-require-imports': 'off',
// Chai-style assertions like expect(x).to.be.true are expressions
'@typescript-eslint/no-unused-expressions': 'off',
// Allow any in Cypress test/support code
'@typescript-eslint/no-explicit-any': 'off',
// Allow Function type in Cypress support shims
'@typescript-eslint/no-unsafe-function-type': 'off',
// Allow console in Cypress support/test files
'no-console': 'off',
// Allow hardcoded test IDs in Cypress tests
'local/no-hardcoded-testid': 'off',
},
},
// Files to ignore
{
ignores: [
'node_modules/**/*.*',
'dist/**',
'build/',
'coverage/',
'**/*.js.map',
'**/*.d.ts.map',
'docs/**',
],
},
];