knip 6.36.0 → 6.38.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.
Files changed (79) hide show
  1. package/dist/ConfigurationChief.d.ts +20 -2
  2. package/dist/ConfigurationChief.js +15 -1
  3. package/dist/DependencyDeputy.d.ts +0 -2
  4. package/dist/DependencyDeputy.js +1 -17
  5. package/dist/WorkspaceWorker.js +1 -2
  6. package/dist/binaries/bash-parser.js +1 -1
  7. package/dist/binaries/command.js +20 -9
  8. package/dist/binaries/fallback.js +5 -4
  9. package/dist/binaries/plugins.js +4 -4
  10. package/dist/binaries/resolvers/bun.js +2 -2
  11. package/dist/binaries/resolvers/find.js +5 -4
  12. package/dist/binaries/resolvers/index.d.ts +2 -1
  13. package/dist/binaries/resolvers/index.js +3 -2
  14. package/dist/binaries/resolvers/npm.js +46 -4
  15. package/dist/binaries/resolvers/npx.js +8 -4
  16. package/dist/binaries/resolvers/nub.js +3 -2
  17. package/dist/binaries/resolvers/pnpm.js +17 -10
  18. package/dist/binaries/resolvers/yarn.js +1 -1
  19. package/dist/binaries/util.d.ts +4 -1
  20. package/dist/binaries/util.js +2 -0
  21. package/dist/compilers/compilers.js +1 -1
  22. package/dist/graph/analyze.js +16 -12
  23. package/dist/manifest/index.js +1 -3
  24. package/dist/plugins/ava/index.js +1 -1
  25. package/dist/plugins/eslint/helpers.d.ts +4 -1
  26. package/dist/plugins/eslint/helpers.js +42 -11
  27. package/dist/plugins/eslint/index.js +2 -2
  28. package/dist/plugins/eslint/resolveFromAST.js +12 -8
  29. package/dist/plugins/eve/index.js +26 -8
  30. package/dist/plugins/github-actions/index.js +1 -1
  31. package/dist/plugins/graphql-codegen/index.js +15 -4
  32. package/dist/plugins/graphql-codegen/types.d.ts +11 -1
  33. package/dist/plugins/graphql-codegen/types.js +6 -0
  34. package/dist/plugins/husky/index.js +1 -1
  35. package/dist/plugins/index.d.ts +2 -0
  36. package/dist/plugins/index.js +4 -0
  37. package/dist/plugins/lefthook/index.js +1 -1
  38. package/dist/plugins/mdx/index.d.ts +3 -0
  39. package/dist/plugins/mdx/index.js +16 -6
  40. package/dist/plugins/mise/scripts.js +5 -5
  41. package/dist/plugins/mocha/index.js +3 -1
  42. package/dist/plugins/mocha/types.d.ts +1 -0
  43. package/dist/plugins/oxlint/index.js +24 -8
  44. package/dist/plugins/oxlint/types.d.ts +1 -0
  45. package/dist/plugins/plop/index.js +2 -2
  46. package/dist/plugins/taskfile/index.js +1 -1
  47. package/dist/plugins/tauri/index.js +1 -1
  48. package/dist/plugins/travis/index.js +1 -1
  49. package/dist/plugins/turbo/index.d.ts +3 -0
  50. package/dist/plugins/turbo/index.js +23 -0
  51. package/dist/plugins/typescript/content-mappers.d.ts +4 -0
  52. package/dist/plugins/typescript/content-mappers.js +4 -0
  53. package/dist/plugins/typescript/index.js +14 -18
  54. package/dist/plugins/typescript-content-mapper/index.d.ts +3 -0
  55. package/dist/plugins/typescript-content-mapper/index.js +23 -0
  56. package/dist/plugins/typescript-content-mapper/types.d.ts +3 -0
  57. package/dist/plugins/typescript-content-mapper/types.js +1 -0
  58. package/dist/plugins/vite-plus/resolveFromAST.js +1 -1
  59. package/dist/schema/configuration.d.ts +33 -0
  60. package/dist/schema/configuration.js +2 -0
  61. package/dist/schema/plugins.d.ts +10 -0
  62. package/dist/schema/plugins.js +2 -0
  63. package/dist/types/PluginNames.d.ts +2 -2
  64. package/dist/types/PluginNames.js +2 -0
  65. package/dist/types/config.d.ts +4 -1
  66. package/dist/types/package-json.d.ts +1 -1
  67. package/dist/types/tsconfig-json.d.ts +1 -3
  68. package/dist/util/create-input-handler.js +3 -3
  69. package/dist/util/create-options.d.ts +28 -2
  70. package/dist/util/jiti.js +1 -0
  71. package/dist/util/modules.d.ts +2 -0
  72. package/dist/util/modules.js +3 -1
  73. package/dist/util/package-json.d.ts +187 -185
  74. package/dist/util/parse-args.d.ts +2 -0
  75. package/dist/util/parse-args.js +6 -1
  76. package/dist/version.d.ts +1 -1
  77. package/dist/version.js +1 -1
  78. package/package.json +5 -5
  79. package/schema.json +20 -0
