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

Classes and Missing space before function parentheses. (space-before-function-paren) #346

Closed
yormi opened this issue Nov 27, 2015 · 7 comments

Comments

@yormi
Copy link

yormi commented Nov 27, 2015

Ok, I'm not sure if it's the right place to post the issue but I haven't manage to determine if the problem lies in standard or eslint or babel-eslint... maybe you could help me !

Same problem than posted here(#59). I tried to test with Eslint using the rc/.eslintrc of this project but I'm still confuse with all that.

class foo {
    somefunction () {
    }
}

giving:
Missing space before function parentheses. (space-before-function-paren)

In package.json:

"standard": {"parser": "babel-eslint"}

@Flet
Copy link
Member

Flet commented Dec 10, 2015

I don't think setting the parser to babel-eslint is required anymore.

When I take the code above and paste it into http://standardjs.com/demo it comes back valid with no errors.

Could you try reinstalling the latest version of standard and testing again?

@yormi
Copy link
Author

yormi commented Dec 10, 2015

Everything is up-to-date. I reinstalled Standard just in case but no difference. Still the same error that indeed doesn't appear on the standardjs demo page.

For the parser, without it, I have weird stuff like an Parsing Error: Unexpected token function when I use that great async keyword.

@yormi
Copy link
Author

yormi commented Dec 11, 2015

Ah ha ! Just found the problem ! I'm using vim as well as the auto-format taken from the readme:
autocmd bufwritepost *.js silent !standard % --format
set autoread

It was actually removing the space between the function name and the () without refreshing the buffer. Got lucky to notice it.

I guess the problem would rely in the formatter then... and maybe some change to the vim autoformat command would help detect other potential future error ?

@yura415
Copy link

yura415 commented Jan 9, 2016

Does standard actually support ES6 features that are now part of the stable node.js build?

export class Foo {
  constructor (bar) {
    this.baz(bar)
  }
  baz (bar) {
    console.log(bar)
  }
  test () {
    console.log('test')
  }
}

Using this code snippet with standardjs.com/demo, "Format" button not giving a correct result:

export class Foo {
  constructor( bar) {
    this.baz(bar)
  }
  baz( bar) {
    console.log(bar)
  }
  test() {
    console.log('test')
  }
}

Of course after code was formatted, linter reports errors. Thats an incorrect behaviour.

Same story with the object shorthand:

let test = {
  foo () {
    console.log('foo')
  }
}

test.foo()

After format, becomes the

let test = {
  foo() {
    console.log('foo')
  }
}

test.foo()

Generating new "Missing space before function parentheses" error.

@lipp
Copy link

lipp commented Jan 25, 2016

+1 same problem as @yura415: the formater messes up the parentheses spacing.

@pnw
Copy link

pnw commented Feb 1, 2016

+1 getting the same thing. The formatter breaks the subsequent lint.

@feross
Copy link
Member

feross commented Feb 5, 2016

Yeah, the formatter has issues with some ES6 features. You can help fix these issues by contributing to the standard-format project! It will get better with time.

This issue is already open on that issue tracker: max-mapper/standard-format#134

@feross feross closed this as completed Feb 5, 2016
@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

6 participants