knip 5.50.5 → 5.51.1
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/README.md +1 -1
- package/dist/ConfigurationChief.d.ts +4 -1
- package/dist/ConfigurationChief.js +3 -0
- package/dist/binaries/package-manager/bun.js +2 -0
- package/dist/binaries/package-manager/pnpm.js +7 -7
- package/dist/cli.js +3 -3
- package/dist/compilers/astro.js +5 -1
- package/dist/compilers/compilers.js +1 -1
- package/dist/compilers/index.d.ts +44 -13
- package/dist/compilers/index.js +9 -6
- package/dist/compilers/types.d.ts +1 -0
- package/dist/graph/build.js +12 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -1
- package/dist/plugins/astro/index.d.ts +1 -0
- package/dist/plugins/astro/index.js +1 -1
- package/dist/plugins/bun/index.d.ts +11 -0
- package/dist/plugins/bun/index.js +28 -0
- package/dist/plugins/eslint/index.js +1 -2
- package/dist/plugins/index.d.ts +37 -10
- package/dist/plugins/index.js +8 -2
- package/dist/plugins/lint-staged/index.d.ts +0 -1
- package/dist/plugins/lint-staged/index.js +0 -2
- package/dist/plugins/nano-staged/index.d.ts +10 -0
- package/dist/plugins/nano-staged/index.js +33 -0
- package/dist/plugins/nano-staged/types.d.ts +7 -0
- package/dist/plugins/next/index.js +2 -1
- package/dist/plugins/oxlint/index.d.ts +12 -0
- package/dist/plugins/oxlint/index.js +16 -0
- package/dist/plugins/preconstruct/index.js +2 -2
- package/dist/plugins/prettier/index.js +3 -3
- package/dist/plugins/relay/index.d.ts +15 -0
- package/dist/plugins/relay/index.js +31 -0
- package/dist/plugins/relay/types.d.ts +12 -0
- package/dist/plugins/relay/types.js +1 -0
- package/dist/plugins/starlight/index.js +1 -1
- package/dist/plugins/tsup/index.js +1 -1
- package/dist/plugins/xo/index.js +1 -1
- package/dist/schema/configuration.d.ts +241 -70
- package/dist/schema/configuration.js +2 -1
- package/dist/schema/plugins.d.ts +92 -23
- package/dist/schema/plugins.js +4 -1
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +4 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/typescript/ast-helpers.d.ts +16 -3
- package/dist/typescript/ast-helpers.js +21 -15
- package/dist/typescript/visitors/dynamic-imports/importCall.js +47 -53
- package/dist/typescript/visitors/exports/exportAssignment.js +17 -2
- package/dist/typescript/visitors/exports/exportKeyword.js +3 -22
- package/dist/util/cli-arguments.d.ts +1 -1
- package/dist/util/cli-arguments.js +1 -1
- package/dist/util/codeowners.js +1 -1
- package/dist/util/glob-core.d.ts +0 -8
- package/dist/util/glob-core.js +16 -49
- package/dist/util/glob.d.ts +4 -0
- package/dist/util/glob.js +2 -0
- package/dist/util/input.d.ts +3 -1
- package/dist/util/package-json.d.ts +1 -4
- package/dist/util/package-json.js +2 -3
- package/dist/util/parse-and-convert-gitignores.d.ts +8 -0
- package/dist/util/parse-and-convert-gitignores.js +40 -0
- package/dist/util/to-source-path.d.ts +1 -0
- package/dist/util/to-source-path.js +23 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
- package/schema.json +20 -4
- package/dist/plugins/tanstack-router/index.d.ts +0 -12
- package/dist/plugins/tanstack-router/index.js +0 -46
- package/dist/plugins/tanstack-router/resolveFromAST.d.ts +0 -2
- package/dist/plugins/tanstack-router/resolveFromAST.js +0 -28
- package/dist/plugins/tanstack-router/types.d.ts +0 -7
- /package/dist/plugins/{tanstack-router → nano-staged}/types.js +0 -0
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
Knip finds and fixes **unused
|
|
18
|
+
Knip finds and fixes **unused dependencies, exports and files** in your
|
|
19
19
|
JavaScript and TypeScript projects. Less code and dependencies lead to improved
|
|
20
20
|
performance, less maintenance and easier refactorings.
|
|
21
21
|
|
|
@@ -77,6 +77,7 @@ export declare class ConfigurationChief {
|
|
|
77
77
|
astro?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
78
78
|
ava?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
79
79
|
babel?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
80
|
+
bun?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
80
81
|
c8?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
81
82
|
capacitor?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
82
83
|
changesets?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -112,6 +113,7 @@ export declare class ConfigurationChief {
|
|
|
112
113
|
mocha?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
113
114
|
moonrepo?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
114
115
|
msw?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
116
|
+
"nano-staged"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
115
117
|
nest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
116
118
|
netlify?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
117
119
|
next?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -121,6 +123,7 @@ export declare class ConfigurationChief {
|
|
|
121
123
|
nx?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
122
124
|
nyc?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
123
125
|
oclif?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
126
|
+
oxlint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
124
127
|
playwright?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
125
128
|
"playwright-ct"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
126
129
|
"playwright-test"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -130,6 +133,7 @@ export declare class ConfigurationChief {
|
|
|
130
133
|
prettier?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
131
134
|
"react-cosmos"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
132
135
|
"react-router"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
136
|
+
relay?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
133
137
|
"release-it"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
134
138
|
remark?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
135
139
|
remix?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -148,7 +152,6 @@ export declare class ConfigurationChief {
|
|
|
148
152
|
svelte?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
149
153
|
syncpack?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
150
154
|
tailwind?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
151
|
-
"tanstack-router"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
152
155
|
travis?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
153
156
|
"ts-node"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
154
157
|
tsup?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -42,6 +42,7 @@ const defaultConfig = {
|
|
|
42
42
|
ignoreExportsUsedInFile: false,
|
|
43
43
|
ignoreWorkspaces: [],
|
|
44
44
|
isIncludeEntryExports: false,
|
|
45
|
+
isTreatConfigHintsAsErrors: false,
|
|
45
46
|
syncCompilers: new Map(),
|
|
46
47
|
asyncCompilers: new Map(),
|
|
47
48
|
rootPluginConfigs: {},
|
|
@@ -132,6 +133,7 @@ export class ConfigurationChief {
|
|
|
132
133
|
const ignoreExportsUsedInFile = rawConfig.ignoreExportsUsedInFile ?? false;
|
|
133
134
|
const ignoreWorkspaces = rawConfig.ignoreWorkspaces ?? defaultConfig.ignoreWorkspaces;
|
|
134
135
|
const isIncludeEntryExports = rawConfig.includeEntryExports ?? this.isIncludeEntryExports;
|
|
136
|
+
const isTreatConfigHintsAsErrors = rawConfig.treatConfigHintsAsErrors ?? defaultConfig.isTreatConfigHintsAsErrors;
|
|
135
137
|
const { syncCompilers, asyncCompilers } = rawConfig;
|
|
136
138
|
const rootPluginConfigs = {};
|
|
137
139
|
for (const [pluginName, pluginConfig] of Object.entries(rawConfig)) {
|
|
@@ -154,6 +156,7 @@ export class ConfigurationChief {
|
|
|
154
156
|
asyncCompilers: new Map(Object.entries(asyncCompilers ?? {})),
|
|
155
157
|
rootPluginConfigs,
|
|
156
158
|
tags: rawConfig.tags ?? [],
|
|
159
|
+
isTreatConfigHintsAsErrors,
|
|
157
160
|
};
|
|
158
161
|
}
|
|
159
162
|
async setWorkspaces() {
|
|
@@ -16,6 +16,8 @@ export const resolve = (_binary, args, options) => {
|
|
|
16
16
|
return [];
|
|
17
17
|
if (manifestScriptNames.has(command))
|
|
18
18
|
return [];
|
|
19
|
+
if (command === 'test')
|
|
20
|
+
return parsed._.filter(id => id !== command).map(toEntry);
|
|
19
21
|
if (command !== 'run' && commands.includes(command))
|
|
20
22
|
return [];
|
|
21
23
|
const filePath = command === 'run' ? script : command;
|
|
@@ -30,6 +30,7 @@ const commands = [
|
|
|
30
30
|
'patch-commit',
|
|
31
31
|
'patch-remove',
|
|
32
32
|
'patch',
|
|
33
|
+
'prepare',
|
|
33
34
|
'prune',
|
|
34
35
|
'publish',
|
|
35
36
|
'rb',
|
|
@@ -57,20 +58,19 @@ const commands = [
|
|
|
57
58
|
export const resolve = (_binary, args, options) => {
|
|
58
59
|
const parsed = parseArgs(args, {
|
|
59
60
|
boolean: ['recursive', 'silent', 'shell-mode'],
|
|
60
|
-
alias: { recursive: 'r', silent: 's', 'shell-mode': 'c' },
|
|
61
|
+
alias: { recursive: 'r', silent: 's', 'shell-mode': 'c', filter: 'F' },
|
|
61
62
|
});
|
|
62
|
-
const [command
|
|
63
|
+
const [command] = parsed._;
|
|
63
64
|
if (command === 'dlx') {
|
|
64
65
|
const argsForDlx = args.filter(arg => arg !== 'dlx');
|
|
65
66
|
return resolveDlx(argsForDlx, options);
|
|
66
67
|
}
|
|
67
68
|
const { manifestScriptNames, fromArgs } = options;
|
|
69
|
+
if (parsed.filter)
|
|
70
|
+
return [];
|
|
68
71
|
if (manifestScriptNames.has(command) || commands.includes(command))
|
|
69
72
|
return [];
|
|
70
|
-
if (command === 'exec')
|
|
71
|
-
|
|
72
|
-
return [toBinary(binary), ...fromArgs(parsed._.slice(1))];
|
|
73
|
-
return [toBinary(binary)];
|
|
74
|
-
}
|
|
73
|
+
if (command === 'exec')
|
|
74
|
+
return fromArgs(parsed._.slice(1));
|
|
75
75
|
return command ? [toBinary(command)] : [];
|
|
76
76
|
};
|
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { splitTags } from './util/tag.js';
|
|
|
10
10
|
import { isTrace } from './util/trace.js';
|
|
11
11
|
import { version } from './version.js';
|
|
12
12
|
const defaultCacheLocation = join(cwd, 'node_modules', '.cache', 'knip');
|
|
13
|
-
const { 'allow-remove-files': isRemoveFiles = false, cache: isCache = false, 'cache-location': cacheLocation = defaultCacheLocation, debug: isDebug = false, dependencies: isDependenciesShorthand = false, exclude: excludedIssueTypes = [], 'experimental-tags': experimentalTags = [], exports: isExportsShorthand = false, files: isFilesShorthand = false, fix: isFix = false, 'fix-type': fixTypes = [], help: isHelp, include: includedIssueTypes = [], 'include-entry-exports': isIncludeEntryExports = false, 'include-libs': isIncludeLibs = false, 'isolate-workspaces': isIsolateWorkspaces = false, 'max-issues': maxIssues = '0', 'no-config-hints': isDisableConfigHints = false, 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': isNoProgress = isDebug || isTrace, preprocessor = [], 'preprocessor-options': preprocessorOptions = '', production: isProduction = false, reporter = ['symbols'], 'reporter-options': reporterOptions = '', strict: isStrict = false, tags = [], 'treat-config-hints-as-errors':
|
|
13
|
+
const { 'allow-remove-files': isRemoveFiles = false, cache: isCache = false, 'cache-location': cacheLocation = defaultCacheLocation, debug: isDebug = false, dependencies: isDependenciesShorthand = false, exclude: excludedIssueTypes = [], 'experimental-tags': experimentalTags = [], exports: isExportsShorthand = false, files: isFilesShorthand = false, fix: isFix = false, 'fix-type': fixTypes = [], help: isHelp, include: includedIssueTypes = [], 'include-entry-exports': isIncludeEntryExports = false, 'include-libs': isIncludeLibs = false, 'isolate-workspaces': isIsolateWorkspaces = false, 'max-issues': maxIssues = '0', 'no-config-hints': isDisableConfigHints = false, 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': isNoProgress = isDebug || isTrace, preprocessor = [], 'preprocessor-options': preprocessorOptions = '', production: isProduction = false, reporter = ['symbols'], 'reporter-options': reporterOptions = '', strict: isStrict = false, tags = [], 'treat-config-hints-as-errors': treatConfigHintsAsErrors = false, tsConfig, version: isVersion, watch: isWatch = false, workspace: rawWorkspaceArg, } = parsedArgValues;
|
|
14
14
|
if (isHelp) {
|
|
15
15
|
console.log(helpText);
|
|
16
16
|
process.exit(0);
|
|
@@ -23,7 +23,7 @@ const isShowProgress = isNoProgress === false && process.stdout.isTTY && typeof
|
|
|
23
23
|
const workspace = rawWorkspaceArg ? toPosix(rawWorkspaceArg).replace(/^\.\//, '').replace(/\/$/, '') : undefined;
|
|
24
24
|
const run = async () => {
|
|
25
25
|
try {
|
|
26
|
-
const { report, issues, counters, rules, tagHints, configurationHints } = await main({
|
|
26
|
+
const { report, issues, counters, rules, tagHints, configurationHints, isTreatConfigHintsAsErrors } = await main({
|
|
27
27
|
cacheLocation,
|
|
28
28
|
cwd,
|
|
29
29
|
excludedIssueTypes,
|
|
@@ -85,7 +85,7 @@ const run = async () => {
|
|
|
85
85
|
logWarning('WARNING', 'Class members are not tracked when using the --isolate-workspaces flag');
|
|
86
86
|
}
|
|
87
87
|
if ((!noExitCode && totalErrorCount > Number(maxIssues)) ||
|
|
88
|
-
(isTreatConfigHintsAsErrors && configurationHints.size > 0)) {
|
|
88
|
+
((treatConfigHintsAsErrors || isTreatConfigHintsAsErrors) && configurationHints.size > 0)) {
|
|
89
89
|
process.exit(1);
|
|
90
90
|
}
|
|
91
91
|
}
|
package/dist/compilers/astro.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { fencedCodeBlockMatcher, importMatcher } from './compilers.js';
|
|
2
2
|
const condition = (hasDependency) => hasDependency('astro');
|
|
3
|
-
const
|
|
3
|
+
const taggedTemplateMatcher = /\w+(?:\.\w+)*`[\s\S]*?`/g;
|
|
4
|
+
const compiler = (text) => {
|
|
5
|
+
const cleanedText = text.replace(fencedCodeBlockMatcher, '').replace(taggedTemplateMatcher, '""');
|
|
6
|
+
return [...cleanedText.matchAll(importMatcher)].join('\n');
|
|
7
|
+
};
|
|
4
8
|
export default { condition, compiler };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const fencedCodeBlockMatcher = /```[\s\S]*?```/g;
|
|
2
2
|
const scriptExtractor = /<script\b[^>]*>([\s\S]*?)<\/script>/gm;
|
|
3
|
-
export const importMatcher = /import[^'"]+['"]
|
|
3
|
+
export const importMatcher = /import[^'"]+['"][^'"]+['"]/g;
|
|
4
4
|
export const importsWithinScripts = (text) => {
|
|
5
5
|
const scripts = [];
|
|
6
6
|
let scriptMatch;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RawConfiguration } from '../types/config.js';
|
|
2
2
|
import type { DependencySet } from '../types/workspace.js';
|
|
3
|
-
import type { AsyncCompilerFn, AsyncCompilers, SyncCompilerFn, SyncCompilers } from './types.js';
|
|
3
|
+
import type { AsyncCompilerFn, AsyncCompilers, RawSyncCompilers, 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>;
|
|
@@ -34,6 +34,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
34
34
|
entry?: string | string[] | undefined;
|
|
35
35
|
project?: string | string[] | undefined;
|
|
36
36
|
} | undefined;
|
|
37
|
+
bun?: string | boolean | string[] | {
|
|
38
|
+
config?: string | string[] | undefined;
|
|
39
|
+
entry?: string | string[] | undefined;
|
|
40
|
+
project?: string | string[] | undefined;
|
|
41
|
+
} | undefined;
|
|
37
42
|
c8?: string | boolean | string[] | {
|
|
38
43
|
config?: string | string[] | undefined;
|
|
39
44
|
entry?: string | string[] | undefined;
|
|
@@ -209,6 +214,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
209
214
|
entry?: string | string[] | undefined;
|
|
210
215
|
project?: string | string[] | undefined;
|
|
211
216
|
} | undefined;
|
|
217
|
+
'nano-staged'?: string | boolean | string[] | {
|
|
218
|
+
config?: string | string[] | undefined;
|
|
219
|
+
entry?: string | string[] | undefined;
|
|
220
|
+
project?: string | string[] | undefined;
|
|
221
|
+
} | undefined;
|
|
212
222
|
nest?: string | boolean | string[] | {
|
|
213
223
|
config?: string | string[] | undefined;
|
|
214
224
|
entry?: string | string[] | undefined;
|
|
@@ -254,6 +264,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
254
264
|
entry?: string | string[] | undefined;
|
|
255
265
|
project?: string | string[] | undefined;
|
|
256
266
|
} | undefined;
|
|
267
|
+
oxlint?: string | boolean | string[] | {
|
|
268
|
+
config?: string | string[] | undefined;
|
|
269
|
+
entry?: string | string[] | undefined;
|
|
270
|
+
project?: string | string[] | undefined;
|
|
271
|
+
} | undefined;
|
|
257
272
|
playwright?: string | boolean | string[] | {
|
|
258
273
|
config?: string | string[] | undefined;
|
|
259
274
|
entry?: string | string[] | undefined;
|
|
@@ -299,6 +314,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
299
314
|
entry?: string | string[] | undefined;
|
|
300
315
|
project?: string | string[] | undefined;
|
|
301
316
|
} | undefined;
|
|
317
|
+
relay?: string | boolean | string[] | {
|
|
318
|
+
config?: string | string[] | undefined;
|
|
319
|
+
entry?: string | string[] | undefined;
|
|
320
|
+
project?: string | string[] | undefined;
|
|
321
|
+
} | undefined;
|
|
302
322
|
'release-it'?: string | boolean | string[] | {
|
|
303
323
|
config?: string | string[] | undefined;
|
|
304
324
|
entry?: string | string[] | undefined;
|
|
@@ -389,11 +409,6 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
389
409
|
entry?: string | string[] | undefined;
|
|
390
410
|
project?: string | string[] | undefined;
|
|
391
411
|
} | undefined;
|
|
392
|
-
'tanstack-router'?: string | boolean | string[] | {
|
|
393
|
-
config?: string | string[] | undefined;
|
|
394
|
-
entry?: string | string[] | undefined;
|
|
395
|
-
project?: string | string[] | undefined;
|
|
396
|
-
} | undefined;
|
|
397
412
|
travis?: string | boolean | string[] | {
|
|
398
413
|
config?: string | string[] | undefined;
|
|
399
414
|
entry?: string | string[] | undefined;
|
|
@@ -505,7 +520,8 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
505
520
|
ignoreExportsUsedInFile?: boolean | Partial<Record<"function" | "type" | "enum" | "class" | "interface" | "member", boolean>> | undefined;
|
|
506
521
|
ignoreWorkspaces?: string[] | undefined;
|
|
507
522
|
includeEntryExports?: boolean | undefined;
|
|
508
|
-
compilers?: Record<string, ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
|
|
523
|
+
compilers?: Record<string, true | ((args_0: string, args_1: string, ...args: unknown[]) => string) | ((args_0: string, args_1: string, ...args: unknown[]) => Promise<string>)> | undefined;
|
|
524
|
+
treatConfigHintsAsErrors?: boolean | undefined;
|
|
509
525
|
workspaces?: Record<string, {
|
|
510
526
|
node?: string | boolean | string[] | {
|
|
511
527
|
config?: string | string[] | undefined;
|
|
@@ -534,6 +550,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
534
550
|
entry?: string | string[] | undefined;
|
|
535
551
|
project?: string | string[] | undefined;
|
|
536
552
|
} | undefined;
|
|
553
|
+
bun?: string | boolean | string[] | {
|
|
554
|
+
config?: string | string[] | undefined;
|
|
555
|
+
entry?: string | string[] | undefined;
|
|
556
|
+
project?: string | string[] | undefined;
|
|
557
|
+
} | undefined;
|
|
537
558
|
c8?: string | boolean | string[] | {
|
|
538
559
|
config?: string | string[] | undefined;
|
|
539
560
|
entry?: string | string[] | undefined;
|
|
@@ -709,6 +730,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
709
730
|
entry?: string | string[] | undefined;
|
|
710
731
|
project?: string | string[] | undefined;
|
|
711
732
|
} | undefined;
|
|
733
|
+
'nano-staged'?: string | boolean | string[] | {
|
|
734
|
+
config?: string | string[] | undefined;
|
|
735
|
+
entry?: string | string[] | undefined;
|
|
736
|
+
project?: string | string[] | undefined;
|
|
737
|
+
} | undefined;
|
|
712
738
|
nest?: string | boolean | string[] | {
|
|
713
739
|
config?: string | string[] | undefined;
|
|
714
740
|
entry?: string | string[] | undefined;
|
|
@@ -754,6 +780,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
754
780
|
entry?: string | string[] | undefined;
|
|
755
781
|
project?: string | string[] | undefined;
|
|
756
782
|
} | undefined;
|
|
783
|
+
oxlint?: string | boolean | string[] | {
|
|
784
|
+
config?: string | string[] | undefined;
|
|
785
|
+
entry?: string | string[] | undefined;
|
|
786
|
+
project?: string | string[] | undefined;
|
|
787
|
+
} | undefined;
|
|
757
788
|
playwright?: string | boolean | string[] | {
|
|
758
789
|
config?: string | string[] | undefined;
|
|
759
790
|
entry?: string | string[] | undefined;
|
|
@@ -799,6 +830,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
799
830
|
entry?: string | string[] | undefined;
|
|
800
831
|
project?: string | string[] | undefined;
|
|
801
832
|
} | undefined;
|
|
833
|
+
relay?: string | boolean | string[] | {
|
|
834
|
+
config?: string | string[] | undefined;
|
|
835
|
+
entry?: string | string[] | undefined;
|
|
836
|
+
project?: string | string[] | undefined;
|
|
837
|
+
} | undefined;
|
|
802
838
|
'release-it'?: string | boolean | string[] | {
|
|
803
839
|
config?: string | string[] | undefined;
|
|
804
840
|
entry?: string | string[] | undefined;
|
|
@@ -889,11 +925,6 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
889
925
|
entry?: string | string[] | undefined;
|
|
890
926
|
project?: string | string[] | undefined;
|
|
891
927
|
} | undefined;
|
|
892
|
-
'tanstack-router'?: string | boolean | string[] | {
|
|
893
|
-
config?: string | string[] | undefined;
|
|
894
|
-
entry?: string | string[] | undefined;
|
|
895
|
-
project?: string | string[] | undefined;
|
|
896
|
-
} | undefined;
|
|
897
928
|
travis?: string | boolean | string[] | {
|
|
898
929
|
config?: string | string[] | undefined;
|
|
899
930
|
entry?: string | string[] | undefined;
|
|
@@ -1003,5 +1034,5 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
1003
1034
|
includeEntryExports?: boolean | undefined;
|
|
1004
1035
|
}> | undefined;
|
|
1005
1036
|
};
|
|
1006
|
-
export declare const getIncludedCompilers: (syncCompilers:
|
|
1037
|
+
export declare const getIncludedCompilers: (syncCompilers: RawSyncCompilers, asyncCompilers: AsyncCompilers, dependencies: DependencySet) => [SyncCompilers, AsyncCompilers];
|
|
1007
1038
|
export declare const getCompilerExtensions: (compilers: [SyncCompilers, AsyncCompilers]) => string[];
|
package/dist/compilers/index.js
CHANGED
|
@@ -9,11 +9,14 @@ export const partitionCompilers = (rawLocalConfig) => {
|
|
|
9
9
|
const asyncCompilers = {};
|
|
10
10
|
for (const extension in rawLocalConfig.compilers) {
|
|
11
11
|
const ext = normalizeExt(extension);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const compilerFn = rawLocalConfig.compilers[extension];
|
|
13
|
+
if (typeof compilerFn === 'function') {
|
|
14
|
+
if (!rawLocalConfig.asyncCompilers?.[ext] && isAsync(compilerFn)) {
|
|
15
|
+
asyncCompilers[ext] = compilerFn;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
syncCompilers[ext] = compilerFn;
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
for (const extension in rawLocalConfig.asyncCompilers) {
|
|
@@ -31,7 +34,7 @@ const compilers = new Map([
|
|
|
31
34
|
export const getIncludedCompilers = (syncCompilers, asyncCompilers, dependencies) => {
|
|
32
35
|
const hasDependency = (packageName) => dependencies.has(packageName);
|
|
33
36
|
for (const [extension, { condition, compiler }] of compilers.entries()) {
|
|
34
|
-
if (!syncCompilers.has(extension) && condition(hasDependency)) {
|
|
37
|
+
if ((!syncCompilers.has(extension) && condition(hasDependency)) || syncCompilers.get(extension) === true) {
|
|
35
38
|
syncCompilers.set(extension, compiler);
|
|
36
39
|
}
|
|
37
40
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
type FileExtension = string;
|
|
2
2
|
export type SyncCompilerFn = (source: string, path: string) => string;
|
|
3
3
|
export type AsyncCompilerFn = (source: string, path: string) => Promise<string>;
|
|
4
|
+
export type RawSyncCompilers = Map<FileExtension, SyncCompilerFn | true>;
|
|
4
5
|
export type SyncCompilers = Map<FileExtension, SyncCompilerFn>;
|
|
5
6
|
export type AsyncCompilers = Map<FileExtension, AsyncCompilerFn>;
|
|
6
7
|
export type HasDependency = (pkgName: string) => boolean;
|
package/dist/graph/build.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WorkspaceWorker } from '../WorkspaceWorker.js';
|
|
2
2
|
import { _getInputsFromScripts } from '../binaries/index.js';
|
|
3
3
|
import { getCompilerExtensions, getIncludedCompilers } from '../compilers/index.js';
|
|
4
|
+
import { DEFAULT_EXTENSIONS } from '../constants.js';
|
|
4
5
|
import { debugLog, debugLogArray } from '../util/debug.js';
|
|
5
6
|
import { getReferencedInputsHandler } from '../util/get-referenced-inputs.js';
|
|
6
7
|
import { _glob, negate } from '../util/glob.js';
|
|
@@ -9,12 +10,13 @@ import { getOrCreateFileNode, updateImportMap } from '../util/module-graph.js';
|
|
|
9
10
|
import { getEntryPathsFromManifest } from '../util/package-json.js';
|
|
10
11
|
import { dirname, isAbsolute, join, relative } from '../util/path.js';
|
|
11
12
|
import {} from '../util/tag.js';
|
|
12
|
-
import { augmentWorkspace, getToSourcePathHandler } from '../util/to-source-path.js';
|
|
13
|
+
import { augmentWorkspace, getToSourcePathHandler, getToSourcePathsHandler } from '../util/to-source-path.js';
|
|
13
14
|
import { loadTSConfig } from '../util/tsconfig-loader.js';
|
|
14
15
|
export async function build({ cacheLocation, chief, collector, cwd, deputy, factory, gitignore, isCache, isFixExports, isFixTypes, isGitIgnored, isIsolateWorkspaces, isProduction, isSkipLibs, isStrict, isWatch, report, streamer, tags, tsConfigFile, workspaces, }) {
|
|
15
16
|
const configFilesMap = new Map();
|
|
16
17
|
const enabledPluginsStore = new Map();
|
|
17
18
|
const toSourceFilePath = getToSourcePathHandler(chief);
|
|
19
|
+
const toSourceFilePaths = getToSourcePathsHandler(chief);
|
|
18
20
|
const getReferencedInternalFilePath = getReferencedInputsHandler(collector, deputy, chief, isGitIgnored);
|
|
19
21
|
const isReportClassMembers = report.classMembers;
|
|
20
22
|
for (const workspace of workspaces) {
|
|
@@ -34,6 +36,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
34
36
|
const dependencies = deputy.getDependencies(name);
|
|
35
37
|
const compilers = getIncludedCompilers(chief.config.syncCompilers, chief.config.asyncCompilers, dependencies);
|
|
36
38
|
const extensions = getCompilerExtensions(compilers);
|
|
39
|
+
const extensionGlobStr = `.{${[...DEFAULT_EXTENSIONS, ...extensions].map(ext => ext.slice(1)).join(',')}}`;
|
|
37
40
|
const config = chief.getConfigForWorkspace(name, extensions);
|
|
38
41
|
const tsConfigFilePath = join(dir, tsConfigFile ?? 'tsconfig.json');
|
|
39
42
|
const { isFile, compilerOptions, definitionPaths } = await loadTSConfig(tsConfigFilePath);
|
|
@@ -69,9 +72,9 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
69
72
|
const ignore = worker.getIgnorePatterns();
|
|
70
73
|
const sharedGlobOptions = { cwd, dir, gitignore };
|
|
71
74
|
collector.addIgnorePatterns(ignore.map(pattern => join(cwd, pattern)));
|
|
72
|
-
const entryPathsFromManifest =
|
|
73
|
-
for (const filePath of entryPathsFromManifest) {
|
|
74
|
-
inputs.add(toProductionEntry(
|
|
75
|
+
const entryPathsFromManifest = getEntryPathsFromManifest(manifest);
|
|
76
|
+
for (const filePath of await toSourceFilePaths(entryPathsFromManifest, dir, extensionGlobStr)) {
|
|
77
|
+
inputs.add(toProductionEntry(filePath));
|
|
75
78
|
}
|
|
76
79
|
const principal = factory.createPrincipal({
|
|
77
80
|
cwd: dir,
|
|
@@ -89,7 +92,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
89
92
|
});
|
|
90
93
|
const inputsFromPlugins = await worker.runPlugins();
|
|
91
94
|
for (const id of inputsFromPlugins)
|
|
92
|
-
inputs.add(Object.assign(id, { skipExportsAnalysis:
|
|
95
|
+
inputs.add(Object.assign(id, { skipExportsAnalysis: !id.allowIncludeExports }));
|
|
93
96
|
enabledPluginsStore.set(name, worker.enabledPlugins);
|
|
94
97
|
const entryPatterns = new Set();
|
|
95
98
|
const entryPatternsSkipExports = new Set();
|
|
@@ -268,8 +271,10 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
268
271
|
if (!principal)
|
|
269
272
|
continue;
|
|
270
273
|
principal.init();
|
|
271
|
-
|
|
272
|
-
|
|
274
|
+
if (principal.asyncCompilers.size > 0) {
|
|
275
|
+
streamer.cast('Running async compilers...');
|
|
276
|
+
await principal.runAsyncCompilers();
|
|
277
|
+
}
|
|
273
278
|
streamer.cast('Analyzing source files...');
|
|
274
279
|
let size = principal.entryPaths.size;
|
|
275
280
|
let round = 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export declare const main: (unresolvedConfiguration: CommandLineOptions) => Prom
|
|
|
8
8
|
rules: import("./types/issues.js").Rules;
|
|
9
9
|
tagHints: Set<import("./types/issues.js").TagHint>;
|
|
10
10
|
configurationHints: Set<import("./types/issues.js").ConfigurationHint>;
|
|
11
|
+
isTreatConfigHintsAsErrors: boolean;
|
|
11
12
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -105,5 +105,13 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
105
105
|
await fixer.fixIssues(issues);
|
|
106
106
|
if (!isWatch)
|
|
107
107
|
streamer.clear();
|
|
108
|
-
return {
|
|
108
|
+
return {
|
|
109
|
+
report,
|
|
110
|
+
issues,
|
|
111
|
+
counters,
|
|
112
|
+
rules,
|
|
113
|
+
tagHints,
|
|
114
|
+
configurationHints,
|
|
115
|
+
isTreatConfigHintsAsErrors: chief.config.isTreatConfigHintsAsErrors,
|
|
116
|
+
};
|
|
109
117
|
};
|
|
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'Astro';
|
|
4
4
|
const enablers = ['astro'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['astro.config.{js,cjs,mjs,ts}'];
|
|
6
|
+
export const config = ['astro.config.{js,cjs,mjs,ts,mts}'];
|
|
7
7
|
const entry = ['src/content/config.ts', 'src/content.config.ts'];
|
|
8
8
|
const production = [
|
|
9
9
|
'src/pages/**/*.{astro,mdx,js,ts}',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ResolveEntryPaths } from '../../types/config.js';
|
|
2
|
+
import type { PackageJson } from '../../types/package-json.js';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
enablers: string[];
|
|
6
|
+
isEnabled: () => boolean;
|
|
7
|
+
config: string[];
|
|
8
|
+
packageJsonPath: (id: PackageJson) => PackageJson;
|
|
9
|
+
resolveEntryPaths: ResolveEntryPaths<PackageJson>;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import parseArgs from 'minimist';
|
|
2
|
+
import { toEntry } from '../../util/input.js';
|
|
3
|
+
const title = 'Bun';
|
|
4
|
+
const enablers = ['bun'];
|
|
5
|
+
const isEnabled = () => true;
|
|
6
|
+
const config = ['package.json'];
|
|
7
|
+
const packageJsonPath = (id) => id;
|
|
8
|
+
const resolveEntryPaths = localConfig => {
|
|
9
|
+
const scripts = localConfig.scripts;
|
|
10
|
+
if (scripts) {
|
|
11
|
+
const testScripts = Object.keys(scripts).filter(script => /(?<=^|\s)bun test/.test(scripts[script]));
|
|
12
|
+
for (const script of testScripts) {
|
|
13
|
+
const parsed = parseArgs(scripts[script].split(' '));
|
|
14
|
+
if (parsed._.filter(id => id !== 'bun' && id !== 'test').length === 0) {
|
|
15
|
+
return ['**/*.{test,spec}.{js,jsx,ts,tsx}', '**/*_{test,spec}.{js,jsx,ts,tsx}'].map(toEntry);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return [];
|
|
20
|
+
};
|
|
21
|
+
export default {
|
|
22
|
+
title,
|
|
23
|
+
enablers,
|
|
24
|
+
isEnabled,
|
|
25
|
+
config,
|
|
26
|
+
packageJsonPath,
|
|
27
|
+
resolveEntryPaths,
|
|
28
|
+
};
|
|
@@ -2,8 +2,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
2
2
|
import { getInputs } from './helpers.js';
|
|
3
3
|
const title = 'ESLint';
|
|
4
4
|
const enablers = ['eslint', '@eslint/js'];
|
|
5
|
-
const isEnabled = ({ dependencies, manifest
|
|
6
|
-
'eslint' in config ||
|
|
5
|
+
const isEnabled = ({ dependencies, manifest }) => hasDependency(dependencies, enablers) ||
|
|
7
6
|
Boolean(manifest.name && /(^eslint-config|\/eslint-config)/.test(manifest.name));
|
|
8
7
|
const packageJsonPath = 'eslintConfig';
|
|
9
8
|
const entry = ['eslint.config.{js,cjs,mjs,ts,cts,mts}'];
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -31,6 +31,14 @@ export declare const Plugins: {
|
|
|
31
31
|
config: string[];
|
|
32
32
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./babel/types.js").BabelConfig>;
|
|
33
33
|
};
|
|
34
|
+
bun: {
|
|
35
|
+
title: string;
|
|
36
|
+
enablers: string[];
|
|
37
|
+
isEnabled: () => boolean;
|
|
38
|
+
config: string[];
|
|
39
|
+
packageJsonPath: (id: import("../types/package-json.js").PackageJson) => import("../types/package-json.js").PackageJson;
|
|
40
|
+
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("../types/package-json.js").PackageJson>;
|
|
41
|
+
};
|
|
34
42
|
c8: {
|
|
35
43
|
title: string;
|
|
36
44
|
args: {
|
|
@@ -252,7 +260,6 @@ export declare const Plugins: {
|
|
|
252
260
|
title: string;
|
|
253
261
|
enablers: string[];
|
|
254
262
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
255
|
-
packageJsonPath: string;
|
|
256
263
|
config: string[];
|
|
257
264
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./lint-staged/types.js").LintStagedConfig>;
|
|
258
265
|
};
|
|
@@ -319,6 +326,13 @@ export declare const Plugins: {
|
|
|
319
326
|
entry: string[];
|
|
320
327
|
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./msw/types.js").MSWConfig>;
|
|
321
328
|
};
|
|
329
|
+
'nano-staged': {
|
|
330
|
+
title: string;
|
|
331
|
+
enablers: string[];
|
|
332
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
333
|
+
config: string[];
|
|
334
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("./nano-staged/types.js").NanoStagedConfig>;
|
|
335
|
+
};
|
|
322
336
|
nest: {
|
|
323
337
|
title: string;
|
|
324
338
|
enablers: RegExp[];
|
|
@@ -405,6 +419,16 @@ export declare const Plugins: {
|
|
|
405
419
|
config: string[];
|
|
406
420
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./oclif/types.js").OclifConfig>;
|
|
407
421
|
};
|
|
422
|
+
oxlint: {
|
|
423
|
+
title: string;
|
|
424
|
+
enablers: string[];
|
|
425
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
426
|
+
config: string[];
|
|
427
|
+
args: {
|
|
428
|
+
binaries: string[];
|
|
429
|
+
config: boolean;
|
|
430
|
+
};
|
|
431
|
+
};
|
|
408
432
|
playwright: {
|
|
409
433
|
title: string;
|
|
410
434
|
enablers: string[];
|
|
@@ -483,6 +507,18 @@ export declare const Plugins: {
|
|
|
483
507
|
config: string[];
|
|
484
508
|
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./react-router/types.js").PluginConfig>;
|
|
485
509
|
};
|
|
510
|
+
relay: {
|
|
511
|
+
title: string;
|
|
512
|
+
enablers: string[];
|
|
513
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
514
|
+
config: string[];
|
|
515
|
+
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./relay/types.js").RelayConfig>;
|
|
516
|
+
args: {
|
|
517
|
+
binaries: string[];
|
|
518
|
+
args: (args: string[]) => string[];
|
|
519
|
+
config: boolean;
|
|
520
|
+
};
|
|
521
|
+
};
|
|
486
522
|
'release-it': {
|
|
487
523
|
title: string;
|
|
488
524
|
enablers: string[];
|
|
@@ -611,15 +647,6 @@ export declare const Plugins: {
|
|
|
611
647
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
612
648
|
entry: string[];
|
|
613
649
|
};
|
|
614
|
-
'tanstack-router': {
|
|
615
|
-
title: string;
|
|
616
|
-
enablers: string[];
|
|
617
|
-
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
618
|
-
config: string[];
|
|
619
|
-
production: string[];
|
|
620
|
-
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./tanstack-router/types.js").TanstackRouterConfig>;
|
|
621
|
-
resolveFromAST: import("../types/config.js").ResolveFromAST;
|
|
622
|
-
};
|
|
623
650
|
travis: {
|
|
624
651
|
title: string;
|
|
625
652
|
enablers: string;
|