Skip to content

Commit e40ebb0

Browse files
committed
Merge branch 'jayrylan-master'
2 parents 2400325 + bd6f23f commit e40ebb0

22 files changed

+349
-526
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ npm install --save-dev vrsource-tslint-rules
1212

1313
Configure tslint to use the vrsource-tslint-rules folder:
1414

15-
Add the following path to the `rulesDirectory` setting in your `tslint.json` file:
15+
Add `"vrsource-tslint-rules"` to the `extends` array of your `tslint.json` file:
1616

1717
```
1818
{

package.json

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,42 @@
11
{
2-
"name": "vrsource-tslint-rules",
3-
"version": "5.8.2",
4-
"description": "Extension rules for tslint",
5-
"repository": {
6-
"type": "git",
7-
"url": "https://github.com/vrsource/vrsource-tslint-rules"
8-
},
9-
"main": "tslint.json",
10-
"keywords": [
11-
"eslint",
12-
"tslint",
13-
"custom-rules",
14-
"rules",
15-
"stylish",
16-
"lint",
17-
"linting",
18-
"linter",
19-
"tslint-plugin"
20-
],
21-
"license": "MIT",
22-
"peerDependencies": {
23-
"tslint": "^5.8.0",
24-
"typescript": ">= 2.5.3"
25-
},
26-
"devDependencies": {
27-
"chokidar-cli": "~1.2.0"
28-
},
29-
"watch": {
30-
"test": "rules/*.ts"
31-
},
32-
"scripts": {
33-
"build": "tsc -p .",
34-
"lint": "tslint rules/*.ts",
35-
"test:once": "./run_tests.sh",
36-
"test": "npm run lint && npm run build && npm run test:once",
37-
"watch": "chokidar 'rules/*.ts' 'test/**/*' -c 'npm run test'"
38-
}
39-
}
2+
"name": "vrsource-tslint-rules",
3+
"version": "5.8.2",
4+
"description": "Extension rules for tslint",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/vrsource/vrsource-tslint-rules"
8+
},
9+
"main": "tslint.json",
10+
"keywords": [
11+
"eslint",
12+
"tslint",
13+
"custom-rules",
14+
"rules",
15+
"stylish",
16+
"lint",
17+
"linting",
18+
"linter",
19+
"tslint-plugin"
20+
],
21+
"license": "MIT",
22+
"peerDependencies": {
23+
"tslint": "*",
24+
"typescript": "*"
25+
},
26+
"devDependencies": {
27+
"@types/node": "^10.0.0",
28+
"chokidar-cli": "~1.2.0",
29+
"tslint": "~5.8.0",
30+
"typescript": "~2.5.3"
31+
},
32+
"watch": {
33+
"test": "rules/*.ts"
34+
},
35+
"scripts": {
36+
"build": "tsc -p .",
37+
"lint": "tslint rules/*.ts --project .",
38+
"test:once": "./run_tests.sh",
39+
"test": "npm run lint && npm run build && npm run test:once",
40+
"watch": "chokidar 'rules/*.ts' 'test/**/*' -c 'npm run test'"
41+
}
42+
}

rules/conditionalExpressionParensRule.js

Lines changed: 24 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rules/conditionalExpressionParensRule.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ const allowedClauseKinds = [
2323
ts.SyntaxKind.ObjectLiteralExpression,
2424
];
2525

26-
export class Rule extends Lint.Rules.AbstractRule {
27-
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
28-
return this.applyWithWalker(new PreferLiteralWalker(sourceFile, this.getOptions()));
29-
}
30-
}
31-
3226
class PreferLiteralWalker extends Lint.RuleWalker {
3327
protected visitConditionalExpression(node: ts.ConditionalExpression) {
3428
let clauses = [node.condition, node.whenFalse, node.whenTrue];
@@ -43,3 +37,8 @@ class PreferLiteralWalker extends Lint.RuleWalker {
4337
}
4438
}
4539

40+
export class Rule extends Lint.Rules.AbstractRule {
41+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
42+
return this.applyWithWalker(new PreferLiteralWalker(sourceFile, this.getOptions()));
43+
}
44+
}

rules/dotNotationRule.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

rules/extVariableNameRule.js

Lines changed: 24 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rules/extVariableNameRule.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ const BANNED_KEYWORDS = ["any", "Number", "number", "String", "string",
102102
"Boolean", "boolean", "Undefined", "undefined"];
103103

104104

105-
export class Rule extends Lint.Rules.AbstractRule {
106-
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
107-
const variableNameWalker = new VariableNameWalker(sourceFile, this.getOptions());
108-
return this.applyWithWalker(variableNameWalker);
109-
}
110-
}
111-
112105
/**
113106
* Configured with details needed to check a specific variable type.
114107
*/
@@ -302,7 +295,7 @@ class VariableNameWalker extends Lint.RuleWalker {
302295
super.visitFunctionDeclaration(node);
303296
}
304297

305-
protected checkName(node: ts.Declaration, tag: string) {
298+
protected checkName(node: ts.NamedDeclaration, tag: string) {
306299
if (node.name && node.name.kind === ts.SyntaxKind.Identifier) {
307300
const matching_checker = this.getMatchingChecker(this.getNodeTags(node, tag));
308301
if (matching_checker !== null) {
@@ -355,7 +348,6 @@ class VariableNameWalker extends Lint.RuleWalker {
355348
}
356349
}
357350

358-
359351
function nearestBody(node: ts.Node): {isSourceFile: boolean, containingBody: ts.Node | undefined} {
360352
const VALID_PARENT_TYPES = [
361353
ts.SyntaxKind.SourceFile,
@@ -423,6 +415,12 @@ function contains(arr: any[], value: any): boolean {
423415
return arr.indexOf(value) !== -1;
424416
}
425417

418+
export class Rule extends Lint.Rules.AbstractRule {
419+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
420+
const variableNameWalker = new VariableNameWalker(sourceFile, this.getOptions());
421+
return this.applyWithWalker(variableNameWalker);
422+
}
423+
}
426424

427425
/**
428426
* Original version based upon variable-name rule:

0 commit comments

Comments
 (0)