Fix TS Lint's fix all quick fix showing up on non-tslint errors
Fixes #48
This commit is contained in:
Родитель
2970dea706
Коммит
425ffede22
|
@ -322,4 +322,17 @@ describe('CodeFixes', () => {
|
|||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should not return ts-lint fixes on non-tslint errors', async () => {
|
||||
const errorResponse = await getCodeFixes(
|
||||
`const a = 1; a = 2`, {
|
||||
startLine: 1,
|
||||
startOffset: 13,
|
||||
endLine: 1,
|
||||
endOffset: 14,
|
||||
});
|
||||
|
||||
assert.isTrue(errorResponse.success);
|
||||
assert.deepEqual(errorResponse.body, []);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -71,7 +71,7 @@ export class TSLintPlugin {
|
|||
const oldGetSupportedCodeFixes = this.ts.getSupportedCodeFixes.bind(this.ts);
|
||||
this.ts.getSupportedCodeFixes = (): string[] => {
|
||||
return [
|
||||
... oldGetSupportedCodeFixes(),
|
||||
...oldGetSupportedCodeFixes(),
|
||||
'' + TSLINT_ERROR_CODE,
|
||||
];
|
||||
};
|
||||
|
@ -181,21 +181,20 @@ export class TSLintPlugin {
|
|||
const documentFixes = this.codeFixActions.get(fileName);
|
||||
if (documentFixes) {
|
||||
const problem = documentFixes.get(start, end);
|
||||
if (problem && problem.fixable) {
|
||||
const fix = problem.failure.getFix();
|
||||
if (fix) {
|
||||
fixes.push(this.getRuleFailureQuickFix(problem.failure, fileName));
|
||||
if (problem) {
|
||||
if (problem.fixable) {
|
||||
const fix = problem.failure.getFix();
|
||||
if (fix) {
|
||||
fixes.push(this.getRuleFailureQuickFix(problem.failure, fileName));
|
||||
|
||||
const fixAll = this.getRuleFailureFixAllQuickFix(problem.failure.getRuleName(), documentFixes, fileName);
|
||||
if (fixAll) {
|
||||
fixes.push(fixAll);
|
||||
const fixAll = this.getRuleFailureFixAllQuickFix(problem.failure.getRuleName(), documentFixes, fileName);
|
||||
if (fixAll) {
|
||||
fixes.push(fixAll);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fixes.push(this.getFixAllAutoFixableQuickFix(documentFixes, fileName));
|
||||
|
||||
if (problem) {
|
||||
fixes.push(this.getFixAllAutoFixableQuickFix(documentFixes, fileName));
|
||||
fixes.push(this.getDisableRuleQuickFix(problem.failure, fileName, this.getProgram().getSourceFile(fileName)!));
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче