knip 5.0.4 → 5.1.1

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.
@@ -90,6 +90,7 @@ export declare class ConfigurationChief {
90
90
  linthtml?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
91
91
  markdownlint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
92
92
  mocha?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
93
+ msw?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
93
94
  netlify?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
94
95
  next?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
95
96
  nx?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -24,9 +24,9 @@ export declare const ConfigurationValidator: z.ZodObject<{
24
24
  ignore: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
25
25
  ignoreExportsUsedInFile: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodRecord<z.ZodUnion<[z.ZodLiteral<"class">, z.ZodLiteral<"enum">, z.ZodLiteral<"function">, z.ZodLiteral<"interface">, z.ZodLiteral<"member">, z.ZodLiteral<"type">]>, z.ZodBoolean>]>>;
26
26
  includeEntryExports: z.ZodOptional<z.ZodBoolean>;
27
- compilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodString>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodPromise<z.ZodString>>]>>>;
28
- syncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodString>>>;
29
- asyncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodPromise<z.ZodString>>>>;
27
+ compilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodString>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodPromise<z.ZodString>>]>>>;
28
+ syncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodString>>>;
29
+ asyncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodPromise<z.ZodString>>>>;
30
30
  include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, "many">>;
31
31
  workspaces: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
32
32
  ignoreBinaries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>;
@@ -322,6 +322,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
322
322
  entry?: string | string[] | undefined;
323
323
  project?: string | string[] | undefined;
324
324
  }>]>>;
325
+ msw: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
326
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
327
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
328
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
329
+ }, "strip", z.ZodTypeAny, {
330
+ config?: string | string[] | undefined;
331
+ entry?: string | string[] | undefined;
332
+ project?: string | string[] | undefined;
333
+ }, {
334
+ config?: string | string[] | undefined;
335
+ entry?: string | string[] | undefined;
336
+ project?: string | string[] | undefined;
337
+ }>]>>;
325
338
  netlify: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
326
339
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
327
340
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -856,6 +869,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
856
869
  entry?: string | string[] | undefined;
857
870
  project?: string | string[] | undefined;
858
871
  } | undefined;
872
+ msw?: string | boolean | string[] | {
873
+ config?: string | string[] | undefined;
874
+ entry?: string | string[] | undefined;
875
+ project?: string | string[] | undefined;
876
+ } | undefined;
859
877
  netlify?: string | boolean | string[] | {
860
878
  config?: string | string[] | undefined;
861
879
  entry?: string | string[] | undefined;
@@ -1134,6 +1152,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
1134
1152
  entry?: string | string[] | undefined;
1135
1153
  project?: string | string[] | undefined;
1136
1154
  } | undefined;
1155
+ msw?: string | boolean | string[] | {
1156
+ config?: string | string[] | undefined;
1157
+ entry?: string | string[] | undefined;
1158
+ project?: string | string[] | undefined;
1159
+ } | undefined;
1137
1160
  netlify?: string | boolean | string[] | {
1138
1161
  config?: string | string[] | undefined;
1139
1162
  entry?: string | string[] | undefined;
@@ -1581,6 +1604,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
1581
1604
  entry?: string | string[] | undefined;
1582
1605
  project?: string | string[] | undefined;
1583
1606
  }>]>>;
1607
+ msw: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
1608
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1609
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1610
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1611
+ }, "strip", z.ZodTypeAny, {
1612
+ config?: string | string[] | undefined;
1613
+ entry?: string | string[] | undefined;
1614
+ project?: string | string[] | undefined;
1615
+ }, {
1616
+ config?: string | string[] | undefined;
1617
+ entry?: string | string[] | undefined;
1618
+ project?: string | string[] | undefined;
1619
+ }>]>>;
1584
1620
  netlify: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
