knip 3.12.0 → 3.13.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.
@@ -621,6 +621,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
621
621
  entry?: string | string[] | undefined;
622
622
  project?: string | string[] | undefined;
623
623
  }>]>>;
624
+ unbuild: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
625
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
626
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
627
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
628
+ }, "strip", z.ZodTypeAny, {
629
+ config?: string | string[] | undefined;
630
+ entry?: string | string[] | undefined;
631
+ project?: string | string[] | undefined;
632
+ }, {
633
+ config?: string | string[] | undefined;
634
+ entry?: string | string[] | undefined;
635
+ project?: string | string[] | undefined;
636
+ }>]>>;
624
637
  vite: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
625
638
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
626
639
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -906,6 +919,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
906
919
  entry?: string | string[] | undefined;
907
920
  project?: string | string[] | undefined;
908
921
  } | undefined;
922
+ unbuild?: string | boolean | string[] | {
923
+ config?: string | string[] | undefined;
924
+ entry?: string | string[] | undefined;
925
+ project?: string | string[] | undefined;
926
+ } | undefined;
909
927
  vite?: string | boolean | string[] | {
910
928
  config?: string | string[] | undefined;
911
929
  entry?: string | string[] | undefined;
@@ -1159,6 +1177,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
1159
1177
  entry?: string | string[] | undefined;
1160
1178
  project?: string | string[] | undefined;
1161
1179
  } | undefined;
1180
+ unbuild?: string | boolean | string[] | {
1181
+ config?: string | string[] | undefined;
1182
+ entry?: string | string[] | undefined;
1183
+ project?: string | string[] | undefined;
1184
+ } | undefined;
1162
1185
  vite?: string | boolean | string[] | {
1163
1186
  config?: string | string[] | undefined;
1164
1187
  entry?: string | string[] | undefined;
@@ -1765,6 +1788,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
1765
1788
  entry?: string | string[] | undefined;
1766
1789
  project?: string | string[] | undefined;
1767
1790
  }>]>>;
1791
+ unbuild: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
1792
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1793
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1794
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1795
+ }, "strip", z.ZodTypeAny, {
1796
+ config?: string | string[] | undefined;
1797
+ entry?: string | string[] | undefined;
1798
+ project?: string | string[] | undefined;
1799
+ }, {
1800
+ config?: string | string[] | undefined;
1801
+ entry?: string | string[] | undefined;
1802
+ project?: string | string[] | undefined;
1803
+ }>]>>;
1768
1804
  vite: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
1769
1805
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1770
1806
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -2066,6 +2102,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2066
2102
  entry?: string | string[] | undefined;
2067
2103
  project?: string | string[] | undefined;
2068
2104
  } | undefined;
2105
+ unbuild?: string | boolean | string[] | {
2106
+ config?: string | string[] | undefined;
2107
+ entry?: string | string[] | undefined;
2108
+ project?: string | string[] | undefined;
2109
+ } | undefined;
2069
2110
  vite?: string | boolean | string[] | {
2070
2111
  config?: string | string[] | undefined;
2071
2112
  entry?: string | string[] | undefined;
@@ -2312,6 +2353,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2312
2353
  entry?: string | string[] | undefined;
2313
2354
  project?: string | string[] | undefined;
2314
2355
  } | undefined;
2356
+ unbuild?: string | boolean | string[] | {
2357
+ config?: string | string[] | undefined;
2358
+ entry?: string | string[] | undefined;
2359
+ project?: string | string[] | undefined;
2360
+ } | undefined;
2315
2361
  vite?: string | boolean | string[] | {
2316
2362
  config?: string | string[] | undefined;
2317
2363
  entry?: string | string[] | undefined;
@@ -2581,6 +2627,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2581
2627
  entry?: string | string[] | undefined;
2582
2628
  project?: string | string[] | undefined;
2583
2629
  } | undefined;
2630
+ unbuild?: string | boolean | string[] | {
2631
+ config?: string | string[] | undefined;
2632
+ entry?: string | string[] | undefined;
2633
+ project?: string | string[] | undefined;
2634
+ } | undefined;
2584
2635
  vite?: string | boolean | string[] | {
2585
2636
  config?: string | string[] | undefined;
2586
2637
  entry?: string | string[] | undefined;
@@ -2827,6 +2878,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2827
2878
  entry?: string | string[] | undefined;
2828
2879
  project?: string | string[] | undefined;
2829
2880
  } | undefined;
