knip 3.3.1 → 3.3.2

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.
@@ -35,6 +35,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
35
35
  ignore: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
36
36
  ignoreBinaries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
37
37
  ignoreDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
38
+ includeEntryExports: z.ZodOptional<z.ZodBoolean>;
38
39
  astro: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
39
40
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
40
41
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -614,6 +615,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
614
615
  ignore?: string | string[] | undefined;
615
616
  ignoreBinaries?: string[] | undefined;
616
617
  ignoreDependencies?: string[] | undefined;
618
+ includeEntryExports?: boolean | undefined;
617
619
  astro?: string | boolean | string[] | {
618
620
  config?: string | string[] | undefined;
619
621
  entry?: string | string[] | undefined;
@@ -841,6 +843,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
841
843
  ignore?: string | string[] | undefined;
842
844
  ignoreBinaries?: string[] | undefined;
843
845
  ignoreDependencies?: string[] | undefined;
846
+ includeEntryExports?: boolean | undefined;
844
847
  astro?: string | boolean | string[] | {
845
848
  config?: string | string[] | undefined;
846
849
  entry?: string | string[] | undefined;
@@ -1657,6 +1660,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
1657
1660
  ignore?: string | string[] | undefined;
1658
1661
  ignoreBinaries?: string[] | undefined;
1659
1662
  ignoreDependencies?: string[] | undefined;
1663
+ includeEntryExports?: boolean | undefined;
1660
1664
  astro?: string | boolean | string[] | {
1661
1665
  config?: string | string[] | undefined;
1662
1666
  entry?: string | string[] | undefined;
@@ -2121,6 +2125,7 @@ export declare const ConfigurationValidator: z.ZodObject<{
2121
2125
  ignore?: string | string[] | undefined;
2122
2126
  ignoreBinaries?: string[] | undefined;
2123
2127
  ignoreDependencies?: string[] | undefined;
2128
+ includeEntryExports?: boolean | undefined;
2124
2129
  astro?: string | boolean | string[] | {
2125
2130
  config?: string | string[] | undefined;
2126
2131
  entry?: string | string[] | undefined;
@@ -113,6 +113,7 @@ const baseWorkspaceConfigurationSchema = z.object({
113
113
  ignore: globSchema.optional(),
114
114
  ignoreBinaries: z.array(z.string()).optional(),
115
115
  ignoreDependencies: z.array(z.string()).optional(),
116
+ includeEntryExports: z.boolean().optional(),
116
117
  });
117
118
  const workspaceConfigurationSchema = baseWorkspaceConfigurationSchema.merge(pluginsSchema.partial());
118
119
  const workspacesConfigurationSchema = z.object({
@@ -23,6 +23,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
23
23
  ignore?: string | string[] | undefined;
24
24
  ignoreBinaries?: string[] | undefined;
25
25
  ignoreDependencies?: string[] | undefined;
26
+ includeEntryExports?: boolean | undefined;
26
27
  astro?: string | boolean | string[] | {
27
28
  config?: string | string[] | undefined;
28
29
  entry?: string | string[] | undefined;
@@ -1,30 +1,24 @@
1
1
  import { ISSUE_TYPES } from '../constants.js';
2
2
  import { ConfigurationError } from './errors.js';
3
+ const normalize = (values) => values.map(value => value.split(',')).flat();
3
4
  export const getIncludedIssueTypes = (cliArgs, { include = [], exclude = [], isProduction = false } = {}) => {
4
- [...cliArgs.include, ...cliArgs.exclude, ...include, ...exclude].forEach(type => {
5
+ let incl = normalize(cliArgs.include);
6
+ let excl = normalize(cliArgs.exclude);
7
+ [...incl, ...excl, ...include, ...exclude].forEach(type => {
5
8
  if (!ISSUE_TYPES.includes(type))
6
9
  throw new ConfigurationError(`Invalid issue type: ${type}`);
7
10
  });
11
+ const excludes = exclude.filter(exclude => !incl.includes(exclude));
12
+ const includes = include.filter(include => !excl.includes(include));
8
13
  if (cliArgs.dependencies) {
9
- cliArgs.include = [
10
- ...cliArgs.include,
11
- 'dependencies',
12
- 'optionalPeerDependencies',
13
- 'unlisted',
14
- 'binaries',
15
- 'unresolved',
16
- ];
14
+ incl = [...incl, 'dependencies', 'optionalPeerDependencies', 'unlisted', 'binaries', 'unresolved'];
17
15
  }
18
16
  if (cliArgs.exports) {
19
17
  const exports = ['exports', 'nsExports', 'classMembers', 'types', 'nsTypes', 'enumMembers', 'duplicates'];
20
- cliArgs.include = [...cliArgs.include, ...exports];
18
+ incl = [...incl, ...exports];
21
19
  }
22
- const normalizedIncludesArg = cliArgs.include.map(value => value.split(',')).flat();
23
- const normalizedExcludesArg = cliArgs.exclude.map(value => value.split(',')).flat();
24
- const excludes = exclude.filter(exclude => !normalizedIncludesArg.includes(exclude));
25
- const includes = include.filter(include => !normalizedExcludesArg.includes(include));
26
- const _include = [normalizedIncludesArg, includes].flat();
27
- const _exclude = [normalizedExcludesArg, excludes].flat();
20
+ const _include = [...incl, ...includes];
21
+ const _exclude = [...excl, ...excludes];
28
22
  if (isProduction) {
29
23
  _exclude.push('devDependencies');
30
24
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "3.3.1";
1
+ export declare const version = "3.3.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '3.3.1';
1
+ export const version = '3.3.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
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
@@ -75,6 +75,7 @@
75
75
  ]
76
76
  },
77
77
  "includeEntryExports": {
78
+ "title": "Include entry files when reporting unused exports",
78
79
  "type": "boolean"
79
80
  },
80
81
  "workspaces": {
@@ -187,6 +188,10 @@
187
188
  "title": "Dependencies from package.json to ignore",
188
189
  "examples": ["husky", "lint-staged"],
189
190
  "$ref": "#/definitions/list"
191
+ },
192
+ "includeEntryExports": {
193
+ "title": "Include entry files when reporting unused exports",
194
+ "type": "boolean"
190
195
  }
191
196
  }
192
197
  },