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

Commit

Permalink
Require semicolons for type aliases (#1475)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy authored and adidahiya committed Aug 11, 2016
1 parent 26b152b commit 6f3d73b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/language/walker/syntaxWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ export class SyntaxWalker {
this.walkChildren(node);
}

protected visitTypeAliasDeclaration(node: ts.TypeAliasDeclaration) {
this.walkChildren(node);
}

protected visitTypeAssertionExpression(node: ts.TypeAssertion) {
this.walkChildren(node);
}
Expand Down Expand Up @@ -584,6 +588,10 @@ export class SyntaxWalker {
this.visitTryStatement(<ts.TryStatement> node);
break;

case ts.SyntaxKind.TypeAliasDeclaration:
this.visitTypeAliasDeclaration(<ts.TypeAliasDeclaration> node);
break;

case ts.SyntaxKind.TypeAssertionExpression:
this.visitTypeAssertionExpression(<ts.TypeAssertion> node);
break;
Expand Down
5 changes: 5 additions & 0 deletions src/rules/semicolonRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ class SemicolonWalker extends Lint.RuleWalker {
super.visitExportAssignment(node);
}

public visitTypeAliasDeclaration(node: ts.TypeAliasDeclaration) {
this.checkSemicolonAt(node);
super.visitTypeAliasDeclaration(node);
}

private checkSemicolonAt(node: ts.Node) {
const sourceFile = this.getSourceFile();
const children = node.getChildren(sourceFile);
Expand Down
3 changes: 3 additions & 0 deletions test/rules/semicolon/always/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ export = Date;
export = Date
~nil [Missing semicolon]

type t = number;
type t = number
~nil [Missing semicolon]
4 changes: 4 additions & 0 deletions test/rules/semicolon/enabled/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ export default LoginPage
export = Date;
export = Date
~nil [Missing semicolon]

type t = number;
type t = number
~nil [Missing semicolon]
4 changes: 4 additions & 0 deletions test/rules/semicolon/ignore-interfaces/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ export default LoginPage
export = Date;
export = Date
~nil [Missing semicolon]

type t = number;
type t = number
~nil [Missing semicolon]
4 changes: 4 additions & 0 deletions test/rules/semicolon/never/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,7 @@ export default LoginPage
export = Date;
~ [Unnecessary semicolon]
export = Date

type t = number;
~ [Unnecessary semicolon]
type t = number

0 comments on commit 6f3d73b

Please sign in to comment.