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
func-names: Allow unnamed generators (option) #9511
Comments
Thanks for the proposal. Could you clarify what the motivation for this option is? Why do you want to allow unnamed generators while disallowing other unnamed functions? |
Sure, happy to clarify! The reason comes down to language-level limitations, and in particular, that arrow notation can be used to create functions but not generators. When we create lightweight functions, we use arrow notation, which are inherently unnamed. As one reference point, the AirBnb styleguide recommends this approach. However, for generators, we can only use the standard |
I see, thanks. That makes sense to me -- let's see if the rest of the team would be in favor of adding an option like this. |
Not sure if this would have to be a new rule request, however generators also spark a similar break with the 'func-style' rule. Say for example we have the following code: const anExampleGenFunc= function* () {
yield () => console.log('Do Something more than a console.log here');
}; I feel as though that this is perfectly valid JS (please correct me if I am wrong), but it raises a warning in eslint. |
It looks like there's more then enough support from the team to accept this. We just need somebody to champion this change to mark it as accepted. @eslint/eslint-team anyone willing to champion? |
@eslint/eslint-team Anyone willing to champion this change? If not, it's probably time to close it. |
I'll champion this. |
@joegoldbeck After quite some time, this issue is now accepted. Would you be interested in submitting a pull request? (If not, no worries-- maybe someone else will, or maybe I can find some time myself in the next few weeks.) |
I'll submit a PR for this in the next couple of days. |
What rule do you want to change?
func-names
Does this change cause the rule to produce more or fewer warnings?
Fewer
How will the change be implemented? (New option, new default behavior, etc.)?
New option
Please provide some example code that this change will affect:
What does the rule currently do for this code?
"Unexpected unnamed generator function" unless the option is set to
"never"
What will the rule do after it's changed?
Allow unnamed generator functions if a second option is set to
{ generators: false }
or similarThe text was updated successfully, but these errors were encountered: