build: enable more zero-baseline oxlint rules

This commit is contained in:
Peter Steinberger
2026-04-23 05:03:58 +01:00
parent b2472d6560
commit 9937452405
9 changed files with 65 additions and 30 deletions

View File

@@ -11,6 +11,7 @@
"eslint-plugin-unicorn/prefer-array-find": "error",
"eslint/no-array-constructor": "error",
"eslint/no-await-in-loop": "off",
"eslint/no-constructor-return": "error",
"eslint/no-div-regex": "error",
"eslint/no-extra-label": "error",
"eslint/no-empty-pattern": ["error", { "allowObjectPatternsAsParameters": false }],
@@ -22,6 +23,7 @@
"eslint/no-regex-spaces": "error",
"eslint/no-return-assign": "error",
"eslint/no-sequences": "error",
"eslint/no-self-compare": "error",
"eslint/no-shadow": "off",
"eslint/no-useless-call": "error",
"eslint/no-useless-computed-key": "error",
@@ -32,16 +34,24 @@
"eslint/prefer-exponentiation-operator": "error",
"eslint/prefer-numeric-literals": "error",
"eslint/unicode-bom": "error",
"import/no-absolute-path": "error",
"import/no-empty-named-blocks": "error",
"import/no-self-import": "error",
"node/no-exports-assign": "error",
"eslint-plugin-unicorn/prefer-set-size": "error",
"oxc/no-accumulating-spread": "error",
"oxc/no-async-endpoint-handlers": "error",
"oxc/no-map-spread": "error",
"promise/no-new-statics": "error",
"typescript/adjacent-overload-signatures": "error",
"typescript/ban-tslint-comment": "error",
"typescript/consistent-return": "error",
"typescript/no-empty-object-type": ["error", { "allowInterfaces": "with-single-extends" }],
"typescript/no-explicit-any": "error",
"typescript/no-extraneous-class": "error",
"typescript/no-meaningless-void-operator": "error",
"typescript/no-non-null-asserted-nullish-coalescing": "error",
"typescript/no-unnecessary-qualifier": "error",
"typescript/no-unnecessary-type-assertion": "error",
"typescript/no-unnecessary-type-arguments": "error",
"typescript/no-unnecessary-type-constraint": "error",
@@ -50,14 +60,22 @@
"typescript/no-unsafe-type-assertion": "off",
"typescript/no-useless-default-assignment": "error",
"typescript/prefer-return-this-type": "error",
"typescript/prefer-find": "error",
"typescript/prefer-reduce-type-parameter": "error",
"typescript/prefer-ts-expect-error": "error",
"unicorn/consistent-date-clone": "error",
"unicorn/consistent-function-scoping": "off",
"unicorn/consistent-template-literal-escape": "error",
"unicorn/no-console-spaces": "error",
"unicorn/no-unnecessary-array-flat-depth": "error",
"unicorn/no-unnecessary-array-splice-count": "error",
"unicorn/no-unnecessary-slice-end": "error",
"unicorn/no-useless-error-capture-stack-trace": "error",
"unicorn/no-useless-promise-resolve-reject": "error",
"unicorn/prefer-date-now": "error",
"unicorn/prefer-dom-node-text-content": "error",
"unicorn/prefer-keyboard-event-key": "error",
"unicorn/prefer-negative-index": "error",
"unicorn/prefer-optional-catch-binding": "error",
"unicorn/prefer-set-size": "error",
"unicorn/require-array-join-separator": "error",

View File