@@ -70,7 +70,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
70
70
  return;
71
71
  const issueType = isEnumMembers ? 'enumMembers' : 'namespaceMembers';
72
72
  const unusedMembers = [];
73
- const ignoredMemberIds = [];
73
+ const ignoredMembers = [];
74
74
  for (const member of exportedItem.members) {
75
75
  if (findMatch(workspace.ignoreMembers, member.identifier))
76
76
  continue;
@@ -78,8 +78,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
78
78
  continue;
79
79
  if (member.hasRefsInFile)
80
80
  continue;
81
- const id = `${identifier}.${member.identifier}`;
82
- const [isMemberReferenced] = explorer.isReferenced(filePath, id, {
81
+ const [isMemberReferenced] = explorer.isReferenced(filePath, `${identifier}.${member.identifier}`, {
83
82
  traverseEntries: true,
84
83
  treatStarAtEntryAsReferenced: true,
85
84
  });
@@ -89,10 +88,19 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
89
88
  unusedMembers.push(member);
90
89
  }
91
90
  else if (isMemberIgnored) {
92
- ignoredMemberIds.push(id);
91
+ ignoredMembers.push(member);
92
+ }
93
+ }
94
+ return { issueType, unusedMembers, ignoredMembers };
95
+ };
96
+ const addMemberTagHints = (members, filePath, identifier) => {
97
+ for (const member of members) {
98
+ for (const tagName of member.jsDocTags) {
99
+ if (options.tags[1].includes(tagName)) {
100
+ collector.addTagHint({ type: 'tag', filePath, identifier: `${identifier}.${member.identifier}`, tagName });
101
+ }
93
102
  }
94
103
  }
95
- return { issueType, unusedMembers, ignoredMemberIds };
96
104
  };
97
105
  const analyzeGraph = async () => {
98
106
  if (options.isReportValues || options.isReportTypes) {
@@ -124,6 +132,8 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
124
132
  const memberIssues = isReferenced
125
133
  ? getMemberIssues(exportedItem, filePath, identifier, workspace, importsForExport)
126
134
  : undefined;
135
+ if (memberIssues)
136
+ addMemberTagHints(memberIssues.ignoredMembers, filePath, identifier);
127
137
  if (!memberIssues || memberIssues.unusedMembers.length === 0) {
128
138
  for (const tagName of exportedItem.jsDocTags) {
129
139
  if (options.tags[1].includes(tagName) || (isInternalProd && tagName === INTERNAL_TAG)) {
@@ -160,13 +170,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
160
170
  fixes: member.fix ? [member.fix] : [],
161
171
  });
162
172
  }
163
- for (const id of memberIssues.ignoredMemberIds) {
164
- for (const tagName of exportedItem.jsDocTags) {
165
- if (options.tags[1].includes(tagName)) {
166
- collector.addTagHint({ type: 'tag', filePath, identifier: id, tagName });
167
- }
168
- }
169
- }
173
+ addMemberTagHints(memberIssues.ignoredMembers, filePath, identifier);
170
174
  }
171
175
  continue;
172
176
  }
