Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit b7e015b

Browse files
committed
Fix: disallowCommaBeforeLineBreak: fix for function params
Fixes #1746
1 parent 5c66c2f commit b7e015b

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

lib/rules/disallow-comma-before-line-break.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ module.exports.prototype = {
8787
return true;
8888
}
8989

90+
// exception for function params
91+
if (node.params &&
92+
node.params[0].loc.start.line === node.params[node.params.length - 1].loc.end.line) {
93+
return true;
94+
}
95+
9096
// See #1841
9197
if (!exceptFunction || !node.properties) {
9298
return false;

test/specs/rules/disallow-comma-before-line-break.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ describe('rules/disallow-comma-before-line-break', function() {
6464
expect(checker.checkString('var a = {a:1, c:3};')).to.have.no.errors();
6565
});
6666

67+
it('should not report comma placement in function declaration #1746', function() {
68+
expect(checker.checkString('function a(b, c) {\n console.log(1)\n}')).to.have.no.errors();
69+
});
70+
6771
describe('options as object', function() {
6872
describe('allExcept as option', function() {
6973
describe('with value `function`', function() {

0 commit comments

Comments
 (0)