knip 5.12.0 → 5.12.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.
- package/dist/ConfigurationChief.js +2 -1
- package/dist/plugins/capacitor/index.js +0 -1
- package/dist/plugins/eslint/helpers.js +6 -6
- package/dist/typescript/getImportsAndExports.js +19 -4
- package/dist/util/map-workspaces.js +1 -1
- package/dist/util/modules.js +5 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -181,11 +181,12 @@ export class ConfigurationChief {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
getListedWorkspaces() {
|
|
184
|
-
|
|
184
|
+
const workspaces = this.manifest?.workspaces
|
|
185
185
|
? Array.isArray(this.manifest.workspaces)
|
|
186
186
|
? this.manifest.workspaces
|
|
187
187
|
: this.manifest.workspaces.packages ?? []
|
|
188
188
|
: [];
|
|
189
|
+
return workspaces.map(pattern => pattern.replace(/(?<=!?)\.\//, ''));
|
|
189
190
|
}
|
|
190
191
|
getIgnoredWorkspacePatterns() {
|
|
191
192
|
const ignoredWorkspaces = this.getListedWorkspaces()
|
|
@@ -10,7 +10,6 @@ const resolveConfig = async (config, { configFileDir }) => {
|
|
|
10
10
|
const plugins = config.includePlugins ?? [];
|
|
11
11
|
const android = (await exists('android/capacitor.settings.gradle')) ? ['@capacitor/android'] : [];
|
|
12
12
|
const ios = (await exists('ios/App/Podfile')) ? ['@capacitor/ios'] : [];
|
|
13
|
-
console.log({ android, ios });
|
|
14
13
|
return [...plugins, ...android, ...ios];
|
|
15
14
|
};
|
|
16
15
|
export default {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compact } from '#p/util/array.js';
|
|
2
2
|
import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier } from '#p/util/modules.js';
|
|
3
|
-
import { isAbsolute, isInternal, toAbsolute } from '#p/util/path.js';
|
|
3
|
+
import { basename, dirname, isAbsolute, isInternal, toAbsolute } from '#p/util/path.js';
|
|
4
4
|
import { load } from '#p/util/plugin.js';
|
|
5
5
|
import { _resolve } from '#p/util/require.js';
|
|
6
6
|
import { getDependenciesFromConfig } from '../babel/index.js';
|
|
@@ -27,11 +27,11 @@ export const getDependenciesDeep = async (localConfig, options, dependencies = n
|
|
|
27
27
|
if (localConfig.extends) {
|
|
28
28
|
for (const extend of [localConfig.extends].flat()) {
|
|
29
29
|
if (isInternal(extend)) {
|
|
30
|
-
const filePath = toAbsolute(extend, configFileDir);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
addAll(await getDependenciesDeep(localConfig,
|
|
30
|
+
const filePath = _resolve(toAbsolute(extend, configFileDir));
|
|
31
|
+
dependencies.add(filePath);
|
|
32
|
+
const localConfig = await load(filePath);
|
|
33
|
+
const opts = { ...options, configFileDir: dirname(filePath), configFileName: basename(filePath) };
|
|
34
|
+
addAll(await getDependenciesDeep(localConfig, opts, dependencies));
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -280,13 +280,28 @@ const getImportsAndExports = (sourceFile, getResolvedModule, typeChecker, option
|
|
|
280
280
|
const setRefs = (item) => {
|
|
281
281
|
if (!item.symbol)
|
|
282
282
|
return;
|
|
283
|
+
const symbols = new Set();
|
|
283
284
|
for (const match of sourceFile.text.matchAll(new RegExp(item.identifier.replace(/\$/g, '\\$'), 'g'))) {
|
|
284
285
|
const isDeclaration = match.index === item.pos || match.index === item.pos + 1;
|
|
285
286
|
if (!isDeclaration) {
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
288
|
-
item.
|
|
289
|
-
|
|
287
|
+
const symbol = typeChecker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, match.index));
|
|
288
|
+
if (symbol) {
|
|
289
|
+
if (item.symbol === symbol) {
|
|
290
|
+
item.refs = 1;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
const declaration = symbol.declarations?.[0];
|
|
294
|
+
if (declaration) {
|
|
295
|
+
if (item.symbol === declaration.name?.flowNode?.node?.symbol) {
|
|
296
|
+
item.refs = 1;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
if (ts.isImportSpecifier(declaration) && symbols.has(symbol)) {
|
|
300
|
+
item.refs = 1;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
symbols.add(symbol);
|
|
290
305
|
}
|
|
291
306
|
}
|
|
292
307
|
}
|
|
@@ -6,7 +6,7 @@ import { getPackageName } from './package-name.js';
|
|
|
6
6
|
import { join } from './path.js';
|
|
7
7
|
import { _require } from './require.js';
|
|
8
8
|
export default async function mapWorkspaces(cwd, workspaces) {
|
|
9
|
-
const [negatedPatterns, patterns] = partition(workspaces, p => p.match(
|
|
9
|
+
const [negatedPatterns, patterns] = partition(workspaces, p => p.match(/^!/));
|
|
10
10
|
const byPkgDir = new Map();
|
|
11
11
|
const byPkgName = new Map();
|
|
12
12
|
if (patterns.length === 0 && negatedPatterns.length === 0)
|
package/dist/util/modules.js
CHANGED
|
@@ -37,7 +37,7 @@ export const getPackageFromDefinitelyTyped = (typedDependency) => {
|
|
|
37
37
|
return typedDependency;
|
|
38
38
|
};
|
|
39
39
|
export const getEntryPathFromManifest = (manifest, sharedGlobOptions) => {
|
|
40
|
-
const { main, bin, exports } = manifest;
|
|
40
|
+
const { main, bin, exports, types, typings } = manifest;
|
|
41
41
|
const entryPaths = new Set();
|
|
42
42
|
if (typeof main === 'string')
|
|
43
43
|
entryPaths.add(main);
|
|
@@ -52,6 +52,10 @@ export const getEntryPathFromManifest = (manifest, sharedGlobOptions) => {
|
|
|
52
52
|
for (const item of getStringValues(exports))
|
|
53
53
|
entryPaths.add(item);
|
|
54
54
|
}
|
|
55
|
+
if (typeof types === 'string')
|
|
56
|
+
entryPaths.add(types);
|
|
57
|
+
if (typeof typings === 'string')
|
|
58
|
+
entryPaths.add(typings);
|
|
55
59
|
return _glob({ ...sharedGlobOptions, patterns: Array.from(entryPaths) });
|
|
56
60
|
};
|
|
57
61
|
export const sanitizeSpecifier = (specifier) => {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.12.
|
|
1
|
+
export declare const version = "5.12.2";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.12.
|
|
1
|
+
export const version = '5.12.2';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.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": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"scripts": {
|
|
39
39
|
"knip": "node ./dist/cli.js --directory ../..",
|
|
40
40
|
"knip:production": "node ./dist/cli.js --directory ../.. --production --strict",
|
|
41
|
-
"lint": "biome lint
|
|
41
|
+
"lint": "biome lint ../..",
|
|
42
42
|
"format": "biome format --write .",
|
|
43
43
|
"test": "bun test test/*.test.ts test/**/*.test.ts",
|
|
44
44
|
"test:node": "glob -c \"npx -y tsx@4.7.1 --test --import ./transform-test.js\" \"test/**/*.test.ts\"",
|