knip 6.39.0 → 6.41.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/ConfigurationChief.d.ts +24 -0
- package/dist/DependencyDeputy.d.ts +1 -0
- package/dist/DependencyDeputy.js +28 -2
- package/dist/IssueCollector.js +13 -15
- package/dist/IssueFixer.js +1 -1
- package/dist/WorkspaceWorker.d.ts +3 -4
- package/dist/WorkspaceWorker.js +25 -45
- package/dist/binaries/bash-parser.js +10 -4
- package/dist/binaries/command.d.ts +1 -1
- package/dist/binaries/command.js +14 -8
- package/dist/compilers/compilers.js +1 -1
- package/dist/graph/build.js +33 -17
- package/dist/manifest/index.d.ts +1 -0
- package/dist/manifest/index.js +5 -0
- package/dist/plugins/capacitor/index.js +1 -1
- package/dist/plugins/commitlint/index.js +34 -9
- package/dist/plugins/eslint/resolveFromAST.d.ts +0 -1
- package/dist/plugins/eslint/resolveFromAST.js +1 -1
- package/dist/plugins/expo/helpers.js +1 -1
- package/dist/plugins/expo/index.js +4 -24
- package/dist/plugins/expo-router/index.d.ts +3 -0
- package/dist/plugins/expo-router/index.js +32 -0
- package/dist/plugins/flue/index.d.ts +3 -0
- package/dist/plugins/flue/index.js +42 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +8 -0
- package/dist/plugins/jasmine/index.d.ts +3 -0
- package/dist/plugins/jasmine/index.js +55 -0
- package/dist/plugins/jasmine/types.d.ts +7 -0
- package/dist/plugins/jasmine/types.js +1 -0
- package/dist/plugins/jest/helpers.d.ts +1 -0
- package/dist/plugins/jest/helpers.js +2 -0
- package/dist/plugins/jest/index.js +20 -11
- package/dist/plugins/mise/scripts.js +32 -10
- package/dist/plugins/moonrepo/index.js +2 -1
- package/dist/plugins/nx/index.js +6 -2
- package/dist/plugins/osls/index.d.ts +3 -0
- package/dist/plugins/osls/index.js +13 -0
- package/dist/plugins/oxlint/index.d.ts +3 -0
- package/dist/plugins/oxlint/index.js +4 -31
- package/dist/plugins/oxlint/types.d.ts +1 -0
- package/dist/plugins/playwright/index.js +17 -0
- package/dist/plugins/playwright/types.d.ts +5 -0
- package/dist/plugins/postcss/index.js +5 -1
- package/dist/plugins/react-native/index.js +1 -1
- package/dist/plugins/rsbuild/index.js +58 -6
- package/dist/plugins/rsbuild/types.d.ts +24 -1
- package/dist/plugins/rspack/index.d.ts +3 -1
- package/dist/plugins/rspack/index.js +1 -1
- package/dist/plugins/rstest/types.d.ts +1 -5
- package/dist/plugins/serverless-framework/index.d.ts +4 -1
- package/dist/plugins/serverless-framework/index.js +40 -7
- package/dist/plugins/serverless-framework/types.d.ts +4 -2
- package/dist/plugins/simple-git-hooks/index.js +1 -1
- package/dist/plugins/sveltejs-package/helpers.js +7 -44
- package/dist/plugins/vitest/index.js +16 -2
- package/dist/plugins/vitest/types.d.ts +2 -0
- package/dist/run.js +2 -0
- package/dist/schema/configuration.d.ts +60 -0
- package/dist/schema/plugins.d.ts +20 -0
- package/dist/schema/plugins.js +4 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +4 -0
- package/dist/types/workspace.d.ts +1 -0
- package/dist/typescript/ast-nodes.js +291 -0
- package/dist/typescript/resolve-module-names.js +15 -4
- package/dist/typescript/visitors/walk.js +12 -0
- package/dist/util/create-options.d.ts +40 -0
- package/dist/util/filter-transitive-dependencies.d.ts +2 -0
- package/dist/util/filter-transitive-dependencies.js +38 -0
- package/dist/util/glob-cache.d.ts +2 -2
- package/dist/util/glob-core.js +70 -47
- package/dist/util/glob.js +15 -10
- package/dist/util/load-tsconfig.d.ts +1 -1
- package/dist/util/load-tsconfig.js +21 -11
- package/dist/util/module-graph.js +9 -4
- package/dist/util/package-json.d.ts +1 -354
- package/dist/util/package-json.js +56 -10
- package/dist/util/scripts.d.ts +3 -2
- package/dist/util/scripts.js +9 -3
- package/dist/util/to-source-path.d.ts +1 -1
- package/dist/util/to-source-path.js +7 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -10
- package/schema.json +16 -0
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { Visitor } from 'oxc-parser';
|
|
2
|
-
import { findProperty, getPropertyValues } from '../../typescript/ast-helpers.js';
|
|
3
1
|
import { toConfig, toDependency, toEntry } from '../../util/input.js';
|
|
4
2
|
import { dirname, isInternal, toAbsolute } from '../../util/path.js';
|
|
5
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
6
4
|
import { getInputsFromSettings } from '../eslint/helpers.js';
|
|
7
|
-
import { getInputsFromSettingsAST } from '../eslint/resolveFromAST.js';
|
|
8
5
|
const title = 'Oxlint';
|
|
9
6
|
const enablers = ['oxlint', 'vite-plus'];
|
|
10
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
11
|
-
const config = ['.oxlintrc.{json,jsonc}', 'oxlint.config.{ts,mts}'
|
|
12
|
-
const isViteConfig = (configFileName) => configFileName.startsWith('vite.config.');
|
|
8
|
+
const config = ['.oxlintrc.{json,jsonc}', 'oxlint.config.{ts,mts}'];
|
|
13
9
|
const args = {
|
|
14
10
|
config: true,
|
|
15
11
|
};
|
|
@@ -25,8 +21,7 @@ const resolveJsPlugins = (jsPlugins, configFilePath) => {
|
|
|
25
21
|
}
|
|
26
22
|
return inputs;
|
|
27
23
|
};
|
|
28
|
-
const
|
|
29
|
-
const resolveExtendedConfig = (config, configFilePath) => {
|
|
24
|
+
export const resolveExtendedConfig = (config, configFilePath) => {
|
|
30
25
|
const inputs = [];
|
|
31
26
|
for (const entry of config.extends ?? []) {
|
|
32
27
|
if (typeof entry === 'string') {
|
|
@@ -43,43 +38,21 @@ const resolveExtendedConfig = (config, configFilePath) => {
|
|
|
43
38
|
for (const override of config.overrides ?? []) {
|
|
44
39
|
for (const input of resolveJsPlugins(override.jsPlugins, configFilePath))
|
|
45
40
|
inputs.push(input);
|
|
41
|
+
for (const input of getInputsFromSettings(override.settings))
|
|
42
|
+
inputs.push(input);
|
|
46
43
|
}
|
|
47
44
|
for (const input of getInputsFromSettings(config.settings))
|
|
48
45
|
inputs.push(input);
|
|
49
46
|
return inputs;
|
|
50
47
|
};
|
|
51
48
|
const resolveConfig = (config, options) => resolveExtendedConfig(config, options.configFilePath);
|
|
52
|
-
const resolveFromAST = (program, options) => {
|
|
53
|
-
if (!isViteConfig(options.configFileName))
|
|
54
|
-
return [];
|
|
55
|
-
const jsPlugins = new Set();
|
|
56
|
-
const visitor = new Visitor({
|
|
57
|
-
ObjectExpression(node) {
|
|
58
|
-
const lint = findProperty(node, 'lint');
|
|
59
|
-
if (lint?.type !== 'ObjectExpression')
|
|
60
|
-
return;
|
|
61
|
-
for (const specifier of getPropertyValues(lint, 'jsPlugins'))
|
|
62
|
-
jsPlugins.add(specifier);
|
|
63
|
-
for (const plugin of findProperty(lint, 'jsPlugins')?.elements ?? []) {
|
|
64
|
-
if (plugin?.type !== 'ObjectExpression')
|
|
65
|
-
continue;
|
|
66
|
-
for (const specifier of getPropertyValues(plugin, 'specifier'))
|
|
67
|
-
jsPlugins.add(specifier);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
visitor.visit(program);
|
|
72
|
-
return [...resolveJsPlugins([...jsPlugins], options.configFilePath), ...getInputsFromSettingsAST(program)];
|
|
73
|
-
};
|
|
74
49
|
const isFilterTransitiveDependencies = true;
|
|
75
50
|
const plugin = {
|
|
76
51
|
title,
|
|
77
52
|
enablers,
|
|
78
53
|
isEnabled,
|
|
79
54
|
config,
|
|
80
|
-
isLoadConfig,
|
|
81
55
|
resolveConfig,
|
|
82
|
-
resolveFromAST,
|
|
83
56
|
isFilterTransitiveDependencies,
|
|
84
57
|
args,
|
|
85
58
|
};
|
|
@@ -21,6 +21,23 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
21
21
|
inputs.push(toEntry(toAbsolute(id, configFileDir)));
|
|
22
22
|
for (const id of arrayify(localConfig.globalTeardown))
|
|
23
23
|
inputs.push(toEntry(toAbsolute(id, configFileDir)));
|
|
24
|
+
for (const server of [localConfig.webServer].flat()) {
|
|
25
|
+
if (!server?.command)
|
|
26
|
+
continue;
|
|
27
|
+
const dir = server.cwd ? toAbsolute(server.cwd, configFileDir) : configFileDir;
|
|
28
|
+
for (const input of options.getInputsFromScripts(server.command, {
|
|
29
|
+
optionalBinaries: true,
|
|
30
|
+
cwd: dir,
|
|
31
|
+
manifest: options.getManifest(dir) ?? options.manifest,
|
|
32
|
+
})) {
|
|
33
|
+
const inputDir = input.dir ?? dir;
|
|
34
|
+
inputs.push({
|
|
35
|
+
...input,
|
|
36
|
+
...(input.type === 'entry' ? { specifier: toAbsolute(input.specifier, inputDir) } : {}),
|
|
37
|
+
dir: inputDir,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
24
41
|
const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
|
|
25
42
|
const reporters = [localConfig.reporter].flat().flatMap(reporter => {
|
|
26
43
|
const name = typeof reporter === 'string' ? reporter : reporter?.[0];
|
|
@@ -31,6 +31,10 @@ type Project = {
|
|
|
31
31
|
use: string;
|
|
32
32
|
testMatch?: string | RegExp | (string | RegExp)[];
|
|
33
33
|
};
|
|
34
|
+
type TestConfigWebServer = {
|
|
35
|
+
command: string;
|
|
36
|
+
cwd?: string;
|
|
37
|
+
};
|
|
34
38
|
export type PlaywrightTestConfig = {
|
|
35
39
|
projects?: Project[];
|
|
36
40
|
testMatch?: string | RegExp | (string | RegExp)[];
|
|
@@ -38,5 +42,6 @@ export type PlaywrightTestConfig = {
|
|
|
38
42
|
reporter?: LiteralUnion<'dot' | 'line' | 'list' | 'junit' | 'html' | 'json' | 'github' | 'null', string> | ReporterDescription[];
|
|
39
43
|
globalSetup?: string | Array<string>;
|
|
40
44
|
globalTeardown?: string | Array<string>;
|
|
45
|
+
webServer?: TestConfigWebServer | TestConfigWebServer[];
|
|
41
46
|
};
|
|
42
47
|
export {};
|
|
@@ -11,7 +11,11 @@ const config = [
|
|
|
11
11
|
];
|
|
12
12
|
const resolveConfig = config => {
|
|
13
13
|
const plugins = config.plugins
|
|
14
|
-
? (Array.isArray(config.plugins)
|
|
14
|
+
? (Array.isArray(config.plugins)
|
|
15
|
+
? config.plugins
|
|
16
|
+
: Object.entries(config.plugins)
|
|
17
|
+
.filter(([, options]) => options !== false)
|
|
18
|
+
.map(([plugin]) => plugin)).flatMap(plugin => {
|
|
15
19
|
if (typeof plugin === 'string')
|
|
16
20
|
return plugin;
|
|
17
21
|
if (Array.isArray(plugin) && typeof plugin[0] === 'string')
|
|
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'React Native';
|
|
4
4
|
const enablers = ['react-native'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['react-native.config.js'];
|
|
6
|
+
const config = ['react-native.config.{js,cjs,mjs,ts}'];
|
|
7
7
|
const RN_CLI_PACKAGES = [
|
|
8
8
|
'@react-native-community/cli',
|
|
9
9
|
'@react-native-community/cli-platform-android',
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { toProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
import { resolveConfig as resolveRspackConfig } from '../rspack/index.js';
|
|
3
4
|
const title = 'Rsbuild';
|
|
4
5
|
const enablers = ['@rsbuild/core'];
|
|
5
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
7
|
const config = ['rsbuild*.config.{mjs,ts,js,cjs,mts,cts}'];
|
|
7
|
-
const
|
|
8
|
+
const configParams = [
|
|
9
|
+
{ env: 'development', command: 'dev', envMode: 'development' },
|
|
10
|
+
{ env: 'production', command: 'build', envMode: 'production' },
|
|
11
|
+
];
|
|
12
|
+
const getConfigs = async (configOrFn) => {
|
|
13
|
+
if (typeof configOrFn !== 'function')
|
|
14
|
+
return [configOrFn];
|
|
15
|
+
const configs = [];
|
|
16
|
+
for (const params of configParams)
|
|
17
|
+
configs.push(await configOrFn(params));
|
|
18
|
+
return configs;
|
|
19
|
+
};
|
|
20
|
+
const resolveConfig = async (configOrFn, options) => {
|
|
8
21
|
const entries = new Set();
|
|
22
|
+
const inputs = [];
|
|
9
23
|
const checkSource = (source) => {
|
|
10
24
|
if (source?.entry) {
|
|
11
25
|
for (const entry of Object.values(source.entry)) {
|
|
@@ -32,13 +46,51 @@ const resolveConfig = async (config) => {
|
|
|
32
46
|
entries.add(e);
|
|
33
47
|
}
|
|
34
48
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
const checkConfig = async (localConfig, config) => {
|
|
50
|
+
checkSource(localConfig.source);
|
|
51
|
+
if (!localConfig.tools?.rspack)
|
|
52
|
+
return;
|
|
53
|
+
const target = localConfig.output?.target ?? config.output?.target ?? 'web';
|
|
54
|
+
const mode = localConfig.mode ?? config.mode;
|
|
55
|
+
const passes = mode ? [mode === 'production'] : options.isProduction ? [true] : [false, true];
|
|
56
|
+
for (const rspack of [localConfig.tools.rspack].flat()) {
|
|
57
|
+
for (const isProduction of typeof rspack === 'function' ? passes : [options.isProduction]) {
|
|
58
|
+
const baseConfig = {
|
|
59
|
+
mode: mode ?? (isProduction ? 'production' : 'development'),
|
|
60
|
+
entry: {},
|
|
61
|
+
resolve: { alias: {} },
|
|
62
|
+
module: { rules: [] },
|
|
63
|
+
plugins: [],
|
|
64
|
+
};
|
|
65
|
+
const utils = {
|
|
66
|
+
env: process.env.NODE_ENV ?? '',
|
|
67
|
+
isDev: baseConfig.mode === 'development',
|
|
68
|
+
isProd: baseConfig.mode === 'production',
|
|
69
|
+
target,
|
|
70
|
+
isServer: target === 'node',
|
|
71
|
+
isWebWorker: target === 'web-worker',
|
|
72
|
+
};
|
|
73
|
+
const resolvedConfig = typeof rspack === 'function' ? await rspack(baseConfig, utils) : rspack;
|
|
74
|
+
const resolvedInputs = await resolveRspackConfig(resolvedConfig ?? baseConfig, {
|
|
75
|
+
...options,
|
|
76
|
+
isProduction: options.isProduction || isProduction,
|
|
77
|
+
});
|
|
78
|
+
for (const input of resolvedInputs)
|
|
79
|
+
inputs.push(input);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
for (const config of await getConfigs(configOrFn)) {
|
|
84
|
+
await checkConfig(config, config);
|
|
85
|
+
if (config.environments) {
|
|
86
|
+
for (const environment of Object.values(config.environments)) {
|
|
87
|
+
await checkConfig(environment, config);
|
|
88
|
+
}
|
|
39
89
|
}
|
|
40
90
|
}
|
|
41
|
-
|
|
91
|
+
for (const entry of entries)
|
|
92
|
+
inputs.push(toProductionEntry(entry));
|
|
93
|
+
return inputs;
|
|
42
94
|
};
|
|
43
95
|
const plugin = {
|
|
44
96
|
title,
|
|
@@ -1,15 +1,38 @@
|
|
|
1
|
+
import type { Configuration } from 'webpack';
|
|
1
2
|
type EntryDescription = Record<string, unknown>;
|
|
2
3
|
type Entry = Record<string, string | string[] | (EntryDescription & {
|
|
3
4
|
html?: boolean;
|
|
4
5
|
})>;
|
|
6
|
+
type RspackConfigUtils = {
|
|
7
|
+
env: string;
|
|
8
|
+
isDev: boolean;
|
|
9
|
+
isProd: boolean;
|
|
10
|
+
target: 'web' | 'node' | 'web-worker';
|
|
11
|
+
isServer: boolean;
|
|
12
|
+
isWebWorker: boolean;
|
|
13
|
+
};
|
|
14
|
+
type RspackConfig = Configuration | ((config: Configuration, utils: RspackConfigUtils) => Configuration | void | Promise<Configuration | void>);
|
|
5
15
|
export type RsbuildConfig = {
|
|
6
16
|
plugins?: unknown[];
|
|
17
|
+
mode?: 'development' | 'production' | 'none';
|
|
18
|
+
output?: {
|
|
19
|
+
target?: RspackConfigUtils['target'];
|
|
20
|
+
};
|
|
7
21
|
source?: {
|
|
8
22
|
entry?: Entry;
|
|
9
23
|
preEntry?: string | string[];
|
|
10
24
|
};
|
|
25
|
+
tools?: {
|
|
26
|
+
rspack?: RspackConfig | RspackConfig[];
|
|
27
|
+
};
|
|
11
28
|
environments?: {
|
|
12
|
-
[k: string]:
|
|
29
|
+
[k: string]: Omit<RsbuildConfig, 'environments'>;
|
|
13
30
|
};
|
|
14
31
|
};
|
|
32
|
+
export type ConfigParams = {
|
|
33
|
+
env: string;
|
|
34
|
+
command: string;
|
|
35
|
+
envMode: string;
|
|
36
|
+
};
|
|
37
|
+
export type RsbuildConfigOrFn = RsbuildConfig | ((params: ConfigParams) => RsbuildConfig | Promise<RsbuildConfig>);
|
|
15
38
|
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type { Plugin } from '../../types/config.ts';
|
|
1
|
+
import type { Plugin, ResolveConfig } from '../../types/config.ts';
|
|
2
|
+
import type { WebpackConfig } from '../webpack/types.ts';
|
|
3
|
+
export declare const resolveConfig: ResolveConfig<WebpackConfig>;
|
|
2
4
|
declare const plugin: Plugin;
|
|
3
5
|
export default plugin;
|
|
@@ -5,7 +5,7 @@ const title = 'Rspack';
|
|
|
5
5
|
const enablers = ['@rspack/core'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
7
|
const config = ['rspack.config*.{js,ts,mjs,mts,cjs,cts}'];
|
|
8
|
-
const resolveConfig = async (localConfig, options) => {
|
|
8
|
+
export const resolveConfig = async (localConfig, options) => {
|
|
9
9
|
const inputs = await findWebpackDependenciesFromConfig(localConfig, options);
|
|
10
10
|
return inputs.filter(input => !input.specifier.startsWith('builtin:'));
|
|
11
11
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ConfigParams } from '../rsbuild/types.ts';
|
|
1
2
|
type TestEnvironment = 'node' | 'jsdom' | 'happy-dom';
|
|
2
3
|
export type RstestProjectConfig = {
|
|
3
4
|
root?: string;
|
|
@@ -23,10 +24,5 @@ type RstestConfig = RstestProjectConfig & {
|
|
|
23
24
|
provider?: 'istanbul' | 'v8';
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
|
-
type ConfigParams = {
|
|
27
|
-
env: string;
|
|
28
|
-
command: string;
|
|
29
|
-
envMode: string;
|
|
30
|
-
};
|
|
31
27
|
export type RstestConfigOrFn = RstestConfig | ((params: ConfigParams) => RstestConfig | Promise<RstestConfig>);
|
|
32
28
|
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type { Plugin } from '../../types/config.ts';
|
|
1
|
+
import type { Plugin, ResolveConfig } from '../../types/config.ts';
|
|
2
|
+
import type { PluginConfig } from './types.ts';
|
|
3
|
+
export declare const config: string[];
|
|
4
|
+
export declare const resolveConfig: ResolveConfig<PluginConfig>;
|
|
2
5
|
declare const plugin: Plugin;
|
|
3
6
|
export default plugin;
|
|
@@ -1,22 +1,55 @@
|
|
|
1
1
|
import { arrayify } from '../../util/array.js';
|
|
2
2
|
import { toDependency, toProductionEntry } from '../../util/input.js';
|
|
3
|
-
import {
|
|
3
|
+
import { _load } from '../../util/loader.js';
|
|
4
|
+
import { get } from '../../util/object.js';
|
|
5
|
+
import { isInternal, join, toAbsolute } from '../../util/path.js';
|
|
4
6
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
7
|
const title = 'Serverless Framework';
|
|
6
8
|
const enablers = ['serverless'];
|
|
7
9
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
|
-
const config = ['serverless.{js,cjs,mjs,ts,cts,mts,yml,yaml}'];
|
|
10
|
+
export const config = ['serverless.{js,cjs,mjs,ts,cts,mts,yml,yaml}'];
|
|
11
|
+
const fileVariable = /^\$\{file\(([^()$]+)\)(?::([^\s,}]+))?/;
|
|
12
|
+
const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
13
|
+
const resolveFileVariable = async (value, dir) => {
|
|
14
|
+
const match = typeof value === 'string' && value.match(fileVariable);
|
|
15
|
+
if (!match)
|
|
16
|
+
return value;
|
|
17
|
+
try {
|
|
18
|
+
const content = await _load(toAbsolute(match[1].trim(), dir));
|
|
19
|
+
return match[2] ? get(content, match[2]) : content;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
9
25
|
const handlerToEntry = (handler) => {
|
|
10
26
|
const dot = handler.lastIndexOf('.');
|
|
11
|
-
|
|
27
|
+
const file = handler.slice(0, dot);
|
|
28
|
+
return toProductionEntry(/\.(?:[cm]?[jt]s|[jt]sx)$/.test(file) ? file : `${file}.{js,ts}`);
|
|
12
29
|
};
|
|
13
30
|
const pluginToInput = (plugin, dir) => isInternal(plugin) ? toProductionEntry(join(dir, plugin)) : toDependency(plugin);
|
|
31
|
+
const getFunctionEntries = async (functions, dir) => {
|
|
32
|
+
const entries = [];
|
|
33
|
+
const resolved = await resolveFileVariable(functions, dir);
|
|
34
|
+
for (const group of Array.isArray(resolved) ? resolved : [resolved]) {
|
|
35
|
+
const fns = await resolveFileVariable(group, dir);
|
|
36
|
+
if (!isRecord(fns))
|
|
37
|
+
continue;
|
|
38
|
+
for (const name in fns) {
|
|
39
|
+
const fn = await resolveFileVariable(fns[name], dir);
|
|
40
|
+
if (isRecord(fn) && typeof fn.handler === 'string')
|
|
41
|
+
entries.push(handlerToEntry(fn.handler));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return entries;
|
|
45
|
+
};
|
|
14
46
|
const getInjectEntries = (esbuild, dir) => esbuild && typeof esbuild === 'object' ? arrayify(esbuild.inject).map(id => toProductionEntry(join(dir, id))) : [];
|
|
15
|
-
const resolveConfig = async (config, options) => {
|
|
16
|
-
const functions = config.functions
|
|
17
|
-
|
|
47
|
+
export const resolveConfig = async (config, options) => {
|
|
48
|
+
const functions = await getFunctionEntries(config.functions, options.configFileDir);
|
|
49
|
+
const resolvedPlugins = await resolveFileVariable(config.plugins, options.configFileDir);
|
|
50
|
+
const plugins = Array.isArray(resolvedPlugins)
|
|
51
|
+
? resolvedPlugins.filter((plugin) => typeof plugin === 'string')
|
|
18
52
|
: [];
|
|
19
|
-
const plugins = config.plugins?.filter((plugin) => typeof plugin === 'string') ?? [];
|
|
20
53
|
const esbuild = config.custom?.esbuild || config.build?.esbuild ? [toDependency('esbuild', { optional: true })] : [];
|
|
21
54
|
const injectEntries = [
|
|
22
55
|
...getInjectEntries(config.custom?.esbuild, options.configFileDir),
|
|
@@ -5,9 +5,11 @@ export type PluginConfig = {
|
|
|
5
5
|
custom?: {
|
|
6
6
|
esbuild?: EsbuildConfig;
|
|
7
7
|
};
|
|
8
|
-
functions?:
|
|
9
|
-
plugins?: unknown[];
|
|
8
|
+
functions?: Functions | Array<Functions | FileVariable> | FileVariable;
|
|
9
|
+
plugins?: unknown[] | FileVariable;
|
|
10
10
|
};
|
|
11
|
+
type FileVariable = string;
|
|
12
|
+
type Functions = Record<string, ServerlessFunction | FileVariable>;
|
|
11
13
|
export type EsbuildConfig = {
|
|
12
14
|
inject?: string[];
|
|
13
15
|
} | boolean;
|
|
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'simple-git-hooks';
|
|
4
4
|
const enablers = ['simple-git-hooks'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['.simple-git-hooks.{js,cjs,json}', 'simple-git-hooks.{js,cjs,json}', 'package.json'];
|
|
6
|
+
const config = ['.simple-git-hooks.{js,cjs,mjs,json}', 'simple-git-hooks.{js,cjs,mjs,json}', 'package.json'];
|
|
7
7
|
const resolveConfig = async (config, options) => {
|
|
8
8
|
if (options.isProduction)
|
|
9
9
|
return [];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import parseArgs from '../../util/parse-args.js';
|
|
2
2
|
import { parse } from 'unbash';
|
|
3
|
+
import { getCommandWords, walkCommands } from '../../util/scripts.js';
|
|
3
4
|
const BIN = 'svelte-package';
|
|
4
5
|
export const DEFAULT_INPUT = 'src/lib';
|
|
5
6
|
export const DEFAULT_OUTPUT = 'dist';
|
|
@@ -7,48 +8,6 @@ const parseCommandIO = (args) => {
|
|
|
7
8
|
const parsed = parseArgs(args, { string: ['i', 'o', 'input', 'output'], alias: { input: ['i'], output: ['o'] } });
|
|
8
9
|
return { input: parsed.input ?? DEFAULT_INPUT, output: parsed.output ?? DEFAULT_OUTPUT };
|
|
9
10
|
};
|
|
10
|
-
const collectFromCommands = (statements, out) => {
|
|
11
|
-
for (const stmt of statements)
|
|
12
|
-
visit(stmt.command, out);
|
|
13
|
-
};
|
|
14
|
-
const visit = (node, out) => {
|
|
15
|
-
switch (node.type) {
|
|
16
|
-
case 'Command':
|
|
17
|
-
if (node.name?.value === BIN)
|
|
18
|
-
out.push(parseCommandIO(node.suffix.map(w => w.value)));
|
|
19
|
-
return;
|
|
20
|
-
case 'AndOr':
|
|
21
|
-
case 'Pipeline':
|
|
22
|
-
for (const n of node.commands)
|
|
23
|
-
visit(n, out);
|
|
24
|
-
return;
|
|
25
|
-
case 'If':
|
|
26
|
-
collectFromCommands(node.clause.commands, out);
|
|
27
|
-
collectFromCommands(node.then.commands, out);
|
|
28
|
-
if (node.else)
|
|
29
|
-
visit(node.else, out);
|
|
30
|
-
return;
|
|
31
|
-
case 'While':
|
|
32
|
-
collectFromCommands(node.clause.commands, out);
|
|
33
|
-
collectFromCommands(node.body.commands, out);
|
|
34
|
-
return;
|
|
35
|
-
case 'For':
|
|
36
|
-
case 'Select':
|
|
37
|
-
case 'Subshell':
|
|
38
|
-
case 'BraceGroup':
|
|
39
|
-
collectFromCommands(node.body.commands, out);
|
|
40
|
-
return;
|
|
41
|
-
case 'CompoundList':
|
|
42
|
-
collectFromCommands(node.commands, out);
|
|
43
|
-
return;
|
|
44
|
-
case 'Function':
|
|
45
|
-
case 'Coproc':
|
|
46
|
-
visit(node.body, out);
|
|
47
|
-
return;
|
|
48
|
-
case 'Statement':
|
|
49
|
-
visit(node.command, out);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
11
|
export const parseScripts = (scripts) => {
|
|
53
12
|
const out = [];
|
|
54
13
|
for (const script of Object.values(scripts ?? {})) {
|
|
@@ -56,8 +15,12 @@ export const parseScripts = (scripts) => {
|
|
|
56
15
|
continue;
|
|
57
16
|
try {
|
|
58
17
|
const parsed = parse(script);
|
|
59
|
-
|
|
60
|
-
|
|
18
|
+
for (const statement of parsed.commands) {
|
|
19
|
+
for (const node of walkCommands(statement.command)) {
|
|
20
|
+
if (node.name?.value === BIN)
|
|
21
|
+
out.push(parseCommandIO(getCommandWords(node).map(word => word.value)));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
61
24
|
}
|
|
62
25
|
catch { }
|
|
63
26
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { DEFAULT_EXTENSIONS } from '../../constants.js';
|
|
2
|
+
import { filterTransitiveDependencies } from '../../util/filter-transitive-dependencies.js';
|
|
2
3
|
import { _glob } from '../../util/glob.js';
|
|
3
4
|
import { toConfig, toDeferResolve, toDependency, toEntry, toProductionEntry } from '../../util/input.js';
|
|
4
5
|
import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
|
|
5
6
|
import { isAbsolute, isInternal, join, toAbsolute, toPosix } from '../../util/path.js';
|
|
6
7
|
import { hasDependency } from '../../util/plugin.js';
|
|
8
|
+
import { resolveExtendedConfig } from '../oxlint/index.js';
|
|
7
9
|
import { getHtmlScriptEntries, getIndexHtmlEntries } from '../vite/helpers.js';
|
|
8
10
|
import { getAliasInputs, getEnvSpecifier, getExternalReporters } from './helpers.js';
|
|
9
11
|
import { createVitestMockVisitor } from './visitors/mock.js';
|
|
@@ -107,6 +109,7 @@ const getConfigs = async (localConfig) => {
|
|
|
107
109
|
};
|
|
108
110
|
export const resolveConfig = async (localConfig, options) => {
|
|
109
111
|
const inputs = new Set();
|
|
112
|
+
const lintInputs = [];
|
|
110
113
|
inputs.add(toEntry(join(options.cwd, 'src/vite-env.d.ts')));
|
|
111
114
|
const configs = await getConfigs(localConfig);
|
|
112
115
|
for (const cfg of configs) {
|
|
@@ -134,6 +137,11 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
134
137
|
};
|
|
135
138
|
const seenRoots = new Set();
|
|
136
139
|
for (const cfg of configs) {
|
|
140
|
+
const lint = cfg.lint;
|
|
141
|
+
if (lint && options.enabledPlugins.includes('oxlint')) {
|
|
142
|
+
for (const input of resolveExtendedConfig(lint, options.configFilePath))
|
|
143
|
+
lintInputs.push(input);
|
|
144
|
+
}
|
|
137
145
|
const viteRoot = toAbsolute(cfg.root ?? '.', options.cwd);
|
|
138
146
|
const publicDir = cfg.publicDir === false || cfg.publicDir === ''
|
|
139
147
|
? undefined
|
|
@@ -143,10 +151,11 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
143
151
|
for (const entry of await getIndexHtmlEntries(viteRoot, publicDir))
|
|
144
152
|
inputs.add(entry);
|
|
145
153
|
}
|
|
146
|
-
const
|
|
154
|
+
const testRoot = cfg.test?.root || !options.isResolvedConfigFile
|
|
147
155
|
? toAbsolute(cfg.test?.root ?? '.', options.cwd)
|
|
148
156
|
: toAbsolute('.', options.configFileDir);
|
|
149
|
-
const
|
|
157
|
+
const vitestRoot = !cfg.test?.root && cfg.root && !options.isResolvedConfigFile ? toAbsolute(cfg.root, options.cwd) : testRoot;
|
|
158
|
+
const dir = cfg.test?.dir ? toAbsolute(cfg.test.dir, testRoot) : vitestRoot;
|
|
150
159
|
if (cfg.test) {
|
|
151
160
|
if (cfg.test?.include) {
|
|
152
161
|
for (const dependency of cfg.test.include)
|
|
@@ -205,6 +214,11 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
205
214
|
for (const dependency of deps)
|
|
206
215
|
inputs.add(dependency);
|
|
207
216
|
}
|
|
217
|
+
if (lintInputs.length > 0) {
|
|
218
|
+
filterTransitiveDependencies(lintInputs, options.configFilePath);
|
|
219
|
+
for (const input of lintInputs)
|
|
220
|
+
inputs.add(input);
|
|
221
|
+
}
|
|
208
222
|
return Array.from(inputs);
|
|
209
223
|
};
|
|
210
224
|
const args = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OxlintConfig } from '../oxlint/types.ts';
|
|
1
2
|
interface Alias {
|
|
2
3
|
find: string | RegExp;
|
|
3
4
|
replacement: string;
|
|
@@ -37,6 +38,7 @@ interface VitestConfig {
|
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
export interface ViteConfig extends VitestConfig {
|
|
41
|
+
lint?: OxlintConfig;
|
|
40
42
|
extends?: string | true;
|
|
41
43
|
root?: string;
|
|
42
44
|
publicDir?: string | false;
|
package/dist/run.js
CHANGED
|
@@ -17,10 +17,12 @@ import { getGitIgnoredHandler } from './util/glob-core.js';
|
|
|
17
17
|
import { isCatalog } from './util/input.js';
|
|
18
18
|
import { createManifest } from './util/package-json.js';
|
|
19
19
|
import { getModuleSourcePathHandler, getWorkspacePackageTargetHandler } from './util/to-source-path.js';
|
|
20
|
+
import { clearResolverCache } from './util/resolve.js';
|
|
20
21
|
import { getSessionHandler } from './util/watch.js';
|
|
21
22
|
export const run = async (options) => {
|
|
22
23
|
debugLogObject('*', 'Unresolved configuration', options);
|
|
23
24
|
debugLogObject('*', 'Included issue types', options.includedIssueTypes);
|
|
25
|
+
clearResolverCache();
|
|
24
26
|
if (options.isCache) {
|
|
25
27
|
initGlobCache(options.cacheLocation);
|
|
26
28
|
initGitignoreCache(options.cacheLocation);
|