[eslint config] [base] [breaking] comma-dangle: require trailing commas for functions

This commit is contained in:
Thomas Grainger
2016-11-01 19:06:39 +00:00
committed by Jordan Harband
parent c51251d17b
commit 7882082954
2 changed files with 59 additions and 3 deletions

View File

@@ -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)**

View File

@@ -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'],