-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheslint.config.cjs
More file actions
372 lines (363 loc) · 13.1 KB
/
Copy patheslint.config.cjs
File metadata and controls
372 lines (363 loc) · 13.1 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
const js = require('@eslint/js')
const tsParser = require('@typescript-eslint/parser')
const tsPlugin = require('@typescript-eslint/eslint-plugin')
const importPlugin = require('eslint-plugin-import')
const unicorn = require('eslint-plugin-unicorn')
const prettierConfig = require('eslint-config-prettier')
const prettierPlugin = require('eslint-plugin-prettier')
const security = require('eslint-plugin-security')
module.exports = [
{
ignores: ['node_modules/**', '**/dist/**', '**/.tsup/**']
},
// Base JS config
{
...js.configs.recommended,
plugins: {
unicorn,
import: importPlugin,
prettier: prettierPlugin
},
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module'
},
rules: {
...prettierConfig.rules,
'prettier/prettier': [
'error',
{
bracketSpacing: true,
semi: false,
singleQuote: true,
trailingComma: 'none'
}
],
quotes: ['error', 'single', { avoidEscape: true }],
camelcase: ['error', { properties: 'never' }],
semi: ['error', 'never'],
eqeqeq: ['error', 'always'],
'prefer-const': 'error',
'no-multiple-empty-lines': [2, { max: 1, maxEOF: 1 }],
'array-bracket-spacing': ['error', 'never'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'comma-spacing': ['error', { before: false, after: true }],
'no-lonely-if': 'error',
'dot-notation': 'error',
'no-else-return': 'error',
'no-tabs': 'error',
'no-trailing-spaces': [
'error',
{ skipBlankLines: false, ignoreComments: false }
],
'no-var': 'error',
'unicode-bom': ['error', 'never'],
curly: ['error', 'all'],
'object-curly-spacing': ['error', 'always'],
'keyword-spacing': ['error'],
'require-atomic-updates': 0,
'linebreak-style': ['error', 'unix'],
'import/extensions': ['error', 'ignorePackages'],
'no-restricted-syntax': [
'error',
'IfStatement > ExpressionStatement > AssignmentExpression'
]
}
},
// TypeScript files
{
files: ['**/*.ts'],
plugins: {
'@typescript-eslint': tsPlugin
},
languageOptions: {
parser: tsParser
},
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true }
],
'@typescript-eslint/consistent-type-imports': 'error',
'no-unused-vars': 'off',
'no-undef': 'off',
'no-redeclare': 'off'
}
},
// Code-quality warnings (CLAUDE.md §3).
// Kept as `warn` so existing legacy violations surface in IDE/CI without
// blocking the build. Promote to `error` once known debt (CLAUDE.md §7)
// is cleared.
// MUST come before the test-file override block — flat config rule blocks
// apply in order, so later blocks override earlier ones for matching files.
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'max-lines': [
'warn',
{ max: 500, skipBlankLines: true, skipComments: true }
],
'max-lines-per-function': [
'warn',
{ max: 50, skipBlankLines: true, skipComments: true, IIFEs: true }
]
}
},
// Security rules — local mirror of the high-signal CodeQL findings that
// burned us in CI. Keeps the round-trip short: `pnpm lint` flags the same
// patterns the PR's CodeQL scan would. GitHub-managed default-setup CodeQL
// still runs as the authoritative gate (it has taint flow /
// interprocedural analysis these rules can't match).
//
// Rule selection is conservative — rules that produced >0 true positives
// here or that fire on unambiguously bad patterns (eval, new Buffer).
// Excluded:
// - detect-non-literal-fs-filename: 50+ false positives on legitimate
// internal file reads (config/test-file discovery, source loading).
// - detect-non-literal-require: createRequire patterns are by design.
// - detect-object-injection: fires on every `arr[i]`.
// - detect-possible-timing-attacks: not relevant for this dashboard.
{
files: ['**/*.{ts,tsx,js,mjs,cjs}'],
plugins: { security },
rules: {
// Matches CodeQL `js/polynomial-redos` + `js/redos`. The detector is
// somewhat over-conservative (flags benign `(\d+)?` patterns) but the
// false-positive cost (one-off review) is lower than missing a real
// ReDoS — keep at `warn`.
'security/detect-unsafe-regex': 'warn',
// Matches CodeQL `js/non-literal-regexp`. `new RegExp(userInput)` is a
// ReDoS vector; even when inputs are controlled it's worth eyes.
'security/detect-non-literal-regexp': 'warn',
// Matches CodeQL `js/code-injection`. Should never appear.
'security/detect-eval-with-expression': 'error',
// Node.js footguns that should never appear in production code.
'security/detect-buffer-noassert': 'error',
'security/detect-new-buffer': 'error',
'security/detect-pseudoRandomBytes': 'error'
}
},
// TypeScript test files — turns off the size rules. MUST come AFTER the
// production rules block above so the off-rule wins for matching files.
{
files: ['**/*.test.ts'],
rules: {
'dot-notation': 'off',
'max-lines': 'off',
'max-lines-per-function': 'off',
// Test fixtures intentionally use `any` to construct partial mocks
// without restating every field of the real type. The cost of forcing
// proper types here is high (lots of `as unknown as RealType` casts)
// and the benefit is low — tests don't ship.
'@typescript-eslint/no-explicit-any': 'off',
// Tests legitimately build dynamic regexes from fixture data.
'security/detect-non-literal-regexp': 'off',
'security/detect-unsafe-regex': 'off'
}
},
// CLAUDE.md §2.3 — no cross-adapter imports.
// Adapters (service, nightwatch-devtools, selenium-devtools) own
// framework-specific glue only. Anything shared between them belongs in
// packages/core (and is currently duplicated — see CLAUDE.md §7).
{
files: ['packages/service/**/*.{ts,tsx,js,mjs,cjs}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@wdio/nightwatch-devtools',
'@wdio/nightwatch-devtools/*'
],
message:
'Adapters must not import from each other (CLAUDE.md §2.3). Extract shared logic to packages/core.'
},
{
group: ['@wdio/selenium-devtools', '@wdio/selenium-devtools/*'],
message:
'Adapters must not import from each other (CLAUDE.md §2.3). Extract shared logic to packages/core.'
}
]
}
]
}
},
{
files: ['packages/nightwatch-devtools/**/*.{ts,tsx,js,mjs,cjs}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@wdio/devtools-service', '@wdio/devtools-service/*'],
message:
'Adapters must not import from each other (CLAUDE.md §2.3). Extract shared logic to packages/core.'
},
{
group: ['@wdio/selenium-devtools', '@wdio/selenium-devtools/*'],
message:
'Adapters must not import from each other (CLAUDE.md §2.3). Extract shared logic to packages/core.'
}
]
}
]
}
},
{
files: ['packages/selenium-devtools/**/*.{ts,tsx,js,mjs,cjs}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@wdio/devtools-service', '@wdio/devtools-service/*'],
message:
'Adapters must not import from each other (CLAUDE.md §2.3). Extract shared logic to packages/core.'
},
{
group: [
'@wdio/nightwatch-devtools',
'@wdio/nightwatch-devtools/*'
],
message:
'Adapters must not import from each other (CLAUDE.md §2.3). Extract shared logic to packages/core.'
}
]
}
]
}
},
// CLAUDE.md §2.4 — backend does not import from adapters or app.
// Backend is framework-agnostic; framework branching uses a typed
// FrameworkId from packages/shared, never adapter internals.
{
files: ['packages/backend/**/*.{ts,tsx,js,mjs,cjs}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@wdio/devtools-service', '@wdio/devtools-service/*'],
message:
'Backend must not depend on any adapter (CLAUDE.md §2.4). Move shared types/constants to packages/shared.'
},
{
group: [
'@wdio/nightwatch-devtools',
'@wdio/nightwatch-devtools/*'
],
message:
'Backend must not depend on any adapter (CLAUDE.md §2.4). Move shared types/constants to packages/shared.'
},
{
group: ['@wdio/selenium-devtools', '@wdio/selenium-devtools/*'],
message:
'Backend must not depend on any adapter (CLAUDE.md §2.4). Move shared types/constants to packages/shared.'
},
{
group: ['@/*', '@components/*'],
message:
'Backend must not import from app (CLAUDE.md §2.4). App talks to backend over WS/HTTP using shared contracts.'
},
{
group: ['@wdio/devtools-core', '@wdio/devtools-core/*'],
message:
'Backend must not depend on core (CLAUDE.md §2.2). core is framework-agnostic adapter logic; backend only needs shared contracts.'
}
]
}
]
}
},
// CLAUDE.md §2.4 — app does not import from adapters or backend.
// App communicates with backend only over WS/HTTP, with contracts
// defined in packages/shared.
{
files: ['packages/app/**/*.{ts,tsx,js,mjs,cjs}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@wdio/devtools-service', '@wdio/devtools-service/*'],
message:
'App must not import from adapters (CLAUDE.md §2.4). Move shared types/constants to packages/shared.'
},
{
group: [
'@wdio/nightwatch-devtools',
'@wdio/nightwatch-devtools/*'
],
message:
'App must not import from adapters (CLAUDE.md §2.4). Move shared types/constants to packages/shared.'
},
{
group: ['@wdio/selenium-devtools', '@wdio/selenium-devtools/*'],
message:
'App must not import from adapters (CLAUDE.md §2.4). Move shared types/constants to packages/shared.'
},
{
group: ['@wdio/devtools-backend', '@wdio/devtools-backend/*'],
message:
'App must not import from backend directly (CLAUDE.md §2.4). Communicate via WS/HTTP using shared contracts.'
},
{
group: ['@wdio/devtools-core', '@wdio/devtools-core/*'],
message:
'App must not import from core (CLAUDE.md §2.2). core is framework-agnostic adapter logic; the app receives normalized events over WS.'
}
]
}
]
}
},
// CLAUDE.md §2.2 — core is for adapters only. Backend, app, and script
// must not depend on core. Core itself may only import from shared.
{
files: ['packages/core/**/*.{ts,tsx,js,mjs,cjs}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@wdio/devtools-service', '@wdio/devtools-service/*'],
message:
'core must not depend on any adapter (CLAUDE.md §2.2). Adapters import core, not the other way around.'
},
{
group: [
'@wdio/nightwatch-devtools',
'@wdio/nightwatch-devtools/*'
],
message:
'core must not depend on any adapter (CLAUDE.md §2.2). Adapters import core, not the other way around.'
},
{
group: ['@wdio/selenium-devtools', '@wdio/selenium-devtools/*'],
message:
'core must not depend on any adapter (CLAUDE.md §2.2). Adapters import core, not the other way around.'
},
{
group: ['@wdio/devtools-backend', '@wdio/devtools-backend/*'],
message:
'core must not depend on backend (CLAUDE.md §2.2). core is the lower layer.'
},
{
group: ['@/*', '@components/*'],
message:
'core must not depend on app (CLAUDE.md §2.2). core is Node-side adapter logic.'
}
]
}
]
}
}
]