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-vars" doesn't work with recursive function correctly, when it is declared with function expression #10982
Comments
Hi @aliaksandr-yermalayeu, thanks for the issue. It seems to me the recursive declaration case should be flagged as used (i.e., neither example should produce a warning). But I'm not 100% sure. @not-an-aardvark @mysticatea Any thoughts? |
The firat example should produce a warning because the function can never be initially called, since it's only referenced from inside itself. The second example could be made to produce a warning for the same reason, although this would require modifying the rule to be able to infer that the function can only be accessed through the |
It has been introduced in #2095; the rule is addressing function declarations to detect recursive calls, but not variable declarations. We can enhance the rule. Maybe...
|
@mysticatea Just to clarify, are you saying this is a bug? |
Re-looked, #2095 was handled as a bug, so this is a bug. |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
function declaration
function expression
What did you expect to happen?
Second case should cause error the same way as the first one.
The text was updated successfully, but these errors were encountered: