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.

RE: generator-star-spacing: work better together with space-before-function-paren #6195

See original GitHub issue

I’d like to drag this one back up, because I feel it should still be addressed (original issue #6195)

To summarize, the issue is that with the rules as below:

"space-before-function-paren": ["error", "never"],
"generator-star-spacing": ["error", {"before": false, "after": true}]

an anonymous generator function can never satisfy both rules

function*()   // fails generator-star-spacing after: true
function* ()  // fails space-before-function-paren: never

This is still an issue that needs a resolution. A decent half-fix would be to allow an unset “before” or “after” in generator-star-spacing to behave as if the rule is off for that half, only enforcing the rule for the values which are explicitly set.

"generator-star-spacing": ["error", {"before": false}]

A better more complete fix would be, as discussed in the previous issue, add configurability based on the function type (named, anonymous, method), in addition.

"generator-star-spacing": ["error", {
    "named": {"before": false, "after": true},
    "anonymous": {"before": false, "after": false},
    "method": {"after": false}
}]
function* gen() {}
let g = function*() {}
let m1 = {*method() {}}
let m2 = { *method() {} }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, Aug 16, 2017

By the way, one thing I want to bring up is that the async iteration proposal will introduce a new case here for async generator methods:

var obj = {
    async *x() {}
};

We don’t need to support that proposal right now, but it’s likely that that syntax will need to be supported at some point, so we should try to make this proposal forwards-compatible so that we can extend it in the future if necessary. (It seems like that might already be the case – for example, we could add an asyncMethod property later on – but I just wanted to bring it up as something to consider.)

0reactions
kaicataldocommented, Aug 16, 2017

I’ll champion this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

space-before-function-paren
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
space-before-function-paren - TypeScript ESLint
Enforce consistent spacing before function parenthesis.. Some problems reported by this rule are automatically fixable by the --fix ESLint command line ...
Read more >
Rule: space-before-function-paren - Palantir Open Source
Config. One argument which is an object which may contain the keys anonymous , named , and asyncArrow These should be set to...
Read more >
Prettier Function Parenthesis Spacing - Opinionated is Key
Space before function paren is important because then you can search for function definitions using `[space]funcName[space]` if you're not using ...
Read more >
VS Code - space before function parentheses
Thanks, exactly what i am looking for, took a while to realize there are different settings for normal and anonymous functions. Looks like...
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