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

Commit

Permalink
Bugfix trailing-comma for new without parens (#2389)
Browse files Browse the repository at this point in the history
[bugfix] `trailing-comma` no longer crashes on new without parentheses (e.g. `new Foo`)
  • Loading branch information
ajafff authored and adidahiya committed Mar 25, 2017
1 parent 13dec24 commit a3eaf5d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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

0 comments on commit a3eaf5d

Please sign in to comment.