@book000/eslint-config 1.16.124 → 1.17.0
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/AGENTS.md +2 -2
- package/index.mjs +51 -12
- package/package.json +2 -2
- package/test.mjs +132 -6
package/AGENTS.md
CHANGED
|
@@ -26,9 +26,9 @@ pnpm install
|
|
|
26
26
|
pnpm test
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
`pnpm test` runs `
|
|
29
|
+
`pnpm test` runs `node --experimental-vm-modules test.mjs`.
|
|
30
30
|
It creates `src/`, `tsconfig.json` and `eslint.config.mjs` in the repository root, lints one temp file per test case in a single ESLint process, and removes the temp files, `tsconfig.json` and `eslint.config.mjs` afterwards (an empty `src/` is left behind).
|
|
31
|
-
The script exits with
|
|
31
|
+
The script exits with a non-zero code when any case fails, and the summary prints the `Failed:` count (failed cases are marked with `❌`).
|
|
32
32
|
There is no separate lint or build step.
|
|
33
33
|
|
|
34
34
|
## Structure of `index.mjs`
|
package/index.mjs
CHANGED
|
@@ -10,20 +10,17 @@ export default tseslint.config(
|
|
|
10
10
|
...neostandard({ noStyle: true }),
|
|
11
11
|
...tseslint.configs.recommended,
|
|
12
12
|
{
|
|
13
|
-
// List eslint-plugin-unicorn rules explicitly instead of using flat/recommended
|
|
14
|
-
//
|
|
15
|
-
// push new errors to every project that depends on this package at once.
|
|
16
|
-
// To adopt a new rule, add it to this list after checking the unicorn changelog.
|
|
13
|
+
// List eslint-plugin-unicorn rules explicitly instead of using flat/recommended, so that a
|
|
14
|
+
// unicorn upgrade never changes the rule set silently for every dependent project.
|
|
17
15
|
//
|
|
18
|
-
// The list
|
|
19
|
-
// and is not re-synced automatically, minus:
|
|
20
|
-
// - deprecated rules
|
|
16
|
+
// The list tracks the installed flat/recommended, minus:
|
|
21
17
|
// - catch-error-name and filename-case, which need options and have dedicated blocks below
|
|
22
18
|
// - rules deliberately turned off (see the "off" entries below)
|
|
23
19
|
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
20
|
+
// test.mjs fails when this list drifts from the installed preset. To resolve a failure,
|
|
21
|
+
// add the new rule here, or turn it off with a reason and add it to the deviation list in
|
|
22
|
+
// test.mjs. A removed or renamed rule ID left here makes ESLint fail config validation
|
|
23
|
+
// and crashes the linter for every consumer.
|
|
27
24
|
plugins: { unicorn },
|
|
28
25
|
rules: {
|
|
29
26
|
// reduce is a legitimate aggregation idiom; forcing a rewrite to for loops hurts readability.
|
|
@@ -78,8 +75,13 @@ export default tseslint.config(
|
|
|
78
75
|
// Assigning to properties of globalThis/window/global is the standard way to set up tests and
|
|
79
76
|
// mocks (globalThis.fetch = mock), so the false-positive rate is high in real code.
|
|
80
77
|
"unicorn/no-global-object-property-assignment": "off",
|
|
78
|
+
// Strips the leading asterisk from JSDoc lines, which contradicts the JSDoc convention
|
|
79
|
+
// and only churns whitespace.
|
|
80
|
+
"unicorn/no-asterisk-prefix-in-documentation-comments": "off",
|
|
81
|
+
// Expands one-line JSDoc blocks into multiple lines, which only churns whitespace.
|
|
82
|
+
"unicorn/single-line-block-comment-style": "off",
|
|
81
83
|
//
|
|
82
|
-
// All remaining rules of
|
|
84
|
+
// All remaining rules of flat/recommended are set to "error" explicitly below.
|
|
83
85
|
"unicorn/better-dom-traversing": "error",
|
|
84
86
|
"unicorn/consistent-assert": "error",
|
|
85
87
|
"unicorn/consistent-compound-words": "error",
|
|
@@ -117,6 +119,7 @@ export default tseslint.config(
|
|
|
117
119
|
"unicorn/no-array-sort": "error",
|
|
118
120
|
"unicorn/no-array-sort-for-min-max": "error",
|
|
119
121
|
"unicorn/no-array-splice": "error",
|
|
122
|
+
"unicorn/no-async-iterator-callback": "error",
|
|
120
123
|
"unicorn/no-async-promise-finally": "error",
|
|
121
124
|
"unicorn/no-await-expression-member": "error",
|
|
122
125
|
"unicorn/no-await-in-promise-methods": "error",
|
|
@@ -126,6 +129,7 @@ export default tseslint.config(
|
|
|
126
129
|
"unicorn/no-chained-comparison": "error",
|
|
127
130
|
"unicorn/no-collection-bracket-access": "error",
|
|
128
131
|
"unicorn/no-computed-property-existence-check": "error",
|
|
132
|
+
"unicorn/no-conflicting-constraints": "error",
|
|
129
133
|
"unicorn/no-confusing-array-splice": "error",
|
|
130
134
|
"unicorn/no-confusing-array-with": "error",
|
|
131
135
|
"unicorn/no-console-spaces": "error",
|
|
@@ -144,21 +148,34 @@ export default tseslint.config(
|
|
|
144
148
|
"unicorn/no-for-loop": "error",
|
|
145
149
|
"unicorn/no-immediate-mutation": "error",
|
|
146
150
|
"unicorn/no-impossible-length-comparison": "error",
|
|
151
|
+
"unicorn/no-incomplete-accessor-override": "error",
|
|
147
152
|
"unicorn/no-incorrect-query-selector": "error",
|
|
148
153
|
"unicorn/no-incorrect-template-string-interpolation": "error",
|
|
154
|
+
"unicorn/no-ineffective-csp-directives": "error",
|
|
149
155
|
"unicorn/no-instanceof-builtins": "error",
|
|
150
156
|
"unicorn/no-invalid-argument-count": "error",
|
|
157
|
+
"unicorn/no-invalid-boolean-attribute-value": "error",
|
|
151
158
|
"unicorn/no-invalid-character-comparison": "error",
|
|
159
|
+
"unicorn/no-invalid-dom-token": "error",
|
|
152
160
|
"unicorn/no-invalid-fetch-options": "error",
|
|
161
|
+
"unicorn/no-invalid-integrity": "error",
|
|
162
|
+
"unicorn/no-invalid-intl-options": "error",
|
|
163
|
+
"unicorn/no-invalid-property-descriptor": "error",
|
|
153
164
|
"unicorn/no-invalid-remove-event-listener": "error",
|
|
165
|
+
"unicorn/no-invalid-response-options": "error",
|
|
166
|
+
"unicorn/no-invalid-style-set-property": "error",
|
|
167
|
+
"unicorn/no-invalid-temporal-arithmetic": "error",
|
|
168
|
+
"unicorn/no-invalid-url-protocol-comparison": "error",
|
|
154
169
|
"unicorn/no-invalid-well-known-symbol-methods": "error",
|
|
155
170
|
"unicorn/no-late-current-target-access": "error",
|
|
156
171
|
"unicorn/no-late-event-control": "error",
|
|
172
|
+
"unicorn/no-leading-empty-lines": "error",
|
|
157
173
|
"unicorn/no-lonely-if": "error",
|
|
158
174
|
"unicorn/no-loop-iterable-mutation": "error",
|
|
159
175
|
"unicorn/no-magic-array-flat-depth": "error",
|
|
160
176
|
"unicorn/no-mismatched-map-key": "error",
|
|
161
177
|
"unicorn/no-misrefactored-assignment": "error",
|
|
178
|
+
"unicorn/no-multiple-promise-resolver-calls": "error",
|
|
162
179
|
"unicorn/no-named-default": "error",
|
|
163
180
|
"unicorn/no-negated-array-predicate": "error",
|
|
164
181
|
"unicorn/no-negated-comparison": "error",
|
|
@@ -171,10 +188,12 @@ export default tseslint.config(
|
|
|
171
188
|
"unicorn/no-object-as-default-parameter": "error",
|
|
172
189
|
"unicorn/no-object-methods-with-collections": "error",
|
|
173
190
|
"unicorn/no-optional-chaining-on-undeclared-variable": "error",
|
|
191
|
+
"unicorn/no-prevent-default-in-passive-listener": "error",
|
|
174
192
|
"unicorn/no-process-exit": "error",
|
|
175
193
|
"unicorn/no-redundant-comparison": "error",
|
|
176
194
|
"unicorn/no-return-array-push": "error",
|
|
177
195
|
"unicorn/no-selector-as-dom-name": "error",
|
|
196
|
+
"unicorn/no-shorthand-property-overrides": "error",
|
|
178
197
|
"unicorn/no-single-promise-in-promise-methods": "error",
|
|
179
198
|
"unicorn/no-static-only-class": "error",
|
|
180
199
|
"unicorn/no-subtraction-comparison": "error",
|
|
@@ -182,6 +201,7 @@ export default tseslint.config(
|
|
|
182
201
|
"unicorn/no-this-assignment": "error",
|
|
183
202
|
"unicorn/no-this-outside-of-class": "error",
|
|
184
203
|
"unicorn/no-top-level-side-effects": "error",
|
|
204
|
+
"unicorn/no-transition-all": "error",
|
|
185
205
|
"unicorn/no-typeof-undefined": "error",
|
|
186
206
|
"unicorn/no-uncalled-method": "error",
|
|
187
207
|
"unicorn/no-undeclared-class-members": "error",
|
|
@@ -193,18 +213,24 @@ export default tseslint.config(
|
|
|
193
213
|
"unicorn/no-unnecessary-fetch-options": "error",
|
|
194
214
|
"unicorn/no-unnecessary-global-this": "error",
|
|
195
215
|
"unicorn/no-unnecessary-nested-ternary": "error",
|
|
216
|
+
"unicorn/no-unnecessary-parameters": "error",
|
|
196
217
|
"unicorn/no-unnecessary-polyfills": "error",
|
|
197
218
|
"unicorn/no-unnecessary-slice-end": "error",
|
|
198
219
|
"unicorn/no-unnecessary-splice": "error",
|
|
220
|
+
"unicorn/no-unnecessary-string-trim": "error",
|
|
199
221
|
"unicorn/no-unreadable-array-destructuring": "error",
|
|
200
222
|
"unicorn/no-unreadable-for-of-expression": "error",
|
|
201
223
|
"unicorn/no-unreadable-iife": "error",
|
|
202
224
|
"unicorn/no-unreadable-object-destructuring": "error",
|
|
203
225
|
"unicorn/no-unsafe-buffer-conversion": "error",
|
|
226
|
+
"unicorn/no-unsafe-json-serialization": "error",
|
|
204
227
|
"unicorn/no-unsafe-promise-all-settled-values": "error",
|
|
205
228
|
"unicorn/no-unsafe-property-key": "error",
|
|
229
|
+
"unicorn/no-unsafe-sqlite-interpolation": "error",
|
|
206
230
|
"unicorn/no-unsafe-string-replacement": "error",
|
|
207
|
-
"unicorn/no-unused-
|
|
231
|
+
"unicorn/no-unused-builtin-method-return": "error",
|
|
232
|
+
"unicorn/no-unused-iterator-helper": "error",
|
|
233
|
+
"unicorn/no-url-in-search-params": "error",
|
|
208
234
|
"unicorn/no-useless-boolean-cast": "error",
|
|
209
235
|
"unicorn/no-useless-coercion": "error",
|
|
210
236
|
"unicorn/no-useless-collection-argument": "error",
|
|
@@ -220,10 +246,13 @@ export default tseslint.config(
|
|
|
220
246
|
"unicorn/no-useless-logical-operand": "error",
|
|
221
247
|
"unicorn/no-useless-override": "error",
|
|
222
248
|
"unicorn/no-useless-promise-resolve-reject": "error",
|
|
249
|
+
"unicorn/no-useless-re-export": "error",
|
|
223
250
|
"unicorn/no-useless-recursion": "error",
|
|
251
|
+
"unicorn/no-useless-set-construction": "error",
|
|
224
252
|
"unicorn/no-useless-spread": "error",
|
|
225
253
|
"unicorn/no-useless-switch-case": "error",
|
|
226
254
|
"unicorn/no-useless-template-literals": "error",
|
|
255
|
+
"unicorn/no-using-resource-escape": "error",
|
|
227
256
|
"unicorn/no-xor-as-exponentiation": "error",
|
|
228
257
|
"unicorn/no-zero-fractions": "error",
|
|
229
258
|
"unicorn/number-literal-case": "error",
|
|
@@ -253,16 +282,19 @@ export default tseslint.config(
|
|
|
253
282
|
"unicorn/prefer-class-fields": "error",
|
|
254
283
|
"unicorn/prefer-classlist-toggle": "error",
|
|
255
284
|
"unicorn/prefer-code-point": "error",
|
|
285
|
+
"unicorn/prefer-combined-guards": "error",
|
|
256
286
|
"unicorn/prefer-continue": "error",
|
|
257
287
|
"unicorn/prefer-date-now": "error",
|
|
258
288
|
"unicorn/prefer-default-parameters": "error",
|
|
259
289
|
"unicorn/prefer-direct-iteration": "error",
|
|
260
290
|
"unicorn/prefer-dom-node-append": "error",
|
|
291
|
+
"unicorn/prefer-dom-node-html-methods": "error",
|
|
261
292
|
"unicorn/prefer-dom-node-remove": "error",
|
|
262
293
|
"unicorn/prefer-dom-node-replace-children": "error",
|
|
263
294
|
"unicorn/prefer-dom-node-text-content": "error",
|
|
264
295
|
"unicorn/prefer-early-return": "error",
|
|
265
296
|
"unicorn/prefer-else-if": "error",
|
|
297
|
+
"unicorn/prefer-escaped-irregular-whitespace": "error",
|
|
266
298
|
"unicorn/prefer-event-target": "error",
|
|
267
299
|
"unicorn/prefer-export-from": "error",
|
|
268
300
|
"unicorn/prefer-flat-math-min-max": "error",
|
|
@@ -280,7 +312,9 @@ export default tseslint.config(
|
|
|
280
312
|
"unicorn/prefer-iterator-helpers": "error",
|
|
281
313
|
"unicorn/prefer-iterator-to-array": "error",
|
|
282
314
|
"unicorn/prefer-iterator-to-array-at-end": "error",
|
|
315
|
+
"unicorn/prefer-iterator-zip": "error",
|
|
283
316
|
"unicorn/prefer-keyboard-event-key": "error",
|
|
317
|
+
"unicorn/prefer-literal-ascii": "error",
|
|
284
318
|
"unicorn/prefer-logical-operator-over-ternary": "error",
|
|
285
319
|
"unicorn/prefer-map-from-entries": "error",
|
|
286
320
|
"unicorn/prefer-math-abs": "error",
|
|
@@ -304,6 +338,7 @@ export default tseslint.config(
|
|
|
304
338
|
"unicorn/prefer-optional-catch-binding": "error",
|
|
305
339
|
"unicorn/prefer-path2d": "error",
|
|
306
340
|
"unicorn/prefer-private-class-fields": "error",
|
|
341
|
+
"unicorn/prefer-promise-static-methods": "error",
|
|
307
342
|
"unicorn/prefer-promise-try": "error",
|
|
308
343
|
"unicorn/prefer-promise-with-resolvers": "error",
|
|
309
344
|
"unicorn/prefer-prototype-methods": "error",
|
|
@@ -316,6 +351,7 @@ export default tseslint.config(
|
|
|
316
351
|
"unicorn/prefer-set-has": "error",
|
|
317
352
|
"unicorn/prefer-set-methods": "error",
|
|
318
353
|
"unicorn/prefer-set-size": "error",
|
|
354
|
+
"unicorn/prefer-short-escape-sequences": "error",
|
|
319
355
|
"unicorn/prefer-simple-condition-first": "error",
|
|
320
356
|
"unicorn/prefer-simple-sort-comparator": "error",
|
|
321
357
|
"unicorn/prefer-simplified-conditions": "error",
|
|
@@ -336,7 +372,9 @@ export default tseslint.config(
|
|
|
336
372
|
"unicorn/prefer-string-trim-start-end": "error",
|
|
337
373
|
"unicorn/prefer-structured-clone": "error",
|
|
338
374
|
"unicorn/prefer-switch": "error",
|
|
375
|
+
"unicorn/prefer-temporal-conversion": "error",
|
|
339
376
|
"unicorn/prefer-ternary": "error",
|
|
377
|
+
"unicorn/prefer-then-catch": "error",
|
|
340
378
|
"unicorn/prefer-toggle-attribute": "error",
|
|
341
379
|
"unicorn/prefer-type-error": "error",
|
|
342
380
|
"unicorn/prefer-type-literal-last": "error",
|
|
@@ -353,6 +391,7 @@ export default tseslint.config(
|
|
|
353
391
|
"unicorn/require-number-to-fixed-digits-argument": "error",
|
|
354
392
|
"unicorn/require-passive-events": "error",
|
|
355
393
|
"unicorn/require-proxy-trap-boolean-return": "error",
|
|
394
|
+
"unicorn/require-text-decoder-streaming": "error",
|
|
356
395
|
"unicorn/switch-case-braces": "error",
|
|
357
396
|
"unicorn/switch-case-break-position": "error",
|
|
358
397
|
"unicorn/template-indent": "error",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@book000/eslint-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "ESLint config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint-config"
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"eslint": "10.14.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"test": "
|
|
31
|
+
"test": "node --experimental-vm-modules test.mjs"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/test.mjs
CHANGED
|
@@ -1,11 +1,102 @@
|
|
|
1
1
|
// Verifies the behavior of the ESLint flat config (index.mjs) by linting temporary files.
|
|
2
2
|
import { execFile } from "child_process";
|
|
3
|
+
import { ESLint } from "eslint";
|
|
4
|
+
import unicorn from "eslint-plugin-unicorn";
|
|
3
5
|
import fs from "fs";
|
|
4
6
|
import path from "path";
|
|
5
7
|
import { promisify } from "util";
|
|
6
8
|
|
|
7
9
|
const execFileAsync = promisify(execFile);
|
|
8
10
|
|
|
11
|
+
// Deviations from unicorn flat/recommended. Each needs a comment in index.mjs.
|
|
12
|
+
const DELIBERATELY_OFF = [
|
|
13
|
+
"no-array-reduce",
|
|
14
|
+
"consistent-function-scoping",
|
|
15
|
+
"prefer-top-level-await",
|
|
16
|
+
"name-replacements",
|
|
17
|
+
"no-null",
|
|
18
|
+
"no-useless-undefined",
|
|
19
|
+
"consistent-class-member-order",
|
|
20
|
+
"prefer-await",
|
|
21
|
+
"consistent-boolean-name",
|
|
22
|
+
"no-non-function-verb-prefix",
|
|
23
|
+
"prefer-number-coercion",
|
|
24
|
+
"no-top-level-assignment-in-function",
|
|
25
|
+
"prefer-unicode-code-point-escapes",
|
|
26
|
+
"no-break-in-nested-loop",
|
|
27
|
+
"class-reference-in-static-methods",
|
|
28
|
+
"prefer-while-loop-condition",
|
|
29
|
+
"prefer-location-assign",
|
|
30
|
+
"max-nested-calls",
|
|
31
|
+
"no-global-object-property-assignment",
|
|
32
|
+
"no-asterisk-prefix-in-documentation-comments",
|
|
33
|
+
"single-line-block-comment-style",
|
|
34
|
+
].map((rule) => `unicorn/${rule}`);
|
|
35
|
+
// Enabled, but with options that differ from the preset.
|
|
36
|
+
const CUSTOM_OPTIONS = ["unicorn/catch-error-name", "unicorn/filename-case"];
|
|
37
|
+
// Turned off by eslint-config-prettier, which comes last in index.mjs.
|
|
38
|
+
const PRETTIER_OFF = [
|
|
39
|
+
"empty-brace-spaces",
|
|
40
|
+
"no-nested-ternary",
|
|
41
|
+
"number-literal-case",
|
|
42
|
+
"template-indent",
|
|
43
|
+
].map((rule) => `unicorn/${rule}`);
|
|
44
|
+
|
|
45
|
+
const SEVERITIES = { off: 0, warn: 1, error: 2 };
|
|
46
|
+
const severityOf = (entry) => {
|
|
47
|
+
const level = Array.isArray(entry) ? entry[0] : entry;
|
|
48
|
+
return typeof level === "string" ? SEVERITIES[level] : (level ?? 0);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Compares the effective unicorn rules of index.mjs with the installed flat/recommended preset.
|
|
53
|
+
* @returns Offending rule IDs per category; every list is empty when there is no drift.
|
|
54
|
+
*/
|
|
55
|
+
async function checkUnicornDrift() {
|
|
56
|
+
const config = (await import("./index.mjs")).default;
|
|
57
|
+
const eslint = new ESLint({
|
|
58
|
+
overrideConfigFile: true,
|
|
59
|
+
overrideConfig: config,
|
|
60
|
+
cwd: process.cwd(),
|
|
61
|
+
});
|
|
62
|
+
// A .ts path so that the TypeScript-only blocks apply too; nothing is written to disk.
|
|
63
|
+
const { rules: effective } = await eslint.calculateConfigForFile(
|
|
64
|
+
path.join(process.cwd(), "src", "drift-probe.ts")
|
|
65
|
+
);
|
|
66
|
+
const isUnicorn = (id) => id.startsWith("unicorn/");
|
|
67
|
+
const preset = Object.fromEntries(
|
|
68
|
+
Object.entries(unicorn.configs.recommended.rules)
|
|
69
|
+
.filter(([id]) => isUnicorn(id))
|
|
70
|
+
.map(([id, entry]) => [id, severityOf(entry)])
|
|
71
|
+
);
|
|
72
|
+
const effectiveSeverity = (id) => severityOf(effective[id]);
|
|
73
|
+
const allowed = new Set([
|
|
74
|
+
...DELIBERATELY_OFF,
|
|
75
|
+
...CUSTOM_OPTIONS,
|
|
76
|
+
...PRETTIER_OFF,
|
|
77
|
+
]);
|
|
78
|
+
const configured = Object.keys(effective).filter(isUnicorn);
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
missing: Object.keys(preset).filter(
|
|
82
|
+
(id) =>
|
|
83
|
+
preset[id] !== 0 &&
|
|
84
|
+
effectiveSeverity(id) !== preset[id] &&
|
|
85
|
+
!allowed.has(id)
|
|
86
|
+
),
|
|
87
|
+
extra: configured.filter(
|
|
88
|
+
(id) => effectiveSeverity(id) !== 0 && (preset[id] ?? 0) === 0
|
|
89
|
+
),
|
|
90
|
+
deprecated: configured.filter((id) => {
|
|
91
|
+
const rule = unicorn.rules[id.slice("unicorn/".length)];
|
|
92
|
+
return !rule || rule.meta.deprecated;
|
|
93
|
+
}),
|
|
94
|
+
staleAllowlist: [...DELIBERATELY_OFF, ...PRETTIER_OFF].filter(
|
|
95
|
+
(id) => effectiveSeverity(id) !== 0
|
|
96
|
+
),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
9
100
|
async function main() {
|
|
10
101
|
const testCases = [
|
|
11
102
|
{
|
|
@@ -300,6 +391,24 @@ async function main() {
|
|
|
300
391
|
rules: ["unicorn/filename-case"],
|
|
301
392
|
dir: "notKebabCaseDir",
|
|
302
393
|
},
|
|
394
|
+
{
|
|
395
|
+
name: "single-line-block-comment-style: a one-line JSDoc block is allowed",
|
|
396
|
+
code: "/** Adds one. */\nexport function addOne(x: number): number { return x + 1; }",
|
|
397
|
+
shouldError: false,
|
|
398
|
+
rules: ["unicorn/single-line-block-comment-style"],
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: "no-asterisk-prefix-in-documentation-comments: a JSDoc block with asterisk-prefixed lines is allowed",
|
|
402
|
+
code: "/**\n * Adds one.\n * Second line.\n */\nexport function addOne(x: number): number { return x + 1; }",
|
|
403
|
+
shouldError: false,
|
|
404
|
+
rules: ["unicorn/no-asterisk-prefix-in-documentation-comments"],
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
name: "no-unnecessary-string-trim: trim() before startsWith() is an error (a rule added by the unicorn resync)",
|
|
408
|
+
code: "export const a = ' x '.trim().startsWith('x');",
|
|
409
|
+
shouldError: true,
|
|
410
|
+
rules: ["unicorn/no-unnecessary-string-trim"],
|
|
411
|
+
},
|
|
303
412
|
];
|
|
304
413
|
|
|
305
414
|
// Create temp files under src/ so they reliably match files: ["**/*.ts"] in the flat config.
|
|
@@ -467,13 +576,30 @@ async function main() {
|
|
|
467
576
|
fs.rmSync(path.join(srcDir, dir), { recursive: true });
|
|
468
577
|
}
|
|
469
578
|
fs.unlinkSync(tsconfigPath);
|
|
470
|
-
console.log("\n--- Summary ---");
|
|
471
|
-
console.log(`Passed: ${pass} / Failed: ${fail} / Total: ${testCases.length}`);
|
|
472
|
-
}
|
|
473
579
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
580
|
+
const drift = await checkUnicornDrift();
|
|
581
|
+
const driftName =
|
|
582
|
+
"unicorn drift: index.mjs matches the installed eslint-plugin-unicorn flat/recommended except for documented deviations";
|
|
583
|
+
if (Object.values(drift).every((ids) => ids.length === 0)) {
|
|
584
|
+
console.log(`✅ ${driftName}`);
|
|
585
|
+
pass++;
|
|
586
|
+
} else {
|
|
587
|
+
console.error(`❌ ${driftName}`);
|
|
588
|
+
for (const [category, ids] of Object.entries(drift)) {
|
|
589
|
+
if (ids.length > 0) {
|
|
590
|
+
console.error(` ${category} (${ids.length}): ${ids.join(", ")}`);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
fail++;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
console.log("\n--- Summary ---");
|
|
597
|
+
console.log(
|
|
598
|
+
`Passed: ${pass} / Failed: ${fail} / Total: ${testCases.length + 1}`
|
|
599
|
+
);
|
|
600
|
+
if (fail > 0) {
|
|
601
|
+
process.exitCode = 1;
|
|
602
|
+
}
|
|
477
603
|
}
|
|
478
604
|
|
|
479
605
|
main().catch((e) => {
|