From e93a50833e2e23ada9d560e4634652e0b47fdf6a Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Wed, 23 Sep 2020 10:57:56 -0700 Subject: [PATCH 1/2] Allow references to typesVersions parent --- src/rules/noBadReferenceRule.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rules/noBadReferenceRule.ts b/src/rules/noBadReferenceRule.ts index ad3da989..b1cacbb6 100644 --- a/src/rules/noBadReferenceRule.ts +++ b/src/rules/noBadReferenceRule.ts @@ -1,3 +1,4 @@ +import * as path from "path"; import * as Lint from "tslint"; import * as ts from "typescript"; @@ -29,7 +30,8 @@ function walk(ctx: Lint.WalkContext): void { const { sourceFile } = ctx; for (const ref of sourceFile.referencedFiles) { if (sourceFile.isDeclarationFile) { - if (ref.fileName.startsWith("..")) { + const dirPath = path.dirname(sourceFile.fileName); + if (path.normalize(ref.fileName).startsWith(/^ts\d+\.\d$/.test(path.basename(dirPath)) ? "../.." : "..")) { ctx.addFailure(ref.pos, ref.end, Rule.FAILURE_STRING); } } else { From d56abc338585055332b1f7f6809a3e36b00ceea9 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Wed, 23 Sep 2020 11:00:28 -0700 Subject: [PATCH 2/2] Add tests --- test/no-bad-reference/ts2.0/index.d.ts.lint | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/no-bad-reference/ts2.0/index.d.ts.lint diff --git a/test/no-bad-reference/ts2.0/index.d.ts.lint b/test/no-bad-reference/ts2.0/index.d.ts.lint new file mode 100644 index 00000000..3fc2ceea --- /dev/null +++ b/test/no-bad-reference/ts2.0/index.d.ts.lint @@ -0,0 +1 @@ +///