Skip to content

Commit

Permalink
Fix: ignore comma before closing paren (fixes #11295)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Feb 11, 2019
1 parent 5eb3121 commit cbae656
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rules/comma-spacing.js
Expand Up @@ -118,6 +118,10 @@ module.exports = {
report(reportItem, "before", tokens.left);
}

if (tokens.right && astUtils.isClosingParenToken(tokens.right)) {
return;
}

if (tokens.right && !options.after && tokens.right.type === "Line") {
return;
}
Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/comma-spacing.js
Expand Up @@ -61,6 +61,7 @@ ruleTester.run("comma-spacing", rule, {
"[' , ']",
{ code: "[` , `]", parserOptions: { ecmaVersion: 6 } },
{ code: "`${[1, 2]}`", parserOptions: { ecmaVersion: 6 } },
{ code: "fn(a, b,)", parserOptions: { ecmaVersion: 2018 } }, // #11295
"foo(/,/, 'a')",
"var x = ',,,,,';",
"var code = 'var foo = 1, bar = 3;'",
Expand Down

0 comments on commit cbae656

Please sign in to comment.