diff --git a/extension/eslint-suppressions.json b/extension/eslint-suppressions.json index 9f0e924..0967ef4 100644 --- a/extension/eslint-suppressions.json +++ b/extension/eslint-suppressions.json @@ -1,52 +1 @@ -{ - "src/lib/__tests__/selector-hide-rule.property.test.ts": { - "unicorn/prefer-dom-node-html-methods": { - "count": 4 - } - }, - "src/lib/message-schemas.ts": { - "unicorn/prefer-simple-condition-first": { - "count": 1 - } - }, - "src/lib/placeholder.ts": { - "unicorn/prefer-simple-condition-first": { - "count": 1 - } - }, - "src/lib/selector-token-index.ts": { - "unicorn/prefer-simple-condition-first": { - "count": 1 - } - }, - "src/rules/__tests__/encoded-payload-redact.property.test.ts": { - "unicorn/prefer-simple-condition-first": { - "count": 1 - } - }, - "src/rules/__tests__/form-prefill-annotate.property.test.ts": { - "unicorn/prefer-simple-condition-first": { - "count": 1 - } - }, - "src/rules/__tests__/noscript-strip.test.ts": { - "unicorn/prefer-dom-node-html-methods": { - "count": 2 - } - }, - "src/rules/__tests__/schema-trust-sanitize.test.ts": { - "unicorn/prefer-dom-node-html-methods": { - "count": 6 - } - }, - "src/rules/hidden-text-strip.ts": { - "unicorn/prefer-simple-condition-first": { - "count": 1 - } - }, - "src/rules/irrelevant-sections-redact.ts": { - "unicorn/prefer-dom-node-html-methods": { - "count": 1 - } - } -} +{} diff --git a/extension/eslint.config.js b/extension/eslint.config.js index 65ae1a2..9bb11ad 100644 --- a/extension/eslint.config.js +++ b/extension/eslint.config.js @@ -298,6 +298,23 @@ export default tseslint.config( // sites, so leaving it on would be all churn for no further upside. "unicorn/no-break-in-nested-loop": "off", + // eslint-plugin-unicorn 72 promoted two more rules to recommended. + // prefer-simple-condition-first was ratcheted in-tree (the six sites were + // reordered so the cheap operand short-circuits first) and stays at its + // recommended `error`. prefer-dom-node-html-methods is turned off: + // Off — the rule rewrites `.innerHTML` *reads* to `element.getHTML()`, + // but for a plain read the two are equivalent (both serialize the + // light-DOM descendants and exclude shadow content); getHTML()'s only + // added value is its shadow-root serialization options, which the fix + // doesn't pass. So there's no correctness or behavior upside. Worse, + // getHTML() is a recent DOM API absent from jsdom, and 12 of the 13 + // hits are jsdom tests asserting on serialized output — rewriting them + // would throw `getHTML is not a function` at runtime (same test-runtime + // block as prefer-uint8array-base64). The lone production read + // (serializePageTree in irrelevant-sections-redact.ts) could switch, + // but only to be inconsistent with every test for no gain. Not worth it. + "unicorn/prefer-dom-node-html-methods": "off", + // eslint-plugin-unicorn 68 turned on another batch of recommended rules // (and renamed `prevent-abbreviations` → `name-replacements`, handled // above). The cleanly autofixable ones (prefer-boolean-return, diff --git a/extension/src/lib/message-schemas.ts b/extension/src/lib/message-schemas.ts index ad96e7c..92dd2c7 100644 --- a/extension/src/lib/message-schemas.ts +++ b/extension/src/lib/message-schemas.ts @@ -68,8 +68,8 @@ const ruleCountsSchema = z const sanitized: RuleCountMap = {}; for (const [key, value] of Object.entries(raw)) { if ( - KNOWN_RULE_IDS.has(key) && typeof value === "number" && + KNOWN_RULE_IDS.has(key) && Number.isFinite(value) && value > 0 ) { diff --git a/extension/src/lib/placeholder.ts b/extension/src/lib/placeholder.ts index 6e76874..3c7e946 100644 --- a/extension/src/lib/placeholder.ts +++ b/extension/src/lib/placeholder.ts @@ -127,7 +127,7 @@ function attachReveal(container: HTMLElement, original: Node): void { event.preventDefault(); event.stopPropagation(); container.removeEventListener("click", reveal); - if (original.nodeType === Node.ELEMENT_NODE && ruleId) { + if (ruleId && original.nodeType === Node.ELEMENT_NODE) { (original as Element).setAttribute(REVEALED_ATTR, ruleId); } container.replaceWith(original); diff --git a/extension/src/lib/selector-token-index.ts b/extension/src/lib/selector-token-index.ts index 454363a..a1e040f 100644 --- a/extension/src/lib/selector-token-index.ts +++ b/extension/src/lib/selector-token-index.ts @@ -159,7 +159,7 @@ function ensureWatcherStarted(): void { } function maybeStopWatcher(): void { - if (!(registrations.size === 0 && sharedWatcher)) { + if (!(sharedWatcher && registrations.size === 0)) { return; } diff --git a/extension/src/rules/__tests__/encoded-payload-redact.property.test.ts b/extension/src/rules/__tests__/encoded-payload-redact.property.test.ts index 1c5b881..6c03e86 100644 --- a/extension/src/rules/__tests__/encoded-payload-redact.property.test.ts +++ b/extension/src/rules/__tests__/encoded-payload-redact.property.test.ts @@ -67,10 +67,10 @@ const highEntropyBytesArb = fc let printable = 0; for (const b of bytes) { if ( - (b >= PRINTABLE_LOW && b <= PRINTABLE_HIGH) || b === 9 || b === 10 || - b === 13 + b === 13 || + (b >= PRINTABLE_LOW && b <= PRINTABLE_HIGH) ) { printable++; } diff --git a/extension/src/rules/__tests__/form-prefill-annotate.property.test.ts b/extension/src/rules/__tests__/form-prefill-annotate.property.test.ts index a634168..3a197f0 100644 --- a/extension/src/rules/__tests__/form-prefill-annotate.property.test.ts +++ b/extension/src/rules/__tests__/form-prefill-annotate.property.test.ts @@ -251,7 +251,7 @@ describe("idempotency (property)", () => { const option = document.createElement("option"); option.value = `o${j}`; option.textContent = `O${j}`; - if (spec.sneaky && j === 2) { + if (j === 2 && spec.sneaky) { option.setAttribute("selected", ""); } select.append(option); diff --git a/extension/src/rules/hidden-text-strip.ts b/extension/src/rules/hidden-text-strip.ts index 94d2e48..76a5ccb 100644 --- a/extension/src/rules/hidden-text-strip.ts +++ b/extension/src/rules/hidden-text-strip.ts @@ -541,7 +541,7 @@ function detectHiddenByCss( style.backgroundClip === "text" || (style as { webkitBackgroundClip?: string }).webkitBackgroundClip === "text"; - if (parsed?.[3] === 0 && !backgroundClipsToText) { + if (!backgroundClipsToText && parsed?.[3] === 0) { return { reason: "text-fill-transparent", details: { webkitTextFillColor: textFill },