-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Linting should be a core feature of the language server #15589
Comments
Just fell into a rabbit hole.
Update from August 2019
Just wanted to illustrate the current state of tooling around this and the rough edges. Thanks for the work so far. 👍 |
I know React isn't build with TypeScript, but I think the new hooks feature illustrates my original use case quite nicely. Taken the question if hooks are useful or not aside, their correct usage relies on certain behavior (like ordering) which can't be covered by static typing alone. The React team created a linter rule which helps users to use hooks correctly. IMHO it would be really nice, if a lib like React could ship with these rules and every time I import the lib TypeScript would pick up these rules automatically without setting up additional tooling. (Given the lib is written in TypeScript. And if not... I guess a |
I don't see much left to do here that wasn't already done. LS plugins exist and side-by-side error providers in editors are well-supported. |
This follows some thoughts I had with "The Maybe Future of Frontend Tooling" and picks up some use cases which aren't covered by the current (awesome!) language server plugin support.
Current state
The compiler has lint level checks like
noUnusedParameters
ornoUnusedLocals
.TSLint deprecated support for
no-unused-variable
because of that.Now issues like Add support for diagnostic severities #13408 were created so the TypeScript compiler only warns about unused variables and don't throw compiler errors.
That would be a nice feature in general, but it misses other useful linter features like auto-fixing linter warnings (e.g. removing unused variables).
(By the way... in TSLint v5 the deprecation message for
no-unused-variable
was removed, because the warning and auto-fix is so useful and not covered by TypeScript currently.)People would like to see unused imports in IDEs (see Suggestion: Show unused imports in VS Code Editor as grayed #8165).
Typings for libs can be shipped with the package itself and are referenced in the
typings
field in thepackage.json
. The lib itself can be written in TypeScript or not.Language server plugins aren't automatically picked up.
What I'd like to see
typings
). Two example use cases:cool-lib
exports a functionfoo
in v1. In v2 it will be renamed tobar
, so we deprecatefoo
and export abar
with v1. I could publishcool-lib
with a linting rule which shows a deprecation warning forfoo
which then could be auto-fixed tobar
.{ content: '' }
is not allowed. We can create a warning at runtime, but with a custom linting rule we can warn the developer while writing this code and auto-fix it to{ content: '""' }
.String.prototype.big()
.Update from August 2019
By now TypeScript support so called suggestions which allow fixes. This leverages the linter idea as a core of TypeScript even more in my opinion. TypeScript even gained several nice refactoring features (like renaming files and automatically update relevant paths) which I would like to call from inside of a linter rule.
The text was updated successfully, but these errors were encountered: