knip 2.32.3 → 2.32.5
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/index.js +2 -2
- package/dist/plugins/ava/index.js +11 -9
- package/dist/plugins/ava/types.d.ts +4 -1
- package/dist/typescript/SourceFileManager.js +1 -1
- package/dist/util/modules.d.ts +1 -0
- package/dist/util/modules.js +7 -6
- package/dist/util/object.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { ProjectPrincipal } from './ProjectPrincipal.js';
|
|
|
9
9
|
import { compact } from './util/array.js';
|
|
10
10
|
import { debugLogObject, debugLogArray, debugLog } from './util/debug.js';
|
|
11
11
|
import { _glob, negate } from './util/glob.js';
|
|
12
|
-
import { getEntryPathFromManifest, getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, } from './util/modules.js';
|
|
12
|
+
import { getEntryPathFromManifest, getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, normalizeSpecifierFromFilePath, } from './util/modules.js';
|
|
13
13
|
import { dirname, isInNodeModules, join, isInternal } from './util/path.js';
|
|
14
14
|
import { fromBinary, isBinary } from './util/protocols.js';
|
|
15
15
|
import { _resolveSpecifier } from './util/require.js';
|
|
@@ -67,7 +67,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
67
67
|
if (packageName && specifier !== packageName) {
|
|
68
68
|
const otherWorkspace = chief.availableWorkspaceManifests.find(w => w.manifest.name === packageName);
|
|
69
69
|
if (otherWorkspace) {
|
|
70
|
-
const filePath = _resolveSpecifier(otherWorkspace.dir, specifier);
|
|
70
|
+
const filePath = _resolveSpecifier(otherWorkspace.dir, normalizeSpecifierFromFilePath(specifier));
|
|
71
71
|
if (filePath) {
|
|
72
72
|
principal.addEntryPath(filePath, { skipExportsAnalysis: true });
|
|
73
73
|
}
|
|
@@ -7,19 +7,21 @@ export const ENABLERS = ['ava'];
|
|
|
7
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
8
8
|
export const CONFIG_FILE_PATTERNS = ['ava.config.{js,cjs,mjs}', 'package.json'];
|
|
9
9
|
export const ENTRY_FILE_PATTERNS = [
|
|
10
|
-
`test.{js,cjs,mjs}`,
|
|
11
|
-
`{src,source}/test.{js,cjs,mjs}`,
|
|
12
|
-
`**/__tests__/**/*.{js,cjs,mjs}`,
|
|
13
|
-
`**/*.spec.{js,cjs,mjs}`,
|
|
14
|
-
`**/*.test.{js,cjs,mjs}`,
|
|
15
|
-
`**/test-*.{js,cjs,mjs}`,
|
|
16
|
-
`**/test/**/*.{js,cjs,mjs}`,
|
|
17
|
-
`**/tests/**/*.{js,cjs,mjs}`,
|
|
10
|
+
`test.{js,cjs,mjs,ts}`,
|
|
11
|
+
`{src,source}/test.{js,cjs,mjs,ts}`,
|
|
12
|
+
`**/__tests__/**/*.{js,cjs,mjs,ts}`,
|
|
13
|
+
`**/*.spec.{js,cjs,mjs,ts}`,
|
|
14
|
+
`**/*.test.{js,cjs,mjs,ts}`,
|
|
15
|
+
`**/test-*.{js,cjs,mjs,ts}`,
|
|
16
|
+
`**/test/**/*.{js,cjs,mjs,ts}`,
|
|
17
|
+
`**/tests/**/*.{js,cjs,mjs,ts}`,
|
|
18
18
|
'!**/__tests__/**/__{helper,fixture}?(s)__/**/*',
|
|
19
19
|
'!**/test?(s)/**/{helper,fixture}?(s)/**/*',
|
|
20
20
|
];
|
|
21
21
|
const findAvaDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
|
|
22
|
-
|
|
22
|
+
let config = configFilePath.endsWith('package.json') ? manifest.ava : await load(configFilePath);
|
|
23
|
+
if (typeof config === 'function')
|
|
24
|
+
config = config();
|
|
23
25
|
const entryPatterns = (config?.files ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
|
|
24
26
|
if (isProduction)
|
|
25
27
|
return entryPatterns;
|
|
@@ -22,7 +22,7 @@ export class SourceFileManager {
|
|
|
22
22
|
const contents = ts.sys.readFile(filePath);
|
|
23
23
|
if (typeof contents !== 'string') {
|
|
24
24
|
if (isInternal(filePath))
|
|
25
|
-
|
|
25
|
+
debugLog(`Unable to read ${filePath}`);
|
|
26
26
|
return this.createSourceFile(filePath, '');
|
|
27
27
|
}
|
|
28
28
|
const ext = extname(filePath);
|
package/dist/util/modules.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PackageJson } from '@npmcli/package-json';
|
|
2
2
|
export declare const getPackageNameFromModuleSpecifier: (moduleSpecifier: string) => string | undefined;
|
|
3
3
|
export declare const getPackageNameFromFilePath: (value: string) => string;
|
|
4
|
+
export declare const normalizeSpecifierFromFilePath: (value: string) => string;
|
|
4
5
|
export declare const isMaybePackageName: (specifier: string) => boolean;
|
|
5
6
|
export declare const isDefinitelyTyped: (packageName: string) => boolean;
|
|
6
7
|
export declare const getDefinitelyTypedFor: (packageName: string) => string;
|
package/dist/util/modules.js
CHANGED
|
@@ -13,6 +13,12 @@ export const getPackageNameFromFilePath = (value) => {
|
|
|
13
13
|
return match[match.length - 1];
|
|
14
14
|
return value;
|
|
15
15
|
};
|
|
16
|
+
export const normalizeSpecifierFromFilePath = (value) => {
|
|
17
|
+
const match = toPosix(value).match(/.*\/node_modules\/(.+)/);
|
|
18
|
+
if (match)
|
|
19
|
+
return match[match.length - 1];
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
16
22
|
export const isMaybePackageName = (specifier) => /^@?[a-z0-9]/.test(specifier);
|
|
17
23
|
export const isDefinitelyTyped = (packageName) => packageName.startsWith('@types/');
|
|
18
24
|
export const getDefinitelyTypedFor = (packageName) => {
|
|
@@ -41,12 +47,7 @@ export const getEntryPathFromManifest = (cwd, dir, manifest) => {
|
|
|
41
47
|
Object.values(bin).forEach(bin => entryPaths.add(bin));
|
|
42
48
|
}
|
|
43
49
|
if (exports) {
|
|
44
|
-
|
|
45
|
-
entryPaths.add(exports);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
getStringValues(exports).forEach(item => entryPaths.add(item));
|
|
49
|
-
}
|
|
50
|
+
getStringValues(exports).forEach(item => entryPaths.add(item));
|
|
50
51
|
}
|
|
51
52
|
return _glob({ cwd, workingDir: dir, patterns: Array.from(entryPaths) });
|
|
52
53
|
};
|
package/dist/util/object.js
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.32.
|
|
1
|
+
export declare const version = "2.32.5";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.32.
|
|
1
|
+
export const version = '2.32.5';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "2.32.
|
|
3
|
+
"version": "2.32.5",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://github.com/webpro/knip",
|
|
6
6
|
"repository": "github:webpro/knip",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@ericcornelissen/bash-parser": "^0.5.2",
|
|
46
46
|
"@npmcli/map-workspaces": "^3.0.4",
|
|
47
47
|
"@pnpm/logger": "5.0.0",
|
|
48
|
-
"@pnpm/workspace.pkgs-graph": "2.0.
|
|
48
|
+
"@pnpm/workspace.pkgs-graph": "2.0.7",
|
|
49
49
|
"@snyk/github-codeowners": "^1.1.0",
|
|
50
50
|
"chalk": "^5.2.0",
|
|
51
51
|
"easy-table": "^1.2.0",
|