knip 5.9.1 → 5.9.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.d.ts +6 -6
- package/dist/ConfigurationChief.js +10 -8
- package/dist/ConsoleStreamer.js +1 -1
- package/dist/DependencyDeputy.d.ts +1 -1
- package/dist/DependencyDeputy.js +22 -18
- package/dist/IssueCollector.js +10 -9
- package/dist/IssueFixer.js +9 -7
- package/dist/PrincipalFactory.d.ts +2 -2
- package/dist/PrincipalFactory.js +3 -5
- package/dist/ProjectPrincipal.d.ts +6 -6
- package/dist/ProjectPrincipal.js +12 -10
- package/dist/WorkspaceWorker.d.ts +2 -2
- package/dist/WorkspaceWorker.js +13 -9
- package/dist/binaries/index.js +1 -1
- package/dist/binaries/resolvers/bun.js +1 -1
- package/dist/binaries/resolvers/index.d.ts +12 -12
- package/dist/binaries/util.js +1 -1
- package/dist/cli.js +9 -8
- package/dist/compilers/index.d.ts +1 -1
- package/dist/index.js +65 -57
- package/dist/issues/initializers.d.ts +1 -1
- package/dist/manifest/helpers.js +1 -1
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.js +4 -4
- package/dist/plugins/ava/index.js +8 -8
- package/dist/plugins/babel/index.js +2 -2
- package/dist/plugins/babel/types.d.ts +1 -1
- package/dist/plugins/babel/types.js +1 -1
- package/dist/plugins/commitlint/index.d.ts +1 -1
- package/dist/plugins/cspell/index.d.ts +1 -1
- package/dist/plugins/drizzle/index.d.ts +1 -1
- package/dist/plugins/eleventy/helpers.d.ts +0 -1
- package/dist/plugins/eleventy/helpers.js +1 -2
- package/dist/plugins/eleventy/index.d.ts +1 -1
- package/dist/plugins/eslint/helpers.d.ts +1 -1
- package/dist/plugins/eslint/helpers.js +5 -2
- package/dist/plugins/eslint/index.d.ts +0 -1
- package/dist/plugins/eslint/index.js +1 -1
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/graphql-codegen/index.d.ts +1 -1
- package/dist/plugins/jest/index.js +5 -4
- package/dist/plugins/lint-staged/index.d.ts +1 -1
- package/dist/plugins/lint-staged/index.js +2 -1
- package/dist/plugins/linthtml/index.d.ts +1 -1
- package/dist/plugins/markdownlint/index.d.ts +1 -1
- package/dist/plugins/npm-package-json-lint/index.d.ts +1 -1
- package/dist/plugins/nyc/index.d.ts +1 -1
- package/dist/plugins/playwright/index.d.ts +1 -1
- package/dist/plugins/playwright-ct/index.js +1 -1
- package/dist/plugins/postcss/index.d.ts +1 -1
- package/dist/plugins/prettier/index.d.ts +1 -1
- package/dist/plugins/release-it/index.d.ts +1 -1
- package/dist/plugins/remark/index.d.ts +1 -1
- package/dist/plugins/semantic-release/index.d.ts +1 -1
- package/dist/plugins/stryker/index.d.ts +1 -1
- package/dist/plugins/stylelint/index.d.ts +1 -1
- package/dist/plugins/tsup/index.d.ts +1 -1
- package/dist/plugins/typescript/index.d.ts +0 -1
- package/dist/plugins/typescript/index.js +4 -3
- package/dist/plugins/unbuild/index.d.ts +1 -1
- package/dist/plugins/vite/index.d.ts +2 -2
- package/dist/plugins/vite/index.js +1 -1
- package/dist/plugins/vitest/index.d.ts +1 -1
- package/dist/plugins/vitest/index.js +8 -4
- package/dist/plugins/vue/index.d.ts +1 -1
- package/dist/plugins/vue/index.js +2 -1
- package/dist/plugins/vue/types.d.ts +1 -1
- package/dist/plugins/webpack/index.js +4 -4
- package/dist/plugins/wireit/index.d.ts +1 -1
- package/dist/plugins/yorkie/index.d.ts +1 -1
- package/dist/plugins/yorkie/index.js +2 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +6 -3
- package/dist/reporters/codeowners.js +9 -7
- package/dist/reporters/compact.js +1 -1
- package/dist/reporters/index.d.ts +5 -5
- package/dist/reporters/json.js +3 -3
- package/dist/reporters/markdown.js +7 -7
- package/dist/reporters/symbols.js +8 -8
- package/dist/reporters/util.js +3 -2
- package/dist/types/config.d.ts +5 -5
- package/dist/types/config.js +1 -3
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/exports.js +1 -1
- package/dist/types/imports.d.ts +1 -1
- package/dist/types/imports.js +1 -1
- package/dist/typescript/SourceFile.d.ts +1 -1
- package/dist/typescript/SourceFile.js +1 -1
- package/dist/typescript/SourceFileManager.d.ts +1 -1
- package/dist/typescript/ast-helpers.js +2 -2
- package/dist/typescript/createHosts.d.ts +1 -1
- package/dist/typescript/createHosts.js +1 -1
- package/dist/typescript/getImportsAndExports.d.ts +1 -1
- package/dist/typescript/getImportsAndExports.js +15 -12
- package/dist/typescript/resolveModuleNames.js +2 -2
- package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/importCall.js +24 -30
- package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/index.d.ts +2 -2
- package/dist/typescript/visitors/dynamic-imports/index.js +0 -1
- package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/propertyAccessCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.js +14 -22
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.js +10 -12
- package/dist/typescript/visitors/exports/exportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/exports/index.d.ts +2 -2
- package/dist/typescript/visitors/exports/index.js +0 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +2 -4
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/importDeclaration.js +18 -20
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/index.d.ts +2 -2
- package/dist/typescript/visitors/imports/index.js +0 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.js +14 -16
- package/dist/typescript/visitors/index.d.ts +1 -1
- package/dist/typescript/visitors/index.js +0 -1
- package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
- package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
- package/dist/typescript/visitors/scripts/index.d.ts +2 -2
- package/dist/typescript/visitors/scripts/index.js +0 -1
- package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
- package/dist/util/Performance.d.ts +1 -1
- package/dist/util/Performance.js +5 -5
- package/dist/util/cli-arguments.js +1 -1
- package/dist/util/debug.js +1 -1
- package/dist/util/fs.d.ts +2 -2
- package/dist/util/fs.js +3 -3
- package/dist/util/get-included-issue-types.js +8 -5
- package/dist/util/get-reexporting-entry-file.js +12 -16
- package/dist/util/git.js +5 -5
- package/dist/util/glob.js +2 -2
- package/dist/util/globby.d.ts +1 -1
- package/dist/util/globby.js +10 -11
- package/dist/util/handle-dependency.d.ts +1 -1
- package/dist/util/handle-dependency.js +1 -2
- package/dist/util/is-identifier-referenced.js +4 -4
- package/dist/util/loader.js +3 -5
- package/dist/util/modules.js +7 -5
- package/dist/util/object.js +1 -1
- package/dist/util/plugin.d.ts +1 -1
- package/dist/util/plugin.js +12 -14
- package/dist/util/regex.js +1 -1
- package/dist/util/require.js +2 -2
- package/dist/util/tag.js +4 -2
- package/dist/util/type.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +15 -23
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import './util/register.js';
|
|
2
1
|
import picocolors from 'picocolors';
|
|
3
2
|
import prettyMilliseconds from 'pretty-ms';
|
|
3
|
+
import { main } from './index.js';
|
|
4
|
+
import { Performance } from './util/Performance.js';
|
|
4
5
|
import parsedArgValues, { helpText } from './util/cli-arguments.js';
|
|
5
|
-
import {
|
|
6
|
+
import { getKnownError, hasCause, isConfigurationError, isKnownError } from './util/errors.js';
|
|
6
7
|
import { cwd } from './util/path.js';
|
|
7
|
-
import
|
|
8
|
+
import './util/register.js';
|
|
8
9
|
import { runPreprocessors, runReporters } from './util/reporter.js';
|
|
9
10
|
import { splitTags } from './util/tag.js';
|
|
10
11
|
import { version } from './version.js';
|
|
11
|
-
|
|
12
|
-
const { debug: isDebug = false, trace: isTrace = false, help: isHelp, 'max-issues': maxIssues = '0', 'no-config-hints': noConfigHints = false, 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': isNoProgress = isDebug || isTrace || false, 'include-entry-exports': isIncludeEntryExports = false, 'include-libs': isIncludeLibs = false, 'isolate-workspaces': isIsolateWorkspaces = false, performance: isObservePerf = false, production: isProduction = false, 'reporter-options': reporterOptions = '', 'preprocessor-options': preprocessorOptions = '', strict: isStrict = false, fix: isFix = false, 'fix-type': fixTypes = [], tsConfig, version: isVersion, 'experimental-tags': experimentalTags = [], tags = [], } = parsedArgValues;
|
|
12
|
+
const { debug: isDebug = false, trace: isTrace = false, help: isHelp, 'max-issues': maxIssues = '0', 'no-config-hints': noConfigHints = false, 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': isNoProgress = isDebug || isTrace, 'include-entry-exports': isIncludeEntryExports = false, 'include-libs': isIncludeLibs = false, 'isolate-workspaces': isIsolateWorkspaces = false, performance: isObservePerf = false, production: isProduction = false, 'reporter-options': reporterOptions = '', 'preprocessor-options': preprocessorOptions = '', strict: isStrict = false, fix: isFix = false, 'fix-type': fixTypes = [], tsConfig, version: isVersion, 'experimental-tags': experimentalTags = [], tags = [], } = parsedArgValues;
|
|
13
13
|
if (isHelp) {
|
|
14
14
|
console.log(helpText);
|
|
15
15
|
process.exit(0);
|
|
@@ -55,13 +55,14 @@ const run = async () => {
|
|
|
55
55
|
.reduce((errorCount, reportGroup) => errorCount + finalData.counters[reportGroup], 0);
|
|
56
56
|
if (isObservePerf) {
|
|
57
57
|
await perfObserver.finalize();
|
|
58
|
-
console.log(
|
|
58
|
+
console.log(`\n${perfObserver.getTable()}`);
|
|
59
59
|
const mem = Math.round((perfObserver.getMemHeapUsage() / 1024 / 1024) * 100) / 100;
|
|
60
60
|
console.log('\nTotal running time:', prettyMilliseconds(perfObserver.getTotalTime()), `(mem: ${mem}MB)`);
|
|
61
61
|
perfObserver.reset();
|
|
62
62
|
}
|
|
63
63
|
if (experimentalTags.length > 0) {
|
|
64
|
-
|
|
64
|
+
const prefix = `${picocolors.yellow('DEPRECATION WARNING:')}`;
|
|
65
|
+
console.warn(`\n${prefix} --experimental-tags is deprecated, please start using --tags instead`);
|
|
65
66
|
}
|
|
66
67
|
if (!noExitCode && totalErrorCount > Number(maxIssues)) {
|
|
67
68
|
process.exit(1);
|
|
@@ -75,7 +76,7 @@ const run = async () => {
|
|
|
75
76
|
if (hasCause(knownError))
|
|
76
77
|
console.error('Reason:', knownError.cause.message);
|
|
77
78
|
if (isConfigurationError(knownError))
|
|
78
|
-
console.log(
|
|
79
|
+
console.log(`\n${helpText}`);
|
|
79
80
|
process.exit(2);
|
|
80
81
|
}
|
|
81
82
|
throw error;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AsyncCompilerFn, AsyncCompilers, SyncCompilerFn, SyncCompilers } from './types.js';
|
|
2
1
|
import type { RawConfiguration } from '../types/config.js';
|
|
3
2
|
import type { DependencySet } from '../types/workspace.js';
|
|
3
|
+
import type { AsyncCompilerFn, AsyncCompilers, SyncCompilerFn, SyncCompilers } from './types.js';
|
|
4
4
|
export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
5
5
|
syncCompilers: Record<string, SyncCompilerFn>;
|
|
6
6
|
asyncCompilers: Record<string, AsyncCompilerFn>;
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { _getDependenciesFromScripts } from './binaries/index.js';
|
|
2
|
-
import { getCompilerExtensions, getIncludedCompilers } from './compilers/index.js';
|
|
3
1
|
import { ConfigurationChief } from './ConfigurationChief.js';
|
|
4
2
|
import { ConsoleStreamer } from './ConsoleStreamer.js';
|
|
5
3
|
import { DependencyDeputy } from './DependencyDeputy.js';
|
|
6
4
|
import { IssueCollector } from './IssueCollector.js';
|
|
7
5
|
import { IssueFixer } from './IssueFixer.js';
|
|
8
|
-
import { getFilteredScripts } from './manifest/helpers.js';
|
|
9
6
|
import { PrincipalFactory } from './PrincipalFactory.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { WorkspaceWorker } from './WorkspaceWorker.js';
|
|
8
|
+
import { _getDependenciesFromScripts } from './binaries/index.js';
|
|
9
|
+
import { getCompilerExtensions, getIncludedCompilers } from './compilers/index.js';
|
|
10
|
+
import { getFilteredScripts } from './manifest/helpers.js';
|
|
11
|
+
import { debugLog, debugLogArray, debugLogObject } from './util/debug.js';
|
|
12
12
|
import { getReExportingEntryFileHandler } from './util/get-reexporting-entry-file.js';
|
|
13
13
|
import { _glob, negate } from './util/glob.js';
|
|
14
14
|
import { getGitIgnoredFn } from './util/globby.js';
|
|
@@ -19,8 +19,7 @@ import { dirname, join } from './util/path.js';
|
|
|
19
19
|
import { hasMatch } from './util/regex.js';
|
|
20
20
|
import { shouldIgnore } from './util/tag.js';
|
|
21
21
|
import { loadTSConfig } from './util/tsconfig-loader.js';
|
|
22
|
-
import {
|
|
23
|
-
import { WorkspaceWorker } from './WorkspaceWorker.js';
|
|
22
|
+
import { getHasStrictlyNsReferences, getType } from './util/type.js';
|
|
24
23
|
export const main = async (unresolvedConfiguration) => {
|
|
25
24
|
const { cwd, tsConfigFile, gitignore, isStrict, isProduction, isShowProgress, isIncludeEntryExports, isIncludeLibs, isIsolateWorkspaces, tags, isFix, fixTypes, } = unresolvedConfiguration;
|
|
26
25
|
debugLogObject('*', 'Unresolved configuration (from CLI arguments)', unresolvedConfiguration);
|
|
@@ -41,7 +40,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
41
40
|
const isReportValues = report.exports || report.nsExports || report.classMembers;
|
|
42
41
|
const isReportTypes = report.types || report.nsTypes || report.enumMembers;
|
|
43
42
|
const isReportClassMembers = report.classMembers;
|
|
44
|
-
const isSkipLibs = !isIncludeLibs
|
|
43
|
+
const isSkipLibs = !(isIncludeLibs || isReportClassMembers);
|
|
45
44
|
const collector = new IssueCollector({ cwd, rules, filters });
|
|
46
45
|
const enabledPluginsStore = new Map();
|
|
47
46
|
deputy.setIgnored(chief.config.ignoreBinaries, chief.config.ignoreDependencies);
|
|
@@ -89,7 +88,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
89
88
|
});
|
|
90
89
|
await worker.init();
|
|
91
90
|
principal.addEntryPaths(definitionPaths);
|
|
92
|
-
debugLogArray(name,
|
|
91
|
+
debugLogArray(name, 'Definition paths', definitionPaths);
|
|
93
92
|
const ignore = worker.getIgnorePatterns();
|
|
94
93
|
const sharedGlobOptions = { cwd, workingDir: dir, gitignore };
|
|
95
94
|
collector.addIgnorePatterns(ignore.map(pattern => join(cwd, pattern)));
|
|
@@ -111,51 +110,54 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
111
110
|
{
|
|
112
111
|
const patterns = worker.getProductionEntryFilePatterns(negatedEntryPatterns);
|
|
113
112
|
const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
114
|
-
debugLogArray(name,
|
|
113
|
+
debugLogArray(name, 'Entry paths', workspaceEntryPaths);
|
|
115
114
|
principal.addEntryPaths(workspaceEntryPaths);
|
|
116
115
|
}
|
|
117
116
|
{
|
|
118
117
|
const patterns = Array.from(productionEntryFilePatterns);
|
|
119
118
|
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
120
|
-
debugLogArray(name,
|
|
119
|
+
debugLogArray(name, 'Production plugin entry paths', pluginWorkspaceEntryPaths);
|
|
121
120
|
principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
|
|
122
121
|
}
|
|
123
122
|
{
|
|
124
123
|
const patterns = worker.getProductionProjectFilePatterns(negatedEntryPatterns);
|
|
125
124
|
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
126
|
-
debugLogArray(name,
|
|
127
|
-
|
|
125
|
+
debugLogArray(name, 'Project paths', workspaceProjectPaths);
|
|
126
|
+
for (const projectPath of workspaceProjectPaths)
|
|
127
|
+
principal.addProjectPath(projectPath);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
131
|
{
|
|
132
132
|
const patterns = worker.getEntryFilePatterns();
|
|
133
133
|
const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
134
|
-
debugLogArray(name,
|
|
134
|
+
debugLogArray(name, 'Entry paths', workspaceEntryPaths);
|
|
135
135
|
principal.addEntryPaths(workspaceEntryPaths);
|
|
136
136
|
}
|
|
137
137
|
{
|
|
138
138
|
const patterns = worker.getProjectFilePatterns([...productionEntryFilePatterns]);
|
|
139
139
|
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
140
|
-
debugLogArray(name,
|
|
141
|
-
|
|
140
|
+
debugLogArray(name, 'Project paths', workspaceProjectPaths);
|
|
141
|
+
for (const projectPath of workspaceProjectPaths)
|
|
142
|
+
principal.addProjectPath(projectPath);
|
|
142
143
|
}
|
|
143
144
|
{
|
|
144
145
|
const patterns = [...entryFilePatterns, ...productionEntryFilePatterns];
|
|
145
146
|
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
146
|
-
debugLogArray(name,
|
|
147
|
+
debugLogArray(name, 'Plugin entry paths', pluginWorkspaceEntryPaths);
|
|
147
148
|
principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
|
|
148
149
|
}
|
|
149
150
|
{
|
|
150
151
|
const patterns = worker.getPluginProjectFilePatterns();
|
|
151
152
|
const pluginWorkspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
152
|
-
debugLogArray(name,
|
|
153
|
-
|
|
153
|
+
debugLogArray(name, 'Plugin project paths', pluginWorkspaceProjectPaths);
|
|
154
|
+
for (const projectPath of pluginWorkspaceProjectPaths)
|
|
155
|
+
principal.addProjectPath(projectPath);
|
|
154
156
|
}
|
|
155
157
|
{
|
|
156
158
|
const patterns = worker.getPluginConfigPatterns();
|
|
157
159
|
const configurationEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
|
|
158
|
-
debugLogArray(name,
|
|
160
|
+
debugLogArray(name, 'Plugin configuration paths', configurationEntryPaths);
|
|
159
161
|
principal.addEntryPaths(configurationEntryPaths, { skipExportsAnalysis: true });
|
|
160
162
|
}
|
|
161
163
|
}
|
|
@@ -173,11 +175,11 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
173
175
|
for (const principal of principals) {
|
|
174
176
|
principal.init();
|
|
175
177
|
const handleReferencedDependency = getHandler(collector, deputy, chief);
|
|
176
|
-
|
|
178
|
+
for (const [containingFilePath, specifier, workspaceName] of principal.referencedDependencies) {
|
|
177
179
|
const workspace = chief.findWorkspaceByName(workspaceName);
|
|
178
180
|
if (workspace)
|
|
179
181
|
handleReferencedDependency(specifier, containingFilePath, workspace, principal);
|
|
180
|
-
}
|
|
182
|
+
}
|
|
181
183
|
const specifierFilePaths = new Set();
|
|
182
184
|
const analyzeSourceFile = (filePath, _principal = principal) => {
|
|
183
185
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
@@ -227,29 +229,29 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
227
229
|
importedModule.isReExport = true;
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
|
-
|
|
232
|
+
for (const symbols of duplicate) {
|
|
231
233
|
if (symbols.length > 1) {
|
|
232
234
|
const symbol = symbols.map(s => s.symbol).join('|');
|
|
233
235
|
collector.addIssue({ type: 'duplicates', filePath, symbol, symbols });
|
|
234
236
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
+
}
|
|
238
|
+
for (const specifier of external) {
|
|
237
239
|
const packageName = getPackageNameFromModuleSpecifier(specifier);
|
|
238
240
|
const isHandled = packageName && deputy.maybeAddReferencedExternalDependency(workspace, packageName);
|
|
239
241
|
if (!isHandled)
|
|
240
242
|
collector.addIssue({ type: 'unlisted', filePath, symbol: specifier });
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
+
}
|
|
244
|
+
for (const unresolvedImport of unresolved) {
|
|
243
245
|
const { specifier, pos, line, col } = unresolvedImport;
|
|
244
246
|
collector.addIssue({ type: 'unresolved', filePath, symbol: specifier, pos, line, col });
|
|
245
|
-
}
|
|
246
|
-
_getDependenciesFromScripts(scripts, {
|
|
247
|
+
}
|
|
248
|
+
for (const specifier of _getDependenciesFromScripts(scripts, {
|
|
247
249
|
cwd: dirname(filePath),
|
|
248
250
|
manifestScriptNames: new Set(),
|
|
249
251
|
dependencies: deputy.getDependencies(workspace.name),
|
|
250
|
-
})
|
|
252
|
+
})) {
|
|
251
253
|
handleReferencedDependency(specifier, filePath, workspace, _principal);
|
|
252
|
-
}
|
|
254
|
+
}
|
|
253
255
|
}
|
|
254
256
|
};
|
|
255
257
|
streamer.cast('Running async compilers...');
|
|
@@ -262,30 +264,30 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
262
264
|
const resolvedFiles = principal.getUsedResolvedFiles();
|
|
263
265
|
const files = resolvedFiles.filter(filePath => !analyzedFiles.has(filePath));
|
|
264
266
|
debugLogArray('*', `Analyzing used resolved files [P${principals.indexOf(principal) + 1}/${++round}]`, files);
|
|
265
|
-
|
|
267
|
+
for (const filePath of files) {
|
|
266
268
|
analyzeSourceFile(filePath);
|
|
267
269
|
analyzedFiles.add(filePath);
|
|
268
|
-
}
|
|
270
|
+
}
|
|
269
271
|
} while (size !== principal.entryPaths.size);
|
|
270
|
-
|
|
272
|
+
for (const specifierFilePath of specifierFilePaths) {
|
|
271
273
|
if (!analyzedFiles.has(specifierFilePath)) {
|
|
272
274
|
analyzedFiles.add(specifierFilePath);
|
|
273
275
|
analyzeSourceFile(specifierFilePath, principal);
|
|
274
276
|
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
}
|
|
278
|
+
for (const filePath of principal.getUnreferencedFiles())
|
|
279
|
+
unreferencedFiles.add(filePath);
|
|
280
|
+
for (const filePath of principal.entryPaths)
|
|
281
|
+
entryPaths.add(filePath);
|
|
278
282
|
if (isSkipLibs)
|
|
279
283
|
factory.deletePrincipal(principal);
|
|
280
284
|
}
|
|
281
285
|
const isIdentifierReferenced = getIsIdentifierReferencedHandler(importedSymbols);
|
|
282
286
|
const getReExportingEntryFile = getReExportingEntryFileHandler(entryPaths, exportedSymbols, importedSymbols);
|
|
283
|
-
const isExportedItemReferenced = (exportedItem) =>
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
: chief.config.ignoreExportsUsedInFile));
|
|
288
|
-
};
|
|
287
|
+
const isExportedItemReferenced = (exportedItem) => exportedItem.refs > 0 &&
|
|
288
|
+
(typeof chief.config.ignoreExportsUsedInFile === 'object'
|
|
289
|
+
? exportedItem.type !== 'unknown' && !!chief.config.ignoreExportsUsedInFile[exportedItem.type]
|
|
290
|
+
: chief.config.ignoreExportsUsedInFile);
|
|
289
291
|
if (isReportValues || isReportTypes) {
|
|
290
292
|
streamer.cast('Analyzing source files...');
|
|
291
293
|
for (const [filePath, exportItems] of Object.entries(exportedSymbols)) {
|
|
@@ -312,11 +314,11 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
312
314
|
}
|
|
313
315
|
if (isIdentifierReferenced(filePath, identifier, importsForExport)) {
|
|
314
316
|
if (report.enumMembers && exportedItem.type === 'enum') {
|
|
315
|
-
exportedItem.members
|
|
317
|
+
for (const member of exportedItem.members) {
|
|
316
318
|
if (hasMatch(workspace.ignoreMembers, member.identifier))
|
|
317
|
-
|
|
319
|
+
continue;
|
|
318
320
|
if (shouldIgnore(member.jsDocTags, tags))
|
|
319
|
-
|
|
321
|
+
continue;
|
|
320
322
|
if (member.refs === 0) {
|
|
321
323
|
if (!isIdentifierReferenced(filePath, `${identifier}.${member.identifier}`, importsForExport)) {
|
|
322
324
|
collector.addIssue({
|
|
@@ -330,11 +332,11 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
330
332
|
});
|
|
331
333
|
}
|
|
332
334
|
}
|
|
333
|
-
}
|
|
335
|
+
}
|
|
334
336
|
}
|
|
335
|
-
if (isReportClassMembers && exportedItem.type === 'class') {
|
|
336
|
-
const members = exportedItem.members.filter(member => !hasMatch(workspace.ignoreMembers, member.identifier)
|
|
337
|
-
principal
|
|
337
|
+
if (principal && isReportClassMembers && exportedItem.type === 'class') {
|
|
338
|
+
const members = exportedItem.members.filter(member => !(hasMatch(workspace.ignoreMembers, member.identifier) || shouldIgnore(member.jsDocTags, tags)));
|
|
339
|
+
for (const member of principal.findUnusedMembers(filePath, members)) {
|
|
338
340
|
collector.addIssue({
|
|
339
341
|
type: 'classMembers',
|
|
340
342
|
filePath,
|
|
@@ -344,14 +346,14 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
344
346
|
line: member.line,
|
|
345
347
|
col: member.col,
|
|
346
348
|
});
|
|
347
|
-
}
|
|
349
|
+
}
|
|
348
350
|
}
|
|
349
351
|
continue;
|
|
350
352
|
}
|
|
351
353
|
}
|
|
352
354
|
const [hasStrictlyNsReferences, namespace] = getHasStrictlyNsReferences(importsForExport);
|
|
353
355
|
const isType = ['enum', 'type', 'interface'].includes(exportedItem.type);
|
|
354
|
-
if (hasStrictlyNsReferences && ((!report.nsTypes && isType) || (
|
|
356
|
+
if (hasStrictlyNsReferences && ((!report.nsTypes && isType) || !(report.nsExports || isType)))
|
|
355
357
|
continue;
|
|
356
358
|
if (!isExportedItemReferenced(exportedItem)) {
|
|
357
359
|
if (!isSkipLibs && principal?.hasReferences(filePath, exportedItem))
|
|
@@ -382,14 +384,20 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
382
384
|
if (isReportDependencies) {
|
|
383
385
|
const { dependencyIssues, devDependencyIssues, optionalPeerDependencyIssues } = deputy.settleDependencyIssues();
|
|
384
386
|
const { configurationHints } = deputy.getConfigurationHints();
|
|
385
|
-
|
|
387
|
+
for (const issue of dependencyIssues)
|
|
388
|
+
collector.addIssue(issue);
|
|
386
389
|
if (!isProduction)
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
+
for (const issue of devDependencyIssues)
|
|
391
|
+
collector.addIssue(issue);
|
|
392
|
+
for (const issue of optionalPeerDependencyIssues)
|
|
393
|
+
collector.addIssue(issue);
|
|
394
|
+
for (const hint of configurationHints)
|
|
395
|
+
collector.addConfigurationHint(hint);
|
|
390
396
|
}
|
|
391
397
|
const unusedIgnoredWorkspaces = chief.getUnusedIgnoredWorkspaces();
|
|
392
|
-
|
|
398
|
+
for (const identifier of unusedIgnoredWorkspaces) {
|
|
399
|
+
collector.addConfigurationHint({ type: 'ignoreWorkspaces', identifier });
|
|
400
|
+
}
|
|
393
401
|
const { issues, counters, configurationHints } = collector.getIssues();
|
|
394
402
|
if (isFix) {
|
|
395
403
|
await fixer.fixIssues(issues);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Counters, Issues, Rules } from '../types/issues.js';
|
|
2
2
|
export declare const initIssues: () => Issues;
|
|
3
3
|
export declare const initCounters: () => Counters;
|
|
4
4
|
export declare const defaultRules: Rules;
|
package/dist/manifest/helpers.js
CHANGED
|
@@ -21,7 +21,7 @@ export const getFilteredScripts = ({ isProduction, scripts }) => {
|
|
|
21
21
|
return scripts;
|
|
22
22
|
const scriptFilter = new Set(['start', 'postinstall']);
|
|
23
23
|
const filteredScripts = {};
|
|
24
|
-
for (
|
|
24
|
+
for (const scriptName in scripts) {
|
|
25
25
|
if (scriptFilter.has(scriptName))
|
|
26
26
|
filteredScripts[scriptName] = scripts[scriptName];
|
|
27
27
|
}
|
package/dist/manifest/index.d.ts
CHANGED
package/dist/manifest/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isDefinitelyTyped } from '../util/modules.js';
|
|
2
1
|
import { timerify } from '../util/Performance.js';
|
|
2
|
+
import { isDefinitelyTyped } from '../util/modules.js';
|
|
3
3
|
import { loadPackageManifest } from './helpers.js';
|
|
4
4
|
const getMetaDataFromPackageJson = ({ cwd, dir, packageNames }) => {
|
|
5
5
|
const hostDependencies = new Map();
|
|
@@ -10,7 +10,7 @@ const getMetaDataFromPackageJson = ({ cwd, dir, packageNames }) => {
|
|
|
10
10
|
if (manifest) {
|
|
11
11
|
const binaryName = packageName.replace(/^@[^/]+\//, '');
|
|
12
12
|
const binaries = typeof manifest.bin === 'string' ? [binaryName] : Object.keys(manifest.bin ?? {});
|
|
13
|
-
|
|
13
|
+
for (const binaryName of binaries) {
|
|
14
14
|
if (installedBinaries.has(binaryName)) {
|
|
15
15
|
installedBinaries.get(binaryName)?.add(packageName);
|
|
16
16
|
}
|
|
@@ -23,7 +23,7 @@ const getMetaDataFromPackageJson = ({ cwd, dir, packageNames }) => {
|
|
|
23
23
|
else {
|
|
24
24
|
installedBinaries.set(packageName, new Set([binaryName]));
|
|
25
25
|
}
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
27
|
const packagePeerDependencies = Object.keys(manifest.peerDependencies ?? {});
|
|
28
28
|
for (const packagePeerDependency of packagePeerDependencies) {
|
|
29
29
|
const hostDependency = {
|
|
@@ -31,7 +31,7 @@ const getMetaDataFromPackageJson = ({ cwd, dir, packageNames }) => {
|
|
|
31
31
|
isPeerOptional: manifest.peerDependenciesMeta?.[packagePeerDependency]?.optional ?? false,
|
|
32
32
|
};
|
|
33
33
|
if (hostDependencies.has(packagePeerDependency)) {
|
|
34
|
-
hostDependencies.get(packagePeerDependency)
|
|
34
|
+
hostDependencies.get(packagePeerDependency)?.push(hostDependency);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
hostDependencies.set(packagePeerDependency, [hostDependency]);
|
|
@@ -5,14 +5,14 @@ const enablers = ['ava'];
|
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const config = ['ava.config.{js,cjs,mjs}', 'package.json'];
|
|
7
7
|
const entry = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
'test.{js,cjs,mjs,ts}',
|
|
9
|
+
'{src,source}/test.{js,cjs,mjs,ts}',
|
|
10
|
+
'**/__tests__/**/*.{js,cjs,mjs,ts}',
|
|
11
|
+
'**/*.spec.{js,cjs,mjs,ts}',
|
|
12
|
+
'**/*.test.{js,cjs,mjs,ts}',
|
|
13
|
+
'**/test-*.{js,cjs,mjs,ts}',
|
|
14
|
+
'**/test/**/*.{js,cjs,mjs,ts}',
|
|
15
|
+
'**/tests/**/*.{js,cjs,mjs,ts}',
|
|
16
16
|
'!**/__tests__/**/__{helper,fixture}?(s)__/**/*',
|
|
17
17
|
'!**/test?(s)/**/{helper,fixture}?(s)/**/*',
|
|
18
18
|
];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { compact } from '#p/util/array.js';
|
|
2
2
|
import { hasDependency } from '#p/util/plugin.js';
|
|
3
|
-
import {
|
|
3
|
+
import { api, resolveName } from './helpers.js';
|
|
4
4
|
const title = 'Babel';
|
|
5
5
|
const enablers = [/^@babel\//];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
7
|
const config = ['babel.config.{json,js,cjs,mjs,cts}', '.babelrc.{json,js,cjs,mjs,cts}', '.babelrc', 'package.json'];
|
|
8
|
-
const getName = (value) =>
|
|
8
|
+
const getName = (value) => [Array.isArray(value) ? value[0] : value].filter(name => typeof name === 'string');
|
|
9
9
|
export const getDependenciesFromConfig = (config) => {
|
|
10
10
|
const presets = config.presets?.flatMap(getName).map(name => resolveName(name, 'preset')) ?? [];
|
|
11
11
|
const plugins = config.plugins?.flatMap(getName).map(name => resolveName(name, 'plugin')) ?? [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export class DummyEleventyConfig {
|
|
2
|
-
constructor() { }
|
|
3
2
|
_getUniqueId() { }
|
|
4
3
|
reset() { }
|
|
5
4
|
versionCheck() { }
|
|
@@ -35,7 +34,7 @@ export class DummyEleventyConfig {
|
|
|
35
34
|
this.passthroughCopies[input] = {};
|
|
36
35
|
}
|
|
37
36
|
else {
|
|
38
|
-
for (
|
|
37
|
+
for (const [inputPath] of Object.entries(input)) {
|
|
39
38
|
this.passthroughCopies[inputPath] = {};
|
|
40
39
|
}
|
|
41
40
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DummyEleventyConfig } from './helpers.js';
|
|
2
1
|
import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '#p/types/plugins.js';
|
|
2
|
+
import { DummyEleventyConfig } from './helpers.js';
|
|
3
3
|
import type { EleventyConfig } from './types.js';
|
|
4
4
|
type T = Partial<EleventyConfig> | ((arg: DummyEleventyConfig) => Promise<Partial<EleventyConfig>>);
|
|
5
5
|
declare const _default: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ESLintConfig } from './types.js';
|
|
2
1
|
import type { PluginOptions } from '../../types/plugins.js';
|
|
2
|
+
import type { ESLintConfig } from './types.js';
|
|
3
3
|
type GetDependenciesDeep = (localConfig: ESLintConfig, options: PluginOptions, dependencies?: Set<string>) => Promise<Set<string>>;
|
|
4
4
|
export declare const getDependenciesDeep: GetDependenciesDeep;
|
|
5
5
|
export {};
|
|
@@ -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 { isInternal, toAbsolute
|
|
3
|
+
import { 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';
|
|
@@ -19,7 +19,10 @@ const getDependencies = (config) => {
|
|
|
19
19
|
};
|
|
20
20
|
export const getDependenciesDeep = async (localConfig, options, dependencies = new Set()) => {
|
|
21
21
|
const { configFileDir } = options;
|
|
22
|
-
const addAll = (deps) =>
|
|
22
|
+
const addAll = (deps) => {
|
|
23
|
+
for (const dependency of deps)
|
|
24
|
+
dependencies.add(dependency);
|
|
25
|
+
};
|
|
23
26
|
if (localConfig) {
|
|
24
27
|
if (localConfig.extends) {
|
|
25
28
|
for (const extend of [localConfig.extends].flat()) {
|
|
@@ -5,7 +5,7 @@ const enablers = ['eslint'];
|
|
|
5
5
|
const isEnabled = ({ dependencies, manifest, config }) => hasDependency(dependencies, enablers) ||
|
|
6
6
|
'eslint' in config ||
|
|
7
7
|
Boolean(manifest.name && /(^eslint-config|\/eslint-config)/.test(manifest.name));
|
|
8
|
-
|
|
8
|
+
const packageJsonPath = 'eslintConfig';
|
|
9
9
|
const entry = ['eslint.config.{js,cjs,mjs}'];
|
|
10
10
|
const config = ['.eslintrc', '.eslintrc.{js,json,cjs}', '.eslintrc.{yml,yaml}', 'package.json'];
|
|
11
11
|
const resolveConfig = async (localConfig, options) => {
|
|
@@ -12,7 +12,7 @@ const resolveConfig = async (config, options) => {
|
|
|
12
12
|
const scripts = getValuesByKeyDeep(config, 'run').filter(isString);
|
|
13
13
|
const getActionDependencies = () => {
|
|
14
14
|
const isActionManifest = configFileName === 'action.yml' || configFileName === 'action.yaml';
|
|
15
|
-
if (!isActionManifest
|
|
15
|
+
if (!(isActionManifest && config?.runs?.using?.startsWith('node')))
|
|
16
16
|
return [];
|
|
17
17
|
const scripts = [config.runs.pre, config.runs.main, config.runs.post].filter(isString);
|
|
18
18
|
return scripts.map(script => join(configFileDir, script));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dirname, isInternal, join, toAbsolute } from '#p/util/path.js';
|
|
2
2
|
import { hasDependency, load } from '#p/util/plugin.js';
|
|
3
3
|
import { toEntryPattern } from '#p/util/protocols.js';
|
|
4
4
|
const title = 'Jest';
|
|
@@ -36,7 +36,8 @@ const resolveDependencies = async (config, options) => {
|
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
38
|
const dependencies = await resolveDependencies(project, options);
|
|
39
|
-
|
|
39
|
+
for (const dependency of dependencies)
|
|
40
|
+
projects.push(dependency);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
const runner = config.runner ? [config.runner] : [];
|
|
@@ -84,7 +85,7 @@ const resolveEntryPaths = async (localConfig, options) => {
|
|
|
84
85
|
localConfig = await localConfig();
|
|
85
86
|
const rootDir = localConfig.rootDir ? join(configFileDir, localConfig.rootDir) : configFileDir;
|
|
86
87
|
const replaceRootDir = (name) => (name.includes('<rootDir>') ? name.replace(/<rootDir>/, rootDir) : name);
|
|
87
|
-
const matchCwd = new RegExp(
|
|
88
|
+
const matchCwd = new RegExp(`^${toEntryPattern(cwd)}/`);
|
|
88
89
|
return (localConfig.testMatch ?? [])
|
|
89
90
|
.map(replaceRootDir)
|
|
90
91
|
.map(dependency => dependency.replace(matchCwd, toEntryPattern('')))
|
|
@@ -97,7 +98,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
97
98
|
const rootDir = localConfig.rootDir ? join(configFileDir, localConfig.rootDir) : configFileDir;
|
|
98
99
|
const replaceRootDir = (name) => (name.includes('<rootDir>') ? name.replace(/<rootDir>/, rootDir) : name);
|
|
99
100
|
const dependencies = await resolveDependencies(localConfig, options);
|
|
100
|
-
const matchCwd = new RegExp(
|
|
101
|
+
const matchCwd = new RegExp(`^${toEntryPattern(cwd)}/`);
|
|
101
102
|
return dependencies.map(replaceRootDir).map(dependency => dependency.replace(matchCwd, toEntryPattern('')));
|
|
102
103
|
};
|
|
103
104
|
export default {
|
|
@@ -19,7 +19,8 @@ const resolveConfig = async (config, options) => {
|
|
|
19
19
|
const dependencies = new Set();
|
|
20
20
|
for (const entry of Object.values(config).flat()) {
|
|
21
21
|
const scripts = [typeof entry === 'function' ? await entry([]) : entry].flat();
|
|
22
|
-
getDependenciesFromScripts(scripts, options)
|
|
22
|
+
for (const id of getDependenciesFromScripts(scripts, options))
|
|
23
|
+
dependencies.add(id);
|
|
23
24
|
}
|
|
24
25
|
return Array.from(dependencies);
|
|
25
26
|
};
|