@@ -17,10 +17,8 @@ const getMetaDataFromPackageJson = ({ dir, packageNames }) => {
17
17
  if (manifest) {
18
18
  const defaultBinaryName = packageName.replace(/^@[^/]+\//, '');
19
19
  const binaries = typeof manifest.bin === 'string' ? [defaultBinaryName] : Object.keys(manifest.bin ?? {});
20
- for (const binaryName of binaries) {
20
+ for (const binaryName of binaries)
21
21
  addBinary(binaryName, packageName);
22
- addBinary(packageName, binaryName);
23
- }
24
22
  const packagePeerDependencies = Object.keys(manifest.peerDependencies ?? {});
25
23
  for (const packagePeerDependency of packagePeerDependencies) {
26
24
  const hostDependency = {
@@ -23,7 +23,7 @@ const resolveConfig = async (localConfig, options) => {
23
23
  const nodeArgs = localConfig.nodeArguments ?? [];
24
24
  const requireArgs = (localConfig.require ?? []).map(require => `--require ${require}`);
25
25
  const fakeCommand = `node ${nodeArgs.join(' ')} ${requireArgs.join(' ')}`;
26
- return files.concat(options.getInputsFromScripts(fakeCommand, { knownBinsOnly: true }));
26
+ return files.concat(options.getInputsFromScripts(fakeCommand, { optionalBinaries: true }));
27
27
  };
28
28
  const plugin = {
29
29
  title,
@@ -1,7 +1,10 @@
1
1
  import type { PluginOptions } from '../../types/config.ts';
2
+ import type { Manifest } from '../../util/package-json.ts';
2
3
  import { type ConfigInput, type Input } from '../../util/input.ts';
3
4
  import type { ESLintConfig, ESLintConfigDeprecated, OverrideConfigDeprecated, Settings } from './types.ts';
4
5
  export declare const isFlatConfig: (fileName: string) => boolean;
5
6
  export declare const getInputs: (config: ESLintConfigDeprecated | OverrideConfigDeprecated | ESLintConfig, options: PluginOptions) => (Input | ConfigInput)[];
7
+ export type ImportSettingKind = 'resolver' | 'parsers';
8
+ export declare const importSettingKinds: Map<string, ImportSettingKind>;
6
9
  export declare const getInputsFromSettings: (settings?: Settings) => Input[];
7
- export declare const resolveFormatters: (formatters: string | string[]) => Set<Input>;
10
+ export declare const resolveFormatters: (formatters: string | string[], manifest: Manifest) => Set<Input>;
@@ -79,13 +79,24 @@ const getResolverNames = (value) => {
79
79
  return [value];
80
80
  if (Array.isArray(value))
81
81
  return value.flatMap(getResolverNames);
82
- if (value && typeof value === 'object')
82
+ if (value && typeof value === 'object') {
83
+ if ('name' in value && 'resolver' in value)
84
+ return [];
83
85
  return Object.keys(value);
86
+ }
84
87
  return [];
85
88
  };
89
+ export const importSettingKinds = new Map([
90
+ ['import/resolver', 'resolver'],
91
+ ['import-x/resolver', 'resolver'],
92
+ ['import-x/resolver-legacy', 'resolver'],
93
+ ['import/parsers', 'parsers'],
94
+ ['import-x/parsers', 'parsers'],
95
+ ]);
86
96
  const getDependenciesFromSettings = (settings = {}) => {
87
97
  return Object.entries(settings).flatMap(([settingKey, settings]) => {
88
- if (settingKey === 'import/resolver') {
98
+ const kind = importSettingKinds.get(settingKey);
99
+ if (kind === 'resolver') {
89
100
  return getResolverNames(settings)
90
101
  .filter(key => key !== 'node')
91
102
  .map(key => {
@@ -96,7 +107,7 @@ const getDependenciesFromSettings = (settings = {}) => {
96
107
  return `eslint-import-resolver-${key}`;
97
108
  });
98
109
  }
99
- if (settingKey === 'import/parsers') {
110
+ if (kind === 'parsers') {
100
111
  return (typeof settings === 'string' ? [settings] : Object.keys(settings)).map(key => {
101
112
  if (isAbsolute(key))
102
113
  return getPackageNameFromFilePath(key);
@@ -107,15 +118,35 @@ const getDependenciesFromSettings = (settings = {}) => {
107
118
  };
108
119
  export const getInputsFromSettings = (settings) => compact(getDependenciesFromSettings(settings)).map(id => toDeferResolve(id, { optional: true }));
109
120
  const builtinFormatters = new Set(['html', 'json-with-metadata', 'json', 'stylish']);
110
- export const resolveFormatters = (formatters) => {
121
+ const builtinFormattersUntilV8 = new Set([
122
+ 'checkstyle',
123
+ 'compact',
124
+ 'jslint-xml',
125
+ 'junit',
126
+ 'tap',
127
+ 'unix',
128
+ 'visualstudio',
129
+ ]);
130
+ const normalizeFormatterName = (name) => {
131
+ if (!name.startsWith('@'))
132
+ return name.startsWith('eslint-formatter-') ? name : `eslint-formatter-${name}`;
133
+ const [scope, id] = name.split('/');
134
+ if (!id)
135
+ return `${scope}/eslint-formatter`;
136
+ return /^eslint-formatter(-|$)/.test(id) ? name : name.replace('/', '/eslint-formatter-');
137
+ };
138
+ export const resolveFormatters = (formatters, manifest) => {
111
139
  const inputs = new Set();
112
- for (const formatter of [formatters].flat()) {
113
- if (builtinFormatters.has(formatter))
114
- continue;
115
- else if (isInternal(formatter))
116
- inputs.add(toDeferResolve(formatter));
117
- else
118
- inputs.add(toDependency(`eslint-formatter-${formatter}`));
140
+ const isBeforeV9 = (manifest.getMajor('eslint') ?? 9) < 9;
141
+ for (const rawFormatter of [formatters].flat()) {
142
+ const formatter = rawFormatter.replace(/\\/g, '/');
143
+ if (!formatter.startsWith('@') && formatter.includes('/')) {
144
+ inputs.add(toDeferResolve(isInternal(formatter) ? formatter : `./${formatter}`));
145
+ }
146
+ else {
147
+ const isBuiltin = builtinFormatters.has(formatter) || (isBeforeV9 && builtinFormattersUntilV8.has(formatter));
148
+ inputs.add(toDependency(normalizeFormatterName(formatter), isBuiltin ? { optional: true } : {}));
149
+ }
119
150
  }
120
151
  return inputs;
121
152
  };
@@ -49,12 +49,12 @@ const args = {
49
49
  config: true,
50
50
  alias: { format: ['f'] },
51
51
  boolean: ['inspect-config'],
52
- resolveInputs: (parsed) => {
52
+ resolveInputs: (parsed, { manifest }) => {
53
53
  const inputs = [];
54
54
  if (parsed['inspect-config'])
55
55
  inputs.push(toDependency('@eslint/config-inspector', { optional: true }));
56
56
  if (parsed['format'])
57
- for (const input of resolveFormatters(parsed['format']))
57
+ for (const input of resolveFormatters(parsed['format'], manifest))
58
58
  inputs.push(input);
59
59
  return inputs;
60
60
  },
@@ -3,27 +3,30 @@ import { toDeferResolve } from '../../util/input.js';
3
3
  import { findProperty, getPropertyKey } from '../../typescript/ast-helpers.js';
4
4
  import { getStringValue } from '../../typescript/ast-nodes.js';
5
5
  import { isInternal } from '../../util/path.js';
6
+ import { importSettingKinds } from './helpers.js';
6
7
  export const getInputsFromSettingsAST = (program) => {
7
8
  const inputs = [];
8
- const addResolver = (key, resolver) => {
9
+ const addResolver = (kind, resolver) => {
9
10
  if (!resolver || resolver === 'node' || isInternal(resolver))
10
11
  return;
11
- const dep = key === 'import/resolver' ? `eslint-import-resolver-${resolver}` : resolver;
12
+ const dep = kind === 'resolver' ? `eslint-import-resolver-${resolver}` : resolver;
12
13
  inputs.push(toDeferResolve(dep, { optional: true }));
13
14
  };
14
- const addResolvers = (key, node) => {
15
+ const addResolvers = (kind, node) => {
15
16
  if (node?.type === 'ArrayExpression') {
16
17
  for (const element of node.elements)
17
- addResolvers(key, element);
18
+ addResolvers(kind, element);
18
19
  }
19
20
  else if (node?.type === 'ObjectExpression') {
21
+ if (kind === 'resolver' && findProperty(node, 'name') && findProperty(node, 'resolver'))
22
+ return;
20
23
  for (const prop of node.properties) {
21
24
  if (prop.type === 'Property')
22
- addResolver(key, getPropertyKey(prop));
25
+ addResolver(kind, getPropertyKey(prop));
23
26
  }
24
27
  }
25
28
  else {
26
- addResolver(key, getStringValue(node));
29
+ addResolver(kind, getStringValue(node));
27
30
  }
28
31
  };
29
32
  const visitor = new Visitor({
@@ -35,8 +38,9 @@ export const getInputsFromSettingsAST = (program) => {
35
38
  if (prop.type !== 'Property')
36
39
  continue;
37
40
  const key = getPropertyKey(prop);
38
- if (key === 'import/resolver' || key === 'import/parsers')
39
- addResolvers(key, prop.value);
41
+ const kind = key && importSettingKinds.get(key);
42
+ if (kind)
43
+ addResolvers(kind, prop.value);
40
44
  }
41
45
  },
42
46
  });
@@ -3,20 +3,38 @@ const title = 'eve';
3
3
  const enablers = ['eve'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
5
  const extensions = '{js,jsx,ts,tsx,mjs,cjs,mts,cts}';
6
- const rootAgentFileNames = '{agent,instructions,instrumentation,sandbox}';
7
- const subagentFileNames = '{agent,instructions,sandbox}';
6
+ const agentRoots = '{,agent/,agents/*/,agents/*/agent/}';
7
+ const subagentRoots = `${agentRoots}+(subagents/*/|extensions/*/subagents/*/)`;
8
+ const extensionMounts = `{${agentRoots},${subagentRoots}}extensions/*`;
9
+ const rootAgentFileNames = '{agent,instructions,instrumentation,memory,sandbox}';
10
+ const rootAgentDirectories = '{channels,connections,hooks,skills,tools,schedules}';
11
+ const subagentFileNames = '{agent,instructions,memory,sandbox}';
12
+ const subagentDirectories = '{connections,hooks,skills,tools}';
13
+ const entry = ['{evals,agents/*/evals}/evals.config.ts', '{evals,agents/*/evals}/**/*.eval.ts'];
8
14
  const production = [
9
- `{,agent/}${rootAgentFileNames}.${extensions}`,
10
- `{,agent/}sandbox/sandbox.${extensions}`,
11
- `{,agent/}{channels,connections,hooks,skills,tools,schedules}/**/*.${extensions}`,
12
- `{,agent/}subagents/**/${subagentFileNames}.${extensions}`,
13
- `{,agent/}subagents/**/sandbox/sandbox.${extensions}`,
14
- `{,agent/}subagents/**/{connections,hooks,skills,tools}/**/*.${extensions}`,
15
+ `${agentRoots}${rootAgentFileNames}.${extensions}`,
16
+ `${agentRoots}{instructions,instrumentation,memory}/*.${extensions}`,
17
+ `${agentRoots}sandbox/sandbox.${extensions}`,
18
+ `${agentRoots}sandbox/workspace/**/*.${extensions}`,
19
+ `${agentRoots}${rootAgentDirectories}/**/*.${extensions}`,
20
+ `${agentRoots}subagents/*.${extensions}`,
21
+ `${subagentRoots}subagents/*.${extensions}`,
22
+ `${subagentRoots}${subagentFileNames}.${extensions}`,
23
+ `${subagentRoots}{instructions,memory}/*.${extensions}`,
24
+ `${subagentRoots}sandbox/sandbox.${extensions}`,
25
+ `${subagentRoots}sandbox/workspace/**/*.${extensions}`,
26
+ `${subagentRoots}${subagentDirectories}/**/*.${extensions}`,
27
+ `${extensionMounts}.${extensions}`,
28
+ `${extensionMounts}/{extension,instructions}.${extensions}`,
29
+ `${extensionMounts}/instructions/*.${extensions}`,
30
+ `${extensionMounts}/${rootAgentDirectories}/**/*.${extensions}`,
31
+ `${extensionMounts}/subagents/*.${extensions}`,
15
32
  ];
16
33
  const plugin = {
17
34
  title,
18
35
  enablers,
19
36
  isEnabled,
37
+ entry,
20
38
  production,
21
39
  };
22
40
  export default plugin;
@@ -34,7 +34,7 @@ const resolveConfig = async (config, options) => {
34
34
  const manifest = getManifest(dir) ?? options.manifest;
35
35
  const actionPath = relative(dir, configFileDir);
36
36
  const run = step.run.replace(ACTION_PATH_VAR, actionPath ? `./${actionPath}` : '.');
37
- for (const input of getInputsFromScripts([run], { knownBinsOnly: true, manifest })) {
37
+ for (const input of getInputsFromScripts([run], { optionalBinaries: true, manifest })) {
38
38
  if (isDeferResolveEntry(input) && path && !workingDir) {
39
39
  input.specifier = relative(join(dir, path), join(rootCwd, input.specifier));
40
40
  }
@@ -1,8 +1,8 @@
1
1
  import { toDependency, toEntry, toProductionEntry } from '../../util/input.js';
2
2
  import { get } from '../../util/object.js';
3
- import { isInternal, join } from '../../util/path.js';
3
+ import { isInternal, join, normalize } from '../../util/path.js';
4
4
  import { hasDependency } from '../../util/plugin.js';
5
- import { isConfigurationOutput, isGraphqlConfigTypes, isGraphqlProjectsConfigTypes } from './types.js';
5
+ import { isConfigurationOutput, isGraphqlConfigTypes, isGraphqlProjectsConfigTypes, isNearOperationFilePreset, } from './types.js';
6
6
  const title = 'GraphQL Codegen';
7
7
  const enablers = [/^@graphql-codegen\//, 'graphql-config'];
8
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -24,6 +24,17 @@ const getPluginPackageName = (name) => {
24
24
  return name;
25
25
  return `@graphql-codegen/${name}`;
26
26
  };
27
+ const getOutputPattern = (output, outputConfig) => {
28
+ if (isConfigurationOutput(outputConfig) && isNearOperationFilePreset(outputConfig.preset)) {
29
+ const presetConfig = outputConfig.presetConfig ?? {};
30
+ const { folder = '', extension = '.generated.ts', fileName = '*', filePerOperation = false } = presetConfig;
31
+ const subfolder = normalize(folder)
32
+ .split('/')
33
+ .filter(segment => segment !== '' && segment !== '.' && segment !== '..');
34
+ return join(output, '**', ...subfolder, `${filePerOperation ? '*' : fileName}${extension}`);
35
+ }
36
+ return output.endsWith('/') ? `${output}**` : output;
37
+ };
27
38
  const resolveConfig = (config, options) => {
28
39
  const codegenConfigs = isGraphqlProjectsConfigTypes(config)
29
40
  ? Object.values(config.projects).flatMap(project => project.extensions?.codegen ?? [])
@@ -33,8 +44,8 @@ const resolveConfig = (config, options) => {
33
44
  const generateConfigs = codegenConfigs.filter((config) => Boolean(config?.generates));
34
45
  const generateSet = generateConfigs.flatMap(config => Object.values(config.generates));
35
46
  const outputs = generateConfigs
36
- .flatMap(config => Object.keys(config.generates))
37
- .map(output => toProductionEntry(join(options.configFileDir, output.endsWith('/') ? `${output}**` : output)));
47
+ .flatMap(config => Object.entries(config.generates))
48
+ .map(([output, outputConfig]) => toProductionEntry(join(options.configFileDir, getOutputPattern(output, outputConfig))));
38
49
  const configurationOutput = generateSet.filter(isConfigurationOutput);
39
50
  const presets = configurationOutput
40
51
  .map(configOutput => (configOutput.preset ? configOutput.preset : undefined))
@@ -12,10 +12,20 @@ type OutputPreset = {
12
12
  buildGeneratesSection: (options: unknown) => Promise<unknown>;
13
13
  prepareDocuments?: (outputFilePath: string, outputSpecificDocuments: unknown) => Promise<unknown>;
14
14
  };
15
+ export interface NearOperationFilePresetConfig {
16
+ baseTypesPath?: string;
17
+ extension?: string;
18
+ fileName?: string;
19
+ filePerOperation?: boolean;
20
+ folder?: string;
21
+ [key: string]: unknown;
22
+ }
23
+ export declare const isNearOperationFilePreset: (preset: ConfiguredOutput['preset']) => preset is PresetNames;
15
24
  export declare function isConfigurationOutput(config: ConfiguredOutput | ConfiguredPlugin[]): config is ConfiguredOutput;
16
- interface ConfiguredOutput {
25
+ export interface ConfiguredOutput {
17
26
  plugins?: OutputConfig[];
18
27
  preset?: PresetNames | OutputPreset;
28
+ presetConfig?: NearOperationFilePresetConfig;
19
29
  }
20
30
  export interface GraphqlCodegenTypes {
21
31
  generates: {
@@ -1,3 +1,9 @@
1
+ const nearOperationFilePresetNames = new Set([
2
+ 'near-operation-file',
3
+ 'near-operation-file-preset',
4
+ '@graphql-codegen/near-operation-file-preset',
5
+ ]);
6
+ export const isNearOperationFilePreset = (preset) => typeof preset === 'string' && nearOperationFilePresetNames.has(preset);
1
7
  export function isConfigurationOutput(config) {
2
8
  return 'preset' in config || 'plugins' in config;
3
9
  }
@@ -17,7 +17,7 @@ const resolveConfig = (script, options) => {
17
17
  return [toDependency('husky'), ...options.getInputsFromScripts(scripts, { ...options })];
18
18
  }
19
19
  }
20
- return options.getInputsFromScripts(String(script), { knownBinsOnly: true });
20
+ return options.getInputsFromScripts(String(script), { optionalBinaries: true });
21
21
  };
22
22
  const plugin = {
23
23
  title,
@@ -157,8 +157,10 @@ export declare const Plugins: {
157
157
  tsdown: import("../types/config.ts").Plugin;
158
158
  tsup: import("../types/config.ts").Plugin;
159
159
  tsx: import("../types/config.ts").Plugin;
160
+ turbo: import("../types/config.ts").Plugin;
160
161
  typedoc: import("../types/config.ts").Plugin;
161
162
  typescript: import("../types/config.ts").Plugin;
163
+ 'typescript-content-mapper': import("../types/config.ts").Plugin;
162
164
  unbuild: import("../types/config.ts").Plugin;
163
165
  unocss: import("../types/config.ts").Plugin;
164
166
  'unplugin-auto-import': import("../types/config.ts").Plugin;
@@ -151,8 +151,10 @@ import { default as tsd } from './tsd/index.js';
151
151
  import { default as tsdown } from './tsdown/index.js';
152
152
  import { default as tsup } from './tsup/index.js';
153
153
  import { default as tsx } from './tsx/index.js';
154
+ import { default as turbo } from './turbo/index.js';
154
155
  import { default as typedoc } from './typedoc/index.js';
155
156
  import { default as typescript } from './typescript/index.js';
157
+ import { default as typescriptContentMapper } from './typescript-content-mapper/index.js';
156
158
  import { default as unbuild } from './unbuild/index.js';
157
159
  import { default as unocss } from './unocss/index.js';
158
160
  import { default as unpluginAutoImport } from './unplugin-auto-import/index.js';
@@ -337,8 +339,10 @@ export const Plugins = {
337
339
  tsdown,
338
340
  tsup,
339
341
  tsx,
342
+ turbo,
340
343
  typedoc,
341
344
  typescript,
345
+ 'typescript-content-mapper': typescriptContentMapper,
342
346
  unbuild,
343
347
  unocss,
344
348
  'unplugin-auto-import': unpluginAutoImport,
@@ -21,7 +21,7 @@ const resolveConfig = async (localConfig, options) => {
21
21
  const inputs = manifest.devDependencies ? Object.keys(manifest.devDependencies).map(id => toDependency(id)) : [];
22
22
  if (extname(configFileName) !== '') {
23
23
  const scripts = findByKeyDeep(localConfig, 'run').flatMap(command => {
24
- const deps = getInputsFromScripts([command.run], { ...options, knownBinsOnly: true });
24
+ const deps = getInputsFromScripts([command.run], { ...options, optionalBinaries: true });
25
25
  const dir = command.root ?? cwd;
26
26
  return deps.flatMap(dependency => ({ ...dependency, dir }));
27
27
  });
@@ -1,3 +1,6 @@
1
1
  import type { Plugin } from '../../types/config.ts';
2
+ import { type Input } from '../../util/input.ts';
3
+ export declare const contentMappers: string[];
4
+ export declare const resolveContentMapperOptions: (options: Record<string, unknown>) => Input[];
2
5
  declare const plugin: Plugin;
3
6
  export default plugin;
@@ -1,25 +1,35 @@
1
- import { toDependency } from '../../util/input.js';
1
+ import { toDeferResolveProductionEntry, toDependency } from '../../util/input.js';
2
+ import { isInternal } from '../../util/path.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
4
  const title = 'MDX';
4
5
  const enablers = ['astro', 'mdxlint'];
5
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
7
  const config = ['tsconfig.json'];
7
- const takeDependencies = (config) => {
8
+ const takeDependencies = (plugins) => {
8
9
  const inputs = [];
9
- if (Array.isArray(config.plugins)) {
10
- for (const plugin of config.plugins) {
10
+ if (Array.isArray(plugins)) {
11
+ for (const plugin of plugins) {
11
12
  if (typeof plugin === 'string')
12
13
  inputs.push(toDependency(plugin));
13
- else if (typeof plugin[0] === 'string')
14
+ else if (Array.isArray(plugin) && typeof plugin[0] === 'string')
14
15
  inputs.push(toDependency(plugin[0]));
15
16
  }
16
17
  }
17
18
  return inputs;
18
19
  };
20
+ export const contentMappers = ['mdx-content-mapper', '@mdx-js/content-mapper'];
21
+ const bundledPlugins = ['remark-mdx-frontmatter'];
22
+ export const resolveContentMapperOptions = (options) => {
23
+ const inputs = takeDependencies(options.remarkPlugins).filter(input => !bundledPlugins.includes(input.specifier));
24
+ const provider = options.providerImportSource;
25
+ if (typeof provider === 'string' && isInternal(provider))
26
+ inputs.push(toDeferResolveProductionEntry(provider));
27
+ return inputs;
28
+ };
19
29
  const resolveConfig = async (config, options) => {
20
30
  const { configFileName } = options;
21
31
  if (configFileName === 'tsconfig.json' && 'mdx' in config)
22
- return takeDependencies(config.mdx);
32
+ return takeDependencies(config.mdx.plugins);
23
33
  return [];
24
34
  };
25
35
  const plugin = {
@@ -2,11 +2,11 @@ import { parse } from 'unbash';
2
2
  import { getDependenciesFromCommand, getInputsFromNodeOptions } from '../../binaries/command.js';
3
3
  import { spawningBinaries } from '../../binaries/fallback.js';
4
4
  import { isWrapper } from '../../binaries/plugins.js';
5
- import KnownResolvers from '../../binaries/resolvers/index.js';
5
+ import { isPackageManager } from '../../binaries/resolvers/index.js';
6
6
  import { toScript } from '../../binaries/util.js';
7
7
  import { SCRIPT_INTERPOLATION } from '../../constants.js';
8
8
  import { isBinary } from '../../util/input.js';
9
- import { extractBinary } from '../../util/modules.js';
9
+ import { extractBinary, isRelativeNodeModulesBin } from '../../util/modules.js';
10
10
  import { walkCommands } from '../../util/scripts.js';
11
11
  export const getInputsFromMiseScript = (script, options, hasLocalBinPath) => {
12
12
  const inputs = [];
@@ -62,10 +62,10 @@ export const getInputsFromMiseScript = (script, options, hasLocalBinPath) => {
62
62
  if (!name || !word || definedFunctions.has(name))
63
63
  continue;
64
64
  const binary = extractBinary(name);
65
- const isPackageManager = binary in KnownResolvers && binary !== 'find';
66
- const isExplicit = isPackageManager || name.startsWith('./') || /^(?:\.\.?\/)*node_modules\/\.bin\//.test(name);
65
+ const isPackageCommand = isPackageManager(binary);
66
+ const isExplicit = isPackageCommand || name.startsWith('./') || isRelativeNodeModulesBin(name);
67
67
  const isLocal = hasLocalBinPath && !command.prefix.some(assignment => assignment.name === 'PATH');
68
- const isWrapperCommand = !isPackageManager && isWrapper(binary);
68
+ const isWrapperCommand = !isPackageCommand && isWrapper(binary);
69
69
  if (!isExplicit && !isLocal && !isWrapperCommand && binary !== 'node' && binary !== 'find')
70
70
  continue;
71
71
  let commandInputs;
@@ -1,4 +1,4 @@
1
- import { toDeferResolve, toEntry } from '../../util/input.js';
1
+ import { toDeferResolve, toDeferResolveEntry, toEntry } from '../../util/input.js';
2
2
  import { isDirectory } from '../../util/fs.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  const title = 'Mocha';
@@ -9,9 +9,11 @@ const entry = ['**/test/*.{js,cjs,mjs}'];
9
9
  const defaultExtensions = ['js', 'cjs', 'mjs'];
10
10
  const resolveConfig = localConfig => {
11
11
  const entryPatterns = localConfig.spec ? [localConfig.spec].flat() : entry;
12
+ const files = localConfig.file ? [localConfig.file].flat() : [];
12
13
  const require = localConfig.require ? [localConfig.require].flat() : [];
13
14
  const inputs = [];
14
15
  inputs.push(...entryPatterns.map(id => toEntry(id)));
16
+ inputs.push(...files.map(id => toDeferResolveEntry(id)));
15
17
  inputs.push(...require.map(id => toDeferResolve(id)));
16
18
  return inputs;
17
19
  };
@@ -1,4 +1,5 @@
1
1
  export interface MochaConfig {
2
+ file?: string | string[];
2
3
  require?: string | string[];
3
4
  spec?: string | string[];
4
5
  }
@@ -1,7 +1,7 @@
1
1
  import { Visitor } from 'oxc-parser';
2
2
  import { findProperty, getPropertyValues } from '../../typescript/ast-helpers.js';
3
- import { toDependency, toEntry } from '../../util/input.js';
4
- import { isInternal } from '../../util/path.js';
3
+ import { toConfig, toDependency, toEntry } from '../../util/input.js';
4
+ import { dirname, isInternal, toAbsolute } from '../../util/path.js';
5
5
  import { hasDependency } from '../../util/plugin.js';
6
6
  import { getInputsFromSettings } from '../eslint/helpers.js';
7
7
  import { getInputsFromSettingsAST } from '../eslint/resolveFromAST.js';
@@ -13,28 +13,42 @@ const isViteConfig = (configFileName) => configFileName.startsWith('vite.config.
13
13
  const args = {
14
14
  config: true,
15
15
  };
16
- const resolveJsPlugins = (jsPlugins) => {
16
+ const resolveJsPlugins = (jsPlugins, configFilePath) => {
17
17
  const inputs = [];
18
+ const dir = dirname(configFilePath);
18
19
  for (const plugin of jsPlugins ?? []) {
19
20
  const specifier = typeof plugin === 'string' ? plugin : plugin.specifier;
20
21
  if (!isInternal(specifier))
21
22
  inputs.push(toDependency(specifier));
22
23
  else
23
- inputs.push(toEntry(specifier));
24
+ inputs.push(toEntry(toAbsolute(specifier, dir)));
24
25
  }
25
26
  return inputs;
26
27
  };
27
28
  const isLoadConfig = ({ configFileName }) => !isViteConfig(configFileName);
28
- const resolveConfig = config => {
29
- const inputs = resolveJsPlugins(config.jsPlugins);
29
+ const resolveExtendedConfig = (config, configFilePath) => {
30
+ const inputs = [];
31
+ for (const entry of config.extends ?? []) {
32
+ if (typeof entry === 'string') {
33
+ const filePath = toAbsolute(entry, dirname(configFilePath));
34
+ inputs.push(toConfig('oxlint', filePath, { containingFilePath: configFilePath }));
35
+ }
36
+ else {
37
+ for (const input of resolveExtendedConfig(entry, configFilePath))
38
+ inputs.push(input);
39
+ }
40
+ }
41
+ for (const input of resolveJsPlugins(config.jsPlugins, configFilePath))
42
+ inputs.push(input);
30
43
  for (const override of config.overrides ?? []) {
31
- for (const input of resolveJsPlugins(override.jsPlugins))
44
+ for (const input of resolveJsPlugins(override.jsPlugins, configFilePath))
32
45
  inputs.push(input);
33
46
  }
34
47
  for (const input of getInputsFromSettings(config.settings))
35
48
  inputs.push(input);
36
49
  return inputs;
37
50
  };
51
+ const resolveConfig = (config, options) => resolveExtendedConfig(config, options.configFilePath);
38
52
  const resolveFromAST = (program, options) => {
39
53
  if (!isViteConfig(options.configFileName))
40
54
  return [];
@@ -55,8 +69,9 @@ const resolveFromAST = (program, options) => {
55
69
  },
56
70
  });
57
71
  visitor.visit(program);
58
- return [...resolveJsPlugins([...jsPlugins]), ...getInputsFromSettingsAST(program)];
72
+ return [...resolveJsPlugins([...jsPlugins], options.configFilePath), ...getInputsFromSettingsAST(program)];
59
73
  };
74
+ const isFilterTransitiveDependencies = true;
60
75
  const plugin = {
61
76
  title,
62
77
  enablers,
@@ -65,6 +80,7 @@ const plugin = {
65
80
  isLoadConfig,
66
81
  resolveConfig,
67
82
  resolveFromAST,
83
+ isFilterTransitiveDependencies,
68
84
  args,
69
85
  };
70
86
  export default plugin;
@@ -7,6 +7,7 @@ type Override = {
7
7
  jsPlugins?: JsPlugin[];
8
8
  };
9
9
  export type OxlintConfig = {
10
+ extends?: (string | OxlintConfig)[];
10
11
  jsPlugins?: JsPlugin[];
11
12
  overrides?: Override[];
12
13
  settings?: Settings;
@@ -2,11 +2,11 @@ import { hasDependency } from '../../util/plugin.js';
2
2
  const title = 'Plop';
3
3
  const enablers = ['plop'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const config = ['plopfile.{cjs,mjs,js,ts}'];
5
+ const entry = ['plopfile.{cjs,mjs,js,ts}'];
6
6
  const plugin = {
7
7
  title,
8
8
  enablers,
9
9
  isEnabled,
10
- config,
10
+ entry,
11
11
  };
12
12
  export default plugin;