Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
328 lines (324 loc) · 9.45 KB
/
Copy patheslint.config.js
File metadata and controls
328 lines (324 loc) · 9.45 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
// ESLint 10 flat config for HTTPS-Proxy
// https://eslint.org/docs/latest/use/configure/configuration-files
const js = require('@eslint/js');
const unusedImports = require('eslint-plugin-unused-imports');
module.exports = [
{
ignores: [
'node_modules/**',
'**/node_modules/**',
'dist/**',
'build/**',
'coverage/**',
'runtime/evidence-gateway/**',
'runtime/local-evidence-plugin/**',
'tauri-ui/dist/**',
'tauri-ui/node_modules/**',
'src-tauri/target/**',
'src-tauri/target*/**',
'src-tauri/gen/**',
'**/*.min.js',
'test.json',
'400',
'prev_electron_ui.html',
'.hpm-runtime/**',
'.hpm-runtime-probe/**',
// Generated probes and frozen acceptance copies are evidence, not source.
// Source/test boundaries remain enforced by governance/lint-scope.test.js.
'**/.hpm-acceptance/**',
'.codex-tmp/**',
'tmp/**',
'.tmp*/**',
'.tmp*',
],
},
js.configs.recommended,
{
plugins: {
'unused-imports': unusedImports,
},
},
{
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
languageOptions: {
ecmaVersion: 2024,
sourceType: 'commonjs',
globals: {
// Node.js
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly',
global: 'readonly',
console: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
setImmediate: 'readonly',
clearImmediate: 'readonly',
queueMicrotask: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
TextEncoder: 'readonly',
TextDecoder: 'readonly',
fetch: 'readonly',
},
},
rules: {
// Possible errors - keep strict
'no-undef': 'error',
// legacy: no-unused-vars remains warn. The big monolithic files
// (openai-proxy.js, app.js) get a per-file off override below until
// they are incrementally refactored.
'no-unused-vars': 'off', // provided by unused-imports/no-unused-vars below
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{
args: 'after-used',
argsIgnorePattern: '^_',
vars: 'all',
varsIgnorePattern: '^_',
// Legacy common short names for unused catch params. Allow e, err,
// error, and `e2` / `errHttps` / `errJs` style numbered variants.
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^(_|e$|err$|error$|e\\d+$|err[A-Z]\\w*|endErr$)',
},
],
'no-unused-expressions': [
'error',
{
allowTernary: true,
allowShortCircuit: true,
allowTaggedTemplates: true,
},
],
'no-dupe-keys': 'error',
'no-dupe-else-if': 'error',
'no-duplicate-case': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-fallthrough': 'error',
'no-inner-declarations': 'error',
'no-invalid-regexp': 'error',
'no-obj-calls': 'error',
'no-prototype-builtins': 'error',
'no-regex-spaces': 'warn',
'no-sparse-arrays': 'error',
'no-unreachable': 'error',
'no-unsafe-finally': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',
// Best practices
'no-console': 'off', // we rely on console.* throughout
'no-debugger': 'warn',
'no-eval': 'error',
'no-implied-eval': 'error',
'no-var': 'error',
'prefer-const': 'warn',
'prefer-template': 'off', // too noisy on existing code
eqeqeq: ['error', 'smart'],
'no-multi-spaces': ['warn', { ignoreEOLComments: true }],
'no-multi-str': 'warn',
'no-new-func': 'error',
'no-useless-escape': 'warn', // legacy fixtures
'no-useless-catch': 'warn',
'no-async-promise-executor': 'warn', // legacy
'no-redeclare': 'warn', // legacy: tighten incrementally
// Style (relaxed - prettier handles formatting)
indent: 'off',
'no-trailing-spaces': 'warn',
'space-before-function-paren': 'off',
quotes: 'off',
semi: 'off',
'comma-dangle': 'off',
},
},
{
files: ['lib/proxy/**/*.js', 'openai-proxy.js'],
ignores: ['lib/proxy/logger.js', 'lib/proxy/runtime-support.js'],
rules: {
'no-console': 'error',
},
},
{
// Tests get a slightly looser rule set
files: ['test/**/*.js', '**/*.test.js'],
languageOptions: {
sourceType: 'module',
globals: {
describe: 'readonly',
it: 'readonly',
test: 'readonly',
before: 'readonly',
beforeEach: 'readonly',
after: 'readonly',
afterEach: 'readonly',
expect: 'readonly',
assert: 'readonly',
sinon: 'readonly',
jest: 'readonly',
},
},
rules: {
'no-unused-expressions': 'off',
},
},
{
// ESM sources (Vite entry, tauri-ui/src/*, *.mjs config files)
files: ['**/*.mjs', 'vite.config.mjs', 'eslint.config.js'],
languageOptions: {
sourceType: 'module',
},
},
{
// ESM modules in tauri-ui/src/ run in the browser (Vite-bundled). Add
// browser globals so `document` and friends are recognized.
files: ['tauri-ui/src/**/*.js'],
languageOptions: {
sourceType: 'module',
globals: {
window: 'readonly',
document: 'readonly',
console: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
fetch: 'readonly',
Promise: 'readonly',
Map: 'readonly',
Set: 'readonly',
WeakMap: 'readonly',
WeakSet: 'readonly',
Symbol: 'readonly',
Proxy: 'readonly',
Reflect: 'readonly',
JSON: 'readonly',
Math: 'readonly',
Date: 'readonly',
RegExp: 'readonly',
Error: 'readonly',
TypeError: 'readonly',
ArrayBuffer: 'readonly',
TextEncoder: 'readonly',
TextDecoder: 'readonly',
HTMLElement: 'readonly',
Element: 'readonly',
Notification: 'readonly',
customElements: 'readonly',
},
},
},
{
// Browser-side ESM modules are bundled by Vite and share explicit imports.
files: ['tauri-ui/src/app/**/*.js'],
languageOptions: {
sourceType: 'module',
globals: {
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
location: 'readonly',
history: 'readonly',
localStorage: 'readonly',
sessionStorage: 'readonly',
alert: 'readonly',
confirm: 'readonly',
prompt: 'readonly',
fetch: 'readonly',
FormData: 'readonly',
FileReader: 'readonly',
Blob: 'readonly',
File: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
Headers: 'readonly',
WebSocket: 'readonly',
EventSource: 'readonly',
AbortController: 'readonly',
AbortSignal: 'readonly',
HTMLElement: 'readonly',
Element: 'readonly',
Notification: 'readonly',
customElements: 'readonly',
requestAnimationFrame: 'readonly',
cancelAnimationFrame: 'readonly',
IntersectionObserver: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
console: 'readonly',
Promise: 'readonly',
Map: 'readonly',
Set: 'readonly',
WeakMap: 'readonly',
WeakSet: 'readonly',
Symbol: 'readonly',
Proxy: 'readonly',
Reflect: 'readonly',
JSON: 'readonly',
Math: 'readonly',
Date: 'readonly',
RegExp: 'readonly',
Error: 'readonly',
TypeError: 'readonly',
RangeError: 'readonly',
SyntaxError: 'readonly',
ArrayBuffer: 'readonly',
Uint8Array: 'readonly',
TextEncoder: 'readonly',
TextDecoder: 'readonly',
atob: 'readonly',
btoa: 'readonly',
crypto: 'readonly',
performance: 'readonly',
jQuery: 'readonly',
},
},
rules: {
'no-unused-vars': 'off',
'unused-imports/no-unused-vars': 'off',
'no-unused-expressions': 'off',
'no-console': 'error',
'no-empty': ['error', { allowEmptyCatch: false }],
},
},
{
// Big monoliths retain existing dead-binding noise until domain extraction.
files: ['openai-proxy.js', 'tauri-ui/src/app/bootstrap.js'],
rules: {
'unused-imports/no-unused-vars': 'off',
'prefer-const': 'off',
},
},
{
// VSCode extension is ESM-flavored CJS
files: ['tools/trae-openai-bridge-extension/**/*.js'],
languageOptions: {
ecmaVersion: 2024,
sourceType: 'module',
globals: {
vscode: 'readonly',
process: 'readonly',
console: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
TextEncoder: 'readonly',
TextDecoder: 'readonly',
},
},
},
];