Skip to content

Commit 8fbacdc

Browse files
committed
Merge pull request #17 from mgechev/syntax-kind
Syntax kind
2 parents fc3aa42 + 8eb17f7 commit 8fbacdc

File tree

4 files changed

+1505
-5
lines changed

4 files changed

+1505
-5
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"name": "codelyzer",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"description": "A set of linters for Angular 2 applications, following https://github.com/mgechev/angular2-style-guide.",
55
"main": "index.js",
66
"scripts": {
77
"test": "mocha --compilers ts:ts-node/register",
8-
"postinstall": "npm run tsc",
98
"tsc": "tsc",
109
"tscw": "tsc -w"
1110
},

src/parameterDecoratorBase.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as Lint from 'tslint/lib/lint';
22
import * as ts from 'typescript';
33
import {sprintf} from 'sprintf-js';
44

5+
import SyntaxKind = require('./util/syntaxKind');
6+
57
export interface IUseParameterDecoratorConfig {
68
propertyName: string;
79
decoratorName: string | string[];
@@ -65,7 +67,7 @@ class DirectiveMetadataWalker extends Lint.RuleWalker {
6567
}
6668

6769
private validateProperty(className: string, decoratorName: string, arg: ts.ObjectLiteralExpression) {
68-
if (arg.kind === ts.SyntaxKind.ObjectLiteralExpression) {
70+
if (arg.kind === SyntaxKind.current().ObjectLiteralExpression) {
6971
(<ts.ObjectLiteralExpression>arg).properties.filter(prop => (<any>prop.name).text === this.config.propertyName)
7072
.forEach(prop => {
7173
let p = <any>prop;

src/selectorNameBase.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as ts from 'typescript';
22
import * as Lint from 'tslint/lib/lint';
33
import {sprintf} from 'sprintf-js';
44

5+
import SyntaxKind = require('./util/syntaxKind');
6+
57
export enum COMPONENT_TYPE {
68
COMPONENT,
79
DIRECTIVE,
@@ -67,11 +69,11 @@ class SelectorNameValidatorWalker extends Lint.RuleWalker {
6769
}
6870

6971
private validateSelector(className: string, arg: ts.Node) {
70-
if (arg.kind === ts.SyntaxKind.ObjectLiteralExpression) {
72+
if (arg.kind === SyntaxKind.current().ObjectLiteralExpression) {
7173
(<ts.ObjectLiteralExpression>arg).properties.filter(prop => (<any>prop.name).text === 'selector')
7274
.forEach(prop => {
7375
let p = <any>prop;
74-
if (p.initializer.kind === ts.SyntaxKind.StringLiteral && !this.rule.validate(p.initializer.text)) {
76+
if (p.initializer.kind === SyntaxKind.current().StringLiteral && !this.rule.validate(p.initializer.text)) {
7577
let error = this.rule.getFailureString({ selector: p.initializer.text, className });
7678
this.addFailure(this.createFailure(p.initializer.getStart(), p.initializer.getWidth(), error));
7779
}

0 commit comments

Comments
 (0)