Skip to content

Commit c6ee20b

Browse files
Merge pull request #2075 from github/robertbrignull/enable-await-thenable
Enable eslint rule to disallow awaiting a non-thenable type
2 parents 95f46b3 + 5f20ef3 commit c6ee20b

File tree

10 files changed

+22
-25
lines changed

10 files changed

+22
-25
lines changed

extensions/ql-vscode/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const baseConfig = {
2929
"plugin:@typescript-eslint/recommended",
3030
],
3131
rules: {
32+
"@typescript-eslint/await-thenable": "error",
3233
"@typescript-eslint/no-use-before-define": 0,
3334
"@typescript-eslint/no-unused-vars": [
3435
"warn",

extensions/ql-vscode/scripts/lint-scenarios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function lintScenarios() {
2828
throw new Error(`Invalid schema: ${ajv.errorsText()}`);
2929
}
3030

31-
const validate = await ajv.compile(schema);
31+
const validate = ajv.compile(schema);
3232

3333
let invalidFiles = 0;
3434

extensions/ql-vscode/src/cli.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ export class CodeQLCliServer implements Disposable {
296296
);
297297
}
298298

299-
return await spawnServer(
299+
return spawnServer(
300300
codeQlPath,
301301
"CodeQL CLI Server",
302302
["execute", "cli-server"],
@@ -456,7 +456,7 @@ export class CodeQLCliServer implements Disposable {
456456
void logStream(child.stderr!, logger);
457457
}
458458

459-
for await (const event of await splitStreamAtSeparators(child.stdout!, [
459+
for await (const event of splitStreamAtSeparators(child.stdout!, [
460460
"\0",
461461
])) {
462462
yield event;
@@ -488,7 +488,7 @@ export class CodeQLCliServer implements Disposable {
488488
cancellationToken?: CancellationToken,
489489
logger?: Logger,
490490
): AsyncGenerator<EventType, void, unknown> {
491-
for await (const event of await this.runAsyncCodeQlCliCommandInternal(
491+
for await (const event of this.runAsyncCodeQlCliCommandInternal(
492492
command,
493493
commandArgs,
494494
cancellationToken,
@@ -751,7 +751,7 @@ export class CodeQLCliServer implements Disposable {
751751
...testPaths,
752752
]);
753753

754-
for await (const event of await this.runAsyncCodeQlCliCommand<TestCompleted>(
754+
for await (const event of this.runAsyncCodeQlCliCommand<TestCompleted>(
755755
["test", "run"],
756756
subcommandArgs,
757757
"Run CodeQL Tests",
@@ -1561,7 +1561,7 @@ const lineEndings = ["\r\n", "\r", "\n"];
15611561
* @param logger The logger that will consume the stream output.
15621562
*/
15631563
async function logStream(stream: Readable, logger: Logger): Promise<void> {
1564-
for await (const line of await splitStreamAtSeparators(stream, lineEndings)) {
1564+
for await (const line of splitStreamAtSeparators(stream, lineEndings)) {
15651565
// Await the result of log here in order to ensure the logs are written in the correct order.
15661566
await logger.log(line);
15671567
}

extensions/ql-vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ export async function activate(
462462
) {
463463
registerErrorStubs([checkForUpdatesCommand], (command) => async () => {
464464
const installActionName = "Install CodeQL CLI";
465-
const chosenAction = await void showAndLogErrorMessage(
465+
const chosenAction = await showAndLogErrorMessage(
466466
`Can't execute ${command}: missing CodeQL CLI.`,
467467
{
468468
items: [installActionName],

extensions/ql-vscode/src/mocks/mock-gh-api-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ export class MockGitHubApiServer extends DisposableObject {
9696
}
9797

9898
public async stopRecording(): Promise<void> {
99-
await this.recorder.stop();
100-
await this.recorder.clear();
99+
this.recorder.stop();
100+
this.recorder.clear();
101101
}
102102

103103
public async getScenarioNames(scenariosPath?: string): Promise<string[]> {

extensions/ql-vscode/src/mocks/vscode-mock-gh-api-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
3535
}
3636

3737
public async startServer(): Promise<void> {
38-
await this.server.startServer();
38+
this.server.startServer();
3939
}
4040

4141
public async stopServer(): Promise<void> {
42-
await this.server.stopServer();
42+
this.server.stopServer();
4343

4444
await commands.executeCommand(
4545
"setContext",

extensions/ql-vscode/src/qlpack-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class QlPackGenerator {
5757

5858
const end = (workspace.workspaceFolders || []).length;
5959

60-
await workspace.updateWorkspaceFolders(end, 0, {
60+
workspace.updateWorkspaceFolders(end, 0, {
6161
name: this.folderName,
6262
uri: this.folderUri,
6363
});

extensions/ql-vscode/src/test-adapter.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,11 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
356356
tests: string[],
357357
cancellationToken: CancellationToken,
358358
): Promise<void> {
359-
const workspacePaths = await getOnDiskWorkspaceFolders();
360-
for await (const event of await this.cliServer.runTests(
361-
tests,
362-
workspacePaths,
363-
{
364-
cancellationToken,
365-
logger: testLogger,
366-
},
367-
)) {
359+
const workspacePaths = getOnDiskWorkspaceFolders();
360+
for await (const event of this.cliServer.runTests(tests, workspacePaths, {
361+
cancellationToken,
362+
logger: testLogger,
363+
})) {
368364
const state = event.pass
369365
? "passed"
370366
: event.messages?.length

extensions/ql-vscode/test/vscode-tests/cli-integration/legacy-query.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ class Checkpoint<T> {
5050
}
5151

5252
async resolve(): Promise<void> {
53-
await this.res();
53+
this.res();
5454
}
5555

5656
async reject(e: Error): Promise<void> {
57-
await this.rej(e);
57+
this.rej(e);
5858
}
5959
}
6060

extensions/ql-vscode/test/vscode-tests/cli-integration/new-query.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ class Checkpoint<T> {
5050
}
5151

5252
async resolve(): Promise<void> {
53-
await this.res();
53+
this.res();
5454
}
5555

5656
async reject(e: Error): Promise<void> {
57-
await this.rej(e);
57+
this.rej(e);
5858
}
5959
}
6060

0 commit comments

Comments
 (0)