knip 5.31.0 → 5.32.0
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/dist/ConfigurationChief.d.ts +1 -0
- package/dist/ConfigurationValidator.d.ts +62 -6
- package/dist/ConfigurationValidator.js +1 -0
- package/dist/WorkspaceWorker.d.ts +2 -2
- package/dist/binaries/bash-parser.js +3 -4
- package/dist/compilers/index.d.ts +11 -1
- package/dist/constants.js +1 -1
- package/dist/index.js +3 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/nyc/index.js +4 -2
- package/dist/plugins/nyc/types.d.ts +1 -0
- package/dist/plugins/stylelint/index.js +4 -3
- package/dist/plugins/stylelint/types.d.ts +1 -0
- package/dist/plugins/travis/index.d.ts +9 -0
- package/dist/plugins/travis/index.js +22 -0
- package/dist/types/config.d.ts +2 -1
- package/dist/typescript/SourceFile.d.ts +10 -1
- package/dist/typescript/ast-helpers.d.ts +1 -0
- package/dist/typescript/ast-helpers.js +9 -1
- package/dist/typescript/find-internal-references.d.ts +1 -0
- package/dist/typescript/find-internal-references.js +3 -1
- package/dist/typescript/get-imports-and-exports.d.ts +2 -1
- package/dist/typescript/get-imports-and-exports.js +68 -63
- package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/index.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/index.js +2 -2
- package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/{propertyAccessCall.d.ts → resolveCall.d.ts} +1 -1
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/exports/index.d.ts +1 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/helpers.js +2 -1
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/index.d.ts +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
- package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
- package/dist/typescript/visitors/scripts/index.d.ts +1 -1
- package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
- package/dist/util/loader.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/schema.json +4 -0
- /package/dist/typescript/visitors/dynamic-imports/{propertyAccessCall.js → resolveCall.js} +0 -0
|
@@ -123,6 +123,7 @@ export declare class ConfigurationChief {
|
|
|
123
123
|
svelte?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
124
124
|
syncpack?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
125
125
|
tailwind?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
126
|
+
travis?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
126
127
|
tsup?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
127
128
|
typedoc?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
128
129
|
typescript?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -808,6 +808,19 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
808
808
|
entry?: string | string[] | undefined;
|
|
809
809
|
project?: string | string[] | undefined;
|
|
810
810
|
}>]>>;
|
|
811
|
+
travis: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
812
|
+
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
813
|
+
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
814
|
+
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
815
|
+
}, "strip", z.ZodTypeAny, {
|
|
816
|
+
config?: string | string[] | undefined;
|
|
817
|
+
entry?: string | string[] | undefined;
|
|
818
|
+
project?: string | string[] | undefined;
|
|
819
|
+
}, {
|
|
820
|
+
config?: string | string[] | undefined;
|
|
821
|
+
entry?: string | string[] | undefined;
|
|
822
|
+
project?: string | string[] | undefined;
|
|
823
|
+
}>]>>;
|
|
811
824
|
tsup: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
812
825
|
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
813
826
|
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
@@ -1320,6 +1333,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
1320
1333
|
entry?: string | string[] | undefined;
|
|
1321
1334
|
project?: string | string[] | undefined;
|
|
1322
1335
|
} | undefined;
|
|
1336
|
+
travis?: string | boolean | string[] | {
|
|
1337
|
+
config?: string | string[] | undefined;
|
|
1338
|
+
entry?: string | string[] | undefined;
|
|
1339
|
+
project?: string | string[] | undefined;
|
|
1340
|
+
} | undefined;
|
|
1323
1341
|
tsup?: string | boolean | string[] | {
|
|
1324
1342
|
config?: string | string[] | undefined;
|
|
1325
1343
|
entry?: string | string[] | undefined;
|
|
@@ -1704,6 +1722,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
1704
1722
|
entry?: string | string[] | undefined;
|
|
1705
1723
|
project?: string | string[] | undefined;
|
|
1706
1724
|
} | undefined;
|
|
1725
|
+
travis?: string | boolean | string[] | {
|
|
1726
|
+
config?: string | string[] | undefined;
|
|
1727
|
+
entry?: string | string[] | undefined;
|
|
1728
|
+
project?: string | string[] | undefined;
|
|
1729
|
+
} | undefined;
|
|
1707
1730
|
tsup?: string | boolean | string[] | {
|
|
1708
1731
|
config?: string | string[] | undefined;
|
|
1709
1732
|
entry?: string | string[] | undefined;
|
|
@@ -2553,6 +2576,19 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
2553
2576
|
entry?: string | string[] | undefined;
|
|
2554
2577
|
project?: string | string[] | undefined;
|
|
2555
2578
|
}>]>>;
|
|
2579
|
+
travis: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
2580
|
+
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
2581
|
+
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
2582
|
+
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
2583
|
+
}, "strip", z.ZodTypeAny, {
|
|
2584
|
+
config?: string | string[] | undefined;
|
|
2585
|
+
entry?: string | string[] | undefined;
|
|
2586
|
+
project?: string | string[] | undefined;
|
|
2587
|
+
}, {
|
|
2588
|
+
config?: string | string[] | undefined;
|
|
2589
|
+
entry?: string | string[] | undefined;
|
|
2590
|
+
project?: string | string[] | undefined;
|
|
2591
|
+
}>]>>;
|
|
2556
2592
|
tsup: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
2557
2593
|
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
2558
2594
|
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
@@ -2775,9 +2811,9 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
2775
2811
|
ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "enum" | "class" | "interface" | "member", boolean>> | undefined;
|
|
2776
2812
|
ignoreWorkspaces?: string[] | undefined;
|
|
2777
2813
|
includeEntryExports?: boolean | undefined;
|
|
2778
|
-
compilers?: Record<string, ((args_0: string, args_1: string, ...
|
|
2779
|
-
syncCompilers?: Record<string, (args_0: string, args_1: string, ...
|
|
2780
|
-
asyncCompilers?: Record<string, (args_0: string, args_1: string, ...
|
|
2814
|
+
compilers?: Record<string, ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
|
|
2815
|
+
syncCompilers?: Record<string, (args_0: string, args_1: string, ...args: unknown[]) => string> | undefined;
|
|
2816
|
+
asyncCompilers?: Record<string, (args_0: string, args_1: string, ...args: unknown[]) => Promise<string>> | undefined;
|
|
2781
2817
|
astro?: string | boolean | string[] | {
|
|
2782
2818
|
config?: string | string[] | undefined;
|
|
2783
2819
|
entry?: string | string[] | undefined;
|
|
@@ -3073,6 +3109,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
3073
3109
|
entry?: string | string[] | undefined;
|
|
3074
3110
|
project?: string | string[] | undefined;
|
|
3075
3111
|
} | undefined;
|
|
3112
|
+
travis?: string | boolean | string[] | {
|
|
3113
|
+
config?: string | string[] | undefined;
|
|
3114
|
+
entry?: string | string[] | undefined;
|
|
3115
|
+
project?: string | string[] | undefined;
|
|
3116
|
+
} | undefined;
|
|
3076
3117
|
tsup?: string | boolean | string[] | {
|
|
3077
3118
|
config?: string | string[] | undefined;
|
|
3078
3119
|
entry?: string | string[] | undefined;
|
|
@@ -3457,6 +3498,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
3457
3498
|
entry?: string | string[] | undefined;
|
|
3458
3499
|
project?: string | string[] | undefined;
|
|
3459
3500
|
} | undefined;
|
|
3501
|
+
travis?: string | boolean | string[] | {
|
|
3502
|
+
config?: string | string[] | undefined;
|
|
3503
|
+
entry?: string | string[] | undefined;
|
|
3504
|
+
project?: string | string[] | undefined;
|
|
3505
|
+
} | undefined;
|
|
3460
3506
|
tsup?: string | boolean | string[] | {
|
|
3461
3507
|
config?: string | string[] | undefined;
|
|
3462
3508
|
entry?: string | string[] | undefined;
|
|
@@ -3552,9 +3598,9 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
3552
3598
|
ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "enum" | "class" | "interface" | "member", boolean>> | undefined;
|
|
3553
3599
|
ignoreWorkspaces?: string[] | undefined;
|
|
3554
3600
|
includeEntryExports?: boolean | undefined;
|
|
3555
|
-
compilers?: Record<string, ((args_0: string, args_1: string, ...
|
|
3556
|
-
syncCompilers?: Record<string, (args_0: string, args_1: string, ...
|
|
3557
|
-
asyncCompilers?: Record<string, (args_0: string, args_1: string, ...
|
|
3601
|
+
compilers?: Record<string, ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
|
|
3602
|
+
syncCompilers?: Record<string, (args_0: string, args_1: string, ...args: unknown[]) => string> | undefined;
|
|
3603
|
+
asyncCompilers?: Record<string, (args_0: string, args_1: string, ...args: unknown[]) => Promise<string>> | undefined;
|
|
3558
3604
|
astro?: string | boolean | string[] | {
|
|
3559
3605
|
config?: string | string[] | undefined;
|
|
3560
3606
|
entry?: string | string[] | undefined;
|
|
@@ -3850,6 +3896,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
3850
3896
|
entry?: string | string[] | undefined;
|
|
3851
3897
|
project?: string | string[] | undefined;
|
|
3852
3898
|
} | undefined;
|
|
3899
|
+
travis?: string | boolean | string[] | {
|
|
3900
|
+
config?: string | string[] | undefined;
|
|
3901
|
+
entry?: string | string[] | undefined;
|
|
3902
|
+
project?: string | string[] | undefined;
|
|
3903
|
+
} | undefined;
|
|
3853
3904
|
tsup?: string | boolean | string[] | {
|
|
3854
3905
|
config?: string | string[] | undefined;
|
|
3855
3906
|
entry?: string | string[] | undefined;
|
|
@@ -4234,6 +4285,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
|
|
|
4234
4285
|
entry?: string | string[] | undefined;
|
|
4235
4286
|
project?: string | string[] | undefined;
|
|
4236
4287
|
} | undefined;
|
|
4288
|
+
travis?: string | boolean | string[] | {
|
|
4289
|
+
config?: string | string[] | undefined;
|
|
4290
|
+
entry?: string | string[] | undefined;
|
|
4291
|
+
project?: string | string[] | undefined;
|
|
4292
|
+
} | undefined;
|
|
4237
4293
|
tsup?: string | boolean | string[] | {
|
|
4238
4294
|
config?: string | string[] | undefined;
|
|
4239
4295
|
entry?: string | string[] | undefined;
|
|
@@ -34,7 +34,7 @@ export declare class WorkspaceWorker {
|
|
|
34
34
|
isStrict: boolean;
|
|
35
35
|
rootIgnore: Configuration['ignore'];
|
|
36
36
|
negatedWorkspacePatterns: string[];
|
|
37
|
-
enabledPluginsMap: Record<"
|
|
37
|
+
enabledPluginsMap: Record<"astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "ladle" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "nest" | "netlify" | "next" | "nuxt" | "nx" | "nyc" | "oclif" | "playwright" | "postcss" | "preconstruct" | "prettier" | "remark" | "remix" | "rollup" | "rsbuild" | "rspack" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "travis" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vue" | "vike" | "vite" | "vitest" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "lockfileLint" | "lostPixel" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "reactCosmos" | "releaseIt" | "semanticRelease" | "simpleGitHooks" | "sizeLimit" | "vercelOg" | "webdriverIo", boolean>;
|
|
38
38
|
enabledPlugins: PluginName[];
|
|
39
39
|
enabledPluginsInAncestors: string[];
|
|
40
40
|
cache: CacheConsultant<CacheItem>;
|
|
@@ -55,7 +55,7 @@ export declare class WorkspaceWorker {
|
|
|
55
55
|
entryFilePatterns: Set<string>;
|
|
56
56
|
productionEntryFilePatterns: Set<string>;
|
|
57
57
|
referencedDependencies: ReferencedDependencies;
|
|
58
|
-
enabledPlugins: ("
|
|
58
|
+
enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "ladle" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "nest" | "netlify" | "next" | "nuxt" | "nx" | "nyc" | "oclif" | "playwright" | "postcss" | "preconstruct" | "prettier" | "remark" | "remix" | "rollup" | "rsbuild" | "rspack" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "travis" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vue" | "vike" | "vite" | "vitest" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "lockfileLint" | "lostPixel" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "reactCosmos" | "releaseIt" | "semanticRelease" | "simpleGitHooks" | "sizeLimit" | "vercelOg" | "webdriverIo")[];
|
|
59
59
|
}>;
|
|
60
60
|
onDispose(): void;
|
|
61
61
|
}
|
|
@@ -15,7 +15,8 @@ export const getBinariesFromScript = (script, options) => {
|
|
|
15
15
|
const getBinariesFromNodes = (nodes) => nodes.flatMap(node => {
|
|
16
16
|
switch (node.type) {
|
|
17
17
|
case 'Command': {
|
|
18
|
-
const
|
|
18
|
+
const text = node.name?.text;
|
|
19
|
+
const binary = text ? trimBinary(text) : text;
|
|
19
20
|
const commandExpansions = node.prefix
|
|
20
21
|
?.filter(isExpansion)
|
|
21
22
|
.map(prefix => prefix.expansion)
|
|
@@ -27,8 +28,6 @@ export const getBinariesFromScript = (script, options) => {
|
|
|
27
28
|
return [];
|
|
28
29
|
if (binary.startsWith('-') || binary.startsWith('"') || binary.startsWith('..'))
|
|
29
30
|
return [];
|
|
30
|
-
if (['deno'].includes(binary))
|
|
31
|
-
return [];
|
|
32
31
|
const args = node.suffix?.map(arg => arg.text) ?? [];
|
|
33
32
|
if (['!', 'test'].includes(binary))
|
|
34
33
|
return fromArgs(args);
|
|
@@ -47,7 +46,7 @@ export const getBinariesFromScript = (script, options) => {
|
|
|
47
46
|
const command = script.replace(new RegExp(`.*${node.name?.text ?? binary}(\\s--\\s)?`), '');
|
|
48
47
|
return [toBinary(binary), ...getBinariesFromScript(command, options)];
|
|
49
48
|
}
|
|
50
|
-
if (options.knownGlobalsOnly)
|
|
49
|
+
if (options.knownGlobalsOnly && !text?.startsWith('.'))
|
|
51
50
|
return [];
|
|
52
51
|
return [...FallbackResolver.resolve(binary, args, { ...options, fromArgs }), ...fromNodeOptions];
|
|
53
52
|
}
|
|
@@ -17,7 +17,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
17
17
|
ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "enum" | "class" | "interface" | "member", boolean>> | undefined;
|
|
18
18
|
ignoreWorkspaces?: string[] | undefined;
|
|
19
19
|
includeEntryExports?: boolean | undefined;
|
|
20
|
-
compilers?: Record<string, ((args_0: string, args_1: string, ...
|
|
20
|
+
compilers?: Record<string, ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
|
|
21
21
|
astro?: string | boolean | string[] | {
|
|
22
22
|
config?: string | string[] | undefined;
|
|
23
23
|
entry?: string | string[] | undefined;
|
|
@@ -313,6 +313,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
313
313
|
entry?: string | string[] | undefined;
|
|
314
314
|
project?: string | string[] | undefined;
|
|
315
315
|
} | undefined;
|
|
316
|
+
travis?: string | boolean | string[] | {
|
|
317
|
+
config?: string | string[] | undefined;
|
|
318
|
+
entry?: string | string[] | undefined;
|
|
319
|
+
project?: string | string[] | undefined;
|
|
320
|
+
} | undefined;
|
|
316
321
|
tsup?: string | boolean | string[] | {
|
|
317
322
|
config?: string | string[] | undefined;
|
|
318
323
|
entry?: string | string[] | undefined;
|
|
@@ -697,6 +702,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
697
702
|
entry?: string | string[] | undefined;
|
|
698
703
|
project?: string | string[] | undefined;
|
|
699
704
|
} | undefined;
|
|
705
|
+
travis?: string | boolean | string[] | {
|
|
706
|
+
config?: string | string[] | undefined;
|
|
707
|
+
entry?: string | string[] | undefined;
|
|
708
|
+
project?: string | string[] | undefined;
|
|
709
|
+
} | undefined;
|
|
700
710
|
tsup?: string | boolean | string[] | {
|
|
701
711
|
config?: string | string[] | undefined;
|
|
702
712
|
entry?: string | string[] | undefined;
|
package/dist/constants.js
CHANGED
|
@@ -118,7 +118,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
118
118
|
'yes',
|
|
119
119
|
]);
|
|
120
120
|
export const IGNORED_DEPENDENCIES = new Set(['knip', 'typescript']);
|
|
121
|
-
export const IGNORED_RUNTIME_DEPENDENCIES = new Set(['bun']);
|
|
121
|
+
export const IGNORED_RUNTIME_DEPENDENCIES = new Set(['bun', 'deno']);
|
|
122
122
|
export const FOREIGN_FILE_EXTENSIONS = new Set([
|
|
123
123
|
'.avif',
|
|
124
124
|
'.css',
|
package/dist/index.js
CHANGED
|
@@ -207,7 +207,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
207
207
|
skipTypeOnly: isStrict,
|
|
208
208
|
isFixExports: fixer.isEnabled && fixer.isFixUnusedExports,
|
|
209
209
|
isFixTypes: fixer.isEnabled && fixer.isFixUnusedTypes,
|
|
210
|
-
ignoreExportsUsedInFile:
|
|
210
|
+
ignoreExportsUsedInFile: chief.config.ignoreExportsUsedInFile,
|
|
211
211
|
isReportClassMembers,
|
|
212
212
|
tags,
|
|
213
213
|
}, isGitIgnored, isPackageNameInternalWorkspace, getPrincipalByFilePath);
|
|
@@ -319,6 +319,8 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
319
319
|
printTrace(traceNode, filePath, identifier);
|
|
320
320
|
if (isReferenced) {
|
|
321
321
|
if (report.enumMembers && exportedItem.type === 'enum') {
|
|
322
|
+
if (importsForExport.refs.has(identifier))
|
|
323
|
+
continue;
|
|
322
324
|
for (const member of exportedItem.members) {
|
|
323
325
|
if (findMatch(workspace.ignoreMembers, member.identifier))
|
|
324
326
|
continue;
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export { default as stylelint } from './stylelint/index.js';
|
|
|
58
58
|
export { default as svelte } from './svelte/index.js';
|
|
59
59
|
export { default as syncpack } from './syncpack/index.js';
|
|
60
60
|
export { default as tailwind } from './tailwind/index.js';
|
|
61
|
+
export { default as travis } from './travis/index.js';
|
|
61
62
|
export { default as tsup } from './tsup/index.js';
|
|
62
63
|
export { default as typedoc } from './typedoc/index.js';
|
|
63
64
|
export { default as typescript } from './typescript/index.js';
|
package/dist/plugins/index.js
CHANGED
|
@@ -58,6 +58,7 @@ export { default as stylelint } from './stylelint/index.js';
|
|
|
58
58
|
export { default as svelte } from './svelte/index.js';
|
|
59
59
|
export { default as syncpack } from './syncpack/index.js';
|
|
60
60
|
export { default as tailwind } from './tailwind/index.js';
|
|
61
|
+
export { default as travis } from './travis/index.js';
|
|
61
62
|
export { default as tsup } from './tsup/index.js';
|
|
62
63
|
export { default as typedoc } from './typedoc/index.js';
|
|
63
64
|
export { default as typescript } from './typescript/index.js';
|
|
@@ -2,9 +2,11 @@ import { hasDependency } from '#p/util/plugin.js';
|
|
|
2
2
|
const title = 'nyc';
|
|
3
3
|
const enablers = ['nyc'];
|
|
4
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
-
const config = ['.nycrc', '.nycrc.json', '.nycrc.{yml,yaml}', 'nyc.config.js'];
|
|
5
|
+
const config = ['.nycrc', '.nycrc.json', '.nycrc.{yml,yaml}', 'nyc.config.js', 'package.json'];
|
|
6
6
|
const resolveConfig = config => {
|
|
7
|
-
|
|
7
|
+
const extend = config?.extends ? [config?.extends].flat() : [];
|
|
8
|
+
const requires = config?.require ? [config?.require].flat() : [];
|
|
9
|
+
return [...extend, ...requires].flat();
|
|
8
10
|
};
|
|
9
11
|
export default {
|
|
10
12
|
title,
|
|
@@ -5,10 +5,11 @@ const enablers = ['stylelint'];
|
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const config = ['package.json', ...toCosmiconfig('stylelint')];
|
|
7
7
|
const resolve = (config) => {
|
|
8
|
-
const extend = config.extends ? [config.extends].flat()
|
|
9
|
-
const plugins = config.plugins ? [config.plugins].flat()
|
|
8
|
+
const extend = config.extends ? [config.extends].flat() : [];
|
|
9
|
+
const plugins = config.plugins ? [config.plugins].flat() : [];
|
|
10
|
+
const customSyntax = config.customSyntax ? [config.customSyntax] : [];
|
|
10
11
|
const overrideConfigs = 'overrides' in config ? config.overrides.flatMap(resolve) : [];
|
|
11
|
-
return [...extend, ...plugins, ...overrideConfigs];
|
|
12
|
+
return [...extend, ...plugins, ...overrideConfigs, ...customSyntax].filter(id => !isInternal(id));
|
|
12
13
|
};
|
|
13
14
|
const resolveConfig = config => resolve(config);
|
|
14
15
|
export default {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { _glob } from '#p/util/glob.js';
|
|
2
|
+
import { getDependenciesFromScripts } from '../../util/plugin.js';
|
|
3
|
+
const title = 'Travis CI';
|
|
4
|
+
const enablers = 'This plugin is enabled when a `.travis.yml` file is found in the root folder.';
|
|
5
|
+
const isEnabled = async ({ cwd }) => Boolean(await _glob({ cwd, patterns: ['.travis.yml'] }));
|
|
6
|
+
const config = ['.travis.yml'];
|
|
7
|
+
const resolveConfig = async (config, options) => {
|
|
8
|
+
if (!config)
|
|
9
|
+
return [];
|
|
10
|
+
const beforeDeploy = [config.before_deploy ?? []].flat();
|
|
11
|
+
const beforeInstall = [config.before_install ?? []].flat();
|
|
12
|
+
const beforeScript = [config.before_script ?? []].flat();
|
|
13
|
+
const scripts = [...beforeDeploy, ...beforeInstall, ...beforeScript];
|
|
14
|
+
return getDependenciesFromScripts(scripts, { ...options, knownGlobalsOnly: true });
|
|
15
|
+
};
|
|
16
|
+
export default {
|
|
17
|
+
title,
|
|
18
|
+
enablers,
|
|
19
|
+
isEnabled,
|
|
20
|
+
config,
|
|
21
|
+
resolveConfig,
|
|
22
|
+
};
|
package/dist/types/config.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ interface BaseWorkspaceConfiguration {
|
|
|
27
27
|
export interface WorkspaceConfiguration extends BaseWorkspaceConfiguration, Partial<PluginsConfiguration> {
|
|
28
28
|
}
|
|
29
29
|
type IgnorableExport = 'class' | 'enum' | 'function' | 'interface' | 'member' | 'type';
|
|
30
|
+
export type IgnoreExportsUsedInFile = boolean | Partial<Record<IgnorableExport, boolean>>;
|
|
30
31
|
export interface Configuration {
|
|
31
32
|
rules: Rules;
|
|
32
33
|
include: IssueType[];
|
|
@@ -34,7 +35,7 @@ export interface Configuration {
|
|
|
34
35
|
ignore: NormalizedGlob;
|
|
35
36
|
ignoreBinaries: IgnorePatterns;
|
|
36
37
|
ignoreDependencies: IgnorePatterns;
|
|
37
|
-
ignoreExportsUsedInFile:
|
|
38
|
+
ignoreExportsUsedInFile: IgnoreExportsUsedInFile;
|
|
38
39
|
ignoreMembers: IgnorePatterns;
|
|
39
40
|
ignoreWorkspaces: string[];
|
|
40
41
|
isIncludeEntryExports: boolean;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
type SymbolTable = Map<string,
|
|
2
|
+
type SymbolTable = Map<string, SymbolWithExportSymbol>;
|
|
3
3
|
type SymbolWithExports = ts.Symbol & {
|
|
4
4
|
exports?: SymbolTable;
|
|
5
5
|
};
|
|
6
|
+
interface SymbolWithExportSymbol extends ts.Symbol {
|
|
7
|
+
exportSymbol?: ts.Symbol;
|
|
8
|
+
}
|
|
6
9
|
type PragmaMap = {
|
|
7
10
|
arguments: {
|
|
8
11
|
factory?: string;
|
|
@@ -15,6 +18,12 @@ type PragmaMap = {
|
|
|
15
18
|
pos?: number;
|
|
16
19
|
};
|
|
17
20
|
};
|
|
21
|
+
range?: {
|
|
22
|
+
kind?: number;
|
|
23
|
+
pos?: number;
|
|
24
|
+
end?: number;
|
|
25
|
+
hasTrailingNewLine?: boolean;
|
|
26
|
+
};
|
|
18
27
|
};
|
|
19
28
|
export interface BoundSourceFile extends ts.SourceFile {
|
|
20
29
|
symbol?: SymbolWithExports;
|
|
@@ -20,6 +20,7 @@ export declare const getAccessMembers: (typeChecker: ts.TypeChecker, node: ts.Id
|
|
|
20
20
|
export declare const isDestructuring: (node: ts.Node) => boolean;
|
|
21
21
|
export declare const getDestructuredIds: (name: ts.ObjectBindingPattern) => string[];
|
|
22
22
|
export declare const isConsiderReferencedNS: (node: ts.Identifier) => boolean;
|
|
23
|
+
export declare const isObjectEnumerationCallExpressionArgument: (node: ts.Identifier) => boolean;
|
|
23
24
|
export declare const isTopLevel: (node: ts.Node) => boolean;
|
|
24
25
|
export declare const getTypeName: (node: ts.Identifier) => ts.QualifiedName | undefined;
|
|
25
26
|
export declare const isImportSpecifier: (node: ts.Node) => boolean;
|
|
@@ -133,12 +133,20 @@ export const isDestructuring = (node) => node.parent &&
|
|
|
133
133
|
ts.isVariableDeclarationList(node.parent.parent) &&
|
|
134
134
|
ts.isObjectBindingPattern(node.parent.name);
|
|
135
135
|
export const getDestructuredIds = (name) => name.elements.map(element => element.name.getText());
|
|
136
|
-
export const isConsiderReferencedNS = (node) => ts.
|
|
136
|
+
export const isConsiderReferencedNS = (node) => ts.isPropertyAssignment(node.parent) ||
|
|
137
|
+
ts.isShorthandPropertyAssignment(node.parent) ||
|
|
137
138
|
(ts.isCallExpression(node.parent) && node.parent.arguments.includes(node)) ||
|
|
138
139
|
ts.isSpreadAssignment(node.parent) ||
|
|
139
140
|
ts.isExportAssignment(node.parent) ||
|
|
140
141
|
(ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) ||
|
|
141
142
|
ts.isTypeQueryNode(node.parent);
|
|
143
|
+
const objectEnumerationMethods = new Set(['keys', 'entries', 'values', 'getOwnPropertyNames']);
|
|
144
|
+
export const isObjectEnumerationCallExpressionArgument = (node) => ts.isCallExpression(node.parent) &&
|
|
145
|
+
node.parent.arguments.includes(node) &&
|
|
146
|
+
ts.isPropertyAccessExpression(node.parent.expression) &&
|
|
147
|
+
ts.isIdentifier(node.parent.expression.expression) &&
|
|
148
|
+
node.parent.expression.expression.escapedText === 'Object' &&
|
|
149
|
+
objectEnumerationMethods.has(String(node.parent.expression.name.escapedText));
|
|
142
150
|
export const isTopLevel = (node) => ts.isSourceFile(node.parent) || (node.parent && ts.isSourceFile(node.parent.parent));
|
|
143
151
|
export const getTypeName = (node) => {
|
|
144
152
|
if (!node.parent?.parent)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { Export, ExportMember } from '../types/dependency-graph.js';
|
|
3
|
+
export declare const isType: (item: Export | ExportMember) => boolean;
|
|
3
4
|
export declare const findInternalReferences: (item: Export | ExportMember, sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker, referencedSymbolsInExportedTypes: Set<ts.Symbol>) => [number, boolean];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { isIdChar } from '../util/regex.js';
|
|
3
|
-
const isType = (item) => item.type === 'type' || item.type === 'interface' || item.type === '
|
|
3
|
+
export const isType = (item) => item.type === 'type' || item.type === 'interface' || item.type === 'enum';
|
|
4
4
|
export const findInternalReferences = (item, sourceFile, typeChecker, referencedSymbolsInExportedTypes) => {
|
|
5
5
|
if (!item.symbol)
|
|
6
6
|
return [0, false];
|
|
7
|
+
if (item.identifier === '')
|
|
8
|
+
return [1, false];
|
|
7
9
|
if (item.symbol.flags & ts.SymbolFlags.AliasExcludes)
|
|
8
10
|
return [1, false];
|
|
9
11
|
const text = sourceFile.text;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { Tags } from '../types/cli.js';
|
|
3
|
+
import type { IgnoreExportsUsedInFile } from '../types/config.js';
|
|
3
4
|
import type { ExportMap, ImportMap, UnresolvedImport } from '../types/dependency-graph.js';
|
|
4
5
|
import type { IssueSymbol } from '../types/issues.js';
|
|
5
6
|
import type { BoundSourceFile } from './SourceFile.js';
|
|
@@ -9,7 +10,7 @@ export type GetImportsAndExportsOptions = {
|
|
|
9
10
|
isFixExports: boolean;
|
|
10
11
|
isFixTypes: boolean;
|
|
11
12
|
isReportClassMembers: boolean;
|
|
12
|
-
ignoreExportsUsedInFile:
|
|
13
|
+
ignoreExportsUsedInFile: IgnoreExportsUsedInFile;
|
|
13
14
|
tags: Tags;
|
|
14
15
|
};
|
|
15
16
|
export declare const _getImportsAndExports: (sourceFile: BoundSourceFile, resolveModule: (specifier: string) => ts.ResolvedModuleFull | undefined, typeChecker: ts.TypeChecker, options: GetImportsAndExportsOptions) => {
|
|
@@ -6,8 +6,8 @@ import { addNsValue, addValue, createImports } from '../util/dependency-graph.js
|
|
|
6
6
|
import { getPackageNameFromFilePath, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
|
|
7
7
|
import { extname, isInNodeModules } from '../util/path.js';
|
|
8
8
|
import { shouldIgnore } from '../util/tag.js';
|
|
9
|
-
import { getAccessMembers, getDestructuredIds, getJSDocTags, getLineAndCharacterOfPosition, getTypeName, isAccessExpression, isConsiderReferencedNS, isDestructuring, isImportSpecifier, isReferencedInExportedType, } from './ast-helpers.js';
|
|
10
|
-
import { findInternalReferences } from './find-internal-references.js';
|
|
9
|
+
import { getAccessMembers, getDestructuredIds, getJSDocTags, getLineAndCharacterOfPosition, getTypeName, isAccessExpression, isConsiderReferencedNS, isDestructuring, isImportSpecifier, isObjectEnumerationCallExpressionArgument, isReferencedInExportedType, } from './ast-helpers.js';
|
|
10
|
+
import { findInternalReferences, isType } from './find-internal-references.js';
|
|
11
11
|
import getDynamicImportVisitors from './visitors/dynamic-imports/index.js';
|
|
12
12
|
import getExportVisitors from './visitors/exports/index.js';
|
|
13
13
|
import { getImportsFromPragmas } from './visitors/helpers.js';
|
|
@@ -47,6 +47,35 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
47
47
|
const importedInternalSymbols = new Map();
|
|
48
48
|
const referencedSymbolsInExportedTypes = new Set();
|
|
49
49
|
const visitors = getVisitors(sourceFile);
|
|
50
|
+
const addNsMemberRefs = (internalImport, namespace, member) => {
|
|
51
|
+
if (typeof member === 'string') {
|
|
52
|
+
internalImport.refs.add(`${namespace}.${member}`);
|
|
53
|
+
traceRefs.add(`${namespace}.${member}`);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
for (const m of member) {
|
|
57
|
+
internalImport.refs.add(`${namespace}.${m}`);
|
|
58
|
+
traceRefs.add(`${namespace}.${m}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const maybeAddAliasedExport = (node, alias) => {
|
|
63
|
+
const identifier = node?.getText();
|
|
64
|
+
if (node && identifier) {
|
|
65
|
+
const symbol = sourceFile.symbol?.exports?.get(identifier);
|
|
66
|
+
if (symbol?.valueDeclaration) {
|
|
67
|
+
if (!aliasedExports.has(identifier)) {
|
|
68
|
+
const pos = getLineAndCharacterOfPosition(symbol.valueDeclaration, symbol.valueDeclaration.pos);
|
|
69
|
+
aliasedExports.set(identifier, [{ symbol: identifier, ...pos }]);
|
|
70
|
+
}
|
|
71
|
+
const aliasedExport = aliasedExports.get(identifier);
|
|
72
|
+
if (aliasedExport) {
|
|
73
|
+
const pos = getLineAndCharacterOfPosition(node, node.pos);
|
|
74
|
+
aliasedExport.push({ symbol: alias, ...pos });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
50
79
|
const addInternalImport = (options) => {
|
|
51
80
|
const { identifier, symbol, filePath, namespace, alias, specifier, isReExport } = options;
|
|
52
81
|
const isStar = identifier === IMPORT_STAR;
|
|
@@ -124,27 +153,6 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
124
153
|
}
|
|
125
154
|
}
|
|
126
155
|
};
|
|
127
|
-
const maybeAddAccessExpressionAsNsImport = (namespace, member) => {
|
|
128
|
-
const symbol = sourceFile.locals?.get(namespace);
|
|
129
|
-
if (symbol) {
|
|
130
|
-
const importedSymbolFilePath = importedInternalSymbols.get(symbol);
|
|
131
|
-
if (importedSymbolFilePath) {
|
|
132
|
-
const internalImport = internalImports.get(importedSymbolFilePath);
|
|
133
|
-
if (internalImport) {
|
|
134
|
-
if (typeof member === 'string') {
|
|
135
|
-
internalImport.refs.add(`${namespace}.${member}`);
|
|
136
|
-
traceRefs.add(`${namespace}.${member}`);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
for (const m of member) {
|
|
140
|
-
internalImport.refs.add(`${namespace}.${m}`);
|
|
141
|
-
traceRefs.add(`${namespace}.${m}`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
156
|
const addExport = ({ node, symbol, identifier, type, pos, members = [], fix }) => {
|
|
149
157
|
if (options.skipExports)
|
|
150
158
|
return;
|
|
@@ -200,33 +208,15 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
200
208
|
}
|
|
201
209
|
};
|
|
202
210
|
const addScript = (script) => scripts.add(script);
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (!aliasedExports.has(identifier)) {
|
|
209
|
-
const pos = getLineAndCharacterOfPosition(symbol.valueDeclaration, symbol.valueDeclaration.pos);
|
|
210
|
-
aliasedExports.set(identifier, [{ symbol: identifier, ...pos }]);
|
|
211
|
-
}
|
|
212
|
-
const aliasedExport = aliasedExports.get(identifier);
|
|
213
|
-
if (aliasedExport) {
|
|
214
|
-
const pos = getLineAndCharacterOfPosition(node, node.pos);
|
|
215
|
-
aliasedExport.push({ symbol: alias, ...pos });
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
211
|
+
const getImport = (id, node) => {
|
|
212
|
+
const local = sourceFile.locals?.get(id);
|
|
213
|
+
const symbol = node.symbol ?? node.parent.symbol ?? local;
|
|
214
|
+
const filePath = importedInternalSymbols.get(symbol) ?? (local && importedInternalSymbols.get(local));
|
|
215
|
+
return { symbol, filePath };
|
|
219
216
|
};
|
|
220
217
|
const visit = (node) => {
|
|
221
218
|
const addImportWithNode = (result) => addImport(result, node);
|
|
222
|
-
|
|
223
|
-
const result = visitor(node, options);
|
|
224
|
-
result && (Array.isArray(result) ? result.forEach(addImportWithNode) : addImportWithNode(result));
|
|
225
|
-
}
|
|
226
|
-
const isTopLevel = node.parent &&
|
|
227
|
-
('commonJsModuleIndicator' in sourceFile
|
|
228
|
-
? node.parent.parent === sourceFile || node.parent === sourceFile
|
|
229
|
-
: node.parent === sourceFile);
|
|
219
|
+
const isTopLevel = node !== sourceFile && ts.isInTopLevelContext(node);
|
|
230
220
|
if (isTopLevel) {
|
|
231
221
|
for (const visitor of visitors.import) {
|
|
232
222
|
const result = visitor(node, options);
|
|
@@ -237,18 +227,21 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
237
227
|
result && (Array.isArray(result) ? result.forEach(addExport) : addExport(result));
|
|
238
228
|
}
|
|
239
229
|
}
|
|
230
|
+
for (const visitor of visitors.dynamicImport) {
|
|
231
|
+
const result = visitor(node, options);
|
|
232
|
+
result && (Array.isArray(result) ? result.forEach(addImportWithNode) : addImportWithNode(result));
|
|
233
|
+
}
|
|
240
234
|
for (const visitor of visitors.script) {
|
|
241
235
|
const result = visitor(node, options);
|
|
242
236
|
result && (Array.isArray(result) ? result.forEach(addScript) : addScript(result));
|
|
243
237
|
}
|
|
244
238
|
if (ts.isIdentifier(node)) {
|
|
245
239
|
const id = String(node.escapedText);
|
|
246
|
-
const symbol =
|
|
240
|
+
const { symbol, filePath } = getImport(id, node);
|
|
247
241
|
if (symbol) {
|
|
248
|
-
|
|
249
|
-
if (importedSymbolFilePath) {
|
|
242
|
+
if (filePath) {
|
|
250
243
|
if (!isImportSpecifier(node)) {
|
|
251
|
-
const imports = internalImports.get(
|
|
244
|
+
const imports = internalImports.get(filePath);
|
|
252
245
|
if (imports) {
|
|
253
246
|
traceRefs.add(id);
|
|
254
247
|
if (isAccessExpression(node.parent)) {
|
|
@@ -257,38 +250,40 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
257
250
|
const ns = String(symbol.escapedName);
|
|
258
251
|
const key = String(node.parent.name.escapedText);
|
|
259
252
|
const members = getDestructuredIds(node.parent.parent.name).map(n => `${key}.${n}`);
|
|
260
|
-
|
|
261
|
-
|
|
253
|
+
addNsMemberRefs(imports, ns, key);
|
|
254
|
+
addNsMemberRefs(imports, ns, members);
|
|
262
255
|
}
|
|
263
256
|
}
|
|
264
257
|
else {
|
|
265
258
|
const members = getAccessMembers(typeChecker, node);
|
|
266
|
-
|
|
259
|
+
addNsMemberRefs(imports, id, members);
|
|
267
260
|
}
|
|
268
261
|
}
|
|
269
262
|
else if (isDestructuring(node)) {
|
|
270
263
|
const members = getDestructuredIds(node.parent.name);
|
|
271
|
-
|
|
264
|
+
addNsMemberRefs(imports, id, members);
|
|
272
265
|
}
|
|
273
266
|
else {
|
|
274
267
|
const typeName = getTypeName(node);
|
|
275
268
|
if (typeName) {
|
|
276
269
|
const [ns, ...right] = [typeName.left.getText(), typeName.right.getText()].join('.').split('.');
|
|
277
270
|
const members = right.map((_r, index) => right.slice(0, index + 1).join('.'));
|
|
278
|
-
|
|
271
|
+
addNsMemberRefs(imports, ns, members);
|
|
279
272
|
}
|
|
280
273
|
else if (imports.importedNs.has(id) && isConsiderReferencedNS(node)) {
|
|
281
274
|
imports.refs.add(id);
|
|
282
275
|
}
|
|
283
|
-
else {
|
|
276
|
+
else if (isObjectEnumerationCallExpressionArgument(node)) {
|
|
284
277
|
imports.refs.add(id);
|
|
285
278
|
}
|
|
286
279
|
}
|
|
287
280
|
}
|
|
288
281
|
}
|
|
289
282
|
}
|
|
290
|
-
if (
|
|
291
|
-
|
|
283
|
+
if (!isTopLevel && symbol.exportSymbol) {
|
|
284
|
+
if (ts.isTypeQueryNode(node.parent) || isReferencedInExportedType(node)) {
|
|
285
|
+
referencedSymbolsInExportedTypes.add(symbol.exportSymbol);
|
|
286
|
+
}
|
|
292
287
|
}
|
|
293
288
|
}
|
|
294
289
|
}
|
|
@@ -297,8 +292,13 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
297
292
|
ts.isQualifiedName(node.moduleReference) &&
|
|
298
293
|
ts.isIdentifier(node.moduleReference.left)) {
|
|
299
294
|
const { left, right } = node.moduleReference;
|
|
300
|
-
|
|
301
|
-
|
|
295
|
+
const namespace = left.text;
|
|
296
|
+
const { filePath } = getImport(namespace, node);
|
|
297
|
+
if (filePath) {
|
|
298
|
+
const internalImport = internalImports.get(filePath);
|
|
299
|
+
if (internalImport)
|
|
300
|
+
addNsMemberRefs(internalImport, namespace, right.text);
|
|
301
|
+
}
|
|
302
302
|
}
|
|
303
303
|
ts.forEachChild(node, visit);
|
|
304
304
|
};
|
|
@@ -307,9 +307,14 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
307
307
|
if (pragmaImports)
|
|
308
308
|
for (const node of pragmaImports)
|
|
309
309
|
addImport(node, sourceFile);
|
|
310
|
-
const isSetRefs = ignoreExportsUsedInFile;
|
|
311
310
|
for (const item of exports.values()) {
|
|
312
|
-
|
|
311
|
+
const isType_ = isType(item);
|
|
312
|
+
if (item.symbol && referencedSymbolsInExportedTypes.has(item.symbol)) {
|
|
313
|
+
item.refs = [1, true];
|
|
314
|
+
}
|
|
315
|
+
else if (ignoreExportsUsedInFile === true ||
|
|
316
|
+
(typeof ignoreExportsUsedInFile === 'object' && item.type !== 'unknown' && ignoreExportsUsedInFile[item.type]) ||
|
|
317
|
+
isType_) {
|
|
313
318
|
item.refs = findInternalReferences(item, sourceFile, typeChecker, referencedSymbolsInExportedTypes);
|
|
314
319
|
}
|
|
315
320
|
for (const member of item.members) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import importCall from './importCall.js';
|
|
2
2
|
import importType from './importType.js';
|
|
3
3
|
import jsDocType from './jsDocType.js';
|
|
4
|
-
import propertyAccessCall from './propertyAccessCall.js';
|
|
5
4
|
import requireCall from './requireCall.js';
|
|
6
|
-
|
|
5
|
+
import resolveCall from './resolveCall.js';
|
|
6
|
+
const visitors = [importCall, importType, jsDocType, resolveCall, requireCall];
|
|
7
7
|
export default (sourceFile) => visitors.map(v => v(sourceFile));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { ImportNode } from '../../../types/imports.js';
|
|
3
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
3
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => ImportNode | ImportNode[] | undefined;
|
|
4
4
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
package/dist/typescript/visitors/dynamic-imports/{propertyAccessCall.d.ts → resolveCall.d.ts}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -10,8 +10,9 @@ export function getImportsFromPragmas(sourceFile) {
|
|
|
10
10
|
? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1]
|
|
11
11
|
: jsxImportSourcePragmas;
|
|
12
12
|
const { factory: specifier } = jsxImportSourcePragma?.arguments ?? {};
|
|
13
|
+
const pos = jsxImportSourcePragma.range?.pos ?? 0;
|
|
13
14
|
if (specifier)
|
|
14
|
-
importNodes.push({ specifier, isTypeOnly: true, identifier: '__jsx', pos
|
|
15
|
+
importNodes.push({ specifier, isTypeOnly: true, identifier: '__jsx', pos });
|
|
15
16
|
}
|
|
16
17
|
const referencePragma = sourceFile.pragmas.get('reference');
|
|
17
18
|
if (referencePragma) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => string | string[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) =>
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../get-imports-and-exports.js").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
package/dist/util/loader.js
CHANGED
|
@@ -31,7 +31,7 @@ const load = async (filePath) => {
|
|
|
31
31
|
if (ext === '.toml') {
|
|
32
32
|
return await loadTOML(filePath);
|
|
33
33
|
}
|
|
34
|
-
return await jiti.import(filePath);
|
|
34
|
+
return await jiti.import(filePath, { default: true });
|
|
35
35
|
}
|
|
36
36
|
catch (error) {
|
|
37
37
|
throw new LoaderError(`Error loading ${filePath}`, { cause: error });
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.32.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.32.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.32.0",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"easy-table": "1.2.0",
|
|
67
67
|
"enhanced-resolve": "^5.17.1",
|
|
68
68
|
"fast-glob": "^3.3.2",
|
|
69
|
-
"jiti": "^2.1
|
|
69
|
+
"jiti": "^2.3.1",
|
|
70
70
|
"js-yaml": "^4.1.0",
|
|
71
71
|
"minimist": "^1.2.8",
|
|
72
72
|
"picocolors": "^1.0.0",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@types/minimist": "^1.2.5",
|
|
91
91
|
"@types/picomatch": "3.0.1",
|
|
92
92
|
"@types/webpack": "^5.28.5",
|
|
93
|
-
"@wdio/types": "^9.
|
|
93
|
+
"@wdio/types": "^9.1.2",
|
|
94
94
|
"glob": "^10.4.2",
|
|
95
95
|
"release-it": "^17.6.0",
|
|
96
96
|
"type-fest": "^4.20.0",
|
package/schema.json
CHANGED
|
@@ -520,6 +520,10 @@
|
|
|
520
520
|
"title": "tailwind plugin configuration (https://knip.dev/reference/plugins/tailwind)",
|
|
521
521
|
"$ref": "#/definitions/plugin"
|
|
522
522
|
},
|
|
523
|
+
"travis": {
|
|
524
|
+
"title": "travis plugin configuration (https://knip.dev/reference/plugins/travis)",
|
|
525
|
+
"$ref": "#/definitions/plugin"
|
|
526
|
+
},
|
|
523
527
|
"tsup": {
|
|
524
528
|
"title": "tsup plugin configuration (https://knip.dev/reference/plugins/tsup)",
|
|
525
529
|
"$ref": "#/definitions/plugin"
|
|
File without changes
|