knip 5.69.0 → 5.70.0
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/CatalogCounselor.d.ts +1 -1
- package/dist/CatalogCounselor.js +5 -2
- package/dist/ConfigurationChief.d.ts +6 -0
- package/dist/DependencyDeputy.js +10 -3
- package/dist/IssueFixer.d.ts +0 -6
- package/dist/IssueFixer.js +37 -56
- package/dist/binaries/package-manager/yarn.js +1 -0
- package/dist/binaries/plugins.js +4 -4
- package/dist/compilers/index.d.ts +10 -0
- package/dist/compilers/index.js +2 -0
- package/dist/compilers/prisma.d.ts +6 -0
- package/dist/compilers/prisma.js +13 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +4 -0
- package/dist/graph/analyze.d.ts +1 -1
- package/dist/graph/analyze.js +20 -17
- package/dist/graph/build.js +3 -3
- package/dist/index.js +1 -2
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/next/index.js +4 -5
- package/dist/plugins/prisma/index.js +27 -5
- package/dist/plugins/prisma/types.d.ts +1 -0
- package/dist/plugins/taskfile/index.d.ts +3 -0
- package/dist/plugins/taskfile/index.js +111 -0
- package/dist/plugins/taskfile/types.d.ts +25 -0
- package/dist/plugins/taskfile/types.js +1 -0
- package/dist/plugins/vitest/helpers.d.ts +1 -1
- package/dist/plugins/vitest/helpers.js +1 -1
- package/dist/plugins/vitest/index.js +11 -4
- package/dist/reporters/util/configuration-hints.js +1 -1
- package/dist/schema/configuration.d.ts +10 -0
- package/dist/schema/plugins.d.ts +5 -0
- package/dist/schema/plugins.js +1 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +1 -0
- package/dist/types/args.d.ts +4 -1
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/issues.d.ts +2 -0
- package/dist/types/module-graph.d.ts +6 -6
- package/dist/typescript/ast-helpers.d.ts +10 -1
- package/dist/typescript/ast-helpers.js +33 -4
- package/dist/typescript/get-imports-and-exports.js +51 -46
- package/dist/typescript/pragmas/custom.d.ts +3 -0
- package/dist/typescript/pragmas/custom.js +25 -0
- package/dist/typescript/pragmas/index.d.ts +3 -0
- package/dist/typescript/pragmas/index.js +3 -0
- package/dist/typescript/pragmas/typescript.d.ts +3 -0
- package/dist/typescript/pragmas/typescript.js +29 -0
- package/dist/typescript/visitors/dynamic-imports/importCall.js +21 -9
- package/dist/typescript/visitors/dynamic-imports/importType.js +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.js +1 -1
- package/dist/typescript/visitors/helpers.d.ts +0 -2
- package/dist/typescript/visitors/helpers.js +0 -38
- package/dist/typescript/visitors/imports/importDeclaration.js +4 -4
- package/dist/typescript/visitors/imports/importEqualsDeclaration.js +1 -1
- package/dist/util/create-options.d.ts +10 -0
- package/dist/util/get-referenced-inputs.js +4 -0
- package/dist/util/has-strictly-ns-references.d.ts +3 -3
- package/dist/util/is-identifier-referenced.js +10 -10
- package/dist/util/module-graph.d.ts +2 -2
- package/dist/util/module-graph.js +22 -22
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
- package/schema.json +4 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { _firstGlob } from '../../util/glob.js';
|
|
2
|
+
import { toConfig } from '../../util/input.js';
|
|
3
|
+
import { join, relative } from '../../util/path.js';
|
|
4
|
+
const title = 'Taskfile';
|
|
5
|
+
const enablers = 'This plugin is enabled when a Taskfile is found (Taskfile.yml, taskfile.yml, Taskfile.yaml, taskfile.yaml, etc.).';
|
|
6
|
+
const isRootOnly = true;
|
|
7
|
+
const defaultConfigPatterns = ['{T,t}askfile.{yml,yaml}', '{T,t}askfile.dist.{yml,yaml}'];
|
|
8
|
+
const isEnabled = async ({ cwd, config }) => {
|
|
9
|
+
if (config.taskfile)
|
|
10
|
+
return true;
|
|
11
|
+
return Boolean(await _firstGlob({ cwd, patterns: defaultConfigPatterns }));
|
|
12
|
+
};
|
|
13
|
+
const extractScriptsFromCommand = (command) => {
|
|
14
|
+
const scripts = [];
|
|
15
|
+
if (typeof command === 'string') {
|
|
16
|
+
scripts.push(command);
|
|
17
|
+
}
|
|
18
|
+
else if (command && typeof command === 'object') {
|
|
19
|
+
if (command.cmd && typeof command.cmd === 'string') {
|
|
20
|
+
scripts.push(command.cmd);
|
|
21
|
+
}
|
|
22
|
+
if (command.defer) {
|
|
23
|
+
if (typeof command.defer === 'string') {
|
|
24
|
+
scripts.push(command.defer);
|
|
25
|
+
}
|
|
26
|
+
else if (command.defer && typeof command.defer === 'object' && 'cmd' in command.defer) {
|
|
27
|
+
if (typeof command.defer.cmd === 'string') {
|
|
28
|
+
scripts.push(command.defer.cmd);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (command.for && 'cmd' in command && typeof command.cmd === 'string') {
|
|
33
|
+
scripts.push(command.cmd);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return scripts;
|
|
37
|
+
};
|
|
38
|
+
const extractScriptsFromTask = (task) => {
|
|
39
|
+
const scripts = [];
|
|
40
|
+
if (typeof task === 'string') {
|
|
41
|
+
scripts.push(task);
|
|
42
|
+
return scripts;
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(task)) {
|
|
45
|
+
for (const cmd of task) {
|
|
46
|
+
if (typeof cmd === 'string') {
|
|
47
|
+
scripts.push(cmd);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return scripts;
|
|
51
|
+
}
|
|
52
|
+
if (task && typeof task === 'object') {
|
|
53
|
+
if (task.cmd && typeof task.cmd === 'string') {
|
|
54
|
+
scripts.push(task.cmd);
|
|
55
|
+
}
|
|
56
|
+
if (task.cmds) {
|
|
57
|
+
if (typeof task.cmds === 'string') {
|
|
58
|
+
scripts.push(task.cmds);
|
|
59
|
+
}
|
|
60
|
+
else if (Array.isArray(task.cmds)) {
|
|
61
|
+
for (const cmd of task.cmds) {
|
|
62
|
+
scripts.push(...extractScriptsFromCommand(cmd));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return scripts;
|
|
68
|
+
};
|
|
69
|
+
const resolveConfig = async (localConfig, options) => {
|
|
70
|
+
if (!localConfig || !options.configFilePath)
|
|
71
|
+
return [];
|
|
72
|
+
const { configFilePath, getInputsFromScripts, isProduction, configFileDir } = options;
|
|
73
|
+
const inputs = [];
|
|
74
|
+
if (localConfig.includes && typeof localConfig.includes === 'object') {
|
|
75
|
+
for (const includeValue of Object.values(localConfig.includes)) {
|
|
76
|
+
const includePath = typeof includeValue === 'string'
|
|
77
|
+
? includeValue
|
|
78
|
+
: includeValue && typeof includeValue === 'object' && 'taskfile' in includeValue
|
|
79
|
+
? includeValue.taskfile
|
|
80
|
+
: undefined;
|
|
81
|
+
if (includePath) {
|
|
82
|
+
const resolvedPath = join(configFileDir, includePath);
|
|
83
|
+
inputs.push(toConfig('taskfile', relative(configFileDir, resolvedPath), { containingFilePath: configFilePath }));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (localConfig.tasks && typeof localConfig.tasks === 'object') {
|
|
88
|
+
for (const task of Object.values(localConfig.tasks)) {
|
|
89
|
+
for (const script of extractScriptsFromTask(task)) {
|
|
90
|
+
for (const input of getInputsFromScripts([script], {
|
|
91
|
+
knownBinsOnly: true,
|
|
92
|
+
containingFilePath: configFilePath,
|
|
93
|
+
})) {
|
|
94
|
+
if (isProduction)
|
|
95
|
+
Object.assign(input, { optional: true });
|
|
96
|
+
inputs.push({ ...input, dir: configFileDir });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return inputs;
|
|
102
|
+
};
|
|
103
|
+
const plugin = {
|
|
104
|
+
title,
|
|
105
|
+
enablers,
|
|
106
|
+
isEnabled,
|
|
107
|
+
config: defaultConfigPatterns,
|
|
108
|
+
resolveConfig,
|
|
109
|
+
isRootOnly,
|
|
110
|
+
};
|
|
111
|
+
export default plugin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type TaskfileCommand = string | {
|
|
2
|
+
cmd?: string;
|
|
3
|
+
task?: string;
|
|
4
|
+
defer?: string | {
|
|
5
|
+
task?: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
for?: unknown;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type TaskfileTask = string | string[] | {
|
|
12
|
+
cmds?: string | TaskfileCommand[];
|
|
13
|
+
cmd?: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
type TaskfileInclude = string | {
|
|
17
|
+
taskfile: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
export type TaskfileConfig = {
|
|
21
|
+
tasks?: Record<string, TaskfileTask>;
|
|
22
|
+
includes?: Record<string, TaskfileInclude>;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ViteConfig } from './types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getEnvSpecifier: (env: string) => string;
|
|
3
3
|
export declare const getExternalReporters: (reporters?: ViteConfig["test"]["reporters"]) => string[];
|
|
@@ -9,7 +9,7 @@ const envPackageNames = {
|
|
|
9
9
|
'happy-dom': 'happy-dom',
|
|
10
10
|
'edge-runtime': '@edge-runtime/vm',
|
|
11
11
|
};
|
|
12
|
-
export const
|
|
12
|
+
export const getEnvSpecifier = (env) => {
|
|
13
13
|
if (env in envPackageNames)
|
|
14
14
|
return envPackageNames[env];
|
|
15
15
|
return `vitest-environment-${env}`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_EXTENSIONS } from '../../constants.js';
|
|
2
2
|
import { _glob } from '../../util/glob.js';
|
|
3
3
|
import { toAlias, toConfig, toDeferResolve, toDependency, toEntry } from '../../util/input.js';
|
|
4
|
-
import { join, toPosix } from '../../util/path.js';
|
|
4
|
+
import { isAbsolute, isInternal, join, toPosix } from '../../util/path.js';
|
|
5
5
|
import { hasDependency } from '../../util/plugin.js';
|
|
6
|
-
import {
|
|
6
|
+
import { getEnvSpecifier, getExternalReporters } from './helpers.js';
|
|
7
7
|
const title = 'Vitest';
|
|
8
8
|
const enablers = ['vitest'];
|
|
9
9
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
@@ -17,7 +17,12 @@ const findConfigDependencies = (localConfig, options) => {
|
|
|
17
17
|
const testConfig = localConfig.test;
|
|
18
18
|
if (!testConfig)
|
|
19
19
|
return [];
|
|
20
|
-
const
|
|
20
|
+
const env = testConfig.environment;
|
|
21
|
+
const environments = env && env !== 'node'
|
|
22
|
+
? isInternal(env) || isAbsolute(env)
|
|
23
|
+
? [toDeferResolve(env)]
|
|
24
|
+
: [toDependency(getEnvSpecifier(env))]
|
|
25
|
+
: [];
|
|
21
26
|
const reporters = getExternalReporters(testConfig.reporters);
|
|
22
27
|
const hasCoverageEnabled = (testConfig.coverage && testConfig.coverage.enabled !== false) || hasScriptWithCoverage(manifest.scripts);
|
|
23
28
|
const coverage = hasCoverageEnabled ? [`@vitest/coverage-${testConfig.coverage?.provider ?? 'v8'}`] : [];
|
|
@@ -38,7 +43,9 @@ const findConfigDependencies = (localConfig, options) => {
|
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
return [
|
|
41
|
-
...
|
|
46
|
+
...environments,
|
|
47
|
+
...reporters.map(id => toDependency(id)),
|
|
48
|
+
...coverage.map(id => toDependency(id)),
|
|
42
49
|
...setupFiles,
|
|
43
50
|
...globalSetup,
|
|
44
51
|
...workspaceDependencies,
|
|
@@ -107,7 +107,7 @@ export const printConfigurationHints = ({ cwd, counters, issues, tagHints, confi
|
|
|
107
107
|
console.warn(getTableForHints(rows).toString());
|
|
108
108
|
}
|
|
109
109
|
if (tagHints.size > 0) {
|
|
110
|
-
console.log(
|
|
110
|
+
console.log(getDimmedTitle('Tag hints', tagHints.size));
|
|
111
111
|
for (const hint of tagHints) {
|
|
112
112
|
const { filePath, identifier, tagName } = hint;
|
|
113
113
|
const message = `Unused tag in ${toRelative(filePath, cwd)}:`;
|
|
@@ -487,6 +487,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
487
487
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
488
488
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
489
489
|
}, z.core.$strip>]>>;
|
|
490
|
+
taskfile: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
491
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
492
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
493
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
494
|
+
}, z.core.$strip>]>>;
|
|
490
495
|
travis: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
491
496
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
492
497
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -1078,6 +1083,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
1078
1083
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1079
1084
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1080
1085
|
}, z.core.$strip>]>>;
|
|
1086
|
+
taskfile: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
1087
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1088
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1089
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1090
|
+
}, z.core.$strip>]>>;
|
|
1081
1091
|
travis: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
1082
1092
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1083
1093
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
package/dist/schema/plugins.d.ts
CHANGED
|
@@ -491,6 +491,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
|
|
|
491
491
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
492
492
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
493
493
|
}, z.core.$strip>]>;
|
|
494
|
+
taskfile: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
495
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
496
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
497
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
498
|
+
}, z.core.$strip>]>;
|
|
494
499
|
travis: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
495
500
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
496
501
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
package/dist/schema/plugins.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'syncpack' | 'tailwind' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
|
|
2
|
-
export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "syncpack", "tailwind", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
|
|
1
|
+
export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'syncpack' | 'tailwind' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
|
|
2
|
+
export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "syncpack", "tailwind", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
|
package/dist/types/args.d.ts
CHANGED
|
@@ -12,5 +12,8 @@ export type Args = {
|
|
|
12
12
|
config?: ConfigArg;
|
|
13
13
|
args?: (args: string[]) => string[];
|
|
14
14
|
fromArgs?: string[] | ((parsed: ParsedArgs, args: string[]) => string[]);
|
|
15
|
-
resolveInputs?: (parsed: ParsedArgs,
|
|
15
|
+
resolveInputs?: (parsed: ParsedArgs, options: {
|
|
16
|
+
cwd: string;
|
|
17
|
+
args: string[];
|
|
18
|
+
}) => Input[];
|
|
16
19
|
};
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
2
|
import type { SymbolType } from './issues.js';
|
|
3
3
|
type Identifier = string;
|
|
4
|
-
|
|
4
|
+
type ExportPosTuple = [number, number, number];
|
|
5
5
|
export type Fix = ExportPosTuple | undefined;
|
|
6
6
|
export type Fixes = Array<ExportPosTuple>;
|
|
7
7
|
export type ExportNode = {
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SYMBOL_TYPE } from '../constants.js';
|
|
2
|
+
import type { Fixes } from './exports.js';
|
|
2
3
|
export type SymbolType = (typeof SYMBOL_TYPE)[keyof typeof SYMBOL_TYPE];
|
|
3
4
|
export type IssueSymbol = {
|
|
4
5
|
symbol: string;
|
|
@@ -19,6 +20,7 @@ export type Issue = {
|
|
|
19
20
|
pos?: number;
|
|
20
21
|
line?: number;
|
|
21
22
|
col?: number;
|
|
23
|
+
fixes: Fixes;
|
|
22
24
|
isFixed?: boolean;
|
|
23
25
|
};
|
|
24
26
|
export type IssueSet = Set<string>;
|
|
@@ -9,7 +9,7 @@ type References = Set<Reference>;
|
|
|
9
9
|
type Tags = Set<string>;
|
|
10
10
|
export type IdToFileMap = Map<Identifier, Set<FilePath>>;
|
|
11
11
|
export type IdToNsToFileMap = Map<Identifier, Map<NamespaceOrAlias, Set<FilePath>>>;
|
|
12
|
-
export type
|
|
12
|
+
export type ImportMaps = {
|
|
13
13
|
refs: References;
|
|
14
14
|
imported: IdToFileMap;
|
|
15
15
|
importedAs: IdToNsToFileMap;
|
|
@@ -18,9 +18,10 @@ export type ImportDetails = {
|
|
|
18
18
|
reExportedAs: IdToNsToFileMap;
|
|
19
19
|
reExportedNs: IdToFileMap;
|
|
20
20
|
};
|
|
21
|
-
export type ImportMap = Map<FilePath,
|
|
21
|
+
export type ImportMap = Map<FilePath, ImportMaps>;
|
|
22
22
|
export type Import = {
|
|
23
23
|
specifier: string;
|
|
24
|
+
identifier: string;
|
|
24
25
|
pos?: number;
|
|
25
26
|
line?: number;
|
|
26
27
|
col?: number;
|
|
@@ -36,7 +37,6 @@ export interface Export {
|
|
|
36
37
|
refs: [number, boolean];
|
|
37
38
|
fixes: Fixes;
|
|
38
39
|
symbol?: ts.Symbol;
|
|
39
|
-
isReExport: boolean;
|
|
40
40
|
}
|
|
41
41
|
export type ExportMember = {
|
|
42
42
|
identifier: Identifier;
|
|
@@ -50,19 +50,19 @@ export type ExportMember = {
|
|
|
50
50
|
jsDocTags: Tags;
|
|
51
51
|
};
|
|
52
52
|
export type ExportMap = Map<Identifier, Export>;
|
|
53
|
-
export type
|
|
53
|
+
export type Imports = Set<[Import, FilePath]>;
|
|
54
54
|
export type FileNode = {
|
|
55
55
|
imports: {
|
|
56
56
|
internal: ImportMap;
|
|
57
57
|
external: Set<Import>;
|
|
58
58
|
unresolved: Set<Import>;
|
|
59
59
|
resolved: Set<FilePath>;
|
|
60
|
-
|
|
60
|
+
imports: Imports;
|
|
61
61
|
};
|
|
62
62
|
exports: ExportMap;
|
|
63
63
|
duplicates: Iterable<Array<IssueSymbol>>;
|
|
64
64
|
scripts: Set<string>;
|
|
65
|
-
imported?:
|
|
65
|
+
imported?: ImportMaps;
|
|
66
66
|
internalImportCache?: ImportMap;
|
|
67
67
|
traceRefs: References;
|
|
68
68
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { Fix } from '../types/exports.js';
|
|
3
3
|
import type { SymbolType } from '../types/issues.js';
|
|
4
|
-
|
|
4
|
+
import type { BoundSourceFile } from './SourceFile.js';
|
|
5
|
+
export declare function isDefaultImport(node: ts.ImportDeclaration | ts.ImportEqualsDeclaration | ts.ExportDeclaration): node is ts.ImportDeclaration;
|
|
5
6
|
export declare function isAccessExpression(node: ts.Node): node is ts.AccessExpression;
|
|
6
7
|
export declare function isImportCall(node: ts.Node): node is ts.ImportCall;
|
|
7
8
|
export declare function isRequireCall(callExpression: ts.Node): callExpression is ts.CallExpression;
|
|
@@ -25,6 +26,13 @@ export declare const getEnumMember: (member: ts.EnumMember, isFixTypes: boolean)
|
|
|
25
26
|
export declare function stripQuotes(name: string): string;
|
|
26
27
|
export declare function findAncestor<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T | undefined;
|
|
27
28
|
export declare function findDescendants<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T[];
|
|
29
|
+
export declare const getLeadingComments: (sourceFile: BoundSourceFile) => {
|
|
30
|
+
text: string;
|
|
31
|
+
hasTrailingNewLine?: boolean;
|
|
32
|
+
kind: ts.CommentKind;
|
|
33
|
+
pos: number;
|
|
34
|
+
end: number;
|
|
35
|
+
}[];
|
|
28
36
|
export declare const isDeclarationFileExtension: (extension: string) => extension is ".d.ts" | ".d.mts" | ".d.cts";
|
|
29
37
|
export declare const getJSDocTags: (node: ts.Node) => Set<string>;
|
|
30
38
|
export declare const getLineAndCharacterOfPosition: (node: ts.Node, pos: number) => {
|
|
@@ -36,6 +44,7 @@ export declare const getAccessMembers: (typeChecker: ts.TypeChecker, node: ts.Id
|
|
|
36
44
|
export declare const isDestructuring: (node: ts.Node) => boolean;
|
|
37
45
|
export declare const getDestructuredNames: (name: ts.ObjectBindingPattern) => [string[], boolean];
|
|
38
46
|
export declare const isConsiderReferencedNS: (node: ts.Identifier) => boolean;
|
|
47
|
+
export declare const isInOpaqueExpression: (node: ts.Node) => boolean;
|
|
39
48
|
export declare const isObjectEnumerationCallExpressionArgument: (node: ts.Identifier) => boolean;
|
|
40
49
|
export declare const isInForIteration: (node: ts.Node) => boolean;
|
|
41
50
|
export declare const isTopLevel: (node: ts.Node) => boolean;
|
|
@@ -115,6 +115,23 @@ export function findDescendants(node, callback) {
|
|
|
115
115
|
visit(node);
|
|
116
116
|
return results;
|
|
117
117
|
}
|
|
118
|
+
export const getLeadingComments = (sourceFile) => {
|
|
119
|
+
const text = sourceFile.text;
|
|
120
|
+
if (!text)
|
|
121
|
+
return [];
|
|
122
|
+
const firstStatement = sourceFile.statements[0];
|
|
123
|
+
const limit = firstStatement ? firstStatement.getStart() : text.length;
|
|
124
|
+
const ranges = ts.getLeadingCommentRanges(text, 0);
|
|
125
|
+
if (!ranges?.length)
|
|
126
|
+
return [];
|
|
127
|
+
const comments = [];
|
|
128
|
+
for (const range of ranges) {
|
|
129
|
+
if (range.end > limit)
|
|
130
|
+
break;
|
|
131
|
+
comments.push({ ...range, text: text.slice(range.pos, range.end) });
|
|
132
|
+
}
|
|
133
|
+
return comments;
|
|
134
|
+
};
|
|
118
135
|
export const isDeclarationFileExtension = (extension) => extension === '.d.ts' || extension === '.d.mts' || extension === '.d.cts';
|
|
119
136
|
export const getJSDocTags = (node) => {
|
|
120
137
|
const tags = new Set();
|
|
@@ -188,6 +205,13 @@ export const isConsiderReferencedNS = (node) => ts.isPropertyAssignment(node.par
|
|
|
188
205
|
ts.isExportAssignment(node.parent) ||
|
|
189
206
|
(ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) ||
|
|
190
207
|
ts.isTypeQueryNode(node.parent.parent);
|
|
208
|
+
export const isInOpaqueExpression = (node) => ts.isAwaitExpression(node.parent)
|
|
209
|
+
? isInOpaqueExpression(node.parent)
|
|
210
|
+
: ts.isCallExpression(node.parent) ||
|
|
211
|
+
ts.isReturnStatement(node.parent) ||
|
|
212
|
+
ts.isArrowFunction(node.parent) ||
|
|
213
|
+
ts.isPropertyAssignment(node.parent) ||
|
|
214
|
+
ts.isSpreadAssignment(node.parent.parent);
|
|
191
215
|
const objectEnumerationMethods = new Set(['keys', 'entries', 'values', 'getOwnPropertyNames']);
|
|
192
216
|
export const isObjectEnumerationCallExpressionArgument = (node) => ts.isCallExpression(node.parent) &&
|
|
193
217
|
node.parent.arguments.includes(node) &&
|
|
@@ -275,14 +299,19 @@ export const getPropertyValues = (node, propertyName) => {
|
|
|
275
299
|
}
|
|
276
300
|
return values;
|
|
277
301
|
};
|
|
302
|
+
const isMatchAlias = (expression, identifier) => {
|
|
303
|
+
while (expression && ts.isAwaitExpression(expression))
|
|
304
|
+
expression = expression.expression;
|
|
305
|
+
return expression && ts.isIdentifier(expression) && expression.escapedText === identifier;
|
|
306
|
+
};
|
|
278
307
|
export const getAccessedIdentifiers = (identifier, scope) => {
|
|
279
308
|
const identifiers = [];
|
|
280
309
|
function visit(node) {
|
|
281
|
-
if (ts.isPropertyAccessExpression(node) && node.expression
|
|
310
|
+
if (ts.isPropertyAccessExpression(node) && isMatchAlias(node.expression, identifier)) {
|
|
282
311
|
identifiers.push({ identifier: String(node.name.escapedText), pos: node.name.pos });
|
|
283
312
|
}
|
|
284
313
|
else if (ts.isElementAccessExpression(node) &&
|
|
285
|
-
node.expression
|
|
314
|
+
isMatchAlias(node.expression, identifier) &&
|
|
286
315
|
ts.isStringLiteral(node.argumentExpression)) {
|
|
287
316
|
identifiers.push({
|
|
288
317
|
identifier: stripQuotes(node.argumentExpression.text),
|
|
@@ -290,12 +319,12 @@ export const getAccessedIdentifiers = (identifier, scope) => {
|
|
|
290
319
|
});
|
|
291
320
|
}
|
|
292
321
|
else if (ts.isVariableDeclaration(node) &&
|
|
293
|
-
node.initializer
|
|
322
|
+
isMatchAlias(node.initializer, identifier) &&
|
|
294
323
|
ts.isObjectBindingPattern(node.name)) {
|
|
295
324
|
for (const element of node.name.elements) {
|
|
296
325
|
if (ts.isBindingElement(element)) {
|
|
297
326
|
const identifier = (element.propertyName ?? element.name).getText();
|
|
298
|
-
identifiers.push({ identifier, pos: element.
|
|
327
|
+
identifiers.push({ identifier, pos: element.getStart() });
|
|
299
328
|
}
|
|
300
329
|
}
|
|
301
330
|
}
|