Skip to content

Commit 1582000

Browse files
authored
Merge pull request #145 from atom-community/update-eslint
2 parents 33e7d4d + 627855a commit 1582000

15 files changed

+71
-41
lines changed

.eslintrc.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{
2-
"extends": "eslint-config-atomic/strict",
2+
"extends": ["eslint-config-atomic/strict", "plugin:chai-friendly/recommended"],
33
"ignorePatterns": ["build/", "node_modules/"],
44
"rules": {
5+
"no-eq-null": "warn",
6+
"eqeqeq": "warn",
7+
"no-empty-function": "warn",
8+
"class-methods-use-this": "warn",
9+
"default-case": "warn",
10+
"no-new": "warn",
11+
"no-shadow": "warn",
12+
"no-invalid-this": "warn",
13+
"require-await": "warn",
14+
"no-useless-constructor": "warn",
515
"@typescript-eslint/ban-types": [
616
"error",
717
{
@@ -16,7 +26,7 @@
1626
"allowArgumentsExplicitlyTypedAsAny": true
1727
}
1828
],
19-
"@typescript-eslint/no-empty-function": "off",
29+
"@typescript-eslint/no-empty-function": "warn",
2030
"@typescript-eslint/no-explicit-any": "off",
2131
"@typescript-eslint/no-unused-vars": [
2232
"error",

lib/adapters/command-execution-adapter.ts

Lines changed: 5 additions & 4 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,13 +24,13 @@ 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 {
3132
return {
32-
command: command,
33+
command,
3334
arguments: commandArgs,
3435
}
3536
}

lib/adapters/outline-view-adapter.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ export default class OutlineViewAdapter {
111111
* @returns An {OutlineTree} containing the given symbols that the Outline View can display.
112112
*/
113113
public static createOutlineTrees(symbols: SymbolInformation[]): atomIde.OutlineTree[] {
114-
symbols.sort((a, b) =>
115-
a.location.range.start.line === b.location.range.start.line
116-
? a.location.range.start.character - b.location.range.start.character
117-
: a.location.range.start.line - b.location.range.start.line
118-
)
114+
symbols.sort((a, b) => {
115+
if (a.location.range.start.line === b.location.range.start.line) {
116+
return a.location.range.start.character - b.location.range.start.character
117+
} else {
118+
return a.location.range.start.line - b.location.range.start.line
119+
}
120+
})
119121

120122
// Temporarily keep containerName through the conversion process
121123
// Also filter out symbols without a name - it's part of the spec but some don't include it

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

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@
3838
"@types/mocha": "^8.2.0",
3939
"@types/node": "14.14.22",
4040
"@types/sinon": "^9.0.10",
41-
"@typescript-eslint/eslint-plugin": "^4.14.1",
42-
"@typescript-eslint/parser": "^4.14.1",
4341
"chai": "^4.2.0",
44-
"eslint": "^7.18.0",
45-
"eslint-config-atomic": "1.10.1",
42+
"eslint-config-atomic": "^1.14.0",
43+
"eslint-plugin-chai-friendly": "^0.6.0",
4644
"mocha": "^8.2.1",
4745
"mocha-appveyor-reporter": "^0.4.2",
4846
"shx": "^0.3.3",

pnpm-lock.yaml

Lines changed: 19 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/adapters/apply-edit-adapter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const TEST_PATH4 = normalizeDriveLetterName(path.join(__dirname, "test4.txt"))
1212

1313
function normalizeDriveLetterName(filePath: string): string {
1414
if (process.platform === "win32") {
15-
return filePath.replace(/^([a-z]):/, ([driveLetter]) => driveLetter.toUpperCase() + ":")
15+
return filePath.replace(/^([a-z]):/, ([driveLetter]) => `${driveLetter.toUpperCase()}:`)
1616
} else {
1717
return filePath
1818
}

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
[

0 commit comments

Comments
 (0)