refactor(lint): report unused extension lint disables

This commit is contained in:
Vincent Koc
2026-04-06 15:51:37 +01:00
parent a010ce462f
commit c921a6ecad
4 changed files with 8 additions and 12 deletions

View File

@@ -711,7 +711,6 @@ describe("ExecApprovalButton", () => {
ephemeral: true,
});
expect(acknowledge).not.toHaveBeenCalled();
// oxlint-disable-next-line typescript/unbound-method -- vi.fn() mock
expect(handler.resolveApproval).not.toHaveBeenCalled();
});
@@ -727,7 +726,6 @@ describe("ExecApprovalButton", () => {
expect(reply).not.toHaveBeenCalled();
expect(acknowledge).toHaveBeenCalledTimes(1);
// oxlint-disable-next-line typescript/unbound-method -- vi.fn() mock
expect(handler.resolveApproval).toHaveBeenCalledWith("test-approval", "allow-once");
});
@@ -742,7 +740,6 @@ describe("ExecApprovalButton", () => {
await button.run(interaction, data);
expect(acknowledge).toHaveBeenCalledTimes(1);
// oxlint-disable-next-line typescript/unbound-method -- vi.fn() mock
expect(handler.resolveApproval).toHaveBeenCalledWith("test-approval", "allow-always");
});
@@ -757,7 +754,6 @@ describe("ExecApprovalButton", () => {
await button.run(interaction, data);
expect(acknowledge).toHaveBeenCalledTimes(1);
// oxlint-disable-next-line typescript/unbound-method -- vi.fn() mock
expect(handler.resolveApproval).toHaveBeenCalledWith("test-approval", "deny");
});
@@ -776,7 +772,6 @@ describe("ExecApprovalButton", () => {
ephemeral: true,
});
expect(acknowledge).not.toHaveBeenCalled();
// oxlint-disable-next-line typescript/unbound-method -- vi.fn() mock
expect(handler.resolveApproval).not.toHaveBeenCalled();
});

View File

@@ -24,9 +24,7 @@ describe("resolveMatrixRoomId", () => {
const roomId = await resolveMatrixRoomId(client, userId);
expect(roomId).toBe("!room:example.org");
// oxlint-disable-next-line typescript/unbound-method
expect(client.getJoinedRooms).not.toHaveBeenCalled();
// oxlint-disable-next-line typescript/unbound-method
expect(client.setAccountData).not.toHaveBeenCalled();
});
@@ -141,7 +139,6 @@ describe("resolveMatrixRoomId", () => {
await expect(resolveMatrixRoomId(client, userId)).rejects.toThrow(
`No direct room found for ${userId} (m.direct missing)`,
);
// oxlint-disable-next-line typescript/unbound-method
expect(client.setAccountData).not.toHaveBeenCalled();
});
@@ -162,7 +159,6 @@ describe("resolveMatrixRoomId", () => {
const resolved = await resolveMatrixRoomId(client, `matrix:user:${userId}`);
expect(resolved).toBe(roomId);
// oxlint-disable-next-line typescript/unbound-method
expect(client.resolveRoom).not.toHaveBeenCalled();
});
@@ -192,9 +188,7 @@ describe("resolveMatrixRoomId", () => {
await expect(resolveMatrixRoomId(clientA, userId)).resolves.toBe("!room-a:example.org");
await expect(resolveMatrixRoomId(clientB, userId)).resolves.toBe("!room-b:example.org");
// oxlint-disable-next-line typescript/unbound-method
expect(clientA.getAccountData).toHaveBeenCalledTimes(1);
// oxlint-disable-next-line typescript/unbound-method
expect(clientB.getAccountData).toHaveBeenCalledTimes(1);
});

View File

@@ -82,7 +82,6 @@ function createMockResponse(): ServerResponse & {
res.end = function (chunk?: unknown) {
if (chunk) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
data += String(chunk);
}
return this;

View File

@@ -5,6 +5,7 @@ import path from "node:path";
import {
acquireLocalHeavyCheckLockSync,
applyLocalOxlintPolicy,
hasFlag,
} from "./local-heavy-check-runtime.mjs";
export function runExtensionOxlint(params) {
@@ -32,6 +33,13 @@ export function runExtensionOxlint(params) {
writeTempOxlintConfig(repoRoot, tempConfigPath);
const baseArgs = ["-c", tempConfigPath, ...process.argv.slice(2), ...extensionFiles];
if (
!hasFlag(baseArgs, "--report-unused-disable-directives") &&
!hasFlag(baseArgs, "--report-unused-disable-directives-severity")
) {
baseArgs.unshift("error");
baseArgs.unshift("--report-unused-disable-directives-severity");
}
const { args: finalArgs, env } = applyLocalOxlintPolicy(baseArgs, process.env);
const result = spawnSync(oxlintPath, finalArgs, {
stdio: "inherit",