Skip to content
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

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

Closed
EthanRutherford opened this issue Jul 10, 2017 · 5 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@EthanRutherford
Copy link
Contributor

EthanRutherford commented Jul 10, 2017

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() {} }
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jul 10, 2017
@ilyavolodin ilyavolodin added enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jul 14, 2017
@ilyavolodin
Copy link
Member

Thanks for the issue. I think half-fix is probably not great, due to the fact that we need some sane defaults. But full configuration proposal sounds reasonable to me.

@EthanRutherford
Copy link
Contributor Author

Could we get some eyes on this issue? I feel like the solution I've implemented is an effective fix for the issue, and is backward compatible to boot. It should be just a matter of getting it approved.
If there's something objectionable to the solution, I'd be happy to take feedback on it, so that I can address said objections and create a better solution.

@not-an-aardvark
Copy link
Member

cc @eslint/eslint-team: Any thoughts on this proposal? It looks like it just needs a champion to move forward.

@not-an-aardvark
Copy link
Member

not-an-aardvark commented 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.)

@kaicataldo
Copy link
Member

I'll champion this.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 16, 2017
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 22, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

5 participants