knip 3.3.1 → 3.3.3
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.js +7 -2
- package/dist/ConfigurationValidator.d.ts +5 -0
- package/dist/ConfigurationValidator.js +1 -0
- package/dist/util/compilers.d.ts +1 -0
- package/dist/util/fs.d.ts +1 -0
- package/dist/util/fs.js +4 -0
- package/dist/util/get-included-issue-types.js +10 -16
- package/dist/util/modules.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -1
- package/schema.json +5 -0
|
@@ -10,7 +10,7 @@ import { arrayify } from './util/array.js';
|
|
|
10
10
|
import parsedArgValues from './util/cli-arguments.js';
|
|
11
11
|
import { partitionCompilers } from './util/compilers.js';
|
|
12
12
|
import { ConfigurationError, LoaderError } from './util/errors.js';
|
|
13
|
-
import { findFile, loadJSON } from './util/fs.js';
|
|
13
|
+
import { findFile, isDirectory, isFile, loadJSON } from './util/fs.js';
|
|
14
14
|
import { getIncludedIssueTypes } from './util/get-included-issue-types.js';
|
|
15
15
|
import { _dirGlob } from './util/glob.js';
|
|
16
16
|
import { _load } from './util/loader.js';
|
|
@@ -363,6 +363,11 @@ export class ConfigurationChief {
|
|
|
363
363
|
getUnusedIgnoredWorkspaces() {
|
|
364
364
|
const ignoredWorkspaceNames = this.config.ignoreWorkspaces;
|
|
365
365
|
const workspaceNames = [...this.manifestWorkspaces.keys(), ...this.additionalWorkspaceNames];
|
|
366
|
-
return ignoredWorkspaceNames
|
|
366
|
+
return ignoredWorkspaceNames
|
|
367
|
+
.filter(ignoredWorkspaceName => !workspaceNames.some(name => micromatch.isMatch(name, ignoredWorkspaceName)))
|
|
368
|
+
.filter(ignoredWorkspaceName => {
|
|
369
|
+
const dir = join(this.cwd, ignoredWorkspaceName);
|
|
370
|
+
return !isDirectory(dir) || isFile(join(dir, 'package.json'));
|
|
371
|
+
});
|
|
367
372
|
}
|
|
368
373
|
}
|
|
@@ -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({
|
package/dist/util/compilers.d.ts
CHANGED
|
@@ -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;
|
package/dist/util/fs.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const isDirectory: (filePath: string) => boolean;
|
|
1
2
|
export declare const isFile: (filePath: string) => boolean;
|
|
2
3
|
export declare const findFile: (workingDir: string, fileName: string) => string | undefined;
|
|
3
4
|
export declare const loadFile: (filePath: string) => Promise<string>;
|
package/dist/util/fs.js
CHANGED
|
@@ -4,6 +4,10 @@ import yaml from 'js-yaml';
|
|
|
4
4
|
import stripJsonComments from 'strip-json-comments';
|
|
5
5
|
import { LoaderError } from './errors.js';
|
|
6
6
|
import { dirname, join } from './path.js';
|
|
7
|
+
export const isDirectory = (filePath) => {
|
|
8
|
+
const stat = statSync(filePath, { throwIfNoEntry: false });
|
|
9
|
+
return stat !== undefined && stat.isDirectory();
|
|
10
|
+
};
|
|
7
11
|
export const isFile = (filePath) => {
|
|
8
12
|
const stat = statSync(filePath, { throwIfNoEntry: false });
|
|
9
13
|
return stat !== undefined && stat.isFile();
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
18
|
+
incl = [...incl, ...exports];
|
|
21
19
|
}
|
|
22
|
-
const
|
|
23
|
-
const
|
|
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/util/modules.js
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "3.3.
|
|
1
|
+
export declare const version = "3.3.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '3.3.
|
|
1
|
+
export const version = '3.3.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.3",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -102,6 +102,9 @@
|
|
|
102
102
|
"npm run knip",
|
|
103
103
|
"npm run knip:production",
|
|
104
104
|
"npm test"
|
|
105
|
+
],
|
|
106
|
+
"after:bump": [
|
|
107
|
+
"git add ../../package-lock.json"
|
|
105
108
|
]
|
|
106
109
|
},
|
|
107
110
|
"github": {
|
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
|
},
|