This repository has been archived by the owner. It is now read-only.

Spaces in generator declarations/expressions #1175

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

Comments

Projects
None yet
4 participants
@geigerzaehler

geigerzaehler commented Mar 17, 2015

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 () {}
@zxqfox

This comment has been minimized.

Show comment
Hide comment
@zxqfox

zxqfox Mar 17, 2015

Member

Yeah, nice idea! Thanks for contributing

Member

zxqfox commented Mar 17, 2015

Yeah, nice idea! Thanks for contributing

@hzoo

This comment has been minimized.

Show comment
Hide comment
@hzoo

hzoo Mar 17, 2015

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@mikesherov

mikesherov Mar 17, 2015

Contributor

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

Contributor

mikesherov commented Mar 17, 2015

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

@zxqfox

This comment has been minimized.

Show comment
Hide comment
@zxqfox

zxqfox Mar 17, 2015

Member

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.

Member

zxqfox 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

This comment has been minimized.

Show comment
Hide comment
@hzoo

hzoo Oct 17, 2015

Member

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

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.