From 31d00c0682f8f88800cf6369f95a34a3b0b681e3 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Sat, 9 Mar 2019 12:32:42 +1000 Subject: [PATCH] fix(subclass): Check qualified name. Closes #87. --- package.json | 2 +- source/rules/rxjsNoSubclassRule.ts | 5 ++++- test/v6/fixtures/issues/87/fixture.ts.lint | 7 ++----- yarn.lock | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 79fec05d..62abca4c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "resolve": "^1.4.0", "tslib": "^1.8.0", "tsutils": "^3.0.0", - "tsutils-etc": "^1.0.0" + "tsutils-etc": "^1.1.0" }, "description": "TSLint rules for RxJS", "devDependencies": { diff --git a/source/rules/rxjsNoSubclassRule.ts b/source/rules/rxjsNoSubclassRule.ts index 42ca1231..00f9692d 100644 --- a/source/rules/rxjsNoSubclassRule.ts +++ b/source/rules/rxjsNoSubclassRule.ts @@ -56,7 +56,10 @@ export class Rule extends Lint.Rules.TypedRule { if (heritageClause.token === ts.SyntaxKind.ExtendsKeyword) { heritageClause.types.forEach(heritageType => { const type = typeChecker.getTypeAtLocation(heritageType); - if (couldBeNames.some(name => couldBeType(type, name))) { + if (couldBeNames.some(name => couldBeType(type, name, { + name: /rxjs/, + typeChecker + }))) { failures.push(new Lint.RuleFailure( sourceFile, heritageType.getStart(), diff --git a/test/v6/fixtures/issues/87/fixture.ts.lint b/test/v6/fixtures/issues/87/fixture.ts.lint index 488fd7a0..3e59d343 100644 --- a/test/v6/fixtures/issues/87/fixture.ts.lint +++ b/test/v6/fixtures/issues/87/fixture.ts.lint @@ -1,8 +1,5 @@ -class Observable { - t: T; -} +class Observable { t: T; } -class StringObservable extends Observable { -} +class StringObservable extends Observable {} [no-subclass]: Subclassing RxJS classes is forbidden diff --git a/yarn.lock b/yarn.lock index f8040594..d0389083 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1540,10 +1540,10 @@ tslint@^5.1.0: tslib "^1.8.0" tsutils "^2.27.2" -tsutils-etc@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/tsutils-etc/-/tsutils-etc-1.0.1.tgz#2114f1b41a1d7ad5498690f011a18fa989ebffad" - integrity sha512-Yp6RQzPfxuZNjw/tHYdr+QRHtoPX2Al+9UmydyMidGqKt3Y13lJhryLUNPxYce5Y8KQ0Q6qn2MLJIxwL48GBWg== +tsutils-etc@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/tsutils-etc/-/tsutils-etc-1.1.0.tgz#82ce1c92da29e07d3cde95692d5c5e8dbdc92fd0" + integrity sha512-pJlLtLmQPUyGHqY/Pq6EGnpGmQCnnTDZetQ7eWkeQ5xaw4GtfcR1Zt7HMKFHGDDp53HzQfbqQ+7ps6iJbfa9Hw== tsutils@^2.27.2: version "2.29.0"