Skip to content

Commit

Permalink
fix(finnish): Handle undefined type symbol
Browse files Browse the repository at this point in the history
Closes #45
  • Loading branch information
zbream committed May 30, 2018
1 parent 25f0932 commit 989c615
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/rules/rxjsFinnishRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class Walker extends Lint.ProgramAwareRuleWalker {
}
for (let i = 0; i < this.types.length; ++i) {
const { regExp, validate } = this.types[i];
if (regExp.test(type.symbol.name) && !validate) {
if (type.symbol !== undefined && regExp.test(type.symbol.name) && !validate) {
return;
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/v5/fixtures/finnish/optional/fixture.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Observable, of } from "rxjs";

const someOptionalObservable$: Observable<any> | undefined = of();

const someOptionalObservable: Observable<any> | undefined = of();
~~~~~~~~~~~~~~~~~~~~~~ [finnish % ("someOptionalObservable")]

[finnish]: Finnish notation required for %s
14 changes: 14 additions & 0 deletions test/v5/fixtures/finnish/optional/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"baseUrl": ".",
"lib": ["es2015"],
"noEmit": true,
"paths": {
"rxjs": ["../../node_modules/rxjs"]
},
"skipLibCheck": true,
"target": "es5",
"strictNullChecks": true
},
"include": ["fixture.ts"]
}
8 changes: 8 additions & 0 deletions test/v5/fixtures/finnish/optional/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"defaultSeverity": "error",
"jsRules": {},
"rules": {
"rxjs-finnish": { "severity": "error" }
},
"rulesDirectory": "../../../../../build/rules"
}
8 changes: 8 additions & 0 deletions test/v6-compat/fixtures/finnish/optional/fixture.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Observable, of } from "rxjs";

const someOptionalObservable$: Observable<any> | undefined = of();

const someOptionalObservable: Observable<any> | undefined = of();
~~~~~~~~~~~~~~~~~~~~~~ [finnish % ("someOptionalObservable")]

[finnish]: Finnish notation required for %s
14 changes: 14 additions & 0 deletions test/v6-compat/fixtures/finnish/optional/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"baseUrl": ".",
"lib": ["es2015"],
"noEmit": true,
"paths": {
"rxjs": ["../../node_modules/rxjs"]
},
"skipLibCheck": true,
"target": "es5",
"strictNullChecks": true
},
"include": ["fixture.ts"]
}
8 changes: 8 additions & 0 deletions test/v6-compat/fixtures/finnish/optional/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"defaultSeverity": "error",
"jsRules": {},
"rules": {
"rxjs-finnish": { "severity": "error" }
},
"rulesDirectory": "../../../../../build/rules"
}
8 changes: 8 additions & 0 deletions test/v6/fixtures/finnish/optional/fixture.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Observable, of } from "rxjs";

const someOptionalObservable$: Observable<any> | undefined = of();

const someOptionalObservable: Observable<any> | undefined = of();
~~~~~~~~~~~~~~~~~~~~~~ [finnish % ("someOptionalObservable")]

[finnish]: Finnish notation required for %s
14 changes: 14 additions & 0 deletions test/v6/fixtures/finnish/optional/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"baseUrl": ".",
"lib": ["es2015"],
"noEmit": true,
"paths": {
"rxjs": ["../../node_modules/rxjs"]
},
"skipLibCheck": true,
"target": "es5",
"strictNullChecks": true
},
"include": ["fixture.ts"]
}
8 changes: 8 additions & 0 deletions test/v6/fixtures/finnish/optional/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"defaultSeverity": "error",
"jsRules": {},
"rules": {
"rxjs-finnish": { "severity": "error" }
},
"rulesDirectory": "../../../../../build/rules"
}

0 comments on commit 989c615

Please sign in to comment.