Thanks to visit codestin.com
Credit goes to github.com

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
8 changes: 4 additions & 4 deletions extension/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ export default tseslint.config(
// no-global-object-property-assignment stays at its recommended `error`
// for production code; it's disabled only for tests (which legitimately
// assign globals to set up mocks) in the test-files block below.
// Partially autofixable — fixable instances are corrected in-tree; the
// remainder warn until handled in #279.
"unicorn/no-unnecessary-global-this": "warn",

// Allow underscore-prefixed unused parameters (e.g. `_root` for the
// Rule#apply signature when a rule ignores the argument).
"@typescript-eslint/no-unused-vars": [
Expand Down Expand Up @@ -280,6 +276,10 @@ export default tseslint.config(
// Tests assign onto global objects to install mocks / stubs; the rule
// stays an error everywhere else.
"unicorn/no-global-object-property-assignment": "off",
// Tests reach for `globalThis.*` deliberately — overriding globals for
// mocks (`globalThis.MutationObserver = …`) and dispatching events /
// reading computed style against the jsdom global. Enforced in prod.
"unicorn/no-unnecessary-global-this": "off",
// Jest matchers and mock patterns routinely pass methods by reference.
"@typescript-eslint/unbound-method": "off",

Expand Down
4 changes: 2 additions & 2 deletions extension/src/lib/placeholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function pickPaletteFromAncestor(
): PlaceholderPalette {
let node: Element | null = start;
while (node) {
const bg = globalThis.getComputedStyle(node).backgroundColor;
const bg = getComputedStyle(node).backgroundColor;
const brightness = parseBackgroundBrightness(bg);
if (brightness !== null) {
return brightness < 0.5 ? "dark" : "light";
Expand Down Expand Up @@ -208,7 +208,7 @@ export function replaceWithBlockPlaceholder(
label: string,
): HTMLDivElement {
const rect = element.getBoundingClientRect();
const computed = globalThis.getComputedStyle(element);
const computed = getComputedStyle(element);

// Outer container is a non-interactive <div> so the inner reveal button can
// use position: sticky (which doesn't work as a child of <button>). Click
Expand Down
8 changes: 4 additions & 4 deletions extension/src/lib/route-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function install(): void {
if (navigation) {
navigation.addEventListener("navigatesuccess", emit);
}
globalThis.addEventListener("popstate", emit);
globalThis.addEventListener("hashchange", emit);
addEventListener("popstate", emit);
addEventListener("hashchange", emit);
}

// Listener is called once per detected URL change. The same listener
Expand All @@ -81,8 +81,8 @@ export function __resetRouteChangeForTesting(): void {
if (navigation) {
navigation.removeEventListener("navigatesuccess", emit);
}
globalThis.removeEventListener("popstate", emit);
globalThis.removeEventListener("hashchange", emit);
removeEventListener("popstate", emit);
removeEventListener("hashchange", emit);
}
listeners.clear();
installed = false;
Expand Down
2 changes: 1 addition & 1 deletion extension/src/lib/yielding-text-walk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface WalkTextNodesChunkedOptions {
function defaultYieldStrategy(): Promise<void> {
if (typeof requestIdleCallback === "function") {
return new Promise<void>((resolve) => {
globalThis.requestIdleCallback(() => {
requestIdleCallback(() => {
resolve();
});
});
Expand Down
4 changes: 2 additions & 2 deletions extension/src/popup/use-tab-debug-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export function useTabDebugTrace(tabId: number | null): TabDebugTrace {
}
};
void poll();
const intervalId = globalThis.setInterval(() => {
const intervalId = setInterval(() => {
void poll();
}, POLL_INTERVAL_MS);
return () => {
cancelled = true;
globalThis.clearInterval(intervalId);
clearInterval(intervalId);
};
}, [tabId]);

Expand Down
4 changes: 2 additions & 2 deletions extension/src/popup/use-tab-pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ export function useTabPause(tabId: number | null): TabPauseState {
}, [tabId]);

useEffect(() => {
const intervalId = globalThis.setInterval(() => {
const intervalId = setInterval(() => {
setNow(Date.now());
}, TICK_INTERVAL_MS);
return () => {
globalThis.clearInterval(intervalId);
clearInterval(intervalId);
};
}, []);

Expand Down
1 change: 0 additions & 1 deletion extension/src/rules/__tests__/hidden-fee-annotate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ describe("findOrderSummaryAncestor", () => {
// the labelledby resolution path can execute. Identity escape is fine
// here — the test only inserts known-safe id values. Read via `globalThis`
// so the absent global reads as `undefined` instead of throwing.
// eslint-disable-next-line unicorn/no-unnecessary-global-this -- global may be undefined here
const previousCss = (globalThis as { CSS?: unknown }).CSS;
(globalThis as { CSS?: { escape: (input: string) => string } }).CSS = {
escape: (input: string) => input,
Expand Down
2 changes: 1 addition & 1 deletion extension/src/rules/cookie-banner-hide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function isOverlay(element: HTMLElement): boolean {
if (role && OVERLAY_ROLES.has(role)) {
return true;
}
const position = globalThis.getComputedStyle(element).position;
const position = getComputedStyle(element).position;
return OVERLAY_POSITIONS.has(position);
}

Expand Down
4 changes: 2 additions & 2 deletions extension/src/rules/hidden-text-strip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ export function __resetColorProbeForTesting(): void {
function effectiveBackgroundColor(element: Element): RGB | null {
let current: Element | null = element;
while (current) {
const style = globalThis.getComputedStyle(current);
const style = getComputedStyle(current);
const bg = parseColor(style.backgroundColor);
if (!bg) {
return null;
Expand Down Expand Up @@ -832,7 +832,7 @@ function findCandidates(root: ParentNode): Candidate[] {
if (!hasNonemptyText(element)) {
continue;
}
const style = globalThis.getComputedStyle(element);
const style = getComputedStyle(element);
if (hasStructuralSrOnlyPattern(style)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/rules/irrelevant-sections-redact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function checkHideable(element: Element): string | null {
}

// Sticky / fixed elements leave a layout hole behind if replaced.
const position = globalThis.getComputedStyle(element).position;
const position = getComputedStyle(element).position;
if (position === "fixed" || position === "sticky") {
return `position-${position}`;
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/rules/newsletter-modal-hide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const NEWSLETTER_TEXT =
const MIN_VIEWPORT_AREA_RATIO = 0.25;

function looksLikeNewsletterModal(element: HTMLElement): boolean {
const style = globalThis.getComputedStyle(element);
const style = getComputedStyle(element);
if (style.position !== "fixed" && style.position !== "sticky") {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/rules/svg-sprite-strip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function isHidden(svg: SVGSVGElement): boolean {
if (svg.getAttribute("aria-hidden") === "true") {
return true;
}
const style = globalThis.getComputedStyle(svg);
const style = getComputedStyle(svg);
if (style.display === "none") {
return true;
}
Expand Down
Loading