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
1 change: 0 additions & 1 deletion extensions/ql-vscode/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default tseslint.config(
// Rules disabled during eslint 9 migration
"github/filenames-match-regex": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/codeql-cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ export class CodeQLCliServer implements Disposable {
subcommandArgs,
"Resolving query by language",
),
);
) as QueryInfoByLanguage;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/common/mock-gh-api/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ async function jsonResponseBody<T>(response: Response): Promise<T> {
const body = await responseBody(response);
const text = new TextDecoder("utf-8").decode(body);

return JSON.parse(text);
return JSON.parse(text) as T;
}

function shouldWriteBodyToFile(
Expand Down
6 changes: 3 additions & 3 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function registerErrorStubs(
stubGenerator: (command: string) => () => Promise<void>,
): void {
// Remove existing stubs
errorStubs.forEach((stub) => stub.dispose());
errorStubs.forEach((stub) => void stub.dispose());

if (extension === undefined) {
throw new Error(`Can't find extension ${extensionId}`);
Expand Down Expand Up @@ -757,7 +757,7 @@ async function activateWithInstalledDistribution(
beganMainExtensionActivation = true;
// Remove any error stubs command handlers left over from first part
// of activation.
errorStubs.forEach((stub) => stub.dispose());
errorStubs.forEach((stub) => void stub.dispose());

void extLogger.log("Initializing configuration listener...");
const qlConfigurationListener =
Expand Down Expand Up @@ -1167,7 +1167,7 @@ async function activateWithInstalledDistribution(
databaseUI,
variantAnalysisManager,
dispose: () => {
ctx.subscriptions.forEach((d) => d.dispose());
ctx.subscriptions.forEach((d) => void d.dispose());
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ export function getSkippedRepoCount(
return 0;
}

return Object.values(skippedRepos).reduce(
(acc, group) => acc + group.repositoryCount,
return Object.values(skippedRepos).reduce<number>(
(acc, group: VariantAnalysisSkippedRepositoryGroup) =>
acc + group.repositoryCount,
0,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ import type { Diagnostic } from "./diagnostics";
import { useOpenKey } from "./useOpenKey";
import { VscodeTextfield } from "@vscode-elements/react-elements";

const Input = styled(VscodeTextfield)<{ $error: boolean }>`
interface InputProps {
$error: boolean;
}

const Input = styled(VscodeTextfield)<InputProps>`
width: 100%;
font-family: var(--vscode-editor-font-family);

${(props) =>
${(props: InputProps) =>
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explicit type annotation props: InputProps is unnecessary since TypeScript can infer the type from the generic parameter. Remove the type annotation for cleaner code.

Suggested change
${(props: InputProps) =>
${(props) =>

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not according to eslint / typescript. This is needed.

props.$error &&
css`
--dropdown-border: var(--vscode-inputValidation-errorBorder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function useEffectEvent<T extends (...args: any[]) => any>(callback: T) {
});

return useCallback<(...args: Parameters<T>) => ReturnType<T>>(
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
(...args) => ref.current(...args),
[],
) as T;
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/test/mock-memento.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MockMemento<T> implements Memento {

public get<T>(key: string): T | undefined;
public get<T>(key: string, defaultValue: T): T;
public get(key: any, defaultValue?: any): T | undefined {
public get(key: any, defaultValue?: T): T | undefined {
return this.map.get(key) || defaultValue;
}

Expand Down
2 changes: 2 additions & 0 deletions extensions/ql-vscode/test/mocked-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export function mockedObject<T extends object>(
return new Proxy<T>({} as unknown as T, {
get: (_target, prop) => {
if (prop in props) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return (props as any)[prop];
}
if (dynamicProperties && prop in dynamicProperties) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return (dynamicProperties as any)[prop]();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ describe("DisposableObject and DisposeHandler", () => {
expect(disposable1.dispose).toHaveBeenCalled();
});

it("ahould use a dispose handler", () => {
it("should use a dispose handler", () => {
const handler = (d: any) =>
d === disposable1 || d === disposable3 || d === nestedDisposableObject
? d.dispose(handler)
? void d.dispose(handler)
: void 0;

disposableObject.push(disposable1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("Invocation rate limiter", () => {
* @return The stored value or the defaultValue.
*/
get<T>(key: string, defaultValue?: T): T | undefined {
return this.map.has(key) ? this.map.get(key) : defaultValue;
return this.map.has(key) ? (this.map.get(key) as T) : defaultValue;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ function toErrorMessage(data: any) {
if (Array.isArray(data.errors)) {
return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}`;
}

return data.message;
if (typeof data.message === "string") {
return data.message as string;
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type assertion as string is redundant since the condition already confirms data.message is a string type. Remove the type assertion and return data.message directly.

Suggested change
return data.message as string;
return data.message;

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not according to eslint / typescript. This is needed.

}
}

// istanbul ignore next - just in case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import type { Release } from "../../../../src/codeql-cli/distribution/release";
import { zip } from "zip-a-folder";

jest.mock("os", () => {
const original = jest.requireActual("os");
const original: typeof os = jest.requireActual("os");
return {
...original,
platform: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export function createMockExtensionContext(): ExtensionContext {
return {
globalState: {
_state: {} as Record<string, any>,
get(key: string) {
return this._state[key];
get<T>(key: string): T | undefined {
return this._state[key] as T | undefined;
},
update(key: string, val: any) {
this._state[key] = val;
},
},
} as any;
} as unknown as ExtensionContext;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Uri } from "vscode";
import { mockDatabaseItem, mockedObject } from "../../../utils/mocking.helpers";
import path from "path";
import { AstBuilder } from "../../../../../src/language-support";
import type { DecodedBqrsChunk } from "../../../../../src/common/bqrs-cli-types";

/**
*
Expand All @@ -29,7 +30,7 @@ int disable_interrupts(void)

describe("AstBuilder", () => {
let mockCli: CodeQLCliServer;
let overrides: Record<string, Record<string, unknown> | undefined>;
let overrides: Record<string, DecodedBqrsChunk | undefined>;

beforeEach(() => {
mockCli = mockedObject<CodeQLCliServer>({
Expand Down Expand Up @@ -132,6 +133,7 @@ describe("AstBuilder", () => {
it("should fail when graphProperties are not correct", async () => {
overrides.graphProperties = {
tuples: [["semmle.graphKind", "hucairz"]],
columns: [],
};

const astBuilder = createAstBuilder();
Expand All @@ -149,7 +151,9 @@ describe("AstBuilder", () => {
);
}

function mockDecode(resultSet: "nodes" | "edges" | "graphProperties") {
async function mockDecode(
resultSet: "nodes" | "edges" | "graphProperties",
): Promise<DecodedBqrsChunk> {
if (overrides[resultSet]) {
return overrides[resultSet];
}
Expand All @@ -166,7 +170,7 @@ describe("AstBuilder", () => {
`${__dirname}/../../data/language-support/ast-viewer/ast-builder.json`,
"utf8",
),
)[index];
)[index] as DecodedBqrsChunk;
} else {
throw new Error(`Invalid resultSet: ${resultSet}`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CancellationTokenSource, Uri } from "vscode";
import type * as fsExtra from "fs-extra";
import type { CodeQLCliServer } from "../../../../src/codeql-cli/cli";
import type {
DatabaseItem,
Expand All @@ -15,7 +16,7 @@ import {
} from "./test-runner-helpers";

jest.mock("fs-extra", () => {
const original = jest.requireActual("fs-extra");
const original: typeof fsExtra = jest.requireActual("fs-extra");
return {
...original,
access: jest.fn(),
Expand Down
Loading