2881
+ unbuild?: string | boolean | string[] | {
2882
+ config?: string | string[] | undefined;
2883
+ entry?: string | string[] | undefined;
2884
+ project?: string | string[] | undefined;
2885
+ } | undefined;
2830
2886
  vite?: string | boolean | string[] | {
2831
2887
  config?: string | string[] | undefined;
2832
2888
  entry?: string | string[] | undefined;
@@ -107,6 +107,7 @@ const pluginsSchema = z.object({
107
107
  tsup: pluginSchema,
108
108
  typedoc: pluginSchema,
109
109
  typescript: pluginSchema,
110
+ unbuild: pluginSchema,
110
111
  vite: pluginSchema,
111
112
  vitest: pluginSchema,
112
113
  webpack: pluginSchema,
@@ -52,7 +52,7 @@ export declare class WorkspaceWorker {
52
52
  installedBinaries: InstalledBinaries;
53
53
  referencedDependencies: ReferencedDependencies;
54
54
  hasTypesIncluded: Set<string>;
55
- enabledPlugins: ("vue" | "astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "tailwind" | "tsup" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "wireit" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease")[];
55
+ enabledPlugins: ("vue" | "astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "vite" | "vitest" | "webpack" | "wireit" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease")[];
56
56
  entryFilePatterns: string[];
57
57
  productionEntryFilePatterns: string[];
58
58
  }>;
package/dist/constants.js CHANGED
@@ -29,6 +29,7 @@ export const IGNORED_GLOBAL_BINARIES = [
29
29
  'pnpm',
30
30
  'pnpx',
31
31
  'rm',
32
+ 'set',
32
33
  'sh',
33
34
  'sudo',
34
35
  'test',
@@ -1,23 +1,39 @@
1
1
  import { _firstGlob } from '../../util/glob.js';
2
2
  import { getValuesByKeyDeep } from '../../util/object.js';
3
+ import { basename, dirname, join } from '../../util/path.js';
3
4
  import { timerify } from '../../util/Performance.js';
4
5
  import { getDependenciesFromScripts, load } from '../../util/plugin.js';
6
+ function isString(value) {
7
+ return typeof value === 'string';
8
+ }
5
9
  export const NAME = 'GitHub Actions';
6
10
  export const ENABLERS = 'This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.';
7
11
  export const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.{yml,yaml}'] }));
8
12
  export const CONFIG_FILE_PATTERNS = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];
9
13
  const findGithubActionsDependencies = async (configFilePath, options) => {
10
14
  const { cwd, manifest, isProduction } = options;
15
+ const configFileName = basename(configFilePath);
11
16
  if (isProduction)
12
17
  return [];
13
18
  const config = await load(configFilePath);
14
19
  if (!config)
15
20
  return [];
16
- const scripts = getValuesByKeyDeep(config, 'run').filter((value) => typeof value === 'string');
17
- return getDependenciesFromScripts(scripts, {
18
- cwd,
19
- manifest,
20
- knownGlobalsOnly: true,
21
- });
21
+ const scripts = getValuesByKeyDeep(config, 'run').filter(isString);
22
+ return [
23
+ ...getActionDependencies(),
24
+ ...getDependenciesFromScripts(scripts, {
25
+ cwd,
26
+ manifest,
27
+ knownGlobalsOnly: true,
28
+ }),
29
+ ];
30
+ function getActionDependencies() {
31
+ const isActionManifest = configFileName === 'action.yml' || configFileName === 'action.yaml';
32
+ if (!isActionManifest || !config?.runs?.using?.startsWith('node')) {
33
+ return [];
34
+ }
35
+ const scripts = [config.runs.pre, config.runs.main, config.runs.post].filter(isString);
36
+ return scripts.map(script => join(dirname(configFilePath), script));
37
+ }
22
38
  };
23
39
  export const findDependencies = timerify(findGithubActionsDependencies);
@@ -44,6 +44,7 @@ export * as tailwind from './tailwind/index.js';
44
44
  export * as tsup from './tsup/index.js';
45
45
  export * as typedoc from './typedoc/index.js';
46
46
  export * as typescript from './typescript/index.js';
47
+ export * as unbuild from './unbuild/index.js';
47
48
  export * as vite from './vite/index.js';
48
49
  export * as vitest from './vitest/index.js';
49
50
  export * as webpack from './webpack/index.js';
@@ -44,6 +44,7 @@ export * as tailwind from './tailwind/index.js';
44
44
  export * as tsup from './tsup/index.js';
45
45
  export * as typedoc from './typedoc/index.js';
46
46
  export * as typescript from './typescript/index.js';
47
+ export * as unbuild from './unbuild/index.js';
47
48
  export * as vite from './vite/index.js';
48
49
  export * as vitest from './vitest/index.js';
49
50
  export * as webpack from './webpack/index.js';
@@ -0,0 +1,6 @@
1
+ import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "unbuild";
3
+ export declare const ENABLERS: string[];
4
+ export declare const isEnabled: IsPluginEnabledCallback;
5
+ export declare const CONFIG_FILE_PATTERNS: string[];
6
+ export declare const findDependencies: GenericPluginCallback;
@@ -0,0 +1,18 @@
1
+ import { timerify } from '../../util/Performance.js';
2
+ import { hasDependency, load } from '../../util/plugin.js';
3
+ import { toEntryPattern } from '../../util/protocols.js';
4
+ export const NAME = 'unbuild';
5
+ export const ENABLERS = ['unbuild'];
6
+ export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
+ export const CONFIG_FILE_PATTERNS = ['build.config.{js,cjs,mjs,ts,mts,cts,json}'];
8
+ const findUnbuildDependencies = async (configFilePath) => {
9
+ const localConfig = await load(configFilePath);
10
+ if (!localConfig)
11
+ return [];
12
+ return [localConfig]
13
+ .flat()
14
+ .map(obj => obj.entries)
15
+ .flatMap(entries => entries?.map(entry => (typeof entry === 'string' ? entry : entry.input)) ?? [])
16
+ .map(toEntryPattern);
17
+ };
18
+ export const findDependencies = timerify(findUnbuildDependencies);
@@ -0,0 +1,13 @@
1
+ type UnbuildConfigObject = Partial<{
2
+ name: string;
3
+ entries: string[] | {
4
+ builder: string;
5
+ input: string;
6
+ outDir: string;
7
+ }[];
8
+ outDir: string;
9
+ declaration: boolean;
10
+ rollup: Record<string, unknown>;
11
+ }>;
12
+ export type UnbuildConfig = UnbuildConfigObject | UnbuildConfigObject[];
13
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -11,7 +11,7 @@ export const CONFIG_FILE_PATTERNS = [
11
11
  'vitest*.config.{js,mjs,ts,cjs,mts,cts}',
12
12
  'vitest.{workspace,projects}.{ts,js,json}',
13
13
  ];
14
- export const ENTRY_FILE_PATTERNS = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
14
+ export const ENTRY_FILE_PATTERNS = ['**/*.{test,test-d,spec}.?(c|m)[jt]s?(x)'];
15
15
  const resolveEntry = (containingFilePath, specifier) => {
16
16
  const dir = dirname(containingFilePath);
17
17
  const resolvedPath = isAbsolute(specifier) ? specifier : tryResolve(join(dir, specifier), containingFilePath);
@@ -249,6 +249,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
249
249
  entry?: string | string[] | undefined;
250
250
  project?: string | string[] | undefined;
251
251
  } | undefined;
252
+ unbuild?: string | boolean | string[] | {
253
+ config?: string | string[] | undefined;
254
+ entry?: string | string[] | undefined;
255
+ project?: string | string[] | undefined;
256
+ } | undefined;
252
257
  vite?: string | boolean | string[] | {
253
258
  config?: string | string[] | undefined;
254
259
  entry?: string | string[] | undefined;
@@ -495,6 +500,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
495
500
  entry?: string | string[] | undefined;
496
501
  project?: string | string[] | undefined;
497
502
  } | undefined;
503
+ unbuild?: string | boolean | string[] | {
504
+ config?: string | string[] | undefined;
505
+ entry?: string | string[] | undefined;
506
+ project?: string | string[] | undefined;
507
+ } | undefined;
498
508
  vite?: string | boolean | string[] | {
499
509
  config?: string | string[] | undefined;
500
510
  entry?: string | string[] | undefined;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "3.12.0";
1
+ export declare const version = "3.13.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '3.12.0';
1
+ export const version = '3.13.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "3.12.0",
3
+ "version": "3.13.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": {
package/schema.json CHANGED
@@ -49,7 +49,9 @@
49
49
  "ignoreExportsUsedInFile": {
50
50
  "title": "Ignore exports used in file",
51
51
  "examples": [
52
- { "ignoreExportsUsedInFile": true },
52
+ {
53
+ "ignoreExportsUsedInFile": true
54
+ },
53
55
  {
54
56
  "ignoreExportsUsedInFile": {
55
57
  "interface": true,
@@ -64,12 +66,24 @@
64
66
  {
65
67
  "type": "object",
66
68
  "properties": {
67
- "class": { "type": "boolean" },
68
- "enum": { "type": "boolean" },
69
- "function": { "type": "boolean" },
70
- "interface": { "type": "boolean" },
71
- "member": { "type": "boolean" },
72
- "type": { "type": "boolean" }
69
+ "class": {
70
+ "type": "boolean"
71
+ },
72
+ "enum": {
73
+ "type": "boolean"
74
+ },
75
+ "function": {
76
+ "type": "boolean"
77
+ },
78
+ "interface": {
79
+ "type": "boolean"
80
+ },
81
+ "member": {
82
+ "type": "boolean"
83
+ },
84
+ "type": {
85
+ "type": "boolean"
86
+ }
73
87
  }
74
88
  }
75
89
  ]
@@ -96,17 +110,39 @@
96
110
  "rules": {
97
111
  "type": "object",
98
112
  "properties": {
99
- "classMembers": { "$ref": "#/definitions/ruleValue" },
100
- "dependencies": { "$ref": "#/definitions/ruleValue" },
101
- "duplicates": { "$ref": "#/definitions/ruleValue" },
102
- "enumMembers": { "$ref": "#/definitions/ruleValue" },
103
- "exports": { "$ref": "#/definitions/ruleValue" },
104
- "files": { "$ref": "#/definitions/ruleValue" },
105
- "nsExports": { "$ref": "#/definitions/ruleValue" },
106
- "nsTypes": { "$ref": "#/definitions/ruleValue" },
107
- "types": { "$ref": "#/definitions/ruleValue" },
108
- "unlisted": { "$ref": "#/definitions/ruleValue" },
109
- "unresolved": { "$ref": "#/definitions/ruleValue" }
113
+ "classMembers": {
114
+ "$ref": "#/definitions/ruleValue"
115
+ },
116
+ "dependencies": {
117
+ "$ref": "#/definitions/ruleValue"
118
+ },
119
+ "duplicates": {
120
+ "$ref": "#/definitions/ruleValue"
121
+ },
122
+ "enumMembers": {
123
+ "$ref": "#/definitions/ruleValue"
124
+ },
125
+ "exports": {
126
+ "$ref": "#/definitions/ruleValue"
127
+ },
128
+ "files": {
129
+ "$ref": "#/definitions/ruleValue"
130
+ },
131
+ "nsExports": {
132
+ "$ref": "#/definitions/ruleValue"
133
+ },
134
+ "nsTypes": {
135
+ "$ref": "#/definitions/ruleValue"
136
+ },
137
+ "types": {
138
+ "$ref": "#/definitions/ruleValue"
139
+ },
140
+ "unlisted": {
141
+ "$ref": "#/definitions/ruleValue"
142
+ },
143
+ "unresolved": {
144
+ "$ref": "#/definitions/ruleValue"
145
+ }
110
146
  }
111
147
  }
112
148
  },
@@ -414,6 +450,10 @@
414
450
  "title": "TypeScript plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/typescript/README.md)",
415
451
  "$ref": "#/definitions/plugin"
416
452
  },
453
+ "unbuild": {
454
+ "title": "unbuild plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/unbuild/README.md)",
455
+ "$ref": "#/definitions/plugin"
456
+ },
417
457
  "vite": {
418
458
  "title": "vite plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/vite/README.md)",
419
459
  "$ref": "#/definitions/plugin"