Skip to content

Commit 7813121

Browse files
committed
compile vs tslints services dts, null check lint
1 parent c31ad6f commit 7813121

5 files changed

Lines changed: 26 additions & 4 deletions

File tree

Jakefile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ task("update-sublime", ["local", serverFile], function() {
773773
var tslintRuleDir = "scripts/tslint";
774774
var tslintRules = ([
775775
"nextLineRule",
776-
"noInferrableTypesRule"
776+
"noInferrableTypesRule",
777+
"noNullRule"
777778
]);
778779
var tslintRulesFiles = tslintRules.map(function(p) {
779780
return path.join(tslintRuleDir, p + ".ts");

scripts/tslint/nextLineRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="../../lib/typescriptServices.d.ts" />
1+
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
22
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
33

44
const OPTION_CATCH = "check-catch";

scripts/tslint/noInferrableTypesRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="../../lib/typescriptServices.d.ts" />
1+
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
22
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
33

44

scripts/tslint/noNullRule.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
2+
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
3+
4+
5+
export class Rule extends Lint.Rules.AbstractRule {
6+
public static FAILURE_STRING = "Don't use the 'null' keyword - use 'undefined' for missing values instead";
7+
8+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
9+
return this.applyWithWalker(new NullWalker(sourceFile, this.getOptions()));
10+
}
11+
}
12+
13+
class NullWalker extends Lint.RuleWalker {
14+
visitNode(node: ts.Node) {
15+
super.visitNode(node);
16+
if (node.kind === ts.SyntaxKind.NullKeyword) {
17+
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
18+
}
19+
}
20+
}

tslint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
],
3939
"no-internal-module": true,
4040
"no-trailing-whitespace": true,
41-
"no-inferrable-types": true
41+
"no-inferrable-types": true,
42+
"no-null": true
4243
}
4344
}

0 commit comments

Comments
 (0)