Require a space between function and (.#605
Conversation
…nction's name, and disallow spaces between the function's name and `(`.
|
Yes please 👍 |
|
👍 |
|
So much 👍 |
There was a problem hiding this comment.
According to the guide (https://github.com/eslint/eslint/blob/master/docs/rules/space-before-function-paren.md) this should be const y = function a () {}
There was a problem hiding this comment.
ah, i think i want {"anonymous": "always", "named": "never"} as a config then.
There was a problem hiding this comment.
Anyway there's another rule that says anonymous function should be named (or use arrow functions)
|
I like this rule, but for a reason different than the explanation submitted. It reserves parentheses touching the word before them strictly for function invocations. Then other parenthesis uses are spaced (e.g. if/while/for and func definitions). It makes for a simple rule to remember "put a space before ( unless you are invoking a method". To that end, this would also apply to method definitions and named functions. See the "always" examples for the rule https://github.com/eslint/eslint/blob/master/docs/rules/space-before-function-paren.md |
2e60adf to
599ca4f
Compare
|
Sorry about that - I've fixed the eslint rules to match what I typed in the guide itself. There must never be a space between a function's name and the |
|
Ah, darn. I like "always", but understand not everyone agrees 😞 |
[breaking] Require function spacing: `function <optional name>(`
The guide was inconsistent in its use of spacing, and the most common convention both inside Airbnb and in community JS is to require this space. This both adds a section on it, and enables the linting rule.