1585
1621
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1586
1622
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -2009,9 +2045,9 @@ export declare const ConfigurationValidator: z.ZodObject<{
2009
2045
  ignore?: string | string[] | undefined;
2010
2046
  ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "interface" | "enum" | "class" | "member", boolean>> | undefined;
2011
2047
  includeEntryExports?: boolean | undefined;
2012
- compilers?: Record<string, ((args_0: string, ...args_1: unknown[]) => string) | ((args_0: string, ...args_1: unknown[]) => Promise<string>)> | undefined;
2013
- syncCompilers?: Record<string, (args_0: string, ...args_1: unknown[]) => string> | undefined;
2014
- asyncCompilers?: Record<string, (args_0: string, ...args_1: unknown[]) => Promise<string>> | undefined;
2048
+ compilers?: Record<string, ((args_0: string, args_1: string, ...args_2: unknown[]) => string) | ((args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>)> | undefined;
2049
+ syncCompilers?: Record<string, (args_0: string, args_1: string, ...args_2: unknown[]) => string> | undefined;
2050
+ asyncCompilers?: Record<string, (args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>> | undefined;
2015
2051
  include?: ("files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
2016
2052
  workspaces?: Record<string, {
2017
2053
  ignoreBinaries?: (string | RegExp)[] | undefined;
@@ -2131,6 +2167,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2131
2167
  entry?: string | string[] | undefined;
2132
2168
  project?: string | string[] | undefined;
2133
2169
  } | undefined;
2170
+ msw?: string | boolean | string[] | {
2171
+ config?: string | string[] | undefined;
2172
+ entry?: string | string[] | undefined;
2173
+ project?: string | string[] | undefined;
2174
+ } | undefined;
2134
2175
  netlify?: string | boolean | string[] | {
2135
2176
  config?: string | string[] | undefined;
2136
2177
  entry?: string | string[] | undefined;
@@ -2402,6 +2443,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2402
2443
  entry?: string | string[] | undefined;
2403
2444
  project?: string | string[] | undefined;
2404
2445
  } | undefined;
2446
+ msw?: string | boolean | string[] | {
2447
+ config?: string | string[] | undefined;
2448
+ entry?: string | string[] | undefined;
2449
+ project?: string | string[] | undefined;
2450
+ } | undefined;
2405
2451
  netlify?: string | boolean | string[] | {
2406
2452
  config?: string | string[] | undefined;
2407
2453
  entry?: string | string[] | undefined;
@@ -2574,9 +2620,9 @@ export declare const ConfigurationValidator: z.ZodObject<{
2574
2620
  ignore?: string | string[] | undefined;
2575
2621
  ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "interface" | "enum" | "class" | "member", boolean>> | undefined;
2576
2622
  includeEntryExports?: boolean | undefined;
2577
- compilers?: Record<string, ((args_0: string, ...args_1: unknown[]) => string) | ((args_0: string, ...args_1: unknown[]) => Promise<string>)> | undefined;
2578
- syncCompilers?: Record<string, (args_0: string, ...args_1: unknown[]) => string> | undefined;
2579
- asyncCompilers?: Record<string, (args_0: string, ...args_1: unknown[]) => Promise<string>> | undefined;
2623
+ compilers?: Record<string, ((args_0: string, args_1: string, ...args_2: unknown[]) => string) | ((args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>)> | undefined;
2624
+ syncCompilers?: Record<string, (args_0: string, args_1: string, ...args_2: unknown[]) => string> | undefined;
2625
+ asyncCompilers?: Record<string, (args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>> | undefined;
2580
2626
  include?: ("files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
2581
2627
  workspaces?: Record<string, {
2582
2628
  ignoreBinaries?: (string | RegExp)[] | undefined;
@@ -2696,6 +2742,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2696
2742
  entry?: string | string[] | undefined;
2697
2743
  project?: string | string[] | undefined;
2698
2744
  } | undefined;
2745
+ msw?: string | boolean | string[] | {
2746
+ config?: string | string[] | undefined;
2747
+ entry?: string | string[] | undefined;
2748
+ project?: string | string[] | undefined;
2749
+ } | undefined;
2699
2750
  netlify?: string | boolean | string[] | {
2700
2751
  config?: string | string[] | undefined;
2701
2752
  entry?: string | string[] | undefined;
@@ -2967,6 +3018,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2967
3018
  entry?: string | string[] | undefined;
2968
3019
  project?: string | string[] | undefined;
2969
3020
  } | undefined;
3021
+ msw?: string | boolean | string[] | {
3022
+ config?: string | string[] | undefined;
3023
+ entry?: string | string[] | undefined;
3024
+ project?: string | string[] | undefined;
3025
+ } | undefined;
2970
3026
  netlify?: string | boolean | string[] | {
2971
3027
  config?: string | string[] | undefined;
2972
3028
  entry?: string | string[] | undefined;
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  const globSchema = z.union([z.string(), z.array(z.string())]);
3
3
  const pathsSchema = z.record(z.string(), z.array(z.string()));
4
- const syncCompilerSchema = z.function().args(z.string()).returns(z.string());
5
- const asyncCompilerSchema = z.function().args(z.string()).returns(z.promise(z.string()));
4
+ const syncCompilerSchema = z.function().args(z.string(), z.string()).returns(z.string());
5
+ const asyncCompilerSchema = z.function().args(z.string(), z.string()).returns(z.promise(z.string()));
6
6
  const compilerSchema = z.union([syncCompilerSchema, asyncCompilerSchema]);
7
7
  const compilersSchema = z.record(z.string(), compilerSchema);
8
8
  const stringOrRegexSchema = z.array(z.union([z.string(), z.instanceof(RegExp)]));
@@ -84,6 +84,7 @@ const pluginsSchema = z.object({
84
84
  linthtml: pluginSchema,
85
85
  markdownlint: pluginSchema,
86
86
  mocha: pluginSchema,
87
+ msw: pluginSchema,
87
88
  netlify: pluginSchema,
88
89
  next: pluginSchema,
89
90
  'node-test-runner': pluginSchema,
@@ -17,6 +17,7 @@ export type PrincipalOptions = {
17
17
  pkgName: string;
18
18
  isGitIgnored: (path: string) => boolean;
19
19
  isIsolateWorkspaces: boolean;
20
+ isSkipLibs: boolean;
20
21
  };
21
22
  export declare class PrincipalFactory {
22
23
  principals: Principals;
@@ -24,6 +24,7 @@ export declare class ProjectPrincipal {
24
24
  extensions: Set<string>;
25
25
  syncCompilers: SyncCompilers;
26
26
  asyncCompilers: AsyncCompilers;
27
+ isSkipLibs: boolean;
27
28
  backend: {
28
29
  fileManager: SourceFileManager;
29
30
  compilerHost: ts.CompilerHost;
@@ -33,7 +34,7 @@ export declare class ProjectPrincipal {
33
34
  languageServiceHost: ts.LanguageServiceHost;
34
35
  };
35
36
  findReferences?: ts.LanguageService['findReferences'];
36
- constructor({ compilerOptions, cwd, compilers, isGitIgnored }: PrincipalOptions);
37
+ constructor({ compilerOptions, cwd, compilers, isGitIgnored, isSkipLibs }: PrincipalOptions);
37
38
  init(): void;
38
39
  addPaths(paths: ts.CompilerOptions['paths']): void;
39
40
  addCompilers(compilers: [SyncCompilers, AsyncCompilers]): void;
@@ -39,9 +39,10 @@ export class ProjectPrincipal {
39
39
  extensions;
40
40
  syncCompilers;
41
41
  asyncCompilers;
42
+ isSkipLibs;
42
43
  backend;
43
44
  findReferences;
44
- constructor({ compilerOptions, cwd, compilers, isGitIgnored }) {
45
+ constructor({ compilerOptions, cwd, compilers, isGitIgnored, isSkipLibs }) {
45
46
  this.cwd = cwd;
46
47
  this.isGitIgnored = isGitIgnored;
47
48
  this.compilerOptions = {
@@ -54,6 +55,7 @@ export class ProjectPrincipal {
54
55
  this.extensions = new Set([...DEFAULT_EXTENSIONS, ...getCompilerExtensions(compilers)]);
55
56
  this.syncCompilers = syncCompilers;
56
57
  this.asyncCompilers = asyncCompilers;
58
+ this.isSkipLibs = isSkipLibs;
57
59
  }
58
60
  init() {
59
61
  this.addCompilers([dummyCompilers, new Map()]);
@@ -62,6 +64,7 @@ export class ProjectPrincipal {
62
64
  compilerOptions: this.compilerOptions,
63
65
  entryPaths: this.entryPaths,
64
66
  compilers: [this.syncCompilers, this.asyncCompilers],
67
+ isSkipLibs: this.isSkipLibs,
65
68
  });
66
69
  this.backend = {
67
70
  fileManager,
@@ -27,7 +27,7 @@ export declare class WorkspaceWorker {
27
27
  isStrict: boolean;
28
28
  rootIgnore: Configuration['ignore'];
29
29
  negatedWorkspacePatterns: string[];
30
- enabledPluginsMap: Record<"typescript" | "astro" | "svelte" | "vue" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "netlify" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "tsup" | "typedoc" | "unbuild" | "vite" | "vitest" | "webpack" | "wireit" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "vercelOg", boolean>;
30
+ enabledPluginsMap: Record<"typescript" | "astro" | "svelte" | "vue" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "msw" | "netlify" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "tsup" | "typedoc" | "unbuild" | "vite" | "vitest" | "webpack" | "wireit" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "vercelOg", boolean>;
31
31
  enabledPlugins: PluginName[];
32
32
  enabledPluginsInAncestors: string[];
33
33
  constructor({ name, dir, cwd, config, manifest, dependencies, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, enabledPluginsInAncestors, }: WorkspaceManagerOptions);
@@ -46,7 +46,7 @@ export declare class WorkspaceWorker {
46
46
  entryFilePatterns: Set<string>;
47
47
  productionEntryFilePatterns: Set<string>;
48
48
  referencedDependencies: ReferencedDependencies;
49
- enabledPlugins: ("typescript" | "astro" | "svelte" | "vue" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "netlify" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "tsup" | "typedoc" | "unbuild" | "vite" | "vitest" | "webpack" | "wireit" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "vercelOg")[];
49
+ enabledPlugins: ("typescript" | "astro" | "svelte" | "vue" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "msw" | "netlify" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "tsup" | "typedoc" | "unbuild" | "vite" | "vitest" | "webpack" | "wireit" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "vercelOg")[];
50
50
  }>;
51
51
  }
52
52
  export {};
@@ -15,7 +15,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
15
15
  ignore?: string | string[] | undefined;
16
16
  ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "interface" | "enum" | "class" | "member", boolean>> | undefined;
17
17
  includeEntryExports?: boolean | undefined;
18
- compilers?: Record<string, ((args_0: string, ...args_1: unknown[]) => string) | ((args_0: string, ...args_1: unknown[]) => Promise<string>)> | undefined;
18
+ compilers?: Record<string, ((args_0: string, args_1: string, ...args_2: unknown[]) => string) | ((args_0: string, args_1: string, ...args_2: unknown[]) => Promise<string>)> | undefined;
19
19
  include?: ("files" | "dependencies" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "exports" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
20
20
  workspaces?: Record<string, {
21
21
  ignoreBinaries?: (string | RegExp)[] | undefined;
@@ -135,6 +135,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
135
135
  entry?: string | string[] | undefined;
136
136
  project?: string | string[] | undefined;
137
137
  } | undefined;
138
+ msw?: string | boolean | string[] | {
139
+ config?: string | string[] | undefined;
140
+ entry?: string | string[] | undefined;
141
+ project?: string | string[] | undefined;
142
+ } | undefined;
138
143
  netlify?: string | boolean | string[] | {
139
144
  config?: string | string[] | undefined;
140
145
  entry?: string | string[] | undefined;
@@ -406,6 +411,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
406
411
  entry?: string | string[] | undefined;
407
412
  project?: string | string[] | undefined;
408
413
  } | undefined;
414
+ msw?: string | boolean | string[] | {
415
+ config?: string | string[] | undefined;
416
+ entry?: string | string[] | undefined;
417
+ project?: string | string[] | undefined;
418
+ } | undefined;
409
419
  netlify?: string | boolean | string[] | {
410
420
  config?: string | string[] | undefined;
411
421
  entry?: string | string[] | undefined;
package/dist/index.js CHANGED
@@ -112,6 +112,7 @@ export const main = async (unresolvedConfiguration) => {
112
112
  pkgName,
113
113
  isGitIgnored,
114
114
  isIsolateWorkspaces,
115
+ isSkipLibs: !isReportClassMembers,
115
116
  });
116
117
  const worker = new WorkspaceWorker({
117
118
  name,
@@ -20,7 +20,7 @@ const findPluginDependencies = async (configFilePath, options) => {
20
20
  const localConfig = basename(configFilePath) === 'package.json' ? manifest[PACKAGE_JSON_PATH] : await load(configFilePath);
21
21
  if (!localConfig)
22
22
  return [];
23
- const generateSet = Object.values(localConfig.generates);
23
+ const generateSet = localConfig.generates ? Object.values(localConfig.generates) : [];
24
24
  const configurationOutput = generateSet.filter(isConfigurationOutput);
25
25
  const presets = configurationOutput
26
26
  .map(configOutput => (configOutput.preset ? configOutput.preset : undefined))
@@ -21,6 +21,7 @@ export { default as lintStaged } from './lint-staged/index.js';
21
21
  export { default as linthtml } from './linthtml/index.js';
22
22
  export { default as markdownlint } from './markdownlint/index.js';
23
23
  export { default as mocha } from './mocha/index.js';
24
+ export { default as msw } from './msw/index.js';
24
25
  export { default as netlify } from './netlify/index.js';
25
26
  export { default as next } from './next/index.js';
26
27
  export { default as nodeTestRunner } from './node-test-runner/index.js';
@@ -21,6 +21,7 @@ export { default as lintStaged } from './lint-staged/index.js';
21
21
  export { default as linthtml } from './linthtml/index.js';
22
22
  export { default as markdownlint } from './markdownlint/index.js';
23
23
  export { default as mocha } from './mocha/index.js';
24
+ export { default as msw } from './msw/index.js';
24
25
  export { default as netlify } from './netlify/index.js';
25
26
  export { default as next } from './next/index.js';
26
27
  export { default as nodeTestRunner } from './node-test-runner/index.js';
@@ -0,0 +1,10 @@
1
+ import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
+ declare const _default: {
3
+ NAME: string;
4
+ ENABLERS: string[];
5
+ isEnabled: IsPluginEnabledCallback;
6
+ CONFIG_FILE_PATTERNS: string[];
7
+ ENTRY_FILE_PATTERNS: string[];
8
+ findDependencies: GenericPluginCallback;
9
+ };
10
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import { join } from '../../util/path.js';
2
+ import { basename } from '../../util/path.js';
3
+ import { hasDependency } from '../../util/plugin.js';
4
+ import { toEntryPattern } from '../../util/protocols.js';
5
+ const NAME = 'Mock Service Worker';
6
+ const ENABLERS = ['msw'];
7
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
+ const CONFIG_FILE_PATTERNS = ['package.json'];
9
+ const ENTRY_FILE_PATTERNS = ['mockServiceWorker.js'];
10
+ const findDependencies = async (configFilePath, options) => {
11
+ const { manifest } = options;
12
+ const localConfig = basename(configFilePath) === 'package.json' ? manifest.msw : undefined;
13
+ const workerDirectory = localConfig?.workerDirectory ?? '.';
14
+ return ENTRY_FILE_PATTERNS.map(pattern => toEntryPattern(join(workerDirectory, pattern)));
15
+ };
16
+ export default {
17
+ NAME,
18
+ ENABLERS,
19
+ isEnabled,
20
+ CONFIG_FILE_PATTERNS,
21
+ ENTRY_FILE_PATTERNS,
22
+ findDependencies,
23
+ };
@@ -0,0 +1,3 @@
1
+ export interface MSWConfig {
2
+ workerDirectory?: string;
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -8,8 +8,7 @@ const productionEntryFilePatternsWithoutSrc = [
8
8
  '{instrumentation,middleware}.{js,ts}',
9
9
  'app/global-error.{js,jsx,ts,tsx}',
10
10
  'app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
11
- 'app/**/route.{js,ts}',
12
- 'app/**/default.{js,jsx,ts,tsx}',
11
+ 'app/**/{route,default}.{js,ts}',
13
12
  'app/{manifest,sitemap,robots}.{js,ts}',
14
13
  'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
15
14
  'app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
@@ -1,13 +1,19 @@
1
1
  import ts from 'typescript';
2
2
  import type { SyncCompilers, AsyncCompilers } from '../compilers/types.js';
3
+ interface SourceFileManagerOptions {
4
+ isSkipLibs: boolean;
5
+ compilers: [SyncCompilers, AsyncCompilers];
6
+ }
3
7
  export declare class SourceFileManager {
8
+ isSkipLibs: boolean;
4
9
  sourceFileCache: Map<string, ts.SourceFile | undefined>;
5
10
  snapshotCache: Map<string, ts.IScriptSnapshot | undefined>;
6
- syncCompilers?: SyncCompilers;
7
- asyncCompilers?: AsyncCompilers;
8
- installCompilers(compilers: [SyncCompilers, AsyncCompilers]): void;
11
+ syncCompilers: SyncCompilers;
12
+ asyncCompilers: AsyncCompilers;
13
+ constructor({ compilers, isSkipLibs }: SourceFileManagerOptions);
9
14
  createSourceFile(filePath: string, contents: string): ts.SourceFile;
10
15
  getSourceFile(filePath: string): ts.SourceFile | undefined;
11
16
  getSnapshot(filePath: string): ts.IScriptSnapshot | undefined;
12
17
  compileAndAddSourceFile(filePath: string): Promise<void>;
13
18
  }
19
+ export {};
@@ -1,12 +1,14 @@
1
1
  import ts from 'typescript';
2
2
  import { debugLog } from '../util/debug.js';
3
- import { extname, isInternal } from '../util/path.js';
3
+ import { extname, isInNodeModules, isInternal } from '../util/path.js';
4
4
  export class SourceFileManager {
5
+ isSkipLibs;
5
6
  sourceFileCache = new Map();
6
7
  snapshotCache = new Map();
7
8
  syncCompilers;
8
9
  asyncCompilers;
9
- installCompilers(compilers) {
10
+ constructor({ compilers, isSkipLibs }) {
11
+ this.isSkipLibs = isSkipLibs;
10
12
  this.syncCompilers = compilers[0];
11
13
  this.asyncCompilers = compilers[1];
12
14
  }
@@ -17,6 +19,8 @@ export class SourceFileManager {
17
19
  return sourceFile;
18
20
  }
19
21
  getSourceFile(filePath) {
22
+ if (this.isSkipLibs && isInNodeModules(filePath))
23
+ return undefined;
20
24
  if (this.sourceFileCache.has(filePath))
21
25
  return this.sourceFileCache.get(filePath);
22
26
  const contents = ts.sys.readFile(filePath);
@@ -6,8 +6,9 @@ type CreateHostsOptions = {
6
6
  compilerOptions: ts.CompilerOptions;
7
7
  entryPaths: Set<string>;
8
8
  compilers: [SyncCompilers, AsyncCompilers];
9
+ isSkipLibs: boolean;
9
10
  };
10
- export declare const createHosts: ({ cwd, compilerOptions, entryPaths, compilers }: CreateHostsOptions) => {
11
+ export declare const createHosts: ({ cwd, compilerOptions, entryPaths, compilers, isSkipLibs }: CreateHostsOptions) => {
11
12
  fileManager: SourceFileManager;
12
13
  compilerHost: ts.CompilerHost;
13
14
  resolveModuleNames: (moduleNames: string[], containingFile: string) => (ts.ResolvedModuleFull | undefined)[];
@@ -6,9 +6,8 @@ import { createCustomModuleResolver } from './resolveModuleNames.js';
6
6
  import { SourceFileManager } from './SourceFileManager.js';
7
7
  import { createCustomSys } from './sys.js';
8
8
  const libLocation = path.dirname(ts.getDefaultLibFilePath({}));
9
- const fileManager = new SourceFileManager();
10
- export const createHosts = ({ cwd, compilerOptions, entryPaths, compilers }) => {
11
- fileManager.installCompilers(compilers);
9
+ export const createHosts = ({ cwd, compilerOptions, entryPaths, compilers, isSkipLibs }) => {
10
+ const fileManager = new SourceFileManager({ compilers, isSkipLibs });
12
11
  const virtualFileExtensions = getCompilerExtensions(compilers);
13
12
  const sys = createCustomSys(cwd, virtualFileExtensions);
14
13
  const resolveModuleNames = createCustomModuleResolver(sys, compilerOptions, virtualFileExtensions);
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
2
2
  import { isBuiltin } from 'node:module';
3
3
  import ts from 'typescript';
4
4
  import { sanitizeSpecifier } from '../util/modules.js';
5
- import { basename, dirname, extname, format, isAbsolute, isInternal, join } from '../util/path.js';
5
+ import { basename, dirname, extname, format, isAbsolute, isInNodeModules, isInternal, join } from '../util/path.js';
6
6
  import { isDeclarationFileExtension } from './ast-helpers.js';
7
7
  import { ensureRealFilePath, isVirtualFilePath } from './utils.js';
8
8
  const resolutionCache = new Map();
@@ -17,22 +17,22 @@ const fileExists = (name, containingFile) => {
17
17
  };
18
18
  }
19
19
  };
20
- const DECLARATION_EXTENSIONS_MAP = {
20
+ const DTS_EXTENSIONS_MAP = {
21
21
  [ts.Extension.Dts]: ts.Extension.Js,
22
22
  [ts.Extension.Dmts]: ts.Extension.Mjs,
23
23
  [ts.Extension.Dcts]: ts.Extension.Cjs,
24
24
  };
25
- const jsMatchingDeclarationFileExists = (resolveDtsFileName, declarationFileExtension) => {
26
- const mappedExtension = DECLARATION_EXTENSIONS_MAP[declarationFileExtension];
25
+ const jsMatchingDeclarationFileExists = (resolveDtsFileName, dtsExtension) => {
26
+ const extension = DTS_EXTENSIONS_MAP[dtsExtension];
27
27
  const resolvedFileName = format({
28
- ext: mappedExtension,
28
+ ext: extension,
29
29
  dir: dirname(resolveDtsFileName),
30
- name: basename(resolveDtsFileName, declarationFileExtension),
30
+ name: basename(resolveDtsFileName, dtsExtension),
31
31
  });
32
32
  if (existsSync(resolvedFileName)) {
33
33
  return {
34
34
  resolvedFileName,
35
- extension: mappedExtension,
35
+ extension,
36
36
  isExternalLibraryImport: false,
37
37
  resolvedUsingTsExtension: false,
38
38
  };
@@ -55,6 +55,8 @@ export function createCustomModuleResolver(customSys, compilerOptions, virtualFi
55
55
  const sanitizedSpecifier = sanitizeSpecifier(name);
56
56
  if (isBuiltin(sanitizedSpecifier))
57
57
  return undefined;
58
+ if (isInNodeModules(name))
59
+ return undefined;
58
60
  const tsResolvedModule = ts.resolveModuleName(sanitizedSpecifier, containingFile, compilerOptions, ts.sys).resolvedModule;
59
61
  if (!tsResolvedModule) {
60
62
  const extension = extname(sanitizedSpecifier);
@@ -65,7 +67,7 @@ export function createCustomModuleResolver(customSys, compilerOptions, virtualFi
65
67
  }
66
68
  }
67
69
  if (tsResolvedModule &&
68
- isDeclarationFileExtension(tsResolvedModule?.extension) &&
70
+ isDeclarationFileExtension(tsResolvedModule.extension) &&
69
71
  isInternal(tsResolvedModule.resolvedFileName)) {
70
72
  {
71
73
  const module = jsMatchingDeclarationFileExists(tsResolvedModule.resolvedFileName, tsResolvedModule.extension);
@@ -19,7 +19,7 @@ export default visit(() => true, node => {
19
19
  const callExpression = node.parent.parent;
20
20
  if (ts.isCallExpression(callExpression) && ts.isFunctionLike(callExpression.arguments[0])) {
21
21
  const arg = callExpression.arguments[0].parameters[0];
22
- if (ts.isIdentifier(arg.name)) {
22
+ if (arg && ts.isIdentifier(arg.name)) {
23
23
  const argName = arg.name.escapedText;
24
24
  const accessExpressions = findDescendants(callExpression.arguments[0].body, ts.isPropertyAccessExpression).filter(binding => binding.expression.getText() === argName);
25
25
  if (accessExpressions.length > 0) {
package/dist/util/fs.d.ts CHANGED
@@ -6,6 +6,6 @@ export declare const loadJSON: (filePath: string) => Promise<any>;
6
6
  export declare const loadYAML: (filePath: string) => Promise<unknown>;
7
7
  export declare const loadTOML: (filePath: string) => Promise<Record<string, import("smol-toml").TomlPrimitive>>;
8
8
  export declare const parseJSON: (filePath: string, contents: string) => Promise<any>;
9
- export declare const parseYAML: (contents: string) => Promise<unknown>;
9
+ export declare const parseYAML: (contents: string) => unknown;
10
10
  export declare function isTypeModule(path: string): boolean;
11
11
  export declare const _loadJSON: (filePath: string) => Promise<any>;
package/dist/util/fs.js CHANGED
@@ -50,7 +50,7 @@ export const parseJSON = async (filePath, contents) => {
50
50
  throw new LoaderError(`Error parsing ${filePath}`, { cause: error });
51
51
  }
52
52
  };
53
- export const parseYAML = async (contents) => {
53
+ export const parseYAML = (contents) => {
54
54
  return yaml.load(contents);
55
55
  };
56
56
  export function isTypeModule(path) {
@@ -13,16 +13,25 @@ const load = async (filePath) => {
13
13
  const ext = extname(filePath);
14
14
  if (filePath.endsWith('rc')) {
15
15
  const contents = await loadFile(filePath);
16
- return parseYAML(contents).catch(() => parseJSON(filePath, contents));
16
+ try {
17
+ return parseYAML(contents);
18
+ }
19
+ catch {
20
+ return parseJSON(filePath, contents);
21
+ }
22
+ }
23
+ if (ext === '.yaml' || ext === '.yml') {
24
+ return await loadYAML(filePath);
17
25
  }
18
26
  if (ext === '.json' || ext === '.jsonc') {
19
- return loadJSON(filePath);
27
+ return await loadJSON(filePath);
20
28
  }
21
- if (ext === '.yaml' || ext === '.yml') {
22
- return loadYAML(filePath);
29
+ if (typeof Bun !== 'undefined') {
30
+ const imported = await import(filePath);
31
+ return imported.default ?? imported;
23
32
  }
24
33
  if (ext === '.toml') {
25
- return loadTOML(filePath);
34
+ return await loadTOML(filePath);
26
35
  }
27
36
  if (ext === '.mjs' || (ext === '.js' && isTypeModule(filePath))) {
28
37
  const fileUrl = pathToFileURL(filePath);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.0.4";
1
+ export declare const version = "5.1.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.0.4';
1
+ export const version = '5.1.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.0.4",
3
+ "version": "5.1.1",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
@@ -86,6 +86,7 @@
86
86
  "@release-it/bumper": "^6.0.1",
87
87
  "@swc/cli": "^0.3.10",
88
88
  "@swc/core": "^1.4.6",
89
+ "@types/bun": "1.0.8",
89
90
  "@types/js-yaml": "^4.0.9",
90
91
  "@types/micromatch": "^4.0.6",
91
92
  "@types/minimist": "^1.2.5",
package/schema.json CHANGED
@@ -358,6 +358,10 @@
358
358
  "title": "Mocha plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/mocha/README.md)",
359
359
  "$ref": "#/definitions/plugin"
360
360
  },
361
+ "msw": {
362
+ "title": "Mocha plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/msw/README.md)",
363
+ "$ref": "#/definitions/plugin"
364
+ },
361
365
  "netlify": {
362
366
  "title": "Netlify plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/netlify/README.md)",
363
367
  "$ref": "#/definitions/plugin"