@definitelytyped/eslint-plugin 0.0.186 → 0.0.188
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 +21 -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/util.test.ts +29 -18
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
-
|
|
3
1
|
import * as noDeclareCurrentPackage from "../src/rules/no-declare-current-package";
|
|
2
|
+
import { runTestsWithFixtures } from "./fixtureTester";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
runTestsWithFixtures("@definitelytyped/no-declare-current-package", noDeclareCurrentPackage, {
|
|
5
|
+
valid: [
|
|
6
|
+
{
|
|
7
|
+
filename: "types/foo/index.d.ts",
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
filename: "types/no-declare-current-package-other/index.d.ts",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
13
|
invalid: [
|
|
14
14
|
{
|
|
15
|
-
filename: "types/
|
|
16
|
-
code: `module "test" { }`,
|
|
15
|
+
filename: "types/no-declare-current-package/index.d.ts",
|
|
17
16
|
errors: [
|
|
18
17
|
{
|
|
19
|
-
line: 1,
|
|
20
18
|
messageId: "noDeclareCurrentPackage",
|
|
19
|
+
data: { text: "no-declare-current-package", preferred: '"index.d.ts"' },
|
|
21
20
|
},
|
|
22
21
|
],
|
|
23
22
|
},
|
|
24
23
|
{
|
|
25
|
-
filename: "types/test/deep/import.d.ts",
|
|
26
|
-
code: `module "test/deep/import" { }`,
|
|
24
|
+
filename: "types/no-declare-current-package/test/deep/import.d.ts",
|
|
27
25
|
errors: [
|
|
28
26
|
{
|
|
29
|
-
line: 1,
|
|
30
27
|
messageId: "noDeclareCurrentPackage",
|
|
28
|
+
data: {
|
|
29
|
+
text: "no-declare-current-package/deep/import",
|
|
30
|
+
preferred:
|
|
31
|
+
'"no-declare-current-package/deep/import.d.ts" or "no-declare-current-package/deep/import/index.d.ts"',
|
|
32
|
+
},
|
|
31
33
|
},
|
|
32
34
|
],
|
|
33
35
|
},
|
|
34
36
|
{
|
|
35
|
-
filename: "types/
|
|
36
|
-
code: `module "@scope/name" { }`,
|
|
37
|
+
filename: "types/scoped__no-declare-current-package/index.d.ts",
|
|
37
38
|
errors: [
|
|
38
39
|
{
|
|
39
|
-
line: 1,
|
|
40
40
|
messageId: "noDeclareCurrentPackage",
|
|
41
|
+
data: { text: "@scoped/no-declare-current-package", preferred: '"index.d.ts"' },
|
|
41
42
|
},
|
|
42
43
|
],
|
|
43
44
|
},
|
|
44
|
-
],
|
|
45
|
-
valid: [
|
|
46
|
-
{
|
|
47
|
-
filename: "types/other/index.d.ts",
|
|
48
|
-
code: `module "foo" { }`,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
filename: "types/other/index.d.ts",
|
|
52
|
-
code: `module "foo/bar/baz" { }`,
|
|
53
|
-
},
|
|
54
45
|
{
|
|
55
|
-
filename: "types/deep/
|
|
56
|
-
|
|
46
|
+
filename: "types/scoped__no-declare-current-package/test/deep/import.d.ts",
|
|
47
|
+
errors: [
|
|
48
|
+
{
|
|
49
|
+
messageId: "noDeclareCurrentPackage",
|
|
50
|
+
data: {
|
|
51
|
+
text: "@scoped/no-declare-current-package/deep/import",
|
|
52
|
+
preferred:
|
|
53
|
+
'"@scoped/no-declare-current-package/deep/import.d.ts" or "@scoped/no-declare-current-package/deep/import/index.d.ts"',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
57
|
},
|
|
58
58
|
],
|
|
59
59
|
});
|
|
@@ -1,72 +1,27 @@
|
|
|
1
|
-
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
-
|
|
3
1
|
import * as noImportDefaultOfDevDependencies from "../src/rules/no-import-of-dev-dependencies";
|
|
2
|
+
import { runTestsWithFixtures } from "./fixtureTester";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
parser: "@typescript-eslint/parser",
|
|
7
|
-
parserOptions: {
|
|
8
|
-
ecmaVersion: 2018,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
ruleTester.run("@definitelytyped/no-import-of-dev-dependencies", noImportDefaultOfDevDependencies, {
|
|
13
|
-
invalid: [
|
|
14
|
-
{
|
|
15
|
-
filename: "index.d.ts",
|
|
16
|
-
code: `import eslint from "eslint"`,
|
|
17
|
-
errors: [
|
|
18
|
-
{
|
|
19
|
-
line: 1,
|
|
20
|
-
messageId: "noImportOfDevDependencies",
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
// test @types/ removal
|
|
25
|
-
{
|
|
26
|
-
filename: "index.d.ts",
|
|
27
|
-
code: `import yargs from "yargs"`,
|
|
28
|
-
errors: [
|
|
29
|
-
{
|
|
30
|
-
line: 1,
|
|
31
|
-
messageId: "noImportOfDevDependencies",
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
filename: "index.d.ts",
|
|
37
|
-
code: `/// <reference types="node" />`,
|
|
38
|
-
errors: [
|
|
39
|
-
{
|
|
40
|
-
line: 1,
|
|
41
|
-
messageId: "noReferenceOfDevDependencies",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
],
|
|
4
|
+
runTestsWithFixtures("@definitelytyped/no-import-of-dev-dependencies", noImportDefaultOfDevDependencies, {
|
|
46
5
|
valid: [
|
|
47
6
|
{
|
|
48
|
-
filename: "index.d.ts",
|
|
49
|
-
code: `import other from 'other'`,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
filename: "types/yargs/index.d.ts",
|
|
53
|
-
code: `import self from "yargs"`,
|
|
7
|
+
filename: "types/foo/index.d.ts",
|
|
54
8
|
},
|
|
55
9
|
{
|
|
56
|
-
filename: "index.d.ts",
|
|
57
|
-
code: `/// <reference types="other"/>`,
|
|
10
|
+
filename: "types/no-import-of-dev-dependencies/index.d.ts",
|
|
58
11
|
},
|
|
59
12
|
{
|
|
60
|
-
filename: "
|
|
61
|
-
code: `import eslint from "eslint"`,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
filename: "test.ts",
|
|
65
|
-
code: `import yargs from "yargs"`,
|
|
13
|
+
filename: "types/no-import-of-dev-dependencies/no-import-of-dev-dependencies-tests.ts",
|
|
66
14
|
},
|
|
15
|
+
],
|
|
16
|
+
invalid: [
|
|
67
17
|
{
|
|
68
|
-
filename: "
|
|
69
|
-
|
|
18
|
+
filename: "types/no-import-of-dev-dependencies/bad.d.ts",
|
|
19
|
+
errors: [
|
|
20
|
+
{ messageId: "noReferenceOfDevDependencies" },
|
|
21
|
+
{ messageId: "noReferenceOfDevDependencies" },
|
|
22
|
+
{ messageId: "noImportOfDevDependencies" },
|
|
23
|
+
{ messageId: "noImportOfDevDependencies" },
|
|
24
|
+
],
|
|
70
25
|
},
|
|
71
26
|
],
|
|
72
27
|
});
|
|
@@ -1,114 +1,30 @@
|
|
|
1
|
-
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
-
|
|
3
1
|
import * as dtHeader from "../src/rules/no-self-import";
|
|
2
|
+
import { runTestsWithFixtures } from "./fixtureTester";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
ruleTester.run("@definitelytyped/no-self-import", dtHeader, {
|
|
10
|
-
invalid: [
|
|
11
|
-
{
|
|
12
|
-
code: `import myself from "this-package";`,
|
|
13
|
-
errors: [
|
|
14
|
-
{
|
|
15
|
-
line: 1,
|
|
16
|
-
messageId: "useRelativeImport",
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
filename: "types/this-package/index.d.ts",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
code: `import abc from "this-package/abc.d.ts";`,
|
|
23
|
-
errors: [
|
|
24
|
-
{
|
|
25
|
-
line: 1,
|
|
26
|
-
messageId: "useRelativeImport",
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
filename: "types/this-package/index.d.ts",
|
|
30
|
-
},
|
|
4
|
+
runTestsWithFixtures("@definitelytyped/no-self-import", dtHeader, {
|
|
5
|
+
valid: [
|
|
31
6
|
{
|
|
32
|
-
|
|
33
|
-
errors: [
|
|
34
|
-
{
|
|
35
|
-
column: 1,
|
|
36
|
-
endColumn: 24,
|
|
37
|
-
line: 1,
|
|
38
|
-
messageId: "useOnlyCurrentVersion",
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
filename: "types.d.ts",
|
|
7
|
+
filename: "types/foo/index.d.ts",
|
|
42
8
|
},
|
|
43
9
|
{
|
|
44
|
-
|
|
45
|
-
errors: [
|
|
46
|
-
{
|
|
47
|
-
column: 1,
|
|
48
|
-
endColumn: 30,
|
|
49
|
-
line: 1,
|
|
50
|
-
messageId: "useOnlyCurrentVersion",
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
filename: "types.d.ts",
|
|
10
|
+
filename: "types/no-self-import/index.d.ts",
|
|
54
11
|
},
|
|
55
12
|
{
|
|
56
|
-
|
|
57
|
-
errors: [
|
|
58
|
-
{
|
|
59
|
-
column: 1,
|
|
60
|
-
endColumn: 36,
|
|
61
|
-
line: 1,
|
|
62
|
-
messageId: "useOnlyCurrentVersion",
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
filename: "types.d.ts",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
code: `import old from "./v0.1"`,
|
|
69
|
-
errors: [
|
|
70
|
-
{
|
|
71
|
-
column: 1,
|
|
72
|
-
endColumn: 25,
|
|
73
|
-
line: 1,
|
|
74
|
-
messageId: "useOnlyCurrentVersion",
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
filename: "types.d.ts",
|
|
13
|
+
filename: "types/no-self-import/no-self-import-tests.ts",
|
|
78
14
|
},
|
|
15
|
+
],
|
|
16
|
+
invalid: [
|
|
79
17
|
{
|
|
80
|
-
|
|
18
|
+
filename: "types/no-self-import/bad.d.ts",
|
|
81
19
|
errors: [
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
},
|
|
20
|
+
{ messageId: "useRelativeImport" },
|
|
21
|
+
{ messageId: "useRelativeImport" },
|
|
22
|
+
{ messageId: "useOnlyCurrentVersion" },
|
|
23
|
+
{ messageId: "useOnlyCurrentVersion" },
|
|
24
|
+
{ messageId: "useOnlyCurrentVersion" },
|
|
25
|
+
{ messageId: "useOnlyCurrentVersion" },
|
|
26
|
+
{ messageId: "useOnlyCurrentVersion" },
|
|
88
27
|
],
|
|
89
|
-
filename: "types.d.ts",
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
valid: [
|
|
93
|
-
{
|
|
94
|
-
code: `import other from "other-package";`,
|
|
95
|
-
filename: "types/this-package/index.d.ts",
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
code: `import other from "other-package/this-package";`,
|
|
99
|
-
filename: "types/this-package/index.d.ts",
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
code: `import myself from "this-package";`,
|
|
103
|
-
filename: "types/grandparent/this-package/index.d.ts",
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
code: `import old from "./v1gardenpath"`,
|
|
107
|
-
filename: "types.d.ts",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
code: `import old from "./v1verb/other"`,
|
|
111
|
-
filename: "types.d.ts",
|
|
112
28
|
},
|
|
113
29
|
],
|
|
114
30
|
});
|
package/test/util.test.ts
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import { getTypesPackageForDeclarationFile } from "../src/util";
|
|
1
|
+
import { findTypesPackage, getTypesPackageForDeclarationFile } from "../src/util";
|
|
2
|
+
import { getFixturePath } from "./fixtureTester";
|
|
2
3
|
|
|
3
4
|
describe("getTypesPackageForDeclarationFile", () => {
|
|
4
5
|
test.each([
|
|
5
|
-
["types/
|
|
6
|
-
["types/
|
|
7
|
-
["types/
|
|
8
|
-
["types/
|
|
9
|
-
["types/
|
|
10
|
-
["
|
|
11
|
-
["
|
|
12
|
-
["
|
|
13
|
-
["
|
|
14
|
-
["/types/abc/nested/other.d.ts", "abc"],
|
|
15
|
-
["DefinitelyTyped/types/abc/index.d.ts", "abc"],
|
|
16
|
-
["DefinitelyTyped/types/abc/other.d.ts", "abc"],
|
|
17
|
-
["DefinitelyTyped/types/scope__abc/other.d.ts", "@scope/abc"],
|
|
18
|
-
["DefinitelyTyped/types/abc/nested/index.d.ts", "abc"],
|
|
19
|
-
["DefinitelyTyped/types/abc/nested/other.d.ts", "abc"],
|
|
20
|
-
["DefinitelyTyped/types/scope__abc/nested/other.d.ts", "@scope/abc"],
|
|
6
|
+
["types/foo/index.d.ts", "foo"],
|
|
7
|
+
["types/foo/foo-tests.ts", undefined],
|
|
8
|
+
["types/foo/v1/index.d.ts", "foo"],
|
|
9
|
+
["types/foo/v1/foo-tests.ts", undefined],
|
|
10
|
+
["types/scoped__foo/index.d.ts", "@scoped/foo"],
|
|
11
|
+
["types/scoped__foo/scoped__foo-tests.ts", undefined],
|
|
12
|
+
["types/scoped__foo/v1/index.d.ts", "@scoped/foo"],
|
|
13
|
+
["types/scoped__foo/v1/scoped__foo-tests.ts", undefined],
|
|
14
|
+
["bad.d.ts", undefined],
|
|
21
15
|
])("%s becomes %s", (input, expected) => {
|
|
22
|
-
expect(getTypesPackageForDeclarationFile(input)).toEqual(expected);
|
|
16
|
+
expect(getTypesPackageForDeclarationFile(getFixturePath(input))).toEqual(expected);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("findTypesPackage realName", () => {
|
|
21
|
+
test.each([
|
|
22
|
+
["types/foo/index.d.ts", "foo"],
|
|
23
|
+
["types/foo/foo-tests.ts", "foo"],
|
|
24
|
+
["types/foo/v1/index.d.ts", "foo"],
|
|
25
|
+
["types/foo/v1/foo-tests.ts", "foo"],
|
|
26
|
+
["types/scoped__foo/index.d.ts", "@scoped/foo"],
|
|
27
|
+
["types/scoped__foo/scoped__foo-tests.ts", "@scoped/foo"],
|
|
28
|
+
["types/scoped__foo/v1/index.d.ts", "@scoped/foo"],
|
|
29
|
+
["types/scoped__foo/v1/scoped__foo-tests.ts", "@scoped/foo"],
|
|
30
|
+
["bad.d.ts", undefined],
|
|
31
|
+
])("%s becomes %s", (input, expected) => {
|
|
32
|
+
const realName = findTypesPackage(getFixturePath(input))?.realName;
|
|
33
|
+
expect(realName).toEqual(expected);
|
|
23
34
|
});
|
|
24
35
|
});
|