You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [7.16](#functions--signature-invocation-indentation) Functions with multiline signatures, or invocations, should be indented just like every other multiline list inthis guide:with each item on a line by itself and without a trailing comma on the last item. eslint: [`function-paren-newline`](https://eslint.org/docs/rules/function-paren-newline)
1360
+
- [7.16](#functions--signature-invocation-indentation) Functions with multiline signatures, or invocations, should be indented just like every other multiline list inthis guide:with each item on a line by itself and with a trailing comma on the last item. eslint: [`function-paren-newline`](https://eslint.org/docs/rules/function-paren-newline)
1361
1361
1362
1362
```javascript
1363
1363
// bad
@@ -1371,7 +1371,7 @@ $ `npm i` - and you're ready to go!
1371
1371
function foo(
1372
1372
bar,
1373
1373
baz,
1374
-
quux
1374
+
quux,
1375
1375
...
1376
1376
){
1377
1377
// ...
@@ -1386,7 +1386,7 @@ $ `npm i` - and you're ready to go!
1386
1386
console.log(
1387
1387
foo,
1388
1388
bar,
1389
-
baz
1389
+
baz,
1390
1390
...
1391
1391
);
1392
1392
```
@@ -3398,7 +3398,7 @@ $ `npm i` - and you're ready to go!
3398
3398
const x = [
3399
3399
foo,
3400
3400
bar,
3401
-
baz
3401
+
baz,
3402
3402
];
3403
3403
3404
3404
// bad
@@ -3414,60 +3414,60 @@ $ `npm i` - and you're ready to go!
> Why?This may lead to cleaner git diffs but also can cause problems and bugs (especially in older browsers). For example, a comma must not appear after a [rest element](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters). It is also more logical to expect _something_ after a comma. [Read more...](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas)
3424
+
> Why?It leads to cleaner git diffs and allows easier copy-pasting. **Careful**:Acomma must not appear after a [rest element](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters). [Read more...](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas)
3425
3425
3426
3426
```diff
3427
-
// git diff with trailing comma (bad anyway)
3428
-
const foo = {
3429
-
bar: "bar",
3430
-
baz: "baz",
3431
-
+ abc: [1, 2, 3],
3432
-
};
3433
-
3434
-
// git diff without trailing comma (still good)
3427
+
// git diff without trailing comma (bad)
3435
3428
const hero = {
3436
3429
bar: "bar",
3437
3430
- baz: "baz"
3438
3431
+ baz: "baz",
3439
3432
+ abc: [1, 2, 3]
3440
3433
};
3434
+
3435
+
// git diff with trailing comma (good)
3436
+
const foo = {
3437
+
bar: "bar",
3438
+
baz: "baz",
3439
+
+ abc: [1, 2, 3],
3440
+
};
3441
3441
```
3442
3442
3443
3443
```javascript
3444
3444
// bad
3445
3445
const foo = {
3446
3446
bar: true,
3447
-
baz: false,
3447
+
baz: false
3448
3448
};
3449
3449
3450
3450
const foo = [
3451
3451
"bar",
3452
-
"baz",
3452
+
"baz"
3453
3453
];
3454
3454
3455
3455
// good
3456
3456
const foo = {
3457
3457
bar: true,
3458
-
baz: false
3458
+
baz: false,
3459
3459
};
3460
3460
3461
3461
const foo = [
3462
3462
"bar",
3463
-
"baz"
3463
+
"baz",
3464
3464
];
3465
3465
3466
3466
// bad
3467
3467
function foo(
3468
3468
arg1,
3469
3469
arg2,
3470
-
agr3,
3470
+
agr3
3471
3471
){
3472
3472
// ..
3473
3473
}
@@ -3476,7 +3476,7 @@ $ `npm i` - and you're ready to go!
3476
3476
function foo(
3477
3477
arg1,
3478
3478
arg2,
3479
-
agr3
3479
+
agr3,
3480
3480
){
3481
3481
// ..
3482
3482
}
@@ -3485,14 +3485,14 @@ $ `npm i` - and you're ready to go!
0 commit comments