Skip to content

Commit

Permalink
Option to ignore interface declarations in the Semicolon rule (palant…
Browse files Browse the repository at this point in the history
  • Loading branch information
schmuli authored and jkillian committed May 27, 2016
1 parent ec696e2 commit 04fe8d7
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/rules/semicolonRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as Lint from "../lint";

const OPTION_ALWAYS = "always";
const OPTION_NEVER = "never";
const OPTION_IGNORE_INTERFACES = "ignore-interfaces";

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING_MISSING = "missing semicolon";
Expand Down Expand Up @@ -91,6 +92,10 @@ class SemicolonWalker extends Lint.RuleWalker {
}

public visitInterfaceDeclaration(node: ts.InterfaceDeclaration) {
if (this.hasOption(OPTION_IGNORE_INTERFACES)) {
return;
}

for (let member of node.members) {
this.checkSemicolonAt(member);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"rules/noConditionalAssignmentRule.ts",
"rules/noConsecutiveBlankLinesRule.ts",
"rules/noConsoleRule.ts",
"rules/noConstructRule.ts",
"rules/noConstructorVarsRule.ts",
"rules/noConstructRule.ts",
"rules/noDebuggerRule.ts",
"rules/noDefaultExportRule.ts",
"rules/noDuplicateKeyRule.ts",
Expand Down
2 changes: 1 addition & 1 deletion test/rules/semicolon/enabled/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class MyClass {
private index : number
~nil [missing semicolon]
private email : string;

public initializedProperty = 6
~nil [missing semicolon]
public initializedMethodProperty = () => { return "hi"; }
Expand All @@ -79,7 +80,6 @@ import {Controller} from 'my-lib'
export default LoginPage;
export default LoginPage
~nil [missing semicolon]

export = Date;
export = Date
~nil [missing semicolon]
85 changes: 85 additions & 0 deletions test/rules/semicolon/ignore-interfaces/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
var x = 3
~nil [missing semicolon]
a += b
~nil [missing semicolon]

c = () => {
}
~nil [missing semicolon]

d = function() { }
~nil [missing semicolon]

console.log("i am adam, am i?")
~nil [missing semicolon]

function xyz() {
return
~nil [missing semicolon]
}

switch(xyz) {
case 1:
break
~nil [missing semicolon]
case 2:
continue
~nil [missing semicolon]
}

throw new Error("some error")
~nil [missing semicolon]

do {
var a = 4
~nil [missing semicolon]
} while(x == 3)
~nil [missing semicolon]

debugger
~nil [missing semicolon]

import v = require("i")
~nil [missing semicolon]
module M {
export var x
~nil [missing semicolon]
}

function useStrictMissingSemicolon() {
"use strict"
~nil [missing semicolon]
return null;
}

class MyClass {
public name : string
~nil [missing semicolon]
private index : number
~nil [missing semicolon]
private email : string;

public initializedProperty = 6
~nil [missing semicolon]
public initializedMethodProperty = () => { return "hi"; }
}

interface ITest {
foo?: string

bar: number

baz: boolean;
}

import {Router} from 'aurelia-router';

import {Controller} from 'my-lib'
~nil [missing semicolon]

export default LoginPage;
export default LoginPage
~nil [missing semicolon]
export = Date;
export = Date
~nil [missing semicolon]
5 changes: 5 additions & 0 deletions test/rules/semicolon/ignore-interfaces/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"semicolon": [true, "always", "ignore-interfaces"]
}
}
2 changes: 1 addition & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
"../src/rules/noConditionalAssignmentRule.ts",
"../src/rules/noConsecutiveBlankLinesRule.ts",
"../src/rules/noConsoleRule.ts",
"../src/rules/noConstructRule.ts",
"../src/rules/noConstructorVarsRule.ts",
"../src/rules/noConstructRule.ts",
"../src/rules/noDebuggerRule.ts",
"../src/rules/noDefaultExportRule.ts",
"../src/rules/noDuplicateKeyRule.ts",
Expand Down

0 comments on commit 04fe8d7

Please sign in to comment.