@naturalcycles/dev-lib 20.76.0 → 20.77.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/cfg/oxlint-plugin-nc.js +5 -3
- package/cfg/oxlint.config.js +53 -17
- package/cfg/summaryOnlyReporter.js +1 -0
- package/package.json +1 -1
package/cfg/oxlint-plugin-nc.js
CHANGED
|
@@ -45,7 +45,6 @@ const preferAssertRule = {
|
|
|
45
45
|
return {
|
|
46
46
|
IfStatement(node) {
|
|
47
47
|
if (node.alternate || node.parent.type === 'IfStatement') return
|
|
48
|
-
if (!isAssertableTest(node.test)) return
|
|
49
48
|
|
|
50
49
|
const { consequent } = node
|
|
51
50
|
const statement =
|
|
@@ -59,11 +58,14 @@ const preferAssertRule = {
|
|
|
59
58
|
error.type !== 'NewExpression' ||
|
|
60
59
|
error.callee.type !== 'Identifier' ||
|
|
61
60
|
!ASSERTABLE_ERRORS.has(error.callee.name) ||
|
|
62
|
-
error.arguments.length > maxArguments(error.callee.name)
|
|
63
|
-
error.arguments.some(argument => containsEvaluation(argument))
|
|
61
|
+
error.arguments.length > maxArguments(error.callee.name)
|
|
64
62
|
) {
|
|
65
63
|
return
|
|
66
64
|
}
|
|
65
|
+
// The checks below walk subtrees, so they run after the cheap shape checks above: most `if`
|
|
66
|
+
// statements do not throw and never reach them
|
|
67
|
+
if (!isAssertableTest(node.test)) return
|
|
68
|
+
if (error.arguments.some(argument => containsEvaluation(argument))) return
|
|
67
69
|
const narrowed = referencedNames(node.test)
|
|
68
70
|
if (error.arguments.some(argument => referencesAny(argument, narrowed))) return
|
|
69
71
|
|
package/cfg/oxlint.config.js
CHANGED
|
@@ -90,20 +90,20 @@ export const sharedConfig = {
|
|
|
90
90
|
'no-this-alias': 0,
|
|
91
91
|
'no-shadow': 0, // too many shadows in the codebase already
|
|
92
92
|
'no-async-promise-executor': 0,
|
|
93
|
-
'no-standalone-expect': 0,
|
|
94
|
-
'no-conditional-expect': 0,
|
|
95
93
|
'vitest/no-conditional-expect': 0,
|
|
96
|
-
'expect-expect': 0,
|
|
97
94
|
'vitest/expect-expect': 0,
|
|
98
|
-
'no-disabled-tests': 0,
|
|
99
95
|
'vitest/no-disabled-tests': 0,
|
|
100
|
-
'no-useless-assignment': 0, //
|
|
96
|
+
'no-useless-assignment': 0, // flags intentional dead stores, e.g. `arr = []` to release memory
|
|
101
97
|
'no-nested-ternary': 2,
|
|
102
98
|
'object-shorthand': 2,
|
|
103
|
-
'valid-expect': 0,
|
|
104
|
-
'valid-title': 0,
|
|
105
99
|
'vitest/valid-title': [2, { mustMatch: { it: '^should ' } }],
|
|
106
|
-
|
|
100
|
+
// Allows a bare `return` in map/filter/find callbacks, but not falling off the end
|
|
101
|
+
'array-callback-return': [2, { allowImplicit: true }],
|
|
102
|
+
'default-param-last': 2,
|
|
103
|
+
'no-constructor-return': 2,
|
|
104
|
+
'no-new-func': 2,
|
|
105
|
+
'no-proto': 2,
|
|
106
|
+
'no-return-assign': 2,
|
|
107
107
|
// Options arguments and variables are `opt`, never `opts`
|
|
108
108
|
'id-denylist': [2, 'opts'],
|
|
109
109
|
// 'id-denylist': [
|
|
@@ -133,7 +133,7 @@ export const sharedConfig = {
|
|
|
133
133
|
'no-useless-call': 2,
|
|
134
134
|
'no-implied-eval': 2,
|
|
135
135
|
'no-accumulating-spread': 2,
|
|
136
|
-
'no-map-spread': 0, //
|
|
136
|
+
'no-map-spread': 0, // its fix mutates the mapped objects, and we never mutate arguments
|
|
137
137
|
'prefer-array-find': 2,
|
|
138
138
|
'prefer-array-flat-map': 2,
|
|
139
139
|
'prefer-set-has': 2,
|
|
@@ -164,7 +164,7 @@ export const sharedConfig = {
|
|
|
164
164
|
'prefer-object-has-own': 2,
|
|
165
165
|
'no-extra-bind': 2,
|
|
166
166
|
'no-duplicate-imports': [
|
|
167
|
-
0, //
|
|
167
|
+
0, // redundant with import/no-duplicates, which can autofix
|
|
168
168
|
{
|
|
169
169
|
allowSeparateTypeImports: true,
|
|
170
170
|
},
|
|
@@ -188,7 +188,9 @@ export const sharedConfig = {
|
|
|
188
188
|
'import/no-default-export': 2,
|
|
189
189
|
'import/no-webpack-loader-syntax': 2,
|
|
190
190
|
'import/no-duplicates': [2, { 'prefer-inline': false }],
|
|
191
|
-
|
|
191
|
+
'import/export': 2,
|
|
192
|
+
// In ESM, code between imports runs after all imports are evaluated
|
|
193
|
+
'import/first': 2,
|
|
192
194
|
'import/no-empty-named-blocks': 2,
|
|
193
195
|
'import/no-absolute-path': 2,
|
|
194
196
|
'import/no-named-as-default': 2,
|
|
@@ -199,7 +201,10 @@ export const sharedConfig = {
|
|
|
199
201
|
'oxc/no-const-enum': 2,
|
|
200
202
|
'oxc/approx-constant': 2,
|
|
201
203
|
'oxc/misrefactored-assign-op': 2,
|
|
202
|
-
'oxc/branches-sharing-code':
|
|
204
|
+
'oxc/branches-sharing-code': 2,
|
|
205
|
+
'oxc/no-this-in-exported-function': 2,
|
|
206
|
+
'promise/no-multiple-resolved': 2,
|
|
207
|
+
'promise/no-return-in-finally': 2,
|
|
203
208
|
'promise/spec-only': 2,
|
|
204
209
|
'typescript/class-literal-property-style': 2,
|
|
205
210
|
'typescript/consistent-type-exports': 2,
|
|
@@ -276,7 +281,7 @@ export const sharedConfig = {
|
|
|
276
281
|
allowSingleElementEquality: 'always',
|
|
277
282
|
},
|
|
278
283
|
],
|
|
279
|
-
'typescript/require-await': 0, //
|
|
284
|
+
'typescript/require-await': 0, // conflicts with promise-function-async (async without await)
|
|
280
285
|
'typescript/restrict-plus-operands': 2,
|
|
281
286
|
'typescript/return-await': [2, 'error-handling-correctness-only'],
|
|
282
287
|
'typescript/only-throw-error': 2,
|
|
@@ -304,9 +309,14 @@ export const sharedConfig = {
|
|
|
304
309
|
ignoreStatic: true,
|
|
305
310
|
},
|
|
306
311
|
],
|
|
307
|
-
|
|
308
|
-
'typescript/
|
|
309
|
-
|
|
312
|
+
// A `default` case counts as exhaustive, so the rule only flags switches without one
|
|
313
|
+
'typescript/switch-exhaustiveness-check': [2, { considerDefaultExhaustiveForUnions: true }],
|
|
314
|
+
// String arrays are allowed; numbers, booleans and numeric enums sort lexicographically
|
|
315
|
+
'typescript/require-array-sort-compare': 2,
|
|
316
|
+
// Mostly flags `${err}`; no-base-to-string already catches "[object Object]"
|
|
317
|
+
'typescript/restrict-template-expressions': 0,
|
|
318
|
+
'typescript/related-getter-setter-pairs': 2,
|
|
319
|
+
'typescript/prefer-readonly': 0, // adds `readonly` to every private member that is never reassigned
|
|
310
320
|
'typescript/no-redundant-type-constituents': 0, // `'a' | string` is still useful for DX
|
|
311
321
|
'@typescript-eslint/explicit-member-accessibility': [
|
|
312
322
|
2,
|
|
@@ -384,6 +394,21 @@ export const sharedConfig = {
|
|
|
384
394
|
'import/no-named-default': 2,
|
|
385
395
|
'import/consistent-type-specifier-style': 2,
|
|
386
396
|
'unicorn/no-new-array': 0, // it's actually ok
|
|
397
|
+
// These force a copy (toSorted/toReversed) even for arrays the function owns, e.g. fresh
|
|
398
|
+
// from slice/filter/Array.from. In-place sort/reverse of an owned array is fine and faster.
|
|
399
|
+
'unicorn/no-array-sort': 0,
|
|
400
|
+
'unicorn/no-array-reverse': 0,
|
|
401
|
+
'unicorn/number-literal-case': 0, // conflicts with oxfmt, which lowercases hex digits
|
|
402
|
+
// A file-level blanket `oxlint-disable` keeps new rules and --fix away from benchmarks,
|
|
403
|
+
// third-party snippets (pixels) and vendored code
|
|
404
|
+
'unicorn/no-abusive-eslint-disable': 0,
|
|
405
|
+
'unicorn/no-array-fill-with-reference-type': 2,
|
|
406
|
+
'unicorn/no-useless-switch-case': 2,
|
|
407
|
+
'unicorn/prefer-array-flat': 2,
|
|
408
|
+
// Its fix (applied by --fix-suggestions) is not equivalent: `re.test()` is stateful for /g
|
|
409
|
+
// and /y regexes, and `str.match(pattern)` with a string pattern becomes `pattern.test()`
|
|
410
|
+
'unicorn/prefer-regexp-test': 0,
|
|
411
|
+
'unicorn/throw-new-error': 2,
|
|
387
412
|
'unicorn/catch-error-name': [
|
|
388
413
|
2,
|
|
389
414
|
{
|
|
@@ -463,7 +488,9 @@ export const sharedConfig = {
|
|
|
463
488
|
'vitest/prefer-snapshot-hint': 0, // annoying
|
|
464
489
|
'vitest/prefer-to-have-length': 2,
|
|
465
490
|
'vitest/require-to-throw-message': 2,
|
|
466
|
-
'vitest/valid-describe-callback':
|
|
491
|
+
'vitest/valid-describe-callback': 2,
|
|
492
|
+
// `expect(value, message)` is valid in vitest; unawaited async assertions are caught by
|
|
493
|
+
// no-floating-promises
|
|
467
494
|
'vitest/valid-expect': 0,
|
|
468
495
|
'vitest/no-import-node-test': 2,
|
|
469
496
|
'vitest/no-mocks-import': 2,
|
|
@@ -471,6 +498,15 @@ export const sharedConfig = {
|
|
|
471
498
|
'vitest/prefer-to-be': 2,
|
|
472
499
|
'vitest/prefer-to-contain': 2,
|
|
473
500
|
'vitest/prefer-called-exactly-once-with': 2,
|
|
501
|
+
// Not type-aware: it also rewrites string and valueOf-object comparisons (dates, LocalDate),
|
|
502
|
+
// but toBeLessThan and friends accept only number | bigint
|
|
503
|
+
'vitest/prefer-comparison-matcher': 0,
|
|
504
|
+
'vitest/prefer-equality-matcher': 2,
|
|
505
|
+
'vitest/prefer-expect-type-of': 2,
|
|
506
|
+
'vitest/prefer-to-have-been-called-times': 2,
|
|
507
|
+
'vitest/prefer-to-be-object': 2,
|
|
508
|
+
'vitest/no-test-prefixes': 2,
|
|
509
|
+
'vitest/no-unneeded-async-expect-function': 2,
|
|
474
510
|
'vitest/consistent-test-filename': 2,
|
|
475
511
|
'vitest/warn-todo': 0,
|
|
476
512
|
'vitest/consistent-test-it': [2, { fn: 'it', withinDescribe: 'it' }],
|