-
Notifications
You must be signed in to change notification settings - Fork 700
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
Update to eslint 4 and enforce extra rules #1231
Conversation
.eslintrc.yml
Outdated
@@ -9,22 +9,28 @@ env: | |||
node: true | |||
|
|||
rules: | |||
arrow-body-style: 2 | |||
arrow-parens: [2, as-needed] |
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.
cc @thelounge/maintainers
@YaManicKill wants this to be always
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.
I would like this to be always, and here's my reasoning:
We require curly braces around all conditional and loop statements. The reason we do this (and why it's a standard across JS development just now) is because you can try to add a second line to an if, and if you forge tto add in the brackets afterwards, it won't do what you expect (it'll run the second line always).
I feel like we have the same issue with arrow functions, where you can technically do a 1 argument arrow function which doesn't have parenthesis, but if you add in a second argument, and forget to add in the brackets, you will end up with issues. The extra characters don't add much work, and they stop us having issues in the future. Also, it keeps all arrow functions looking consistent.
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.
I personally would prefer as-needed
over always
, but I won't fight over it :)
I completely get what you're saying, but there is a small subtlety to it though:
if (something)
doThis();
doThat();
The above is perfectly valid JS, but probably not what one wants. However:
arr.map(x, y => x * 2); // 💥
is simply broken JS, and a typo that one of our checks (tests, linters, compilers) should detect, regardless of the style preference.
Reason why I'd rather keep as-needed
is because of the beauty/simplicty of the new syntax:
arr.map(x => x * 2);
This is much nicer than:
arr.map((x) => x * 2);
And the reason why I won't fight over it is because parentheses are needed in other scenarios:
myFunction(() => doSomething());
myOtherFunction((x, y) => doSomethingElse(x, y));
And also because there is more important in life 😅
Anyway, my recommendation is to keep as-needed
and if we start seeing some issues with it, we can become more strict about it.
semi: [2, always] | ||
space-before-blocks: 2 | ||
space-before-function-paren: [2, never] | ||
space-in-parens: [2, never] | ||
space-infix-ops: 2 | ||
spaced-comment: [2, always] | ||
strict: 2 | ||
template-curly-spacing: 2 | ||
yoda: 2 |
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.
Was this removed from recommended
or something?
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.
My bad, it was never in there, good addition.
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.
Great stuff!
@@ -9,22 +9,28 @@ env: | |||
node: true | |||
|
|||
rules: | |||
arrow-body-style: 2 | |||
arrow-parens: [2, always] |
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.
Oh well :(
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.
Yay!
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.
Update to eslint 4 and enforce extra rules
No description provided.