question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

func-names: Allow unnamed generators (option)

See original GitHub issue

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:

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:closed
  • Created 6 years ago
  • Reactions:17
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
joegoldbeckcommented, Oct 25, 2017

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.

3reactions
not-an-aardvarkcommented, Oct 29, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found