knip 5.50.5 → 5.51.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/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/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 +8 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -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 +1 -1
- 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/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/input.d.ts +3 -1
- 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 -1
- package/dist/util/to-source-path.js +2 -2
- 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;
|
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';
|
|
@@ -34,6 +35,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
34
35
|
const dependencies = deputy.getDependencies(name);
|
|
35
36
|
const compilers = getIncludedCompilers(chief.config.syncCompilers, chief.config.asyncCompilers, dependencies);
|
|
36
37
|
const extensions = getCompilerExtensions(compilers);
|
|
38
|
+
const extensionGlobStr = `.{${[...DEFAULT_EXTENSIONS, ...extensions].map(ext => ext.slice(1)).join(',')}}`;
|
|
37
39
|
const config = chief.getConfigForWorkspace(name, extensions);
|
|
38
40
|
const tsConfigFilePath = join(dir, tsConfigFile ?? 'tsconfig.json');
|
|
39
41
|
const { isFile, compilerOptions, definitionPaths } = await loadTSConfig(tsConfigFilePath);
|
|
@@ -71,7 +73,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
71
73
|
collector.addIgnorePatterns(ignore.map(pattern => join(cwd, pattern)));
|
|
72
74
|
const entryPathsFromManifest = await getEntryPathsFromManifest(manifest, { cwd: dir, ignore });
|
|
73
75
|
for (const filePath of entryPathsFromManifest) {
|
|
74
|
-
inputs.add(toProductionEntry(toSourceFilePath(filePath) ?? filePath));
|
|
76
|
+
inputs.add(toProductionEntry(toSourceFilePath(filePath, extensionGlobStr) ?? filePath));
|
|
75
77
|
}
|
|
76
78
|
const principal = factory.createPrincipal({
|
|
77
79
|
cwd: dir,
|
|
@@ -89,7 +91,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
89
91
|
});
|
|
90
92
|
const inputsFromPlugins = await worker.runPlugins();
|
|
91
93
|
for (const id of inputsFromPlugins)
|
|
92
|
-
inputs.add(Object.assign(id, { skipExportsAnalysis:
|
|
94
|
+
inputs.add(Object.assign(id, { skipExportsAnalysis: !id.allowIncludeExports }));
|
|
93
95
|
enabledPluginsStore.set(name, worker.enabledPlugins);
|
|
94
96
|
const entryPatterns = new Set();
|
|
95
97
|
const entryPatternsSkipExports = new Set();
|
|
@@ -268,8 +270,10 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
268
270
|
if (!principal)
|
|
269
271
|
continue;
|
|
270
272
|
principal.init();
|
|
271
|
-
|
|
272
|
-
|
|
273
|
+
if (principal.asyncCompilers.size > 0) {
|
|
274
|
+
streamer.cast('Running async compilers...');
|
|
275
|
+
await principal.runAsyncCompilers();
|
|
276
|
+
}
|
|
273
277
|
streamer.cast('Analyzing source files...');
|
|
274
278
|
let size = principal.entryPaths.size;
|
|
275
279
|
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
|
};
|
|
@@ -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;
|
package/dist/plugins/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { default as angular } from './angular/index.js';
|
|
|
2
2
|
import { default as astro } from './astro/index.js';
|
|
3
3
|
import { default as ava } from './ava/index.js';
|
|
4
4
|
import { default as babel } from './babel/index.js';
|
|
5
|
+
import { default as bun } from './bun/index.js';
|
|
5
6
|
import { default as c8 } from './c8/index.js';
|
|
6
7
|
import { default as capacitor } from './capacitor/index.js';
|
|
7
8
|
import { default as changesets } from './changesets/index.js';
|
|
@@ -37,6 +38,7 @@ import { default as metro } from './metro/index.js';
|
|
|
37
38
|
import { default as mocha } from './mocha/index.js';
|
|
38
39
|
import { default as moonrepo } from './moonrepo/index.js';
|
|
39
40
|
import { default as msw } from './msw/index.js';
|
|
41
|
+
import { default as nanoStaged } from './nano-staged/index.js';
|
|
40
42
|
import { default as nest } from './nest/index.js';
|
|
41
43
|
import { default as netlify } from './netlify/index.js';
|
|
42
44
|
import { default as next } from './next/index.js';
|
|
@@ -47,6 +49,7 @@ import { default as nuxt } from './nuxt/index.js';
|
|
|
47
49
|
import { default as nx } from './nx/index.js';
|
|
48
50
|
import { default as nyc } from './nyc/index.js';
|
|
49
51
|
import { default as oclif } from './oclif/index.js';
|
|
52
|
+
import { default as oxlint } from './oxlint/index.js';
|
|
50
53
|
import { default as playwrightCt } from './playwright-ct/index.js';
|
|
51
54
|
import { default as playwrightTest } from './playwright-test/index.js';
|
|
52
55
|
import { default as playwright } from './playwright/index.js';
|
|
@@ -56,6 +59,7 @@ import { default as preconstruct } from './preconstruct/index.js';
|
|
|
56
59
|
import { default as prettier } from './prettier/index.js';
|
|
57
60
|
import { default as reactCosmos } from './react-cosmos/index.js';
|
|
58
61
|
import { default as reactRouter } from './react-router/index.js';
|
|
62
|
+
import { default as relay } from './relay/index.js';
|
|
59
63
|
import { default as releaseIt } from './release-it/index.js';
|
|
60
64
|
import { default as remark } from './remark/index.js';
|
|
61
65
|
import { default as remix } from './remix/index.js';
|
|
@@ -74,7 +78,6 @@ import { default as stylelint } from './stylelint/index.js';
|
|
|
74
78
|
import { default as svelte } from './svelte/index.js';
|
|
75
79
|
import { default as syncpack } from './syncpack/index.js';
|
|
76
80
|
import { default as tailwind } from './tailwind/index.js';
|
|
77
|
-
import { default as tanstackRouter } from './tanstack-router/index.js';
|
|
78
81
|
import { default as travis } from './travis/index.js';
|
|
79
82
|
import { default as tsNode } from './ts-node/index.js';
|
|
80
83
|
import { default as tsup } from './tsup/index.js';
|
|
@@ -100,6 +103,7 @@ export const Plugins = {
|
|
|
100
103
|
astro,
|
|
101
104
|
ava,
|
|
102
105
|
babel,
|
|
106
|
+
bun,
|
|
103
107
|
c8,
|
|
104
108
|
capacitor,
|
|
105
109
|
changesets,
|
|
@@ -135,6 +139,7 @@ export const Plugins = {
|
|
|
135
139
|
mocha,
|
|
136
140
|
moonrepo,
|
|
137
141
|
msw,
|
|
142
|
+
'nano-staged': nanoStaged,
|
|
138
143
|
nest,
|
|
139
144
|
netlify,
|
|
140
145
|
next,
|
|
@@ -145,6 +150,7 @@ export const Plugins = {
|
|
|
145
150
|
nx,
|
|
146
151
|
nyc,
|
|
147
152
|
oclif,
|
|
153
|
+
oxlint,
|
|
148
154
|
playwright,
|
|
149
155
|
'playwright-ct': playwrightCt,
|
|
150
156
|
'playwright-test': playwrightTest,
|
|
@@ -154,6 +160,7 @@ export const Plugins = {
|
|
|
154
160
|
prettier,
|
|
155
161
|
'react-cosmos': reactCosmos,
|
|
156
162
|
'react-router': reactRouter,
|
|
163
|
+
relay,
|
|
157
164
|
'release-it': releaseIt,
|
|
158
165
|
remark,
|
|
159
166
|
remix,
|
|
@@ -172,7 +179,6 @@ export const Plugins = {
|
|
|
172
179
|
svelte,
|
|
173
180
|
syncpack,
|
|
174
181
|
tailwind,
|
|
175
|
-
'tanstack-router': tanstackRouter,
|
|
176
182
|
travis,
|
|
177
183
|
'ts-node': tsNode,
|
|
178
184
|
tsup,
|
|
@@ -3,7 +3,6 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'lint-staged';
|
|
4
4
|
const enablers = ['lint-staged'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const packageJsonPath = 'lint-staged';
|
|
7
6
|
const config = [
|
|
8
7
|
'package.json',
|
|
9
8
|
'package.yaml',
|
|
@@ -30,7 +29,6 @@ export default {
|
|
|
30
29
|
title,
|
|
31
30
|
enablers,
|
|
32
31
|
isEnabled,
|
|
33
|
-
packageJsonPath,
|
|
34
32
|
config,
|
|
35
33
|
resolveConfig,
|
|
36
34
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
2
|
+
import type { NanoStagedConfig } from './types.js';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
enablers: string[];
|
|
6
|
+
isEnabled: IsPluginEnabled;
|
|
7
|
+
config: string[];
|
|
8
|
+
resolveConfig: ResolveConfig<NanoStagedConfig>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|