Skip to content

Commit 627855a

Browse files
committed
chore: remove excess await/async + add TODOs
1 parent 9e03432 commit 627855a

6 files changed

+21
-13
lines changed

lib/adapters/command-execution-adapter.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export default class CommandExecutionAdapter {
1414
this.commandsCustomCallbacks.set(command, callback)
1515
}
1616

17-
public static async executeCommand(
17+
/** Returns a {Promise} */
18+
public static executeCommand(
1819
connection: LanguageClientConnection,
1920
command: string,
2021
commandArgs?: any[]
@@ -23,8 +24,8 @@ export default class CommandExecutionAdapter {
2324
const commandCustomCallback = this.commandsCustomCallbacks.get(command)
2425

2526
return commandCustomCallback !== undefined
26-
? await commandCustomCallback(executeCommandParams)
27-
: await connection.executeCommand(executeCommandParams)
27+
? commandCustomCallback(executeCommandParams)
28+
: connection.executeCommand(executeCommandParams)
2829
}
2930

3031
private static createExecuteCommandParams(command: string, commandArgs?: any[]): ExecuteCommandParams {

lib/auto-languageclient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,9 @@ export default class AutoLanguageClient {
428428
lsProcess.on("close", (code, signal) => this.onSpawnClose(code, signal))
429429
lsProcess.on("disconnect", () => this.onSpawnDisconnect())
430430
lsProcess.on("exit", (code, signal) => this.onSpawnExit(code, signal))
431+
// eslint-disable-next-line chai-friendly/no-unused-expressions
431432
lsProcess.stderr?.setEncoding("utf8")
433+
// eslint-disable-next-line chai-friendly/no-unused-expressions
432434
lsProcess.stderr?.on("data", (chunk: Buffer) => this.onSpawnStdErrData(chunk, projectPath))
433435
}
434436

lib/download-file.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ async function streamWithProgress(
6060

6161
// eslint-disable-next-line no-constant-condition
6262
while (true) {
63+
// TODO use Promise.all
64+
// eslint-disable-next-line no-await-in-loop
6365
const result = await reader.read()
6466
if (result.done) {
6567
if (progressCallback != null) {

lib/server-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ export class ServerManager {
138138
if (startingPromise) {
139139
return startingPromise
140140
}
141-
141+
// TODO remove eslint-disable
142+
// eslint-disable-next-line no-return-await
142143
return shouldStart && this._startForEditor(textEditor) ? await this.startServer(finalProjectPath) : null
143144
}
144145

test/adapters/autocomplete-adapter.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe("AutoCompleteAdapter", () => {
4444
type getSuggestionParams = Parameters<typeof autoCompleteAdapter.getSuggestions>
4545

4646
/** Function that stubs `server.connection.completion` and returns the `autoCompleteAdapter.getSuggestions(...)` */
47-
async function getSuggestionsMock(
47+
function getSuggestionsMock(
4848
items: CompletionItem[],
4949
request: getSuggestionParams[1],
5050
onDidConvertCompletionItem?: getSuggestionParams[2],
@@ -288,7 +288,7 @@ describe("AutoCompleteAdapter", () => {
288288

289289
it("respects onDidConvertCompletionItem", async () => {
290290
const results = await getSuggestionsMock([{ label: "label" }], createRequest({}), (c, a, r) => {
291-
;(a as ac.TextSuggestion).text = c.label + " ok"
291+
;(a as ac.TextSuggestion).text = `${c.label} ok`
292292
a.displayText = r.scopeDescriptor.getScopesArray()[0]
293293
})
294294

@@ -448,7 +448,7 @@ describe("AutoCompleteAdapter", () => {
448448
expect(result.replacementPrefix).equals("")
449449
})
450450

451-
describe("applies changes from TextEdit to text", async () => {
451+
describe("applies changes from TextEdit to text", () => {
452452
const customRequest = createRequest({ prefix: "", position: new Point(0, 10) })
453453
customRequest.editor.setText("foo #align bar")
454454

@@ -473,7 +473,7 @@ describe("AutoCompleteAdapter", () => {
473473
expect((results[0] as TextSuggestion).customReplacmentPrefix).equals("#align")
474474
})
475475

476-
describe("applies the change if shouldReplace is true", async () => {
476+
describe("applies the change if shouldReplace is true", () => {
477477
it("1", async () => {
478478
const results = await getSuggestionsMock(
479479
[
@@ -575,7 +575,7 @@ describe("AutoCompleteAdapter", () => {
575575
})
576576
})
577577

578-
describe("applies the change if shouldReplace is false", async () => {
578+
describe("applies the change if shouldReplace is false", () => {
579579
it("1", async () => {
580580
const results = await getSuggestionsMock(
581581
[

test/adapters/show-document-adapter.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,23 @@ import { createSpyConnection } from "../helpers"
1010

1111
describe("ShowDocumentAdapter", () => {
1212
describe("can attach to a server", () => {
13-
it("subscribes to onShowDocument", async () => {
13+
it("subscribes to onShowDocument", () => {
1414
const connection = createSpyConnection()
1515
const lcc = new LanguageClientConnection(connection)
1616

1717
const spy = sinon.spy()
18-
lcc["_onRequest"] = spy
18+
// eslint-disable-next-line dot-notation
19+
lcc["_onRequest"] = spy // private method access
1920

2021
ShowDocumentAdapter.attach(lcc)
22+
// eslint-disable-next-line dot-notation
2123
expect((lcc["_onRequest"] as sinon.SinonSpy).calledOnce).to.be.true
2224
const spyArgs = spy.firstCall.args
2325
expect(spyArgs[0]).to.deep.equal({ method: "window/showDocument" })
2426
expect(spyArgs[1]).to.equal(ShowDocumentAdapter.showDocument)
2527
})
2628

27-
it("onRequest connection is called", async () => {
29+
it("onRequest connection is called", () => {
2830
const connection = createSpyConnection()
2931
const lcc = new LanguageClientConnection(connection)
3032

@@ -39,7 +41,7 @@ describe("ShowDocumentAdapter", () => {
3941
})
4042
})
4143
describe("can show documents", () => {
42-
describe("shows the document inside Atom", async () => {
44+
describe("shows the document inside Atom", () => {
4345
const helloPath = join(dirname(__dirname), "fixtures", "hello.js")
4446

4547
async function canShowDocumentInAtom(params: ShowDocumentParams) {

0 commit comments

Comments
 (0)