-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[no-unused-var] varsIgnorePattern not working for this module definition #2648
Comments
Your example code doesn't include a usage. |
This is a minimal example for the behavior in our 460000 loc project with TS compiler option It is fine if eslint can not detect usage of the object. But at least the entry |
I ask because the usage is very important. In this case - in your updated example... Usages from within the namespace do not count, and are not considered by the rule. You get the same functionality with /* eslint no-unused-vars: ["error"] */
function foo() {
return foo(); // Error: 'foo' is defined but never used. (no-unused-vars)
} |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ok, I am perfectly fine with that. Another example from my code base: module Hmi.System {
export class Init {
public static run() {
// Run the HMI
}
}
Hmi.System.Init.run(); // This code kick starts the main code.
} I have no problem adding |
I guess I have a few questions here before I can provide a good course of action:
|
It is a technical dept in our code (which started with TS 1.6) we want to change in the (far?) future.
You are right. This can be adjusted with some files (but not in all). Sorry if I repeat myself. But I see |
Yeah sometimes this can be solved in the code, sometimes it needs config. The more information I have, the easier it is for me to figure out what the best solution could be for your use case. In this case, yes likely using Though I would definitely recommend prioritising off of (what I assume are) global non-exported namespaces and onto ES6 modules 🙂 |
I think you did not understood what I am trying to say since four messages: |
I did not understand that was what you meant, no sorry. The bug is here. Our extensions to rule doesn't consider typescript-eslint/packages/eslint-plugin/src/rules/no-unused-vars.ts Lines 199 to 209 in c41dbe5
Should be a simple fix. happy to accept a PR. |
Repro
Or even shorter:
Expected Result
No rule violation.
Because the module is used.Hmi
intovarsIgnorePattern
Actual Result
Additional Info
This examples are working!
Versions
The text was updated successfully, but these errors were encountered: