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

Require semicolon for type alias #1475

Merged
merged 1 commit into from Aug 11, 2016
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: 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