Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 1 addition & 52 deletions extension/eslint-suppressions.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
{}
17 changes: 17 additions & 0 deletions extension/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion extension/src/lib/message-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/lib/placeholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion extension/src/lib/selector-token-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function ensureWatcherStarted(): void {
}

function maybeStopWatcher(): void {
if (!(registrations.size === 0 && sharedWatcher)) {
if (!(sharedWatcher && registrations.size === 0)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion extension/src/rules/hidden-text-strip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
Loading