-
Notifications
You must be signed in to change notification settings - Fork 887
[Breaking change] Remove all use of the language service. Use only the Program. #2235
Conversation
src/language/rule/typedRule.ts
Outdated
@@ -31,5 +31,5 @@ export abstract class TypedRule extends AbstractRule { | |||
throw new Error(`The '${this.ruleName}' rule requires type checking`); | |||
} | |||
|
|||
public abstract applyWithProgram(sourceFile: ts.SourceFile, languageService: ts.LanguageService): RuleFailure[]; | |||
public abstract applyWithProgram(sourceFile: ts.SourceFile, languageService: ts.Program): RuleFailure[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also rename the parameter
actually, #1481 is no longer being deprecated due to community response. Can you put it back? |
The parameter originally used Need to verify that the original issue is doesn't break |
Rewrote |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes look good
Note that this makes |
That might be a problem for people who use plug-ins like the VSCode-TSLint since typed rules are not supported. People seem to use this rule to see the warnings instead of using the compiler flag so it doesn't block compilation; see #1481 (comment). |
I'm already working on a solution to use both rules without type checking. |
It may be possible to create a program consisting of a single file and run the rest as usual. |
PR checklist
no-use-before-declare
is enabled. #2181 (that error was in document highlights, which we no longer call)What changes did you make?
Tslint now only provides the
Program
, not theLanguageService
.LanguageService
is for editors; tslint should use theProgram
andTypeChecker
API.This would be break any custom typed rules, so should be in a major version change. So long as the custom typed rules do not use the language service, conversion is simple. See await-promise for an example.
Only
no-use-before-declare
andno-unused-variable
used the language service.Rewrote
no-use-before-declare
. It now gets the symbol at each use and checks that it comes after the declaration.I think
no-unused-variable
was going to be deprecated anyway, so removed it. It would be possible to rewrite that too if you want to keep it.As a side-effect, fixes #1969 since we don't have
wrapProgram
, which creates a new language service, which then has its own program. This probably helps performance too, but I haven't tested.Also changed tslint's own linting to use the program. Using typed rules in this repo could be done in another PR.
Will rebase after #2234 is in.