-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
TSLint or ESLint rule #19
Comments
AFAIK, |
Yes tslint rules only work on 1 file at a time. So I don't see how this could be implemented. Closing. |
Don’t tslint/typescript-eslint rules have access to the type checker which has the whole project loaded? Can that bot be used to find references? |
We should definitely explore the linter possibility. Specially now that we have TS support in ESLint. In raw TS, with |
(re-opened) With However - I don't know that much about how There is a Visitor pattern, and a rule can implement one or more of the visiting methods. For example, this is a simple rule, that accepts visits from This is the same general pattern used by brainstorming: Is is possible that OR if it's possible to have static state across 'rule runs', then it could be possible to check A concern could be performance ... |
There is a discussion here at |
File boundaries seem convenient for linter implementation but otherwise a fairly arbitrary compartmentalization of linting, because file bounds have relatively little coincidence with data flow, calls etc. |
I was reading a little bit about ESLint rules/plugins yesterday and I don't think we can access multiple files inside a rule. More specifically I found this: That being said, if we completely ignore that ☝️ then we might get away with something. If we (pre-)generate the analysis for the whole project and we could incrementally update/replace everything related to the current file, we might get away with a workable prototype. Given that we start the POC by blatantly ignoring everything that is considered a good practice from the ESLint POV this might not be an ideal solution but it just might work. A brutal first approach would be to run a a full ts-unused-exports analysis for each file. Performance will be laughable (specially in big projects) but we could quickly check if this as a viable solution. If it is, we could start thinking on incremental analysis (something that will be required to get this done). |
I'd recommend looking to integrate with |
Hi all, will the new rule offer something better than the approach described here (typescript-eslint/typescript-eslint#371 (comment)). I understand that approach requires some configuration but apart from that, does this new rule seem to offer any other benefits? Edit: Upon testing, that approach was catching unused-exports of functions and variables but not the interfaces. |
@maneetgoyal the approach in that comment seems more suited to eslint architecture. (Parser and Resolver). But either way sounds like a rewrite |
You might try this https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unused-modules.md It worked like a charm for me. The |
Thanks @cscleison, that rule is working perfectly for me! RE: |
I was confused that this is not implemented as a tslint rule. It would be great to have the editor integration, line/column data for errors, shareable configuration and autofixing of tslint for this.
The text was updated successfully, but these errors were encountered: