@definitelytyped/eslint-plugin 0.0.187 → 0.0.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/configs/all.js +1 -0
- package/dist/configs/all.js.map +1 -1
- package/dist/rules/index.d.ts +1 -1
- package/dist/rules/no-bad-reference.d.ts +1 -1
- package/dist/rules/no-bad-reference.js +172 -28
- package/dist/rules/no-bad-reference.js.map +1 -1
- package/dist/rules/no-declare-current-package.js +4 -1
- package/dist/rules/no-declare-current-package.js.map +1 -1
- package/dist/rules/no-import-default-of-export-equals.js +4 -3
- package/dist/rules/no-import-default-of-export-equals.js.map +1 -1
- package/dist/rules/no-import-of-dev-dependencies.js +32 -60
- package/dist/rules/no-import-of-dev-dependencies.js.map +1 -1
- package/dist/rules/no-old-dt-header.js +2 -1
- package/dist/rules/no-old-dt-header.js.map +1 -1
- package/dist/rules/no-relative-import-in-test.js +2 -3
- package/dist/rules/no-relative-import-in-test.js.map +1 -1
- package/dist/rules/no-self-import.js +3 -0
- package/dist/rules/no-self-import.js.map +1 -1
- package/dist/rules/prefer-declare-function.js +2 -1
- package/dist/rules/prefer-declare-function.js.map +1 -1
- package/dist/util.d.ts +15 -0
- package/dist/util.js +50 -8
- package/dist/util.js.map +1 -1
- package/package.json +2 -2
- package/src/configs/all.ts +1 -0
- package/src/rules/no-bad-reference.ts +176 -33
- package/src/rules/no-declare-current-package.ts +4 -1
- package/src/rules/no-import-default-of-export-equals.ts +2 -1
- package/src/rules/no-import-of-dev-dependencies.ts +40 -59
- package/src/rules/no-old-dt-header.ts +2 -1
- package/src/rules/no-relative-import-in-test.ts +2 -5
- package/src/rules/no-self-import.ts +3 -0
- package/src/rules/prefer-declare-function.ts +2 -1
- package/src/util.ts +69 -9
- package/test/fixtureTester.ts +64 -0
- package/test/fixtures/notNeededPackages.json +3 -0
- package/test/fixtures/package.json +4 -0
- package/test/fixtures/types/foo/foo-tests.ts +0 -0
- package/test/fixtures/types/foo/index.d.ts +1 -0
- package/test/fixtures/types/foo/package.json +5 -0
- package/test/fixtures/types/foo/tsconfig.json +20 -0
- package/test/fixtures/types/foo/v1/foo-tests.ts +0 -0
- package/test/fixtures/types/foo/v1/index.d.ts +1 -0
- package/test/fixtures/types/foo/v1/package.json +5 -0
- package/test/fixtures/types/foo/v1/tsconfig.json +20 -0
- package/test/fixtures/types/no-bad-reference/index.d.ts +16 -0
- package/test/fixtures/types/no-bad-reference/no-bad-reference-tests.ts +2 -0
- package/test/fixtures/types/no-bad-reference/package.json +5 -0
- package/test/fixtures/types/no-bad-reference/tsconfig.json +20 -0
- package/test/fixtures/types/no-bad-reference/v0.1/index.d.ts +15 -0
- package/test/fixtures/types/no-bad-reference/v0.1/no-bad-reference-tests.ts +0 -0
- package/test/fixtures/types/no-bad-reference/v0.1/package.json +5 -0
- package/test/fixtures/types/no-bad-reference/v0.1/tsconfig.json +20 -0
- package/test/fixtures/types/no-bad-reference/v11/index.d.ts +15 -0
- package/test/fixtures/types/no-bad-reference/v11/no-bad-reference-tests.ts +0 -0
- package/test/fixtures/types/no-bad-reference/v11/package.json +5 -0
- package/test/fixtures/types/no-bad-reference/v11/tsconfig.json +20 -0
- package/test/fixtures/types/no-declare-current-package/index.d.ts +1 -0
- package/test/fixtures/types/no-declare-current-package/no-declare-current-package-tests.ts +0 -0
- package/test/fixtures/types/no-declare-current-package/package.json +8 -0
- package/test/fixtures/types/no-declare-current-package/test/deep/import.d.ts +1 -0
- package/test/fixtures/types/no-declare-current-package/tsconfig.json +20 -0
- package/test/fixtures/types/no-declare-current-package-other/index.d.ts +2 -0
- package/test/fixtures/types/no-declare-current-package-other/no-declare-current-package-other-tests.ts +0 -0
- package/test/fixtures/types/no-declare-current-package-other/package.json +8 -0
- package/test/fixtures/types/no-declare-current-package-other/tsconfig.json +20 -0
- package/test/fixtures/types/no-import-of-dev-dependencies/bad.d.ts +5 -0
- package/test/fixtures/types/no-import-of-dev-dependencies/index.d.ts +4 -0
- package/test/fixtures/types/no-import-of-dev-dependencies/no-import-of-dev-dependencies-tests.ts +9 -0
- package/test/fixtures/types/no-import-of-dev-dependencies/package.json +14 -0
- package/test/fixtures/types/no-import-of-dev-dependencies/tsconfig.json +20 -0
- package/test/fixtures/types/no-relative-references/index.d.ts +12 -0
- package/test/fixtures/types/no-relative-references/no-relative-references-tests.ts +0 -0
- package/test/fixtures/types/no-relative-references/other/other.d.ts +7 -0
- package/test/fixtures/types/no-relative-references/package.json +5 -0
- package/test/fixtures/types/no-relative-references/tsconfig.json +20 -0
- package/test/fixtures/types/no-relative-references/v1/index.d.ts +15 -0
- package/test/fixtures/types/no-relative-references/v1/no-relative-references-tests.ts +0 -0
- package/test/fixtures/types/no-relative-references/v1/other/other.d.ts +7 -0
- package/test/fixtures/types/no-relative-references/v1/package.json +5 -0
- package/test/fixtures/types/no-relative-references/v1/tsconfig.json +20 -0
- package/test/fixtures/types/no-self-import/bad.d.ts +8 -0
- package/test/fixtures/types/no-self-import/index.d.ts +7 -0
- package/test/fixtures/types/no-self-import/no-self-import-tests.ts +9 -0
- package/test/fixtures/types/no-self-import/package.json +11 -0
- package/test/fixtures/types/no-self-import/tsconfig.json +20 -0
- package/test/fixtures/types/other/index.d.ts +1 -0
- package/test/fixtures/types/other/other-tests.ts +0 -0
- package/test/fixtures/types/other/package.json +5 -0
- package/test/fixtures/types/other/tsconfig.json +20 -0
- package/test/fixtures/types/other/v1/index.d.ts +1 -0
- package/test/fixtures/types/other/v1/other-tests.ts +0 -0
- package/test/fixtures/types/other/v1/package.json +5 -0
- package/test/fixtures/types/other/v1/tsconfig.json +20 -0
- package/test/fixtures/types/scoped__foo/index.d.ts +1 -0
- package/test/fixtures/types/scoped__foo/package.json +5 -0
- package/test/fixtures/types/scoped__foo/scoped__foo-tests.ts +0 -0
- package/test/fixtures/types/scoped__foo/tsconfig.json +20 -0
- package/test/fixtures/types/scoped__foo/v1/index.d.ts +1 -0
- package/test/fixtures/types/scoped__foo/v1/package.json +5 -0
- package/test/fixtures/types/scoped__foo/v1/scoped__foo-tests.ts +0 -0
- package/test/fixtures/types/scoped__foo/v1/tsconfig.json +20 -0
- package/test/fixtures/types/scoped__no-declare-current-package/index.d.ts +1 -0
- package/test/fixtures/types/scoped__no-declare-current-package/no-declare-current-package-tests.ts +0 -0
- package/test/fixtures/types/scoped__no-declare-current-package/package.json +8 -0
- package/test/fixtures/types/scoped__no-declare-current-package/test/deep/import.d.ts +1 -0
- package/test/fixtures/types/scoped__no-declare-current-package/tsconfig.json +20 -0
- package/test/fixtures/types/scoped__no-relative-references/index.d.ts +12 -0
- package/test/fixtures/types/scoped__no-relative-references/no-relative-references-tests.ts +0 -0
- package/test/fixtures/types/scoped__no-relative-references/other/other.d.ts +7 -0
- package/test/fixtures/types/scoped__no-relative-references/package.json +5 -0
- package/test/fixtures/types/scoped__no-relative-references/tsconfig.json +20 -0
- package/test/fixtures/types/scoped__no-relative-references/v1/index.d.ts +15 -0
- package/test/fixtures/types/scoped__no-relative-references/v1/no-relative-references-tests.ts +0 -0
- package/test/fixtures/types/scoped__no-relative-references/v1/other/other.d.ts +7 -0
- package/test/fixtures/types/scoped__no-relative-references/v1/package.json +5 -0
- package/test/fixtures/types/scoped__no-relative-references/v1/tsconfig.json +20 -0
- package/test/no-bad-reference.test.ts +87 -94
- package/test/no-declare-current-package.test.ts +31 -31
- package/test/no-import-of-dev-dependencies.test.ts +14 -59
- package/test/no-self-import.test.ts +16 -100
- package/test/no-single-declare-module.test.ts +0 -1
- package/test/no-unnecessary-generics.test.ts +1 -1
- package/test/tsconfig.json +9 -6
- package/test/tsconfig.test.json +10 -0
- package/test/util.test.ts +29 -18
- package/tsconfig.tsbuildinfo +1 -1
package/src/util.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isDeclarationPath, typesPackageNameToRealName } from "@definitelytyped/utils";
|
|
2
2
|
import { TSESTree, ESLintUtils } from "@typescript-eslint/utils";
|
|
3
3
|
import { RuleWithMetaAndName } from "@typescript-eslint/utils/dist/eslint-utils";
|
|
4
4
|
import { RuleListener, RuleModule, SourceCode } from "@typescript-eslint/utils/dist/ts-eslint";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import fs from "fs";
|
|
5
7
|
|
|
6
8
|
// Possible TS bug can't figure out how to do declaration emit of created rules
|
|
7
9
|
// without an explicit type annotation here due to pnpm symlink stuff
|
|
@@ -13,16 +15,10 @@ export const createRule: <TOptions extends readonly unknown[], TMessageIds exten
|
|
|
13
15
|
);
|
|
14
16
|
|
|
15
17
|
export function getTypesPackageForDeclarationFile(file: string) {
|
|
16
|
-
if (!file
|
|
18
|
+
if (!isDeclarationPath(file)) {
|
|
17
19
|
return undefined;
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
const match = file.match(/types\/([^\/]+)\//)?.[1];
|
|
21
|
-
if (!match) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return unmangleScopedPackage(match) ?? match;
|
|
21
|
+
return findTypesPackage(file)?.realName;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
export function commentsMatching(
|
|
@@ -35,3 +31,67 @@ export function commentsMatching(
|
|
|
35
31
|
if (m) f(m[1], comment);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
34
|
+
|
|
35
|
+
function findUp<T extends {}>(p: string, fn: (p: string) => T | undefined): T | undefined {
|
|
36
|
+
p = path.resolve(p);
|
|
37
|
+
const root = path.parse(p).root;
|
|
38
|
+
|
|
39
|
+
while (true) {
|
|
40
|
+
const v = fn(p);
|
|
41
|
+
if (v !== undefined) {
|
|
42
|
+
return v;
|
|
43
|
+
}
|
|
44
|
+
if (p === root) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
p = path.dirname(p);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface TypesPackageInfo {
|
|
54
|
+
dir: string;
|
|
55
|
+
/** package.json with name="@types/foo__bar-baz" */
|
|
56
|
+
packageJson: PackageJSON;
|
|
57
|
+
/** real package name being typed, like "@foo/bar-baz" */
|
|
58
|
+
realName: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface PackageJSON {
|
|
62
|
+
name: string;
|
|
63
|
+
version: string;
|
|
64
|
+
owners: string[];
|
|
65
|
+
dependencies?: Record<string, string | undefined>;
|
|
66
|
+
devDependencies?: Record<string, string | undefined>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// TODO(jakebailey): pull this helper out to util package?
|
|
70
|
+
function isTypesPackage(packageJson: Partial<PackageJSON>): boolean {
|
|
71
|
+
return (
|
|
72
|
+
typeof packageJson.name === "string" &&
|
|
73
|
+
packageJson.name.startsWith("@types/") &&
|
|
74
|
+
typeof packageJson.version === "string" &&
|
|
75
|
+
Array.isArray(packageJson.owners)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function findTypesPackage(file: string): TypesPackageInfo | undefined {
|
|
80
|
+
return findUp(file, (p) => {
|
|
81
|
+
const packageJsonPath = path.join(p, "package.json");
|
|
82
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const packageJsonContents = fs.readFileSync(packageJsonPath, "utf8");
|
|
87
|
+
const packageJson = JSON.parse(packageJsonContents);
|
|
88
|
+
if (!isTypesPackage(packageJson)) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
dir: p,
|
|
93
|
+
packageJson,
|
|
94
|
+
realName: typesPackageNameToRealName(packageJson.name),
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { TSESLint, ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
|
|
5
|
+
export const fixtureRoot = path.join(__dirname, "fixtures");
|
|
6
|
+
|
|
7
|
+
export function getFixturePath(filename: string): string {
|
|
8
|
+
return path.join(fixtureRoot, filename);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type ValidTestCase<TOptions extends Readonly<unknown[]>> = Omit<
|
|
12
|
+
TSESLint.ValidTestCase<TOptions>,
|
|
13
|
+
"code" | "filename"
|
|
14
|
+
> & {
|
|
15
|
+
filename: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type InvalidTestCase<TMessageIds extends string, TOptions extends Readonly<unknown[]>> = Omit<
|
|
19
|
+
TSESLint.InvalidTestCase<TMessageIds, TOptions>,
|
|
20
|
+
"code" | "filename"
|
|
21
|
+
> & {
|
|
22
|
+
filename: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
interface RunTests<TMessageIds extends string, TOptions extends Readonly<unknown[]>> {
|
|
26
|
+
readonly valid: readonly ValidTestCase<TOptions>[];
|
|
27
|
+
readonly invalid: readonly InvalidTestCase<TMessageIds, TOptions>[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function convertTestCase<TOptions extends Readonly<unknown[]>>(
|
|
31
|
+
test: ValidTestCase<TOptions>
|
|
32
|
+
): TSESLint.ValidTestCase<TOptions>;
|
|
33
|
+
function convertTestCase<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(
|
|
34
|
+
test: InvalidTestCase<TMessageIds, TOptions>
|
|
35
|
+
): TSESLint.InvalidTestCase<TMessageIds, TOptions>;
|
|
36
|
+
function convertTestCase<
|
|
37
|
+
TMessageIds extends string,
|
|
38
|
+
TOptions extends Readonly<unknown[]>,
|
|
39
|
+
T extends ValidTestCase<TOptions> | InvalidTestCase<TMessageIds, TOptions>
|
|
40
|
+
>(test: T): TSESLint.ValidTestCase<TOptions> | TSESLint.InvalidTestCase<TMessageIds, TOptions> {
|
|
41
|
+
const fixture = getFixturePath(test.filename);
|
|
42
|
+
const code = fs.readFileSync(fixture, "utf8");
|
|
43
|
+
return {
|
|
44
|
+
name: test.filename,
|
|
45
|
+
...test,
|
|
46
|
+
code,
|
|
47
|
+
filename: fixture,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function runTestsWithFixtures<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(
|
|
52
|
+
name: string,
|
|
53
|
+
rule: TSESLint.RuleModule<TMessageIds, TOptions>,
|
|
54
|
+
tests: RunTests<TMessageIds, TOptions>
|
|
55
|
+
): void {
|
|
56
|
+
const ruleTester = new ESLintUtils.RuleTester({
|
|
57
|
+
parser: "@typescript-eslint/parser",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return ruleTester.run(name, rule, {
|
|
61
|
+
valid: tests.valid.map(convertTestCase<TOptions>),
|
|
62
|
+
invalid: tests.invalid.map(convertTestCase<TMessageIds, TOptions>),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const foo = 1234;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"foo-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const foo = 1234;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"foo-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference path="../other" />
|
|
2
|
+
/// <reference path="./v11" />
|
|
3
|
+
/// <reference path="./v11/index" />
|
|
4
|
+
/// <reference path="./v11/subdir/file" />
|
|
5
|
+
/// <reference path="./v0.1" />
|
|
6
|
+
/// <reference path="./v0.1/index" />
|
|
7
|
+
/// <reference path="other" />
|
|
8
|
+
/// <reference path="./other" />
|
|
9
|
+
/// <reference path="./v1gardenpath" />
|
|
10
|
+
/// <reference path="./v1verb/other" />
|
|
11
|
+
/// <reference path="other" />
|
|
12
|
+
/// <reference path="other2" />
|
|
13
|
+
/// <reference path="..\index.d.ts" />
|
|
14
|
+
|
|
15
|
+
// unrelated comment
|
|
16
|
+
/// similar (reference path) comment
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"no-relative-references-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference path="../../foo/index.d.ts" />
|
|
2
|
+
/// <reference path="../v1/index.d.ts" />
|
|
3
|
+
/// <reference path="../../foo/v0.1/index.d.ts" />
|
|
4
|
+
/// <reference path="../index.d.ts" />
|
|
5
|
+
|
|
6
|
+
import * as foo from "../../foo";
|
|
7
|
+
import * as foo2 from "../v0.1";
|
|
8
|
+
import * as foo3 from "../../foo/v0.1";
|
|
9
|
+
import * as va4 from "../index";
|
|
10
|
+
|
|
11
|
+
declare module "no-relative-references" {
|
|
12
|
+
import A = require("no-relative-references/blah"); // Okay; relative
|
|
13
|
+
import B = require("no-relative-references/v0.1"); // Okay; no versioned dir here
|
|
14
|
+
import C = require("../index"); // Bad; parent dir
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"no-relative-references-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference path="../../foo/index.d.ts" />
|
|
2
|
+
/// <reference path="../v11/index.d.ts" />
|
|
3
|
+
/// <reference path="../../foo/v1/index.d.ts" />
|
|
4
|
+
/// <reference path="../index.d.ts" />
|
|
5
|
+
|
|
6
|
+
import * as foo from "../../foo";
|
|
7
|
+
import * as foo2 from "../v11";
|
|
8
|
+
import * as foo3 from "../../foo/v11";
|
|
9
|
+
import * as va4 from "../index";
|
|
10
|
+
|
|
11
|
+
declare module "no-relative-references" {
|
|
12
|
+
import A = require("no-relative-references/blah"); // Okay; relative
|
|
13
|
+
import B = require("no-relative-references/v11"); // Okay; no versioned dir here
|
|
14
|
+
import C = require("../index"); // Bad; parent dir
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"no-relative-references-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "no-declare-current-package" { }
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "no-declare-current-package/deep/import" { }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"no-import-of-dev-dependencies-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"no-import-of-dev-dependencies-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/test/fixtures/types/no-import-of-dev-dependencies/no-import-of-dev-dependencies-tests.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="devdep"/>
|
|
2
|
+
/// <reference types="otherdevdep"/>
|
|
3
|
+
/// <reference types="other"/>
|
|
4
|
+
|
|
5
|
+
import other from "other";
|
|
6
|
+
import self from "no-import-of-dev-dependencies";
|
|
7
|
+
|
|
8
|
+
import devdep from "devdep";
|
|
9
|
+
import * as otherdevdep from "otherdevdep";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@types/no-import-of-dev-dependencies",
|
|
3
|
+
"version": "2.0.9999",
|
|
4
|
+
"owners": [],
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@types/foo": "*",
|
|
7
|
+
"other": "*"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@types/devdep": "*",
|
|
11
|
+
"@types/no-import-of-dev-dependencies": "workspace:.",
|
|
12
|
+
"otherdevdep": "*"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"no-import-of-dev-dependencies-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference path="../foo/index.d.ts" />
|
|
2
|
+
/// <reference path="./v1/index.d.ts" />
|
|
3
|
+
/// <reference path="../foo/v1/index.d.ts" />
|
|
4
|
+
|
|
5
|
+
import * as foo from "../foo";
|
|
6
|
+
import * as foo2 from "./v1";
|
|
7
|
+
import * as foo3 from "../foo/v1";
|
|
8
|
+
|
|
9
|
+
declare module "no-relative-references" {
|
|
10
|
+
import A = require("no-relative-references/blah"); // Okay; relative
|
|
11
|
+
import B = require("no-relative-references/v1"); // Bad; versioned subdir
|
|
12
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"no-relative-references-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference path="../../foo/index.d.ts" />
|
|
2
|
+
/// <reference path="../v1/index.d.ts" />
|
|
3
|
+
/// <reference path="../../foo/v1/index.d.ts" />
|
|
4
|
+
/// <reference path="../index.d.ts" />
|
|
5
|
+
|
|
6
|
+
import * as foo from "../../foo";
|
|
7
|
+
import * as foo2 from "../v1";
|
|
8
|
+
import * as foo3 from "../../foo/v1";
|
|
9
|
+
import * as va4 from "../index";
|
|
10
|
+
|
|
11
|
+
declare module "no-relative-references" {
|
|
12
|
+
import A = require("no-relative-references/blah"); // Okay; relative
|
|
13
|
+
import B = require("no-relative-references/v1"); // Okay; no versioned dir here
|
|
14
|
+
import C = require("../index"); // Bad; parent dir
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference path="../../../foo/index.d.ts" />
|
|
2
|
+
/// <reference path="../../v1/index.d.ts" />
|
|
3
|
+
/// <reference path="../../../foo/v1/index.d.ts" />
|
|
4
|
+
|
|
5
|
+
import * as foo from "../../../foo";
|
|
6
|
+
import * as foo2 from "../../v1";
|
|
7
|
+
import * as foo3 from "../../../foo/v1";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": [
|
|
5
|
+
"es6",
|
|
6
|
+
"dom"
|
|
7
|
+
],
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"strictFunctionTypes": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"no-relative-references-tests.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|