-
Notifications
You must be signed in to change notification settings - Fork 26.6k
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
Require a space between function
and (
.
#605
Conversation
…nction's name, and disallow spaces between the function's name and `(`.
Yes please 👍 |
👍 |
So much 👍 |
|
||
// good | ||
const x = function () {}; | ||
const y = function a() {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, i think i want {"anonymous": "always", "named": "never"}
as a config then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.