knip 3.8.1 → 3.8.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/ConfigurationValidator.d.ts +56 -0
- package/dist/ConfigurationValidator.js +1 -0
- package/dist/DependencyDeputy.js +11 -11
- package/dist/WorkspaceWorker.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +3 -3
- package/dist/plugins/svelte/index.js +9 -3
- package/dist/util/compilers.d.ts +10 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -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;
|
package/dist/DependencyDeputy.js
CHANGED
|
@@ -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"
|
|
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/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
31
31
|
const report = chief.getIssueTypesToReport();
|
|
32
32
|
const rules = chief.getRules();
|
|
33
33
|
const filters = chief.getFilters();
|
|
34
|
-
const fixer = new IssueFixer({ isEnabled: isFix
|
|
34
|
+
const fixer = new IssueFixer({ isEnabled: isFix, cwd, fixTypes });
|
|
35
35
|
const isReportDependencies = report.dependencies || report.unlisted || report.unresolved;
|
|
36
36
|
const isReportValues = report.exports || report.nsExports || report.classMembers;
|
|
37
37
|
const isReportTypes = report.types || report.nsTypes || report.enumMembers;
|
|
@@ -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;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { timerify } from '../../util/Performance.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
3
|
import { toEntryPattern, toProductionEntryPattern } from '../../util/protocols.js';
|
|
4
|
+
import { CONFIG_FILE_PATTERNS as VITE_CONFIG_FILE_PATTERNS } from '../vite/index.js';
|
|
4
5
|
export const NAME = 'Svelte';
|
|
5
6
|
export const ENABLERS = ['svelte'];
|
|
6
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
|
-
export const ENTRY_FILE_PATTERNS = ['svelte.config.js',
|
|
8
|
+
export const ENTRY_FILE_PATTERNS = ['svelte.config.js', ...VITE_CONFIG_FILE_PATTERNS];
|
|
8
9
|
export const PRODUCTION_ENTRY_FILE_PATTERNS = [
|
|
9
10
|
'src/routes/**/+{page,server,page.server,error,layout,layout.server}{,@*}.{js,ts,svelte}',
|
|
11
|
+
'src/hooks.{server,client}.{js,ts}',
|
|
12
|
+
'src/params/*{js,ts}',
|
|
10
13
|
];
|
|
11
14
|
export const PROJECT_FILE_PATTERNS = ['src/**/*.{js,ts,svelte}'];
|
|
12
|
-
const findSvelteDependencies = async () => {
|
|
13
|
-
|
|
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)];
|
|
14
20
|
};
|
|
15
21
|
export const findDependencies = timerify(findSvelteDependencies);
|
package/dist/util/compilers.d.ts
CHANGED
|
@@ -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.
|
|
1
|
+
export declare const version = "3.8.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '3.8.
|
|
1
|
+
export const version = '3.8.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.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": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"qa": "npm run lint && npm run build && npm run knip && npm run knip:production && npm test",
|
|
46
46
|
"release": "release-it",
|
|
47
47
|
"create-plugin": "tsx --no-warnings ./scripts/create-new-plugin.ts",
|
|
48
|
-
"postcreate-plugin": "prettier schema.json schema-jsonc.json src/ConfigurationValidator.ts --write --config .prettierrc
|
|
48
|
+
"postcreate-plugin": "prettier schema.json schema-jsonc.json src/ConfigurationValidator.ts --write --config .prettierrc.json"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"dist",
|
|
@@ -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.
|
|
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,7 +92,7 @@
|
|
|
92
92
|
"@types/pkgjs__parseargs": "^0.10.3",
|
|
93
93
|
"@types/webpack": "^5.28.5",
|
|
94
94
|
"c8": "8.0.1",
|
|
95
|
-
"eslint": "^8.
|
|
95
|
+
"eslint": "^8.56.0",
|
|
96
96
|
"playwright": "^1.40.1",
|
|
97
97
|
"prettier": "^3.1.1",
|
|
98
98
|
"release-it": "^17.0.1",
|