Skip to content

Commit ec1c911

Browse files
Merge pull request #4110 from github/robertbrignull/enable-typescript-eslint/no-unsafe-return
Enable the @typescript-eslint/no-unsafe-return rule
2 parents 79c26b4 + ac398f4 commit ec1c911

File tree

16 files changed

+37
-24
lines changed

16 files changed

+37
-24
lines changed

extensions/ql-vscode/eslint.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export default tseslint.config(
7070
// Rules disabled during eslint 9 migration
7171
"github/filenames-match-regex": "off",
7272
"@typescript-eslint/restrict-template-expressions": "off",
73-
"@typescript-eslint/no-unsafe-return": "off",
7473
"@typescript-eslint/no-unsafe-assignment": "off",
7574
"@typescript-eslint/no-unsafe-argument": "off",
7675
"@typescript-eslint/no-unsafe-member-access": "off",

extensions/ql-vscode/src/codeql-cli/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ export class CodeQLCliServer implements Disposable {
979979
subcommandArgs,
980980
"Resolving query by language",
981981
),
982-
);
982+
) as QueryInfoByLanguage;
983983
}
984984

985985
/**

extensions/ql-vscode/src/common/mock-gh-api/recorder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ async function jsonResponseBody<T>(response: Response): Promise<T> {
283283
const body = await responseBody(response);
284284
const text = new TextDecoder("utf-8").decode(body);
285285

286-
return JSON.parse(text);
286+
return JSON.parse(text) as T;
287287
}
288288

289289
function shouldWriteBodyToFile(

extensions/ql-vscode/src/extension.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function registerErrorStubs(
251251
stubGenerator: (command: string) => () => Promise<void>,
252252
): void {
253253
// Remove existing stubs
254-
errorStubs.forEach((stub) => stub.dispose());
254+
errorStubs.forEach((stub) => void stub.dispose());
255255

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

762762
void extLogger.log("Initializing configuration listener...");
763763
const qlConfigurationListener =
@@ -1167,7 +1167,7 @@ async function activateWithInstalledDistribution(
11671167
databaseUI,
11681168
variantAnalysisManager,
11691169
dispose: () => {
1170-
ctx.subscriptions.forEach((d) => d.dispose());
1170+
ctx.subscriptions.forEach((d) => void d.dispose());
11711171
},
11721172
};
11731173
}

extensions/ql-vscode/src/variant-analysis/shared/variant-analysis.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ export function getSkippedRepoCount(
287287
return 0;
288288
}
289289

290-
return Object.values(skippedRepos).reduce(
291-
(acc, group) => acc + group.repositoryCount,
290+
return Object.values(skippedRepos).reduce<number>(
291+
(acc, group: VariantAnalysisSkippedRepositoryGroup) =>
292+
acc + group.repositoryCount,
292293
0,
293294
);
294295
}

extensions/ql-vscode/src/view/common/SuggestBox/SuggestBox.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ import type { Diagnostic } from "./diagnostics";
2222
import { useOpenKey } from "./useOpenKey";
2323
import { VscodeTextfield } from "@vscode-elements/react-elements";
2424

25-
const Input = styled(VscodeTextfield)<{ $error: boolean }>`
25+
interface InputProps {
26+
$error: boolean;
27+
}
28+
29+
const Input = styled(VscodeTextfield)<InputProps>`
2630
width: 100%;
2731
font-family: var(--vscode-editor-font-family);
2832
29-
${(props) =>
33+
${(props: InputProps) =>
3034
props.$error &&
3135
css`
3236
--dropdown-border: var(--vscode-inputValidation-errorBorder);

extensions/ql-vscode/src/view/common/SuggestBox/useEffectEvent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export function useEffectEvent<T extends (...args: any[]) => any>(callback: T) {
1818
});
1919

2020
return useCallback<(...args: Parameters<T>) => ReturnType<T>>(
21+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
2122
(...args) => ref.current(...args),
2223
[],
2324
) as T;

extensions/ql-vscode/test/mock-memento.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MockMemento<T> implements Memento {
1717

1818
public get<T>(key: string): T | undefined;
1919
public get<T>(key: string, defaultValue: T): T;
20-
public get(key: any, defaultValue?: any): T | undefined {
20+
public get(key: any, defaultValue?: T): T | undefined {
2121
return this.map.get(key) || defaultValue;
2222
}
2323

extensions/ql-vscode/test/mocked-object.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export function mockedObject<T extends object>(
2525
return new Proxy<T>({} as unknown as T, {
2626
get: (_target, prop) => {
2727
if (prop in props) {
28+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
2829
return (props as any)[prop];
2930
}
3031
if (dynamicProperties && prop in dynamicProperties) {
32+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
3133
return (dynamicProperties as any)[prop]();
3234
}
3335

extensions/ql-vscode/test/unit-tests/common/disposable-object.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ describe("DisposableObject and DisposeHandler", () => {
7777
expect(disposable1.dispose).toHaveBeenCalled();
7878
});
7979

80-
it("ahould use a dispose handler", () => {
80+
it("should use a dispose handler", () => {
8181
const handler = (d: any) =>
8282
d === disposable1 || d === disposable3 || d === nestedDisposableObject
83-
? d.dispose(handler)
83+
? void d.dispose(handler)
8484
: void 0;
8585

8686
disposableObject.push(disposable1);

0 commit comments

Comments
 (0)