mirror of
https://github.com/airbnb/javascript.git
synced 2026-04-25 03:00:19 -04:00
[eslint config] [base] [breaking] comma-dangle: require trailing commas for functions
This commit is contained in:
committed by
Jordan Harband
parent
c51251d17b
commit
7882082954
54
README.md
54
README.md
@@ -816,8 +816,8 @@ Other Style Guides
|
||||
```javascript
|
||||
// bad
|
||||
function foo(bar,
|
||||
baz,
|
||||
quux) {
|
||||
baz,
|
||||
quux) {
|
||||
// body
|
||||
}
|
||||
|
||||
@@ -2430,6 +2430,56 @@ Other Style Guides
|
||||
'Batman',
|
||||
'Superman',
|
||||
];
|
||||
|
||||
// bad
|
||||
function createHero(
|
||||
firstName,
|
||||
lastName,
|
||||
inventorOf
|
||||
) {
|
||||
// does nothing
|
||||
}
|
||||
|
||||
// good
|
||||
function createHero(
|
||||
firstName,
|
||||
lastName,
|
||||
inventorOf,
|
||||
) {
|
||||
// does nothing
|
||||
}
|
||||
|
||||
// good (note that a comma must not appear after a "rest" element)
|
||||
function createHero(
|
||||
firstName,
|
||||
lastName,
|
||||
inventorOf,
|
||||
...heroArgs
|
||||
) {
|
||||
// does nothing
|
||||
}
|
||||
|
||||
// bad
|
||||
createHero(
|
||||
firstName,
|
||||
lastName,
|
||||
inventorOf
|
||||
);
|
||||
|
||||
// good
|
||||
createHero(
|
||||
firstName,
|
||||
lastName,
|
||||
inventorOf,
|
||||
);
|
||||
|
||||
// good (note that a comma must not appear after a "rest" element)
|
||||
createHero(
|
||||
firstName,
|
||||
lastName,
|
||||
inventorOf,
|
||||
...heroArgs
|
||||
)
|
||||
```
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
module.exports = {
|
||||
rules: {
|
||||
// require trailing commas in multiline object literals
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'comma-dangle': ['error', {
|
||||
arrays: 'always-multiline',
|
||||
objects: 'always-multiline',
|
||||
imports: 'always-multiline',
|
||||
exports: 'always-multiline',
|
||||
functions: 'always-multiline',
|
||||
}],
|
||||
|
||||
// disallow assignment in conditional expressions
|
||||
'no-cond-assign': ['error', 'always'],
|
||||
|
||||
Reference in New Issue
Block a user