Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Spaces in generator declarations/expressions #1175

Closed
geigerzaehler opened this issue Mar 17, 2015 · 5 comments
Closed

Spaces in generator declarations/expressions #1175

geigerzaehler opened this issue Mar 17, 2015 · 5 comments

Comments

@geigerzaehler
Copy link

If you use generators and JSCS’s esnext option, the behaviour is counter-intuitive.

{
  "esnext": true,
  "requireSpacesInAnonymousFunctionExpression": {
    "beforeOpeningRoundBrace": true
  }
}
var f = function* () {}

This shows the “Missing space before opening round brace“ error. The following doesn’t.

var f = function *() {}

Moreover, with the requireSpaceAfterKeyword option set to true, the following is also an error.

function* f () {}
@qfox
Copy link
Member

qfox commented Mar 17, 2015

Yeah, nice idea! Thanks for contributing

@hzoo
Copy link
Member

hzoo commented Mar 17, 2015

Should this be a bunch of new rules like requireSpacesInGeneratorFunctionExpression? Something similar would be to check the location of the * for

function * ()
function* ()
function *()
function*()

Oh ok there's a similar rule in ESLint http://eslint.org/docs/rules/generator-star-spacing.html

@mikesherov
Copy link
Contributor

right, seperate rule for generator * because they can show up in a few unexpected places.

@qfox
Copy link
Member

qfox commented Mar 17, 2015

For me it's pretty close to requireSpacesInConditionalExpression with their afterTest/beforeConsequent: beforeStar, afterStar?

But if we look further and reach ES7's async function * name () we can also try to group up all of them to requireSpacesInFunctionExpression options: beforeAsync, afterAsync. Just a thought.

@hzoo hzoo added the esnext label Oct 8, 2015
@hzoo hzoo self-assigned this Oct 17, 2015
@hzoo
Copy link
Member

hzoo commented Oct 17, 2015

Going to at least fix the function spacing rules - we can add the generator spacing rule later.

I guess it since we check beforeRoundBrace then instead of checking function( vs function ( we check *( vs * (

Sorry this could of been done a lot earlier

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants