knip 3.8.2 → 3.8.4

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.
@@ -517,6 +517,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
517
517
  entry?: string | string[] | undefined;
518
518
  project?: string | string[] | undefined;
519
519
  }>]>>;
520
+ svelte: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
521
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
522
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
523
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
524
+ }, "strip", z.ZodTypeAny, {
525
+ config?: string | string[] | undefined;
526
+ entry?: string | string[] | undefined;
527
+ project?: string | string[] | undefined;
528
+ }, {
529
+ config?: string | string[] | undefined;
530
+ entry?: string | string[] | undefined;
531
+ project?: string | string[] | undefined;
532
+ }>]>>;
520
533
  tailwind: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
521
534
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
522
535
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -801,6 +814,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
801
814
  entry?: string | string[] | undefined;
802
815
  project?: string | string[] | undefined;
803
816
  } | undefined;
817
+ svelte?: string | boolean | string[] | {
818
+ config?: string | string[] | undefined;
819
+ entry?: string | string[] | undefined;
820
+ project?: string | string[] | undefined;
821
+ } | undefined;
804
822
  tailwind?: string | boolean | string[] | {
805
823
  config?: string | string[] | undefined;
806
824
  entry?: string | string[] | undefined;
@@ -1029,6 +1047,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
1029
1047
  entry?: string | string[] | undefined;
1030
1048
  project?: string | string[] | undefined;
1031
1049
  } | undefined;
1050
+ svelte?: string | boolean | string[] | {
1051
+ config?: string | string[] | undefined;
1052
+ entry?: string | string[] | undefined;
1053
+ project?: string | string[] | undefined;
1054
+ } | undefined;
1032
1055
  tailwind?: string | boolean | string[] | {
1033
1056
  config?: string | string[] | undefined;
1034
1057
  entry?: string | string[] | undefined;
@@ -1546,6 +1569,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
1546
1569
  entry?: string | string[] | undefined;
1547
1570
  project?: string | string[] | undefined;
1548
1571
  }>]>>;
1572
+ svelte: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
1573
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1574
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1575
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1576
+ }, "strip", z.ZodTypeAny, {
1577
+ config?: string | string[] | undefined;
1578
+ entry?: string | string[] | undefined;
1579
+ project?: string | string[] | undefined;
1580
+ }, {
1581
+ config?: string | string[] | undefined;
1582
+ entry?: string | string[] | undefined;
1583
+ project?: string | string[] | undefined;
1584
+ }>]>>;
1549
1585
  tailwind: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
1550
1586
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1551
1587
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -1846,6 +1882,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
1846
1882
  entry?: string | string[] | undefined;
1847
1883
  project?: string | string[] | undefined;
1848
1884
  } | undefined;
1885
+ svelte?: string | boolean | string[] | {
1886
+ config?: string | string[] | undefined;
1887
+ entry?: string | string[] | undefined;
1888
+ project?: string | string[] | undefined;
1889
+ } | undefined;
1849
1890
  tailwind?: string | boolean | string[] | {
1850
1891
  config?: string | string[] | undefined;
1851
1892
  entry?: string | string[] | undefined;
@@ -2067,6 +2108,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2067
2108
  entry?: string | string[] | undefined;
2068
2109
  project?: string | string[] | undefined;
2069
2110
  } | undefined;
2111
+ svelte?: string | boolean | string[] | {
2112
+ config?: string | string[] | undefined;
2113
+ entry?: string | string[] | undefined;
2114
+ project?: string | string[] | undefined;
2115
+ } | undefined;
2070
2116
  tailwind?: string | boolean | string[] | {
2071
2117
  config?: string | string[] | undefined;
2072
2118
  entry?: string | string[] | undefined;
@@ -2311,6 +2357,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2311
2357
  entry?: string | string[] | undefined;
2312
2358
  project?: string | string[] | undefined;
2313
2359
  } | undefined;
2360
+ svelte?: string | boolean | string[] | {
2361
+ config?: string | string[] | undefined;
2362
+ entry?: string | string[] | undefined;
2363
+ project?: string | string[] | undefined;
2364
+ } | undefined;
2314
2365
  tailwind?: string | boolean | string[] | {
2315
2366
  config?: string | string[] | undefined;
2316
2367
  entry?: string | string[] | undefined;
@@ -2532,6 +2583,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2532
2583
  entry?: string | string[] | undefined;
2533
2584
  project?: string | string[] | undefined;
2534
2585
  } | undefined;
2586
+ svelte?: string | boolean | string[] | {
2587
+ config?: string | string[] | undefined;
2588
+ entry?: string | string[] | undefined;
2589
+ project?: string | string[] | undefined;
2590
+ } | undefined;
2535
2591
  tailwind?: string | boolean | string[] | {
2536
2592
  config?: string | string[] | undefined;
2537
2593
  entry?: string | string[] | undefined;
@@ -99,6 +99,7 @@ const pluginsSchema = z.object({
99
99
  storybook: pluginSchema,
100
100
  stryker: pluginSchema,
101
101
  stylelint: pluginSchema,
102
+ svelte: pluginSchema,
102
103
  tailwind: pluginSchema,
103
104
  tsup: pluginSchema,
104
105
  typedoc: pluginSchema,
@@ -275,7 +275,7 @@ export class DependencyDeputy {
275
275
  return true;
276
276
  const isReferenced = hasMatchInSet(referencedDependencies, packageName);
277
277
  const isListed = hasMatchInArray(dependencies, packageName) && !hasMatchInArray(peerDependencies, packageName);
278
- return (isListed && isReferenced) || (!isReferenced && !isListed);
278
+ return (isListed && isReferenced) || (!this.isProduction && !isReferenced && !isListed);
279
279
  })
280
280
  .forEach(identifier => {
281
281
  configurationHints.add({ workspaceName, identifier, type: 'ignoreDependencies' });
@@ -288,7 +288,7 @@ export class DependencyDeputy {
288
288
  return true;
289
289
  const isReferenced = hasMatchInSet(referencedBinaries, binaryName);
290
290
  const isInstalled = hasMatchInArray(Array.from(installedBinaries?.keys() ?? []), binaryName);
291
- return (isReferenced && isInstalled) || (!isInstalled && !isReferenced);
291
+ return (isReferenced && isInstalled) || (!this.isProduction && !isInstalled && !isReferenced);
292
292
  })
293
293
  .forEach(identifier => configurationHints.add({ workspaceName, identifier, type: 'ignoreBinaries' }));
294
294
  }
@@ -298,15 +298,6 @@ export class DependencyDeputy {
298
298
  ...this.getDevDependencies(ROOT_WORKSPACE_NAME),
299
299
  ];
300
300
  const peerDependencies = this.getPeerDependencies(ROOT_WORKSPACE_NAME);
301
- Array.from(rootIgnoreBinaries.keys())
302
- .filter(binaryName => {
303
- if (hasMatchInArray(IGNORED_GLOBAL_BINARIES, binaryName))
304
- return true;
305
- const isReferenced = rootIgnoreBinaries.get(binaryName) !== 0;
306
- const isInstalled = hasMatchInArray(Array.from(installedBinaries?.keys() ?? []), binaryName);
307
- return (isReferenced && isInstalled) || (!this.isProduction && !isReferenced && !isInstalled);
308
- })
309
- .forEach(identifier => configurationHints.add({ workspaceName: ROOT_WORKSPACE_NAME, identifier, type: 'ignoreBinaries' }));
310
301
  Array.from(rootIgnoreDependencies.keys())
311
302
  .filter(packageName => {
312
303
  if (hasMatchInArray(IGNORED_DEPENDENCIES, packageName))
@@ -316,6 +307,15 @@ export class DependencyDeputy {
316
307
  return (isReferenced && isListed) || (!this.isProduction && !isReferenced && !isListed);
317
308
  })
318
309
  .forEach(identifier => configurationHints.add({ workspaceName: ROOT_WORKSPACE_NAME, identifier, type: 'ignoreDependencies' }));
310
+ Array.from(rootIgnoreBinaries.keys())
311
+ .filter(binaryName => {
312
+ if (hasMatchInArray(IGNORED_GLOBAL_BINARIES, binaryName))
313
+ return true;
314
+ const isReferenced = rootIgnoreBinaries.get(binaryName) !== 0;
315
+ const isInstalled = hasMatchInArray(Array.from(installedBinaries?.keys() ?? []), binaryName);
316
+ return (isReferenced && isInstalled) || (!this.isProduction && !isReferenced && !isInstalled);
317
+ })
318
+ .forEach(identifier => configurationHints.add({ workspaceName: ROOT_WORKSPACE_NAME, identifier, type: 'ignoreBinaries' }));
319
319
  return { configurationHints };
320
320
  }
321
321
  }
@@ -52,7 +52,7 @@ export declare class WorkspaceWorker {
52
52
  installedBinaries: InstalledBinaries;
53
53
  referencedDependencies: ReferencedDependencies;
54
54
  hasTypesIncluded: Set<string>;
55
- enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "tsup" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "svelte")[];
55
+ enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "tailwind" | "tsup" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease")[];
56
56
  entryFilePatterns: string[];
57
57
  productionEntryFilePatterns: string[];
58
58
  }>;
package/dist/index.js CHANGED
@@ -194,8 +194,8 @@ export const main = async (unresolvedConfiguration) => {
194
194
  if (workspace) {
195
195
  const { imports, exports, scripts } = _principal.analyzeSourceFile(filePath, {
196
196
  skipTypeOnly: isStrict,
197
- isFixExports: fixer.isFixUnusedExports,
198
- isFixTypes: fixer.isFixUnusedTypes,
197
+ isFixExports: fixer.isEnabled && fixer.isFixUnusedExports,
198
+ isFixTypes: fixer.isEnabled && fixer.isFixUnusedTypes,
199
199
  });
200
200
  const { internal, external, unresolved } = imports;
201
201
  const { exported, duplicate } = exports;
@@ -7,6 +7,7 @@ export const ENTRY_FILE_PATTERNS = ['next.config.{js,ts,cjs,mjs}'];
7
7
  const productionEntryFilePatternsWithoutSrc = [
8
8
  'middleware.{js,ts}',
9
9
  'app/**/route.{js,ts}',
10
+ 'app/global-error.{js,jsx,ts,tsx}',
10
11
  'app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
11
12
  'instrumentation.{js,ts}',
12
13
  'app/{manifest,sitemap,robots}.{js,ts}',
@@ -12,7 +12,10 @@ export const PRODUCTION_ENTRY_FILE_PATTERNS = [
12
12
  'src/params/*{js,ts}',
13
13
  ];
14
14
  export const PROJECT_FILE_PATTERNS = ['src/**/*.{js,ts,svelte}'];
15
- const findSvelteDependencies = async () => {
16
- return [...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern), ...ENTRY_FILE_PATTERNS.map(toEntryPattern)];
15
+ const findSvelteDependencies = async (configFilePath, options) => {
16
+ const { config } = options;
17
+ return config.entry
18
+ ? config.entry.map(toProductionEntryPattern)
19
+ : [...ENTRY_FILE_PATTERNS.map(toEntryPattern), ...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern)];
17
20
  };
18
21
  export const findDependencies = timerify(findSvelteDependencies);
@@ -209,6 +209,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
209
209
  entry?: string | string[] | undefined;
210
210
  project?: string | string[] | undefined;
211
211
  } | undefined;
212
+ svelte?: string | boolean | string[] | {
213
+ config?: string | string[] | undefined;
214
+ entry?: string | string[] | undefined;
215
+ project?: string | string[] | undefined;
216
+ } | undefined;
212
217
  tailwind?: string | boolean | string[] | {
213
218
  config?: string | string[] | undefined;
214
219
  entry?: string | string[] | undefined;
@@ -430,6 +435,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
430
435
  entry?: string | string[] | undefined;
431
436
  project?: string | string[] | undefined;
432
437
  } | undefined;
438
+ svelte?: string | boolean | string[] | {
439
+ config?: string | string[] | undefined;
440
+ entry?: string | string[] | undefined;
441
+ project?: string | string[] | undefined;
442
+ } | undefined;
433
443
  tailwind?: string | boolean | string[] | {
434
444
  config?: string | string[] | undefined;
435
445
  entry?: string | string[] | undefined;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "3.8.2";
1
+ export declare const version = "3.8.4";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '3.8.2';
1
+ export const version = '3.8.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "3.8.2",
3
+ "version": "3.8.4",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
@@ -83,7 +83,7 @@
83
83
  "@knip/eslint-config": "0.0.0",
84
84
  "@release-it/bumper": "^6.0.1",
85
85
  "@swc/cli": "^0.1.63",
86
- "@swc/core": "^1.3.100",
86
+ "@swc/core": "^1.3.101",
87
87
  "@types/js-yaml": "^4.0.9",
88
88
  "@types/micromatch": "^4.0.6",
89
89
  "@types/minimist": "^1.2.5",
@@ -92,11 +92,11 @@
92
92
  "@types/pkgjs__parseargs": "^0.10.3",
93
93
  "@types/webpack": "^5.28.5",
94
94
  "c8": "8.0.1",
95
- "eslint": "^8.55.0",
95
+ "eslint": "^8.56.0",
96
96
  "playwright": "^1.40.1",
97
97
  "prettier": "^3.1.1",
98
98
  "release-it": "^17.0.1",
99
- "tsx": "^4.6.2",
99
+ "tsx": "^4.7.0",
100
100
  "type-fest": "^4.8.3",
101
101
  "typescript": "5.3.3"
102
102
  },