RE: generator-star-spacing: work better together with space-before-function-paren #6195
See original GitHub issueI’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:
- Created 6 years ago
- Reactions:5
- Comments:5 (5 by maintainers)
Top 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 >
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 Free
Top 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
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:
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.)I’ll champion this.