Skip to content

Commit 0b5a8e9

Browse files
committed
Add recommended type-checking ESLint rules
1 parent 81dd60f commit 0b5a8e9

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"root": true,
33
"extends": [
44
"eslint:recommended",
5-
"plugin:@typescript-eslint/recommended"
5+
"plugin:@typescript-eslint/recommended",
6+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
67
],
78
"parser": "@typescript-eslint/parser",
89
"parserOptions": {
910
"ecmaVersion": 6,
11+
"project": "./tsconfig.json",
1012
"sourceType": "module"
1113
},
1214
"plugins": ["@typescript-eslint"],

src/extension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import { generateSnippet } from './lib/textHelpers';
33

44
export function activate(context: ExtensionContext): void {
55
context.subscriptions.push(
6-
commands.registerTextEditorCommand('snippet-copy.copySnippet', async (editor) => {
6+
commands.registerTextEditorCommand('snippet-copy.copySnippet', (editor) => {
77
const snippet = generateSnippet(editor.document, editor.selections, false);
88

9-
await env.clipboard.writeText(snippet);
9+
void env.clipboard.writeText(snippet);
1010
})
1111
);
1212
context.subscriptions.push(
13-
commands.registerTextEditorCommand('snippet-copy.copySnippetAsMarkdownCodeBlock', async (editor) => {
13+
commands.registerTextEditorCommand('snippet-copy.copySnippetAsMarkdownCodeBlock', (editor) => {
1414
const snippet = generateSnippet(editor.document, editor.selections, true);
1515

16-
await env.clipboard.writeText(snippet);
16+
void env.clipboard.writeText(snippet);
1717
})
1818
);
1919
}

src/test/runTest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path';
2-
32
import { runTests } from 'vscode-test';
43

4+
55
async function main() {
66
try {
77
// The folder containing the Extension Manifest package.json
@@ -20,4 +20,5 @@ async function main() {
2020
}
2121
}
2222

23+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
2324
main();

src/test/suite/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as path from 'path';
2-
import * as Mocha from 'mocha';
31
import * as glob from 'glob';
2+
import * as Mocha from 'mocha';
3+
import * as path from 'path';
44

55
export function run(): Promise<void> {
66
// Create the mocha test
@@ -12,7 +12,7 @@ export function run(): Promise<void> {
1212
const testsRoot = path.resolve(__dirname, '..');
1313

1414
return new Promise((c, e) => {
15-
glob('**/**.test.js', { cwd: testsRoot }, async (err, files) => {
15+
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
1616
if (err) {
1717
return e(err);
1818
}
@@ -22,7 +22,6 @@ export function run(): Promise<void> {
2222

2323
try {
2424
// Run the mocha test
25-
await mocha.loadFilesAsync();
2625
mocha.run(failures => {
2726
if (failures > 0) {
2827
e(new Error(`${failures} tests failed.`));

src/test/suite/lib/documentHelpers.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('Document Helpers', function () {
2828
});
2929
});
3030

31-
context('minimumIndentationLevelForLineIndexes', async () => {
31+
context('minimumIndentationLevelForLineIndexes', () => {
3232
it('calculates the correct minimum indentation level for a single line', () => {
3333
assert.equal(minimumIndentationForLineIndexes(document, [3]), 6);
3434
});
@@ -38,7 +38,7 @@ describe('Document Helpers', function () {
3838
});
3939
});
4040

41-
context('contentOfLinesWithAdjustedIndentation', async () => {
41+
context('contentOfLinesWithAdjustedIndentation', () => {
4242
it('returns multiline text with the indentation adjusted correctly', () => {
4343
assert.equal(contentOfLinesWithAdjustedIndentation(document, [2, 3, 4], 4), 'if (aValue) {\n console.log(`Doing something with ${aValue}!`);\n}');
4444
});
@@ -68,7 +68,7 @@ describe('Document Helpers', function () {
6868
});
6969

7070
context('endOfLineCharacter', () => {
71-
it('correctly returns LF', async () => {
71+
it('correctly returns LF', () => {
7272
assert.equal(endOfLineCharacter(document), '\n');
7373
});
7474

0 commit comments

Comments
 (0)