Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Bugfix trailing-comma for new without parens #2389

Merged
merged 1 commit into from
Mar 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/rules/trailingCommaRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ class TrailingCommaWalker extends Lint.AbstractWalker<Options> {
case ts.SyntaxKind.EnumDeclaration:
this.checkList((node as ts.EnumDeclaration).members, node.end);
break;
case ts.SyntaxKind.CallExpression:
case ts.SyntaxKind.NewExpression:
this.checkList((node as ts.CallExpression | ts.NewExpression).arguments, node.end);
if ((node as ts.NewExpression).arguments === undefined) {
break;
}
// falls through
case ts.SyntaxKind.CallExpression:
this.checkList((node as ts.CallExpression | ts.NewExpression).arguments!, node.end);
break;
case ts.SyntaxKind.ArrowFunction:
case ts.SyntaxKind.Constructor:
Expand Down
3 changes: 3 additions & 0 deletions test/rules/trailing-comma/multiline-always/test.ts.fix
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,6 @@ export {
foo,
bar,
};

// don't crash
new Foo
3 changes: 3 additions & 0 deletions test/rules/trailing-comma/multiline-always/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,6 @@ export {
bar
~nil [Missing trailing comma]
};

// don't crash
new Foo