func-names: Allow unnamed generators (option)
See original GitHub issueWhat 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:
const parse = coroutinify(function* (input) { ... })
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 similar
Issue Analytics
- State:
- Created 6 years ago
- Reactions:17
- Comments:9 (7 by maintainers)
Top Results From Across the Web
func-names - ESLint - Pluggable JavaScript Linter
This rule has an object option: "generators": "always" | "as-needed" | "never". "always" require named generators; "as-needed" require named generators if ...
Read more >eslint func name enforcement rules - Stack Overflow
I am currently using eslint func-names . What I want to achieve is as follow. Note that I do not want to use...
Read more >function* expression - JavaScript - MDN Web Docs - Mozilla
The following example defines an unnamed generator function and assigns it to x . The function yields the square of its argument:.
Read more >Bash Variables (Bash Reference Manual) - GNU.org
Each word in the list is a valid argument for the -s option to the shopt builtin command (see ... The shell function...
Read more >要求或禁止命名的function 表达式(func-names) - ESLint
... option. 当没有为 generators 提供值时,生成器函数的行为将回退到基本选项。 ... /*eslint func-names: ["error", "always"]*/ Foo.prototype.bar = function() ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
function*
, and so an exception for generators would allow us to create lightweight unnamed generators while leaving our stricter linting rules for functions intact.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.