Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit eda533e

Browse files
committed
Add lint task
1 parent cd015a1 commit eda533e

File tree

6 files changed

+293
-12
lines changed

6 files changed

+293
-12
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,15 @@
154154
"scripts": {
155155
"vscode:prepublish": "npm run compile",
156156
"compile": "tsc -p ./",
157-
"watch": "tsc -w -p ./"
157+
"watch": "tsc -w -p ./",
158+
"lint": "tslint -c tslint.json -p ."
158159
},
159160
"dependencies": {
160161
"typescript-tslint-plugin": "0.5.0"
161162
},
162163
"devDependencies": {
163164
"@types/vscode": "^1.32.0",
165+
"tslint": "^5.17.0",
164166
"typescript": "^3.4.5"
165167
}
166168
}

src/fixAll.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11

22
import * as vscode from 'vscode';
3-
import { isTypeScriptDocument, isEnabledForJavaScriptDocument } from './utils';
3+
import { isEnabledForJavaScriptDocument, isTypeScriptDocument } from './utils';
44

55
function executeCodeActionProvider(uri: vscode.Uri, range: vscode.Range) {
66
return vscode.commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', uri, range);
77
}
88

9-
109
async function getTsLintFixAllCodeAction(document: vscode.TextDocument): Promise<vscode.CodeAction | undefined> {
1110
const diagnostics = vscode.languages
1211
.getDiagnostics(document.uri)
13-
.filter(diagnostic => diagnostic.source === 'tslint');
12+
.filter((diagnostic) => diagnostic.source === 'tslint');
1413

1514
for (const diagnostic of diagnostics) {
1615
const codeActions = await executeCodeActionProvider(document.uri, diagnostic.range);
1716
if (codeActions) {
18-
const fixAll = codeActions.filter(action => action.title === 'Fix all auto-fixable tslint failures');
17+
const fixAll = codeActions.filter((action) => action.title === 'Fix all auto-fixable tslint failures');
1918
if (fixAll.length > 0) {
2019
return fixAll[0];
2120
}
@@ -24,19 +23,18 @@ async function getTsLintFixAllCodeAction(document: vscode.TextDocument): Promise
2423
return undefined;
2524
}
2625

27-
2826
const fixAllCodeActionKind = vscode.CodeActionKind.SourceFixAll.append('tslint');
2927

3028
export class FixAllProvider implements vscode.CodeActionProvider {
3129
public static metadata: vscode.CodeActionProviderMetadata = {
3230
providedCodeActionKinds: [fixAllCodeActionKind],
3331
};
3432

35-
async provideCodeActions(
33+
public async provideCodeActions(
3634
document: vscode.TextDocument,
3735
_range: vscode.Range | vscode.Selection,
3836
context: vscode.CodeActionContext,
39-
_token: vscode.CancellationToken
37+
_token: vscode.CancellationToken,
4038
): Promise<vscode.CodeAction[]> {
4139
if (!context.only) {
4240
return [];

0 commit comments

Comments
 (0)