knip 5.30.3 → 5.30.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/DependencyDeputy.js +3 -3
- package/dist/WorkspaceWorker.d.ts +2 -2
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +5 -1
- package/dist/plugins/playwright/index.js +4 -3
- package/dist/typescript/ast-helpers.d.ts +2 -0
- package/dist/typescript/ast-helpers.js +6 -0
- package/dist/typescript/get-imports-and-exports.js +1 -3
- package/dist/typescript/visitors/dynamic-imports/requireCall.js +7 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +4 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/DependencyDeputy.js
CHANGED
|
@@ -175,11 +175,11 @@ export class DependencyDeputy {
|
|
|
175
175
|
return false;
|
|
176
176
|
const [scope, typedDependency] = dependency.split('/');
|
|
177
177
|
if (scope === DT_SCOPE) {
|
|
178
|
-
if (hasTypesIncluded?.has(typedDependency))
|
|
179
|
-
return false;
|
|
180
178
|
const typedPackageName = getPackageFromDefinitelyTyped(typedDependency);
|
|
181
|
-
if (IGNORE_DEFINITELY_TYPED.
|
|
179
|
+
if (IGNORE_DEFINITELY_TYPED.has(typedPackageName))
|
|
182
180
|
return true;
|
|
181
|
+
if (hasTypesIncluded?.has(typedDependency))
|
|
182
|
+
return false;
|
|
183
183
|
const hostDependencies = [
|
|
184
184
|
...this.getHostDependenciesFor(workspace, dependency),
|
|
185
185
|
...this.getHostDependenciesFor(workspace, typedPackageName),
|
|
@@ -34,7 +34,7 @@ export declare class WorkspaceWorker {
|
|
|
34
34
|
isStrict: boolean;
|
|
35
35
|
rootIgnore: Configuration['ignore'];
|
|
36
36
|
negatedWorkspacePatterns: string[];
|
|
37
|
-
enabledPluginsMap: Record<"
|
|
37
|
+
enabledPluginsMap: Record<"angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "ladle" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "nest" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nuxt" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "preconstruct" | "prettier" | "reactCosmos" | "releaseIt" | "remark" | "remix" | "rollup" | "rsbuild" | "rspack" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vike" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie", boolean>;
|
|
38
38
|
enabledPlugins: PluginName[];
|
|
39
39
|
enabledPluginsInAncestors: string[];
|
|
40
40
|
cache: CacheConsultant<CacheItem>;
|
|
@@ -55,7 +55,7 @@ export declare class WorkspaceWorker {
|
|
|
55
55
|
entryFilePatterns: Set<string>;
|
|
56
56
|
productionEntryFilePatterns: Set<string>;
|
|
57
57
|
referencedDependencies: ReferencedDependencies;
|
|
58
|
-
enabledPlugins: ("
|
|
58
|
+
enabledPlugins: ("angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "ladle" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "nest" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nuxt" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "preconstruct" | "prettier" | "reactCosmos" | "releaseIt" | "remark" | "remix" | "rollup" | "rsbuild" | "rspack" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vike" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie")[];
|
|
59
59
|
}>;
|
|
60
60
|
onDispose(): void;
|
|
61
61
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ export declare const IGNORED_GLOBAL_BINARIES: Set<string>;
|
|
|
14
14
|
export declare const IGNORED_DEPENDENCIES: Set<string>;
|
|
15
15
|
export declare const IGNORED_RUNTIME_DEPENDENCIES: Set<string>;
|
|
16
16
|
export declare const FOREIGN_FILE_EXTENSIONS: Set<string>;
|
|
17
|
-
export declare const IGNORE_DEFINITELY_TYPED: string
|
|
17
|
+
export declare const IGNORE_DEFINITELY_TYPED: Set<string>;
|
|
18
18
|
export declare const ISSUE_TYPES: IssueType[];
|
|
19
19
|
export declare const ISSUE_TYPE_TITLE: Record<IssueType, string>;
|
package/dist/constants.js
CHANGED
|
@@ -142,7 +142,11 @@ export const FOREIGN_FILE_EXTENSIONS = new Set([
|
|
|
142
142
|
'.yaml',
|
|
143
143
|
'.yml',
|
|
144
144
|
]);
|
|
145
|
-
export const IGNORE_DEFINITELY_TYPED = [
|
|
145
|
+
export const IGNORE_DEFINITELY_TYPED = new Set([
|
|
146
|
+
'node',
|
|
147
|
+
'bun',
|
|
148
|
+
'jest',
|
|
149
|
+
]);
|
|
146
150
|
export const ISSUE_TYPES = [
|
|
147
151
|
'files',
|
|
148
152
|
'dependencies',
|
|
@@ -6,10 +6,11 @@ const enablers = ['@playwright/test'];
|
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
7
|
const config = ['playwright.config.{js,ts}'];
|
|
8
8
|
export const entry = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
|
|
9
|
-
const toEntryPatterns = (testMatch, cwd, configDir, localConfig) => {
|
|
9
|
+
const toEntryPatterns = (testMatch, cwd, configDir, localConfig, rootConfig) => {
|
|
10
10
|
if (!testMatch)
|
|
11
11
|
return [];
|
|
12
|
-
const
|
|
12
|
+
const testDir = localConfig.testDir ?? rootConfig.testDir;
|
|
13
|
+
const dir = relative(cwd, testDir ? join(configDir, testDir) : configDir);
|
|
13
14
|
const patterns = [testMatch].flat().filter((p) => typeof p === 'string');
|
|
14
15
|
return patterns.map(pattern => toEntryPattern(join(dir, pattern)));
|
|
15
16
|
};
|
|
@@ -17,7 +18,7 @@ const builtinReporters = ['dot', 'line', 'list', 'junit', 'html', 'blob', 'json'
|
|
|
17
18
|
export const resolveEntryPaths = async (localConfig, options) => {
|
|
18
19
|
const { cwd, configFileDir } = options;
|
|
19
20
|
const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
|
|
20
|
-
return projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFileDir, config));
|
|
21
|
+
return projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFileDir, config, localConfig));
|
|
21
22
|
};
|
|
22
23
|
export const resolveConfig = async (config) => {
|
|
23
24
|
const reporters = [config.reporter].flat().flatMap(reporter => {
|
|
@@ -26,3 +26,5 @@ export declare const isImportSpecifier: (node: ts.Node) => boolean;
|
|
|
26
26
|
export declare const isReferencedInExportedType: (node: ts.Node) => boolean;
|
|
27
27
|
export declare const getExportKeywordNode: (node: ts.Node) => ts.ExportKeyword | undefined;
|
|
28
28
|
export declare const getDefaultKeywordNode: (node: ts.Node) => ts.DefaultKeyword | undefined;
|
|
29
|
+
export declare const hasRequireCall: (node: ts.Node) => boolean;
|
|
30
|
+
export declare const isModuleExportsAccess: (node: ts.PropertyAccessExpression) => boolean;
|
|
@@ -170,3 +170,9 @@ export const isReferencedInExportedType = (node) => {
|
|
|
170
170
|
};
|
|
171
171
|
export const getExportKeywordNode = (node) => node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.ExportKeyword);
|
|
172
172
|
export const getDefaultKeywordNode = (node) => node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.DefaultKeyword);
|
|
173
|
+
export const hasRequireCall = (node) => {
|
|
174
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'require')
|
|
175
|
+
return true;
|
|
176
|
+
return node.getChildren().some(child => hasRequireCall(child));
|
|
177
|
+
};
|
|
178
|
+
export const isModuleExportsAccess = (node) => ts.isIdentifier(node.expression) && node.expression.escapedText === 'module' && node.name.escapedText === 'exports';
|
|
@@ -102,9 +102,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
102
102
|
if (module.isExternalLibraryImport) {
|
|
103
103
|
if (skipTypeOnly && isTypeOnly)
|
|
104
104
|
return;
|
|
105
|
-
const sanitizedSpecifier = isInNodeModules(specifier)
|
|
106
|
-
? getPackageNameFromFilePath(specifier)
|
|
107
|
-
: sanitizeSpecifier(specifier);
|
|
105
|
+
const sanitizedSpecifier = sanitizeSpecifier(isInNodeModules(specifier) || isInNodeModules(filePath) ? getPackageNameFromFilePath(specifier) : specifier);
|
|
108
106
|
if (!isStartsLikePackageName(sanitizedSpecifier)) {
|
|
109
107
|
return;
|
|
110
108
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { IMPORT_STAR } from '../../../constants.js';
|
|
3
|
+
import { findAncestor, findDescendants, isModuleExportsAccess, isRequireCall, isTopLevel } from '../../ast-helpers.js';
|
|
3
4
|
import { isNotJS } from '../helpers.js';
|
|
4
5
|
import { importVisitor as visit } from '../index.js';
|
|
5
6
|
export default visit(() => true, node => {
|
|
@@ -43,6 +44,11 @@ export default visit(() => true, node => {
|
|
|
43
44
|
}
|
|
44
45
|
return { identifier: 'default', specifier, pos: node.arguments[0].pos, resolve };
|
|
45
46
|
}
|
|
47
|
+
if (ts.isBinaryExpression(node.parent) &&
|
|
48
|
+
ts.isPropertyAccessExpression(node.parent.left) &&
|
|
49
|
+
isModuleExportsAccess(node.parent.left)) {
|
|
50
|
+
return { identifier: IMPORT_STAR, specifier, isReExport: true, pos: node.arguments[0].pos };
|
|
51
|
+
}
|
|
46
52
|
return { identifier: 'default', specifier, pos: node.arguments[0].pos, resolve };
|
|
47
53
|
}
|
|
48
54
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { SymbolType } from '../../../types/issues.js';
|
|
3
|
-
import { stripQuotes } from '../../ast-helpers.js';
|
|
3
|
+
import { hasRequireCall, isModuleExportsAccess, stripQuotes } from '../../ast-helpers.js';
|
|
4
4
|
import { isJS } from '../helpers.js';
|
|
5
5
|
import { exportVisitor as visit } from '../index.js';
|
|
6
|
-
const isModuleExportsAccess = (node) => ts.isIdentifier(node.expression) && node.expression.escapedText === 'module' && node.name.escapedText === 'exports';
|
|
7
6
|
export default visit(isJS, (node, { isFixExports }) => {
|
|
8
7
|
if (ts.isExpressionStatement(node)) {
|
|
9
8
|
if (ts.isBinaryExpression(node.expression)) {
|
|
@@ -29,6 +28,9 @@ export default visit(isJS, (node, { isFixExports }) => {
|
|
|
29
28
|
return { node, identifier: node.getText(), type: SymbolType.UNKNOWN, pos: node.getStart(), fix };
|
|
30
29
|
});
|
|
31
30
|
}
|
|
31
|
+
if (ts.isCallExpression(node.expression.right) && hasRequireCall(node.expression.right)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
32
34
|
return { node, identifier: 'default', type: SymbolType.UNKNOWN, pos: expr.pos + 1, fix: undefined };
|
|
33
35
|
}
|
|
34
36
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.30.
|
|
1
|
+
export declare const version = "5.30.5";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.30.
|
|
1
|
+
export const version = '5.30.5';
|