Skip to content

Commit 028ae9f

Browse files
committed
chore(eslint): update eslint-plugin-unicorn to 72
Post-Node 18 API recommendations stay disabled for backports. Promise and short-circuit rewrites remain deferred because they broaden existing behavior. Folding SHA filtering into the existing loop measured 13.9 µs to 11.9 µs for 500 entries on Node 24.18.0 (7 trials, drop best and worst).
1 parent 0bbf75c commit 028ae9f

41 files changed

Lines changed: 233 additions & 107 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ci/diagnose.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ function findScriptMatches (scripts, patterns) {
13941394

13951395
for (const script of scripts) {
13961396
if (!/test|spec|e2e|integration|unit/i.test(script.name) &&
1397-
!patterns.some(pattern => pattern.test(script.command))) {
1397+
patterns.every(pattern => !pattern.test(script.command))) {
13981398
continue
13991399
}
14001400

ci/test-optimization-validation/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ function getValidationCoverage ({ results, requestedScenario, frameworks, scenar
546546
if (runnableFrameworks.length === 0) return 'partial'
547547
for (const framework of runnableFrameworks) {
548548
for (const scenario of scenarios) {
549-
if (!results.some(result => result.frameworkId === framework.id && result.scenario === scenario)) {
549+
if (results.every(result => !(result.frameworkId === framework.id && result.scenario === scenario))) {
550550
return 'partial'
551551
}
552552
}

ci/test-optimization-validation/command-suitability.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function getVitestGeneratedPathError (command, framework, repositoryRoot) {
183183
const relative = path.relative(path.dirname(configFile), file.path).split(path.sep).join('/')
184184
if (relative === '..' || relative.startsWith('../') || path.isAbsolute(relative)) continue
185185

186-
if (includes.length > 0 && !includes.some(pattern => matchesGlob(relative, pattern))) {
186+
if (includes.length > 0 && includes.every(pattern => !matchesGlob(relative, pattern))) {
187187
return `uses temporary test path ${file.path}, which does not match the literal test.include patterns in ` +
188188
`${configFile}: ${includes.join(', ')}. Choose a temporary test path accepted by the selected Vitest ` +
189189
'config ' +
@@ -257,9 +257,7 @@ function readLiteralStringArray (config, offset) {
257257
}
258258
patterns.push(value)
259259
quote = ''
260-
} else if (character.charCodeAt(0) === 92) {
261-
return []
262-
} else if (character === '\r' || character === '\n') {
260+
} else if (character.charCodeAt(0) === 92 || character === '\r' || character === '\n') {
263261
return []
264262
} else {
265263
value += character

ci/test-optimization-validation/generated-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function getMissingDirectories (root, directory) {
9797
*/
9898
function cleanupCreatedDirectories (root) {
9999
const resolvedRoot = path.resolve(root)
100-
const directories = [...createdGeneratedDirectories.entries()]
100+
const directories = [...createdGeneratedDirectories]
101101
.filter(([directory, authorization]) => {
102102
return isPathInside(resolvedRoot, directory) && isCleanupAuthorizationValid(directory, authorization)
103103
})

ci/test-optimization-validation/report-writer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ function getResultDetailLines (result, options = {}) {
845845

846846
function getCommonArtifactDirectory (artifacts) {
847847
let directory = path.dirname(path.resolve(artifacts[0]))
848-
while (!artifacts.every(artifact => isPathInside(directory, path.resolve(artifact)))) {
848+
while (artifacts.some(artifact => !isPathInside(directory, path.resolve(artifact)))) {
849849
const parent = path.dirname(directory)
850850
if (parent === directory) return directory
851851
directory = parent

ci/test-optimization-validation/scenarios/test-management.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function summarizeManagedTests (testManagementTests) {
209209
}
210210
summary.set(displaySuite, testNames)
211211
}
212-
return [...summary.entries()].slice(0, 5).map(([suite, tests]) => ({
212+
return [...summary].slice(0, 5).map(([suite, tests]) => ({
213213
suite,
214214
tests: [...tests].slice(0, 5),
215215
}))

eslint.config.mjs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,8 @@ export default [
586586
...eslintPluginUnicorn.configs.recommended.rules,
587587

588588
// Overriding recommended unicorn rules.
589-
// Rules not listed here are left at the `recommended` default. The v65→v68 bump
590-
// turned ~130 rules on in `recommended`; the entries below are the ones that fire
591-
// on our source and are intentionally kept off (counts are from the v68 run).
589+
// Rules not listed here are left at the `recommended` default. The entries below
590+
// document deliberate exceptions (counts are from the v72 run where applicable).
592591
'unicorn/catch-error-name': ['off', { name: 'err' }], // Many errors
593592
'unicorn/expiring-todo-comments': 'off',
594593
'unicorn/filename-case': ['off', { case: 'kebabCase' }], // Many errors
@@ -598,10 +597,15 @@ export default [
598597
// These rules require a newer Node.js version than we support
599598
'unicorn/no-array-reverse': 'off', // Node.js 20
600599
'unicorn/no-array-sort': 'off', // Node.js 20
600+
'unicorn/prefer-abort-signal-any': 'off', // Node.js 18.17
601601
'unicorn/prefer-dispose': 'off', // Explicit resource management (newer Node.js)
602+
'unicorn/prefer-group-by': 'off', // Node.js 21
603+
'unicorn/prefer-iterator-helpers': 'off', // Iterator helpers (Node.js 22)
602604
'unicorn/prefer-iterator-to-array': 'off', // Iterator helpers (Node.js 22)
603605
'unicorn/prefer-iterator-to-array-at-end': 'off', // Iterator helpers (Node.js 22)
606+
'unicorn/prefer-promise-try': 'off', // Promise.try (Node.js 24)
604607
'unicorn/prefer-promise-with-resolvers': 'off', // 6 errors | Promise.withResolvers (Node.js 22)
608+
'unicorn/prefer-set-methods': 'off', // Set methods (Node.js 22)
605609
'unicorn/prefer-temporal': 'off', // Temporal is not stable on supported Node.js
606610
'unicorn/prefer-uint8array-base64': 'off', // Uint8Array base64 (Node.js 22)
607611

@@ -615,31 +619,29 @@ export default [
615619
'unicorn/no-array-callback-reference': 'off',
616620
'unicorn/no-computed-property-existence-check': 'off', // 160 errors | needs an audit
617621
'unicorn/no-declarations-before-early-exit': 'off', // 62 errors
618-
'unicorn/no-duplicate-if-branches': 'off', // 1 error | may surface real bugs
619-
'unicorn/no-duplicate-logical-operands': 'off', // 2 errors | may surface real bugs
620622
'unicorn/no-error-property-assignment': 'off', // 6 errors
621623
'unicorn/no-for-loop': 'off', // Activate if this is resolved https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2664
622-
'unicorn/no-incorrect-template-string-interpolation': 'off', // 3 errors | audit for real bugs first
623624
'unicorn/no-invalid-argument-count': 'off', // 98 errors | high false-positive risk, worth a focused pass
624-
'unicorn/no-loop-iterable-mutation': 'off', // 2 errors | may surface real bugs
625625
'unicorn/no-nonstandard-builtin-properties': 'off', // 34 errors | needs an audit
626626
'unicorn/no-this-assignment': 'off', // This would need some further refactoring and the benefit is small
627627
'unicorn/no-undeclared-class-members': 'off', // 272 errors | requires declaring every field
628628
'unicorn/no-unreadable-array-destructuring': 'off', // 4 errors | not autofixable, needs manual rewrite
629629
'unicorn/no-unreadable-for-of-expression': 'off', // 32 errors
630630
'unicorn/no-unreadable-object-destructuring': 'off', // 57 errors
631-
'unicorn/no-unsafe-string-replacement': 'off', // 6 errors
632-
'unicorn/no-useless-recursion': 'off', // 2 errors
631+
'unicorn/no-unsafe-string-replacement': 'off', // 16 errors | replacement callbacks reduce readability
632+
'unicorn/no-useless-recursion': 'off', // 7 errors | iterative rewrites add substantial nesting
633633
'unicorn/prefer-code-point': 'off', // Should be activated, but needs a refactor of some code
634634
'unicorn/prefer-early-return': 'off', // 67 errors | tension with our positive-`if` style
635635
'unicorn/prefer-hoisting-branch-code': 'off', // 2 errors | reshapes branch bodies
636636
'unicorn/prefer-minimal-ternary': 'off', // 24 errors
637637
'unicorn/prefer-number-is-safe-integer': 'off', // 17 errors
638638
'unicorn/prefer-object-iterable-methods': 'off', // 56 errors
639639
'unicorn/prefer-queue-microtask': 'off', // process.nextTick semantics differ
640+
'unicorn/prefer-simple-condition-first': 'off', // 184 errors | needs a short-circuit behavior audit
640641
'unicorn/prefer-smaller-scope': 'off', // 3 errors
641642
'unicorn/prefer-split-limit': 'off', // 23 errors
642-
'unicorn/require-array-sort-compare': 'off', // 8 errors | may surface real default-sort bugs
643+
'unicorn/prefer-then-catch': 'off', // 45 errors | broadens rejection boundaries
644+
'unicorn/require-array-sort-compare': 'off', // 28 errors | many intentional lexicographic sorts
643645

644646
// The following rules should not be activated!
645647
'unicorn/consistent-boolean-name': 'off', // Would rename public API and config booleans
@@ -659,6 +661,7 @@ export default [
659661
'unicorn/operator-assignment': 'off', // Covered by core operator-assignment
660662
'unicorn/prefer-array-last-methods': 'off', // Questionable benefit
661663
'unicorn/prefer-await': 'off', // We avoid async/await in production hot paths
664+
'unicorn/prefer-dom-node-html-methods': 'off', // Browser compatibility and different serialization semantics
662665
'unicorn/prefer-event-target': 'off', // Benefit only outside of Node.js
663666
'unicorn/prefer-global-this': 'off', // Questionable benefit in Node.js alone
664667
'unicorn/prefer-includes-over-repeated-comparisons': 'off', // Bad for performance
@@ -674,32 +677,22 @@ export default [
674677
'unicorn/prefer-unicode-code-point-escapes': 'off', // Replaces the dropped no-hex-escape; questionable benefit
675678
'unicorn/switch-case-braces': 'off', // Questionable benefit
676679

677-
// Safe to enable in a follow-up: autofixable and aligned with our style. Kept off
678-
// here only to keep this version bump free of source churn (counts from the v68 run).
679-
'unicorn/logical-assignment-operators': 'off', // 42 errors | matches our ??=/||= usage
680+
// These remaining rules need focused rewrites before activation (counts from the v72 run).
681+
'unicorn/logical-assignment-operators': 'off', // 51 errors | matches our ??=/||= usage
680682
'unicorn/no-confusing-array-splice': 'off', // 1 error
681683
'unicorn/no-for-each': 'off', // 10 errors | we already prefer for-of in production
682-
'unicorn/no-negated-array-predicate': 'off', // 2 errors
683684
'unicorn/no-negated-comparison': 'off', // 1 error
684685
'unicorn/no-subtraction-comparison': 'off', // 2 errors
685-
'unicorn/no-unnecessary-boolean-comparison': 'off', // 6 errors
686-
'unicorn/no-unnecessary-global-this': 'off', // 4 errors
686+
'unicorn/no-unnecessary-global-this': 'off', // 3 errors | explicit globals are clearer
687687
'unicorn/no-unnecessary-splice': 'off', // 2 errors
688688
'unicorn/no-useless-concat': 'off', // 4 errors
689689
'unicorn/no-useless-continue': 'off', // 1 error
690690
'unicorn/no-useless-delete-check': 'off', // 1 error
691-
'unicorn/no-useless-fallback-in-spread': 'off', // 5 errors
692-
'unicorn/no-useless-override': 'off', // 1 error
693-
'unicorn/no-useless-template-literals': 'off', // 13 errors
694-
'unicorn/prefer-array-from-map': 'off', // 6 errors
695-
'unicorn/prefer-boolean-return': 'off', // 1 error
691+
'unicorn/no-useless-template-literals': 'off', // 16 errors | String() rewrites reduce readability
692+
'unicorn/prefer-array-from-map': 'off', // 9 errors | loops avoid callback allocation
696693
'unicorn/prefer-continue': 'off', // 52 errors
697-
'unicorn/prefer-direct-iteration': 'off', // 5 errors
698-
'unicorn/prefer-else-if': 'off', // 6 errors
699-
'unicorn/prefer-global-number-constants': 'off', // 3 errors
700694
'unicorn/prefer-logical-operator-over-ternary': 'off', // 3 errors
701695
'unicorn/prefer-ternary': 'off', // 16 errors
702-
'unicorn/prefer-unary-minus': 'off', // 1 error
703696
},
704697
},
705698
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
"eslint-plugin-n": "^18.2.1",
214214
"eslint-plugin-promise": "^7.3.0",
215215
"eslint-plugin-sonarjs": "^4.2.0",
216-
"eslint-plugin-unicorn": "^68.0.0",
216+
"eslint-plugin-unicorn": "^72.0.0",
217217
"express": "^5.1.0",
218218
"glob": "^10.4.5",
219219
"globals": "^17.7.0",

packages/datadog-esbuild/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ ${build.initialOptions.banner.js}`
340340

341341
if (data.isESM) {
342342
if (args.path.endsWith(ESM_INTERCEPTED_SUFFIX)) {
343-
args.path = args.path.slice(0, -1 * ESM_INTERCEPTED_SUFFIX.length)
343+
args.path = args.path.slice(0, -ESM_INTERCEPTED_SUFFIX.length)
344344

345345
if (data.internal) {
346346
args.path = args.path.slice(INTERNAL_ESM_INTERCEPTED_PREFIX.length)

packages/datadog-esbuild/src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async function processModule ({ path, internal = false, context, excludeDefault
174174
for (const n of exportNames) {
175175
if (n === 'default' && excludeDefault) continue
176176

177-
if (isStarExportLine(n) === true) {
177+
if (isStarExportLine(n)) {
178178
// export * from 'wherever'
179179
const [, modFile] = n.split('* from ')
180180

0 commit comments

Comments
 (0)