@rexezuge/tooling 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint-boundaries.d.ts +75 -0
- package/dist/eslint-boundaries.d.ts.map +1 -0
- package/dist/eslint-boundaries.js +138 -0
- package/dist/eslint-boundaries.js.map +1 -0
- package/dist/eslint-rules.d.ts +41 -0
- package/dist/eslint-rules.d.ts.map +1 -0
- package/dist/eslint-rules.js +273 -0
- package/dist/eslint-rules.js.map +1 -0
- package/dist/eslint.d.ts +11 -35
- package/dist/eslint.d.ts.map +1 -1
- package/dist/eslint.js +27 -389
- package/dist/eslint.js.map +1 -1
- package/package.json +2 -2
- package/src/eslint-boundaries.ts +169 -0
- package/src/eslint-rules.ts +276 -0
- package/src/eslint.ts +28 -411
package/dist/eslint.js
CHANGED
|
@@ -6,23 +6,14 @@
|
|
|
6
6
|
* rules). Merged in from the other three stacks that share the same plugin set:
|
|
7
7
|
*
|
|
8
8
|
* - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,
|
|
9
|
-
* with a narrow override block for Vitest idioms), and
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* complying would make the code worse for what the project is, and each is
|
|
13
|
-
* listed rather than dropped so the decision stays reviewable.
|
|
14
|
-
* - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.
|
|
9
|
+
* with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`
|
|
10
|
+
* is off. Edge-Sonic is also the source for the dynamic-`import()` boundary
|
|
11
|
+
* guard and its `apps/web` layer block.
|
|
15
12
|
* - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.
|
|
16
13
|
* - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses
|
|
17
|
-
* `allowTypeImports` where the source repos do. It is also the source for
|
|
18
|
-
* anchored skip patterns and the symlink-safe walk that came out of its own
|
|
19
|
-
*
|
|
20
|
-
* with a narrow override block for Vitest idioms), `unicorn/prefer-ternary` is off
|
|
21
|
-
* with a documented reason, and the `import()` hole in `no-restricted-imports` is
|
|
22
|
-
* covered by a matching `no-restricted-syntax` rule. Edge-Sonic's per-rule
|
|
23
|
-
* "deliberately does not follow" block is carried over verbatim in spirit: each
|
|
24
|
-
* entry is off because complying would make the code worse for what the project
|
|
25
|
-
* is, and each is listed rather than dropped so the decision stays reviewable.
|
|
14
|
+
* `allowTypeImports` where the source repos do not. It is also the source for
|
|
15
|
+
* the anchored skip patterns and the symlink-safe walk that came out of its own
|
|
16
|
+
* backlog.
|
|
26
17
|
*
|
|
27
18
|
* Canonical decisions, and why each one:
|
|
28
19
|
*
|
|
@@ -32,6 +23,7 @@
|
|
|
32
23
|
* 2. **The layered boundary rules are parameterized by `scope`.** Every source
|
|
33
24
|
* repo wrote the same seven blocks with a different npm scope hardcoded; the
|
|
34
25
|
* factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.
|
|
26
|
+
* The table itself lives in {@link ./eslint-boundaries}.
|
|
35
27
|
* 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;
|
|
36
28
|
* Edge-Sonic does not, and records why: ~200 KB of test code had accumulated
|
|
37
29
|
* violations that nothing reported.
|
|
@@ -47,8 +39,9 @@
|
|
|
47
39
|
* zero-dependency, and the plugin belongs to the app that has JSX. A consumer
|
|
48
40
|
* appends it — the README shows the four lines.
|
|
49
41
|
*
|
|
50
|
-
* The
|
|
51
|
-
*
|
|
42
|
+
* The rule bodies live in {@link ./eslint-rules} and the boundary table in
|
|
43
|
+
* {@link ./eslint-boundaries}; this file is the assembly. A repo that needs a
|
|
44
|
+
* boundary the canonical table does not name passes `extraLayers` — see
|
|
52
45
|
* {@link RepoLintConfigOptions}.
|
|
53
46
|
*/
|
|
54
47
|
import globals from 'globals';
|
|
@@ -58,6 +51,8 @@ import { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';
|
|
|
58
51
|
import pluginRegexp from 'eslint-plugin-regexp';
|
|
59
52
|
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
60
53
|
import prettier from 'eslint-plugin-prettier';
|
|
54
|
+
import { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries';
|
|
55
|
+
import { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules';
|
|
61
56
|
/**
|
|
62
57
|
* Bridge a third-party preset into `tseslint.config()`.
|
|
63
58
|
*
|
|
@@ -70,133 +65,17 @@ function asConfig(config) {
|
|
|
70
65
|
return config;
|
|
71
66
|
}
|
|
72
67
|
/**
|
|
73
|
-
*
|
|
74
|
-
*/
|
|
75
|
-
const DEFAULT_PROJECT_DIRS = [
|
|
76
|
-
'packages/shared',
|
|
77
|
-
'packages/backend-errors',
|
|
78
|
-
'packages/backend-runtime',
|
|
79
|
-
'packages/backend-data',
|
|
80
|
-
'packages/backend-services',
|
|
81
|
-
'apps/api',
|
|
82
|
-
'apps/background',
|
|
83
|
-
'apps/web',
|
|
84
|
-
];
|
|
85
|
-
/**
|
|
86
|
-
* The layer table, parameterized by `scope`.
|
|
68
|
+
* Bridge a rule block onto `tseslint.config()`'s `rules` field.
|
|
87
69
|
*
|
|
88
|
-
*
|
|
89
|
-
* `
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
70
|
+
* The blocks in `eslint-rules.ts` are written as ESLint expects them —
|
|
71
|
+
* `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a
|
|
72
|
+
* rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`
|
|
73
|
+
* union is narrower than the data shape, and widening every entry to that union
|
|
74
|
+
* would buy nothing; one assertion here, with the reason, is the cheaper and
|
|
75
|
+
* more honest of the two.
|
|
94
76
|
*/
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
return [
|
|
98
|
-
{
|
|
99
|
-
dir: 'packages/shared',
|
|
100
|
-
ban: [at('*')],
|
|
101
|
-
message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
dir: 'packages/backend-errors',
|
|
105
|
-
ban: [at('*')],
|
|
106
|
-
message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
dir: 'packages/backend-runtime',
|
|
110
|
-
ban: [at('backend-data'), at('webdav'), at('backend-services'), at('api'), at('background')],
|
|
111
|
-
message: 'backend-runtime must not import from a higher layer',
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
dir: 'packages/backend-data',
|
|
115
|
-
ban: [at('backend-runtime'), at('webdav'), at('backend-services'), at('api'), at('background')],
|
|
116
|
-
message: 'backend-data must not import from a higher layer',
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
dir: 'packages/backend-services',
|
|
120
|
-
ban: [at('api'), at('background')],
|
|
121
|
-
message: 'backend-services must not import from apps',
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
dir: 'apps/api',
|
|
125
|
-
ban: [at('backend-data/dao'), at('backend-data')],
|
|
126
|
-
allowTypeImports: true,
|
|
127
|
-
message: 'apps/api must not import DAOs or backend-data values directly; use backend-services instead',
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
dir: 'apps/background',
|
|
131
|
-
ban: [at('api')],
|
|
132
|
-
message: 'apps/background must not import from apps/api',
|
|
133
|
-
},
|
|
134
|
-
// The browser half, and the only layer that bans the namespace wholesale
|
|
135
|
-
// rather than a list of siblings: a backend package imported by the SPA
|
|
136
|
-
// typechecks and then fails at bundle time, with the error pointing at the
|
|
137
|
-
// bundler rather than at the boundary. Edge-Sonic is the source; the others had
|
|
138
|
-
// no block for it at all, which is how their layer table's "may import: the
|
|
139
|
-
// browser" was a convention instead of a gate.
|
|
140
|
-
{
|
|
141
|
-
dir: 'apps/web',
|
|
142
|
-
ban: [at('*')],
|
|
143
|
-
message: `${at('apps/web')} ships zero backend dependencies — this module is the SPA's own copy`,
|
|
144
|
-
},
|
|
145
|
-
];
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* The `no-restricted-imports` entries for one layer.
|
|
149
|
-
*
|
|
150
|
-
* Written as `group` patterns rather than exact `paths`, so `@myapp/backend-data`
|
|
151
|
-
* and `@myapp/backend-data/dao` are both caught by one entry. `allowTypeImports`
|
|
152
|
-
* is passed through only where the source repos set it, because
|
|
153
|
-
* `apps/api` legitimately types its filters and models against DAO shapes.
|
|
154
|
-
*/
|
|
155
|
-
function restrictedImports(bans) {
|
|
156
|
-
return bans.map(({ dir, ban, message, allowTypeImports }) => ({
|
|
157
|
-
files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],
|
|
158
|
-
rules: {
|
|
159
|
-
'no-restricted-imports': [
|
|
160
|
-
'error',
|
|
161
|
-
{
|
|
162
|
-
patterns: ban.map((group) => ({
|
|
163
|
-
group: [group, `${group}/*`],
|
|
164
|
-
message,
|
|
165
|
-
...(allowTypeImports === true && { allowTypeImports: true }),
|
|
166
|
-
})),
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
},
|
|
170
|
-
}));
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* The dynamic-`import()` guard, generated from the same table.
|
|
174
|
-
*
|
|
175
|
-
* `no-restricted-imports` reads `ImportDeclaration` nodes only; a dynamic
|
|
176
|
-
* `import()` is an `ImportExpression`, and this ESLint version does not report it
|
|
177
|
-
* under that rule at all. Edge-Sonic verified this rather than assumed it — a
|
|
178
|
-
* static import of a restricted specifier from the same file is an `error`, and
|
|
179
|
-
* the identical specifier reached through `await import(...)` is silent. That
|
|
180
|
-
* hole was load-bearing there: the credential path reached a banned module
|
|
181
|
-
* through it. `no-restricted-syntax` sees `ImportExpression`, so the boundary is
|
|
182
|
-
* stated a second way.
|
|
183
|
-
*
|
|
184
|
-
* The specifier list is duplicated from the layer table on purpose; see the
|
|
185
|
-
* comment on `layerBans`.
|
|
186
|
-
*/
|
|
187
|
-
function restrictedDynamicImports(bans) {
|
|
188
|
-
return bans.map(({ dir, ban, message }) => ({
|
|
189
|
-
files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],
|
|
190
|
-
rules: {
|
|
191
|
-
'no-restricted-syntax': [
|
|
192
|
-
'error',
|
|
193
|
-
...ban.map((specifier) => ({
|
|
194
|
-
selector: `ImportExpression[source.type='Literal'][source.value=/^${specifier.replaceAll('/', '\\/')}/]`,
|
|
195
|
-
message: `A dynamic import() is not covered by no-restricted-imports, so this layer reaches \`${specifier}\` through the one syntax that gate does not see. Both say no: ${message}`,
|
|
196
|
-
})),
|
|
197
|
-
],
|
|
198
|
-
},
|
|
199
|
-
}));
|
|
77
|
+
function asRules(block) {
|
|
78
|
+
return block;
|
|
200
79
|
}
|
|
201
80
|
/**
|
|
202
81
|
* Build the repo's flat config.
|
|
@@ -258,194 +137,15 @@ export function defineRepoLintConfig(options) {
|
|
|
258
137
|
// --- typescript-eslint overrides (identical in all four source stacks) ---
|
|
259
138
|
{
|
|
260
139
|
files: ['**/*.{ts,mts,cts,tsx}'],
|
|
261
|
-
rules:
|
|
262
|
-
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
|
263
|
-
// Allow `void expr` for intentional fire-and-forget in Workers.
|
|
264
|
-
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
|
|
265
|
-
// Relax the unsafe-any rules to warn: the external API boundaries
|
|
266
|
-
// (Cloudflare bindings, provider SDKs) are typed `any` upstream, and the
|
|
267
|
-
// alternative is a config that cannot be adopted.
|
|
268
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
269
|
-
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
270
|
-
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
271
|
-
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
272
|
-
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
273
|
-
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
274
|
-
// JSX event handlers and hook callback objects commonly use async
|
|
275
|
-
// functions where void is expected.
|
|
276
|
-
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { attributes: false, properties: false } }],
|
|
277
|
-
},
|
|
140
|
+
rules: asRules(TYPESCRIPT_RULES),
|
|
278
141
|
},
|
|
279
142
|
// --- Unicorn: modern JS/TS quality rules ---
|
|
280
143
|
asConfig(unicorn.configs['flat/recommended']), {
|
|
281
|
-
rules:
|
|
282
|
-
// Codebase uses ctx, req, res, env, err, util, db, dao, etc. — too
|
|
283
|
-
// invasive to rename.
|
|
284
|
-
'unicorn/prevent-abbreviations': 'off',
|
|
285
|
-
// D1/DAO layer returns null; disabling this avoids mass rewrites.
|
|
286
|
-
'unicorn/no-null': 'off',
|
|
287
|
-
// Monorepo uses CommonJS-compatible module style in some configs.
|
|
288
|
-
'unicorn/prefer-module': 'off',
|
|
289
|
-
// Top-level await not available in all Workers entry points.
|
|
290
|
-
'unicorn/prefer-top-level-await': 'off',
|
|
291
|
-
// Error subclassing via `new MyError()` is intentional in backend-errors.
|
|
292
|
-
'unicorn/custom-error-definition': 'off',
|
|
293
|
-
// Allow process.exit in build/script files.
|
|
294
|
-
'unicorn/no-process-exit': 'off',
|
|
295
|
-
// Array reduce is used intentionally in analytics/data transformation.
|
|
296
|
-
'unicorn/no-array-reduce': 'off',
|
|
297
|
-
// Allow Number() — parseInt/parseFloat are used in some cases intentionally.
|
|
298
|
-
'unicorn/prefer-number-properties': ['error', { checkInfinity: false }],
|
|
299
|
-
// Allow nested ternaries in JSX (React render patterns).
|
|
300
|
-
'unicorn/no-nested-ternary': 'off',
|
|
301
|
-
// Allow Array.from — codebase uses it for iterables.
|
|
302
|
-
'unicorn/prefer-spread': 'off',
|
|
303
|
-
// Entire codebase uses PascalCase for TS files; kebab-case would require
|
|
304
|
-
// mass renames.
|
|
305
|
-
'unicorn/filename-case': 'off',
|
|
306
|
-
// Established names should not be force-renamed.
|
|
307
|
-
'unicorn/name-replacements': 'off',
|
|
308
|
-
// Zod schema builder chains and other deep method chains are intentional.
|
|
309
|
-
'unicorn/max-nested-calls': 'off',
|
|
310
|
-
// import.meta.dirname is not available in all test environments.
|
|
311
|
-
'unicorn/prefer-import-meta-properties': 'off',
|
|
312
|
-
// Codebase uses `err` as catch parameter name throughout.
|
|
313
|
-
'unicorn/catch-error-name': 'off',
|
|
314
|
-
// Established boolean param names (retryable, enabled, etc.).
|
|
315
|
-
'unicorn/consistent-boolean-name': 'off',
|
|
316
|
-
// Uint8Array#toBase64 / fromBase64 are not in all Workers runtime versions.
|
|
317
|
-
'unicorn/prefer-uint8array-base64': 'off',
|
|
318
|
-
// Class member ordering would require extensive restructuring.
|
|
319
|
-
'unicorn/consistent-class-member-order': 'off',
|
|
320
|
-
// API response fields use verb prefixes by convention.
|
|
321
|
-
'unicorn/no-non-function-verb-prefix': 'off',
|
|
322
|
-
// forEach is used intentionally throughout the provider and utility layers.
|
|
323
|
-
'unicorn/no-for-each': 'off',
|
|
324
|
-
// .then() chains in DAO and provider layers are often intentional.
|
|
325
|
-
'unicorn/prefer-await': 'warn',
|
|
326
|
-
// Callback references (e.g. .map(Number)) are sometimes intentional.
|
|
327
|
-
'unicorn/no-array-callback-reference': 'warn',
|
|
328
|
-
// toSorted() is ES2023 and may not be in all tsconfig lib targets.
|
|
329
|
-
'unicorn/no-array-sort': 'warn',
|
|
330
|
-
// Early-return guard clauses are the established style; the rule only
|
|
331
|
-
// rewrites the final guard of a ladder, which yields asymmetric mixed
|
|
332
|
-
// style and long inline ternaries. Off in Mail-Meow and Edge-Sonic;
|
|
333
|
-
// canonical here because it is the family's established style.
|
|
334
|
-
'unicorn/prefer-ternary': 'off',
|
|
335
|
-
// `(await x).y` -> a named intermediate. Fires constantly in the tests,
|
|
336
|
-
// where destructuring beside the assertion it serves is clearer.
|
|
337
|
-
'unicorn/no-await-expression-member': 'off',
|
|
338
|
-
// `Number(x)` over `+x`: the `+` form is used where an explicit typeof
|
|
339
|
-
// check has already narrowed the operand.
|
|
340
|
-
'unicorn/prefer-number-coercion': 'off',
|
|
341
|
-
// Code-point iteration: the byte-level readers index deliberately,
|
|
342
|
-
// because the offset *is* what they are reading.
|
|
343
|
-
'unicorn/prefer-code-point': 'off',
|
|
344
|
-
// `if (!x) return;` over a compound condition: one guard per line, each
|
|
345
|
-
// with its own comment, is what keeps endpoint guards readable.
|
|
346
|
-
'unicorn/prefer-simple-condition-first': 'off',
|
|
347
|
-
// Module-scope `let` assigned from `beforeEach` in the test harnesses.
|
|
348
|
-
'unicorn/no-top-level-assignment-in-function': 'off',
|
|
349
|
-
// Sequential `for...of` with `await` in the DAOs — D1's subrequest
|
|
350
|
-
// budget is the scarce resource.
|
|
351
|
-
'unicorn/no-unreadable-for-of-expression': 'off',
|
|
352
|
-
// `Object.hasOwn` over `in`: used where a prototype-chain hit is harmless.
|
|
353
|
-
'unicorn/no-computed-property-existence-check': 'off',
|
|
354
|
-
// A labeled `break` out of two loops.
|
|
355
|
-
'unicorn/no-break-in-nested-loop': 'off',
|
|
356
|
-
// `this` outside a class body: the module-level cache singletons
|
|
357
|
-
// document their `this` contract in prose.
|
|
358
|
-
'unicorn/no-this-outside-of-class': 'off',
|
|
359
|
-
// A class named inside its own static method.
|
|
360
|
-
'unicorn/class-reference-in-static-methods': 'off',
|
|
361
|
-
// `void promise` where initiating the call is the point and the rejection
|
|
362
|
-
// is handled at a named site elsewhere.
|
|
363
|
-
'sonarjs/void-use': 'off',
|
|
364
|
-
// An `async` function with no `await`: every handler and DAO method is
|
|
365
|
-
// `async` by shape so a future `await` does not change its signature.
|
|
366
|
-
'@typescript-eslint/require-await': 'off',
|
|
367
|
-
// Backtracking risk in bounded-prefix readers that run over a file the
|
|
368
|
-
// server already chose to fetch, never over a request parameter.
|
|
369
|
-
'sonarjs/super-linear-regex': 'off',
|
|
370
|
-
// Assigning `globalThis.fetch` in a test — the only way to intercept the
|
|
371
|
-
// ambient fetch in Node without a module mock.
|
|
372
|
-
'unicorn/no-global-object-property-assignment': 'off',
|
|
373
|
-
// `(a ? b : c) && d`: written longhand so each precedence decision is
|
|
374
|
-
// visible.
|
|
375
|
-
'unicorn/prefer-logical-operator-over-ternary': 'off',
|
|
376
|
-
// `children[0]` in the XML helpers, which index a child list positionally.
|
|
377
|
-
'unicorn/better-dom-traversing': 'off',
|
|
378
|
-
// `entries()` -> `keys()`/`values()`: the full entry is destructured.
|
|
379
|
-
'unicorn/prefer-iterator-to-array': 'off',
|
|
380
|
-
// `.map(fn, thisArg)`: rejected on purpose.
|
|
381
|
-
'unicorn/no-array-method-this-argument': 'off',
|
|
382
|
-
// A module-scope function that closes over nothing.
|
|
383
|
-
'unicorn/consistent-function-scoping': 'off',
|
|
384
|
-
// `foo[0] === 'a' || foo[0] === 'b'` written longhand where the
|
|
385
|
-
// alternatives are not adjacent.
|
|
386
|
-
'unicorn/prefer-includes-over-repeated-comparisons': 'off',
|
|
387
|
-
// A `type` alias over an inline union, where the name is what makes the
|
|
388
|
-
// signature and its doc comment readable.
|
|
389
|
-
'sonarjs/use-type-alias': 'off',
|
|
390
|
-
// A short local alias for a type imported from a protocol package.
|
|
391
|
-
'sonarjs/redundant-type-aliases': 'off',
|
|
392
|
-
// `type: value` narrowing the other way, where both spellings appear in
|
|
393
|
-
// the same schema and the code follows whichever the spec uses there.
|
|
394
|
-
'sonarjs/no-nested-assignment': 'off',
|
|
395
|
-
// `Number.isInteger` plus a separate range check, where the bounds come
|
|
396
|
-
// from the caller's own options in one place.
|
|
397
|
-
'unicorn/prefer-number-is-safe-integer': 'off',
|
|
398
|
-
// `\u{...}` over a `\xNN` escape: the table is written in the byte form
|
|
399
|
-
// the spec prints.
|
|
400
|
-
'unicorn/prefer-unicode-code-point-escapes': 'off',
|
|
401
|
-
// `self.x = this.x` in an entry model: the alias makes the verbatim
|
|
402
|
-
// round-trip explicit.
|
|
403
|
-
'unicorn/no-this-assignment': 'off',
|
|
404
|
-
// Building a `Set` at module scope from a constant list, for O(1)
|
|
405
|
-
// membership on a path that runs per parameter.
|
|
406
|
-
'unicorn/no-top-level-side-effects': 'off',
|
|
407
|
-
// `await` on a value the types say is not thenable, where the value is a
|
|
408
|
-
// `PromiseLike` from an interface declared that way.
|
|
409
|
-
'@typescript-eslint/await-thenable': 'off',
|
|
410
|
-
// A conditional whose branches are identical, kept where the two branches
|
|
411
|
-
// are named separately to document that they are meant to diverge.
|
|
412
|
-
'sonarjs/no-all-duplicated-branches': 'off',
|
|
413
|
-
// An `else` after a `return`: the flat form keeps the remaining cases at
|
|
414
|
-
// one indent level in the dispatch tables.
|
|
415
|
-
'unicorn/prefer-else-if': 'off',
|
|
416
|
-
// A nested ternary in a sort comparator, where the three-way order is the
|
|
417
|
-
// point.
|
|
418
|
-
'unicorn/prefer-minimal-ternary': 'off',
|
|
419
|
-
// `x === undefined` reported as always-true/false. With
|
|
420
|
-
// `noUncheckedIndexedAccess` on, the guard is exactly right.
|
|
421
|
-
'sonarjs/different-types-comparison': 'off',
|
|
422
|
-
// An accumulating loop with a sequential `await` in it, over D1 writes.
|
|
423
|
-
'unicorn/prefer-array-from-async': 'off',
|
|
424
|
-
},
|
|
144
|
+
rules: asRules(UNICORN_RULES),
|
|
425
145
|
},
|
|
426
146
|
// --- SonarJS: code smell and bug detection ---
|
|
427
147
|
asConfig(sonarjsConfigs.recommended), {
|
|
428
|
-
rules:
|
|
429
|
-
// Raise duplicate-string threshold to avoid flagging intentional repeated
|
|
430
|
-
// literals like provider IDs.
|
|
431
|
-
'sonarjs/no-duplicate-string': ['warn', { threshold: 5 }],
|
|
432
|
-
// Cognitive complexity — warn rather than error, so the ratchet can move
|
|
433
|
-
// without a red build. Raise the number only as files are decomposed.
|
|
434
|
-
'sonarjs/cognitive-complexity': ['warn', 20],
|
|
435
|
-
// False positives: connection method names like 'imap-password' and
|
|
436
|
-
// field names like 'password_hash'.
|
|
437
|
-
'sonarjs/no-hardcoded-passwords': 'off',
|
|
438
|
-
// Third-party deprecations are warnings, not errors.
|
|
439
|
-
'sonarjs/deprecation': 'warn',
|
|
440
|
-
// Nested ternaries in complex data-mapping code.
|
|
441
|
-
'sonarjs/no-nested-conditional': 'warn',
|
|
442
|
-
// React component props are commonly not marked Readonly<>.
|
|
443
|
-
'sonarjs/prefer-read-only-props': 'warn',
|
|
444
|
-
// Static readonly properties require invasive refactoring.
|
|
445
|
-
'sonarjs/public-static-readonly': 'warn',
|
|
446
|
-
// Nested template literals in SQL queries and prompt construction.
|
|
447
|
-
'sonarjs/no-nested-template-literals': 'warn',
|
|
448
|
-
},
|
|
148
|
+
rules: asRules(SONARJS_RULES),
|
|
449
149
|
},
|
|
450
150
|
// --- Regexp: static analysis for regular expressions ---
|
|
451
151
|
asConfig(pluginRegexp.configs['flat/recommended']),
|
|
@@ -479,73 +179,11 @@ export function defineRepoLintConfig(options) {
|
|
|
479
179
|
},
|
|
480
180
|
// --- Test suite ---
|
|
481
181
|
//
|
|
482
|
-
// `test/**` is deliberately NOT in the ignores list above.
|
|
483
|
-
//
|
|
484
|
-
// violations that nothing reported. This block puts the suite back under the
|
|
485
|
-
// same rules as the rest of the workspace and switches off only the handful
|
|
486
|
-
// whose findings are structural artefacts of test code rather than defects.
|
|
487
|
-
// It does not disable correctness rules: the unused-variable, dead-store,
|
|
488
|
-
// regex and sorting findings in the suite are real and are fixed, not
|
|
489
|
-
// suppressed.
|
|
182
|
+
// `test/**` is deliberately NOT in the ignores list above. See TEST_RULES
|
|
183
|
+
// for the override block and the reasoning behind it.
|
|
490
184
|
{
|
|
491
185
|
files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],
|
|
492
|
-
rules:
|
|
493
|
-
// `it('…', async () => …)` is the Vitest idiom.
|
|
494
|
-
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { arguments: false, attributes: false } }],
|
|
495
|
-
// Unbound method is a common false positive in mock assertions like
|
|
496
|
-
// expect(fn).toHaveBeenCalledWith(...).
|
|
497
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
498
|
-
// Test helpers and stubs routinely use async functions without await.
|
|
499
|
-
'@typescript-eslint/require-await': 'off',
|
|
500
|
-
// Redundant type constituents appear in typed mock stubs.
|
|
501
|
-
'@typescript-eslint/no-redundant-type-constituents': 'off',
|
|
502
|
-
// `as never` casts are the standard fake-DB double pattern in tests.
|
|
503
|
-
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
|
|
504
|
-
// Promise.withResolvers() and function-scoping refactors are cosmetic.
|
|
505
|
-
'unicorn/prefer-promise-with-resolvers': 'off',
|
|
506
|
-
'unicorn/consistent-function-scoping': 'off',
|
|
507
|
-
// Fake-DB builders push-then-return and sort without comparators.
|
|
508
|
-
'unicorn/no-return-array-push': 'off',
|
|
509
|
-
'unicorn/require-array-sort-compare': 'off',
|
|
510
|
-
// Iterator-helper rewrites churn test fakes with no runtime benefit.
|
|
511
|
-
'unicorn/prefer-iterator-helpers': 'off',
|
|
512
|
-
'unicorn/prefer-iterator-to-array': 'off',
|
|
513
|
-
// String replacement with test-driven values is intentional in assertions.
|
|
514
|
-
'unicorn/no-unsafe-string-replacement': 'off',
|
|
515
|
-
// Fake-D1 doubles await a DAO thunk and call straight onto the result.
|
|
516
|
-
'unicorn/no-await-expression-member': 'off',
|
|
517
|
-
// `void promise` marks a deliberately unawaited promise in a test.
|
|
518
|
-
'sonarjs/void-use': 'off',
|
|
519
|
-
// A test asserting request routing has to name `http://` hosts, and a
|
|
520
|
-
// proxy test has to name a loopback upstream. Both are the subject
|
|
521
|
-
// matter, not leaked configuration. `unicorn/prefer-https` must stay off
|
|
522
|
-
// here and this is not a style preference: it rewrites `http://` to
|
|
523
|
-
// `https://` *inside string literals*, and `--fix` applies it silently.
|
|
524
|
-
'sonarjs/no-clear-text-protocols': 'off',
|
|
525
|
-
'sonarjs/no-hardcoded-ip': 'off',
|
|
526
|
-
'unicorn/prefer-https': 'off',
|
|
527
|
-
// sonarjs/assertions-in-tests fires false positives when test helpers
|
|
528
|
-
// handle assertions indirectly.
|
|
529
|
-
'sonarjs/assertions-in-tests': 'off',
|
|
530
|
-
// sonarjs/no-extra-arguments fires incorrectly on Vitest mock overloads.
|
|
531
|
-
'sonarjs/no-extra-arguments': 'off',
|
|
532
|
-
// Union/inline types in test fakes are more readable than aliases.
|
|
533
|
-
'sonarjs/use-type-alias': 'off',
|
|
534
|
-
// Alphabetical-sort rule fights deterministic fixture ordering.
|
|
535
|
-
'sonarjs/no-alphabetical-sort': 'off',
|
|
536
|
-
// Repeated string literals in fixtures/assertions are clearer inline.
|
|
537
|
-
'sonarjs/no-duplicate-string': 'off',
|
|
538
|
-
// Fake-D1 doubles break out of a nested loop to model a statement miss.
|
|
539
|
-
'unicorn/no-break-in-nested-loop': 'off',
|
|
540
|
-
// Fixtures are naturally built with sort()/for…of over composed expressions.
|
|
541
|
-
'unicorn/no-array-sort': 'off',
|
|
542
|
-
'unicorn/no-unreadable-for-of-expression': 'off',
|
|
543
|
-
'unicorn/no-useless-template-literals': 'off',
|
|
544
|
-
'unicorn/no-declarations-before-early-exit': 'off',
|
|
545
|
-
'unicorn/prefer-includes-over-repeated-comparisons': 'off',
|
|
546
|
-
'sonarjs/prefer-specific-assertions': 'off',
|
|
547
|
-
'sonarjs/no-inverted-boolean-check': 'off',
|
|
548
|
-
},
|
|
186
|
+
rules: asRules(TEST_RULES),
|
|
549
187
|
});
|
|
550
188
|
}
|
|
551
189
|
//# sourceMappingURL=eslint.js.map
|
package/dist/eslint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6C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AAC,oBAAoB,CAAC,EAC9B;QACE,OAAO,EAAE,EAAE,QAAQ,EAAE;QACrB,KAAK,EAAE;YACL,mBAAmB,EAAE,OAAO;SAC7B;KACF;IAED,+DAA+D;IAC/D,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAC1B,GAAG,wBAAwB,CAAC,IAAI,CAAC;IAEjC,oEAAoE;IACpE,EAAE;IACF,wEAAwE;IACxE,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,+CAA+C;IAC/C;QACE,KAAK,EAAE,CAAC,+CAA+C,CAAC;QACxD,eAAe,EAAE;YACf,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE;SACjD;KACF;IAED,qBAAqB;IACrB,EAAE;IACF,0EAA0E;IAC1E,sDAAsD;IACtD;QACE,KAAK,EAAE,CAAC,4BAA4B,EAAE,4BAA4B,EAAE,4BAA4B,CAAC;QACjG,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC;KAC3B,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/tooling",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"src"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@rexezuge/d1": "1.0.
|
|
29
|
+
"@rexezuge/d1": "1.0.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"eslint": "^10.0.0",
|