@@ -18,13 +18,12 @@ const {
} = vi.hoisted(() => ({
bodyLocator: {
waitFor: vi.fn(async () => undefined),
innerText: vi.fn(async () => "hello from body"),
textContent: vi.fn(async () => "hello from body"),
},
browserClose: vi.fn(async () => undefined),
contextClose: vi.fn(async () => undefined),
contextNewPage: vi.fn(),
goto: vi.fn(async () => undefined),
innerText: vi.fn(async () => "hello from body"),
launch: vi.fn(),
locatorFill: vi.fn(async () => undefined),
locatorPress: vi.fn(async () => undefined),

View File

@@ -93,7 +93,7 @@ export async function qaWebWait(params: QaWebWaitParams) {
}
if (params.text) {
await session.page.waitForFunction(
(expected) => document.body?.innerText?.toLowerCase().includes(expected.toLowerCase()),
(expected) => document.body?.textContent?.toLowerCase().includes(expected.toLowerCase()),
params.text,
{ timeout: timeoutMs },
);
@@ -119,7 +119,7 @@ export async function qaWebSnapshot(params: QaWebSnapshotParams) {
const timeoutMs = resolveTimeoutMs(params.timeoutMs);
const body = session.page.locator("body");
await body.waitFor({ timeout: timeoutMs });
const text = await body.innerText({ timeout: timeoutMs });
const text = (await body.textContent({ timeout: timeoutMs })) ?? "";
const maxChars =
typeof params.maxChars === "number" && Number.isFinite(params.maxChars)
? Math.max(1, Math.floor(params.maxChars))

View File

@@ -350,14 +350,11 @@ export async function parseAndSendMediaTags(
return { handled: false, normalizedText: text };
}
const tagCounts = mediaTagMatches.reduce(
(acc, m) => {
const t = normalizeLowercaseStringOrEmpty(m[1]);
acc[t] = (acc[t] ?? 0) + 1;
return acc;
},
{} as Record<string, number>,
);
const tagCounts = mediaTagMatches.reduce<Record<string, number>>((acc, m) => {
const t = normalizeLowercaseStringOrEmpty(m[1]);
acc[t] = (acc[t] ?? 0) + 1;
return acc;
}, {});
log?.debug?.(
`Detected media tags: ${Object.entries(tagCounts)
.map(([k, v]) => `${v} <${k}>`)

View File

@@ -407,9 +407,13 @@ function checkPatchBoundariesLenient(lines: string[]): string[] {
throw new Error(strictError);
}
const first = lines[0];
const last = lines[lines.length - 1];
if ((first === "<<EOF" || first === "<<'EOF'" || first === '<<"EOF"') && last.endsWith("EOF")) {
const inner = lines.slice(1, lines.length - 1);
const last = lines.at(-1);
if (
last &&
(first === "<<EOF" || first === "<<'EOF'" || first === '<<"EOF"') &&
last.endsWith("EOF")
) {
const inner = lines.slice(1, -1);
const innerError = checkPatchBoundariesStrict(inner);
if (!innerError) {
return inner;

View File

@@ -88,12 +88,12 @@ function warnRejectedCredentialEntries(source: string, rejected: RejectedCredent
if (rejected.length === 0) {
return;
}
const reasons = rejected.reduce(
const reasons = rejected.reduce<Partial<Record<CredentialRejectReason, number>>>(
(acc, current) => {
acc[current.reason] = (acc[current.reason] ?? 0) + 1;
return acc;
},
{} as Partial<Record<CredentialRejectReason, number>>,
{},
);
log.warn("ignored invalid auth profile entries during store load", {
source,

View File

@@ -9,19 +9,18 @@ function normalizeAuthProfileOrder(raw: unknown): AuthProfileState["order"] {
if (!raw || typeof raw !== "object") {
return undefined;
}
const normalized = Object.entries(raw as Record<string, unknown>).reduce(
(acc, [provider, value]) => {
if (!Array.isArray(value)) {
return acc;
}
const list = value.map((entry) => normalizeOptionalString(entry) ?? "").filter(Boolean);
if (list.length > 0) {
acc[provider] = list;
}
const normalized = Object.entries(raw as Record<string, unknown>).reduce<
Record<string, string[]>
>((acc, [provider, value]) => {
if (!Array.isArray(value)) {
return acc;
},
{} as Record<string, string[]>,
);
}
const list = value.map((entry) => normalizeOptionalString(entry) ?? "").filter(Boolean);
if (list.length > 0) {
acc[provider] = list;
}
return acc;
}, {});
return Object.keys(normalized).length > 0 ? normalized : undefined;
}

View File

@@ -110,7 +110,7 @@ function redactText(text: string, patterns: RegExp[]): string {
let next = text;
for (const pattern of patterns) {
next = replacePatternBounded(next, pattern, (...args: string[]) =>
redactMatch(args[0], args.slice(1, args.length - 2)),
redactMatch(args[0], args.slice(1, -2)),
);
}
return next;

View File

@@ -13,18 +13,36 @@ type OxlintTsconfig = {
const ZERO_BASELINE_RULES = [
"eslint/no-div-regex",
"eslint/no-constructor-return",
"eslint/no-extra-label",
"eslint/no-lone-blocks",
"eslint/no-multi-str",
"eslint/no-proto",
"eslint/no-regex-spaces",
"eslint/no-sequences",
"eslint/no-self-compare",
"eslint/prefer-exponentiation-operator",
"eslint/prefer-numeric-literals",
"eslint/unicode-bom",
"import/no-absolute-path",
"import/no-empty-named-blocks",
"import/no-self-import",
"node/no-exports-assign",
"promise/no-new-statics",
"typescript/adjacent-overload-signatures",
"typescript/ban-tslint-comment",
"typescript/no-non-null-asserted-nullish-coalescing",
"typescript/no-unnecessary-qualifier",
"typescript/prefer-find",
"typescript/prefer-reduce-type-parameter",
"typescript/prefer-return-this-type",
"unicorn/consistent-date-clone",
"unicorn/consistent-template-literal-escape",
"unicorn/no-console-spaces",
"unicorn/no-useless-error-capture-stack-trace",
"unicorn/prefer-dom-node-text-content",
"unicorn/prefer-keyboard-event-key",
"unicorn/prefer-negative-index",
"unicorn/prefer-optional-catch-binding",
"unicorn/require-array-join-separator",
"unicorn/throw-new-error",