Skip to content
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

Closed
donaldpipowitch opened this issue May 4, 2017 · 3 comments
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@donaldpipowitch
Copy link
Contributor

donaldpipowitch commented May 4, 2017

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 or noUnusedLocals.

  • 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 the package.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

  • It would be nice if linting would be a core feature of the language service - they don't stop compiling the source code and they have auto-fix ability.
  • It would be nice if lib authors could publish linting rules which are automatically picked up by the language service (just like typings). Two example use cases:
    • Say my lib cool-lib exports a function foo in v1. In v2 it will be renamed to bar, so we deprecate foo and export a bar with v1. I could publish cool-lib with a linting rule which shows a deprecation warning for foo which then could be auto-fixed to bar.
    • A real world example (see content: ' ' generates invalid CSS threepointone/glamor#249): In glamor writing { 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: '""' }.
    • TypeScript itself could ship with more specific linting rules in the future which would help the average developer (e.g. show warnings for deprecated methods like 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.

@donaldpipowitch
Copy link
Contributor Author

donaldpipowitch commented Aug 30, 2017

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. 👍

@donaldpipowitch
Copy link
Contributor Author

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 DefinitelyLinted project wouldn't be too far away to support non-TypeScript libs. :))

@RyanCavanaugh
Copy link
Member

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.

@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants