Skip to content
Permalink
Browse files

Breaking: comma-dangle enable functions: "never" (fixes #11502) (#11519)

  • Loading branch information...
aladdin-add authored and not-an-aardvark committed Apr 4, 2019
1 parent 12f256f commit 4e7cdca571632a3f3c32b39eb03022fe88ca8b30
@@ -48,7 +48,7 @@ This rule has a string option or an object option:
"objects": "never",
"imports": "never",
"exports": "never",
"functions": "ignore"
"functions": "never"
}]
}
```
@@ -58,8 +58,6 @@ This rule has a string option or an object option:
* `"always-multiline"` requires trailing commas when the last element or property is in a *different* line than the closing `]` or `}` and disallows trailing commas when the last element or property is on the *same* line as the closing `]` or `}`
* `"only-multiline"` allows (but does not require) trailing commas when the last element or property is in a *different* line than the closing `]` or `}` and disallows trailing commas when the last element or property is on the *same* line as the closing `]` or `}`

Trailing commas in function declarations and function calls are valid syntax since ECMAScript 2017; however, the string option does not check these situations for backwards compatibility.

You can also use an object option to configure this rule for each type of syntax.
Each of the following options can be set to `"never"`, `"always"`, `"always-multiline"`, `"only-multiline"`, or `"ignore"`.
The default for each option is `"never"` unless otherwise specified.
@@ -69,7 +67,6 @@ The default for each option is `"never"` unless otherwise specified.
* `imports` is for import declarations of ES Modules. (e.g. `import {a,} from "foo";`)
* `exports` is for export declarations of ES Modules. (e.g. `export {a,};`)
* `functions` is for function declarations and function calls. (e.g. `(function(a,){ })(b,);`)
* `functions` is set to `"ignore"` by default for consistency with the string option.
* `functions` should only be enabled when linting ECMAScript 2017 or higher.

### never
@@ -21,7 +21,7 @@ const DEFAULT_OPTIONS = Object.freeze({
objects: "never",
imports: "never",
exports: "never",
functions: "ignore"
functions: "never"
});

/**
@@ -13,7 +13,7 @@ rules:
camelcase: "error"
callback-return: ["error", ["cb", "callback", "next"]]
class-methods-use-this: "error"
comma-dangle: ["error", { functions: "never" }]
comma-dangle: "error"
comma-spacing: "error"
comma-style: ["error", "last"]
computed-property-spacing: "error"
@@ -1433,6 +1433,14 @@ let d = 0;export {d,};
options: [{ functions: "never" }],
parser: parser("return-type-2"),
errors: [{ messageId: "unexpected" }]
},

// https://github.com/eslint/eslint/issues/11502
{
code: "foo(a,)",
output: "foo(a)",
parserOptions: { ecmaVersion: 8 },
errors: [{ messageId: "unexpected" }]
}
]
});

0 comments on commit 4e7cdca

Please sign in to comment.
You can’t perform that action at this time.