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
[@typescript-eslint/no-unused-vars] Rule should not fail on definition files #1772
Comments
Apologies if this is a duplicate of #1596. It seems to me to be slightly different so I preferred to open a ticket and see what you think. |
It's all the same bug under the hood. We don't have good scope analysis support due to the complexity of the dual-scope nature of TS, and it never being a high priority. There's the Ultimately though, we just recommend that people use typescript's no unused compiler option. |
Merging into #1856 |
Thank you! I'll follow the ticket there! |
@bradzacher, regarding
To be clear, I would love to add such notes myself, but I prefer asking first to make sure I have the right understanding before opening PRs. |
The difference is that Many people don't like the options because they want This is the tradeoff, and one of the reasons that the creators of TS now sort of regret building
|
That's a great explanation, thanks @bradzacher! So, when using However, do you think there is a benefit in using I'm currently seeing a case where this rule flags an unused parameter while TS doesn't: setStart: (_node: Node, _offset: number) => {}, (it's an unfortunate mock that we have no control over, sadly, and not including those parameters fails the type checker). |
setting There's not really any point in having both on - they report the same things. And also right now (as per the above issue) |
Repro
We are using the
flora-sql-parser
package which has no type definitions in its repo, nor is there a@types/flora-sql-parser
on DefinitelyTyped.At the moment, we are maintaining a
flora-sql-parser.d.ts
file locally (which is highly not exhaustive, which is why it has not been submitted to DefinitelyTyped). Part of our definition file has:to express the typing of the
Parser
class.Expected Result
Classes defined in definition files should not fail the
@typescript-eslint/no-unused-vars
rule: it's expected that they are not exported nor used in the current file.Actual Result
We get the following:
Additional Info
I am filing this as a bug report, but I do not have a lot of experience writing definition files so I would totally understand if I'm doing something incorrect in the definition file above (i.e. using a
class
instead of another construct, e.g.namespace
, etc.).Versions
@typescript-eslint/eslint-plugin
2.24.0
@typescript-eslint/parser
2.24.0
TypeScript
3.8.3
ESLint
6.8.0
node
12.14.0
npm
6.13.4
The text was updated successfully, but these errors were encountered: