Skip to content

Commit df35fc1

Browse files
arrow-parens and function-call-argument-newline eslintrc mods
1 parent 7a11901 commit df35fc1

2 files changed

Lines changed: 79 additions & 3 deletions

File tree

.eslintrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@
573573
// https://eslint.org/docs/rules/arrow-parens
574574
"arrow-parens": [
575575
"error",
576-
"always"
576+
"as-needed"
577577
],
578578
// require space before/after arrow function"s arrow
579579
// https://eslint.org/docs/rules/arrow-spacing
@@ -1166,9 +1166,8 @@
11661166
"always"
11671167
],
11681168
// https://eslint.org/docs/rules/function-call-argument-newline
1169-
// TODO: enable, semver-minor, once eslint v6.2 is required (which is a major)
11701169
"function-call-argument-newline": [
1171-
"off",
1170+
"error",
11721171
"consistent"
11731172
],
11741173
// enforce spacing between functions and their invocations

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,52 @@ Other Style Guides
865865
// good
866866
new Date(...[2016, 8, 5]);
867867
```
868+
<a name="functions--function-call-spacing"></a><a name="7.15"></a>
869+
- [7.15](#functions--function-call-spacing) Function argument spacing should be consistent within the function.
870+
871+
```javascript
872+
/*eslint function-call-argument-newline: ["error", "consistent"]*/
873+
874+
foo("one", "two", "three");
875+
// or
876+
foo(
877+
"one",
878+
"two",
879+
"three"
880+
);
881+
882+
bar("one", "two", {
883+
one: 1,
884+
two: 2
885+
});
886+
// or
887+
bar(
888+
"one",
889+
"two",
890+
{ one: 1, two: 2 }
891+
);
892+
// or
893+
bar(
894+
"one",
895+
"two",
896+
{
897+
one: 1,
898+
two: 2
899+
}
900+
);
901+
902+
baz("one", "two", (x) => {
903+
console.log(x);
904+
});
905+
// or
906+
baz(
907+
"one",
908+
"two",
909+
(x) => {
910+
console.log(x);
911+
}
912+
);
913+
```
868914
869915
**[⬆ back to top](#table-of-contents)**
870916
@@ -935,6 +981,37 @@ Other Style Guides
935981
bool = true;
936982
});
937983
```
984+
<a name="arrows--one-arg-parens"></a><a name="8.4"></a>
985+
- [8.4](#arrows--one-arg-parens) Include parentheses as-needed around arguments. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html)
986+
987+
```javascript
988+
// Incorrect
989+
(a) => {};
990+
(a) => a;
991+
(a) => {'\n'};
992+
a.then((foo) => {});
993+
a.then((foo) => a);
994+
a((foo) => { if (true) {} });
995+
const f = /** @type {number} */(a) => a + a;
996+
const g = /* comment */ (a) => a + a;
997+
const h = (a) /* comment */ => a + a;
998+
999+
// Correct
1000+
() => {};
1001+
a => {};
1002+
a => a;
1003+
a => {'\n'};
1004+
a.then(foo => {});
1005+
a.then(foo => { if (true) {} });
1006+
(a, b, c) => a;
1007+
(a = 10) => a;
1008+
([a, b]) => a;
1009+
({a, b}) => a;
1010+
const f = (/** @type {number} */a) => a + a;
1011+
const g = (/* comment */ a) => a + a;
1012+
const h = (a /* comment */) => a + a;
1013+
```
1014+
9381015
<a name="arrows--confusing"></a><a name="8.5"></a>
9391016
- [8.5](#arrows--confusing) Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [`no-confusing-arrow`](https://eslint.org/docs/rules/no-confusing-arrow)
9401017

0 commit comments

Comments
 (0)