knip 6.35.0 → 6.36.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 (82) hide show
  1. package/dist/ConfigurationChief.d.ts +12 -0
  2. package/dist/IssueCollector.d.ts +3 -0
  3. package/dist/IssueCollector.js +5 -0
  4. package/dist/WorkspaceWorker.d.ts +3 -1
  5. package/dist/WorkspaceWorker.js +10 -5
  6. package/dist/binaries/command.js +2 -2
  7. package/dist/cli.js +4 -0
  8. package/dist/compilers/compilers.js +1 -1
  9. package/dist/compilers/scss.js +2 -2
  10. package/dist/graph/build.js +1 -0
  11. package/dist/graph-explorer/cache.d.ts +3 -0
  12. package/dist/graph-explorer/cache.js +6 -0
  13. package/dist/graph-explorer/explorer.d.ts +1 -0
  14. package/dist/graph-explorer/explorer.js +2 -0
  15. package/dist/graph-explorer/operations/build-exports-tree.js +14 -2
  16. package/dist/graph-explorer/operations/get-ambiguous-star-export.d.ts +8 -0
  17. package/dist/graph-explorer/operations/get-ambiguous-star-export.js +11 -0
  18. package/dist/graph-explorer/operations/get-contention.js +265 -122
  19. package/dist/graph-explorer/operations/resolve-export-origins.d.ts +32 -0
  20. package/dist/graph-explorer/operations/resolve-export-origins.js +255 -0
  21. package/dist/graph-explorer/utils.js +8 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/plugins/eslint/helpers.js +31 -6
  24. package/dist/plugins/eslint/resolveFromAST.js +17 -11
  25. package/dist/plugins/eslint/types.d.ts +3 -3
  26. package/dist/plugins/index.d.ts +2 -0
  27. package/dist/plugins/index.js +4 -0
  28. package/dist/plugins/next/index.js +39 -5
  29. package/dist/plugins/node/index.js +6 -0
  30. package/dist/plugins/tailwind/compiler.js +2 -2
  31. package/dist/plugins/tailwind/index.js +7 -1
  32. package/dist/plugins/textlint/helpers.d.ts +4 -0
  33. package/dist/plugins/textlint/helpers.js +39 -0
  34. package/dist/plugins/textlint/index.d.ts +3 -0
  35. package/dist/plugins/textlint/index.js +52 -0
  36. package/dist/plugins/textlint/types.d.ts +5 -0
  37. package/dist/plugins/textlint/types.js +1 -0
  38. package/dist/plugins/typedoc/index.js +3 -2
  39. package/dist/plugins/typedoc/types.d.ts +2 -2
  40. package/dist/plugins/varlock/index.d.ts +3 -0
  41. package/dist/plugins/varlock/index.js +31 -0
  42. package/dist/plugins/varlock/parse.d.ts +11 -0
  43. package/dist/plugins/varlock/parse.js +185 -0
  44. package/dist/plugins/varlock/scan.d.ts +2 -0
  45. package/dist/plugins/varlock/scan.js +78 -0
  46. package/dist/plugins/vitest/index.js +4 -2
  47. package/dist/reporters/trace.js +30 -1
  48. package/dist/reporters/util/configuration-hints.d.ts +1 -1
  49. package/dist/reporters/util/configuration-hints.js +11 -2
  50. package/dist/run.d.ts +2 -0
  51. package/dist/run.js +2 -1
  52. package/dist/schema/configuration.d.ts +30 -0
  53. package/dist/schema/plugins.d.ts +10 -0
  54. package/dist/schema/plugins.js +2 -0
  55. package/dist/session/build-maps.js +9 -1
  56. package/dist/session/file-descriptor.js +0 -2
  57. package/dist/session/index.d.ts +1 -1
  58. package/dist/session/types.d.ts +18 -0
  59. package/dist/types/PluginNames.d.ts +2 -2
  60. package/dist/types/PluginNames.js +2 -0
  61. package/dist/types/config.d.ts +1 -0
  62. package/dist/types/issues.d.ts +1 -0
  63. package/dist/types/module-graph.d.ts +3 -0
  64. package/dist/typescript/get-imports-and-exports.js +43 -9
  65. package/dist/typescript/resolve-module-names.js +7 -27
  66. package/dist/typescript/visitors/exports.js +9 -4
  67. package/dist/typescript/visitors/walk.d.ts +1 -1
  68. package/dist/typescript/visitors/walk.js +4 -1
  69. package/dist/util/array.d.ts +1 -1
  70. package/dist/util/array.js +5 -1
  71. package/dist/util/create-options.d.ts +20 -0
  72. package/dist/util/file-entry-cache.js +1 -1
  73. package/dist/util/glob-core.d.ts +1 -0
  74. package/dist/util/glob-core.js +11 -3
  75. package/dist/util/package-json.d.ts +2 -0
  76. package/dist/util/url.d.ts +1 -0
  77. package/dist/util/url.js +2 -0
  78. package/dist/util/watch.d.ts +1 -0
  79. package/dist/version.d.ts +1 -1
  80. package/dist/version.js +1 -1
  81. package/package.json +1 -1
  82. package/schema.json +8 -0
@@ -0,0 +1,52 @@
1
+ import { isInternal } from '../../util/path.js';
2
+ import { hasDependency } from '../../util/plugin.js';
3
+ import { toFilterRuleDependency, toPluginDependency, toRuleDependency } from './helpers.js';
4
+ const title = 'textlint';
5
+ const enablers = ['textlint'];
6
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
+ const packageJsonPath = 'textlint';
8
+ const config = ['package.json', '.textlintrc', '.textlintrc.{json,yaml,yml,js,cjs}'];
9
+ const resolveConfig = (config, { cwd, manifest }) => {
10
+ const inputs = [];
11
+ for (const [key, options] of Object.entries(config.rules ?? {})) {
12
+ if (options)
13
+ inputs.push(toRuleDependency(key, manifest, cwd));
14
+ }
15
+ for (const key of Object.keys(config.filters ?? {}))
16
+ inputs.push(toFilterRuleDependency(key, manifest, cwd));
17
+ const plugins = Array.isArray(config.plugins) ? config.plugins : Object.keys(config.plugins ?? {});
18
+ for (const key of plugins)
19
+ inputs.push(toPluginDependency(key, manifest, cwd));
20
+ return inputs;
21
+ };
22
+ const toList = (value) => [value ?? []]
23
+ .flat()
24
+ .flatMap(item => String(item).split(','))
25
+ .map(item => item.trim())
26
+ .filter(Boolean);
27
+ const args = {
28
+ config: true,
29
+ string: ['rule', 'preset', 'plugin'],
30
+ resolveInputs: (parsed, { cwd, manifest }) => {
31
+ const inputs = [];
32
+ for (const rule of toList(parsed.rule))
33
+ inputs.push(toRuleDependency(rule, manifest, cwd));
34
+ for (const preset of toList(parsed.preset)) {
35
+ const key = isInternal(preset) || preset.includes('preset-') ? preset : `preset-${preset}`;
36
+ inputs.push(toRuleDependency(key, manifest, cwd));
37
+ }
38
+ for (const plugin of toList(parsed.plugin))
39
+ inputs.push(toPluginDependency(plugin, manifest, cwd));
40
+ return inputs;
41
+ },
42
+ };
43
+ const plugin = {
44
+ title,
45
+ enablers,
46
+ isEnabled,
47
+ packageJsonPath,
48
+ config,
49
+ resolveConfig,
50
+ args,
51
+ };
52
+ export default plugin;
@@ -0,0 +1,5 @@
1
+ export type TextlintConfig = {
2
+ rules?: Record<string, unknown>;
3
+ filters?: Record<string, unknown>;
4
+ plugins?: string[] | Record<string, unknown>;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import { arrayify } from '../../util/array.js';
1
2
  import { toDeferResolve, toEntry } from '../../util/input.js';
2
3
  import { join } from '../../util/path.js';
3
4
  import { hasDependency } from '../../util/plugin.js';
@@ -15,8 +16,8 @@ const config = [
15
16
  ];
16
17
  const resolveConfig = (config, options) => {
17
18
  const cfg = 'typedocOptions' in config ? config.typedocOptions : config;
18
- const plugins = cfg?.plugin ?? [];
19
- const themes = cfg?.theme ?? [];
19
+ const plugins = arrayify(cfg?.plugin);
20
+ const themes = arrayify(cfg?.theme);
20
21
  const inputs = [...plugins, ...themes].map(id => toDeferResolve(id));
21
22
  for (const file of [cfg?.customCss, cfg?.customJs]) {
22
23
  if (file)
@@ -1,6 +1,6 @@
1
1
  export type TypeDocConfig = {
2
- plugin?: string[];
3
- theme?: string[];
2
+ plugin?: string | string[];
3
+ theme?: string | string[];
4
4
  customCss?: string;
5
5
  customJs?: string;
6
6
  };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,31 @@
1
+ import { arrayify } from '../../util/array.js';
2
+ import { get } from '../../util/object.js';
3
+ import { hasDependency } from '../../util/plugin.js';
4
+ import { scanVarlockFiles } from './scan.js';
5
+ const title = 'Varlock';
6
+ const enablers = ['varlock'];
7
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
+ const getLoadPaths = (manifest) => arrayify(get(manifest, 'varlock.loadPath'));
9
+ const resolve = options => {
10
+ const loadPaths = getLoadPaths(options.manifest);
11
+ return scanVarlockFiles(loadPaths.length > 0 ? loadPaths : ['.'], options.cwd);
12
+ };
13
+ const args = {
14
+ alias: { path: ['p'] },
15
+ string: ['path', 'env'],
16
+ fromArgs: parsed => (parsed._[0] === 'run' ? (parsed['--'] ?? []) : []),
17
+ resolveInputs: (parsed, { cwd, manifest }) => {
18
+ const paths = arrayify(parsed.path);
19
+ const loadPaths = getLoadPaths(manifest);
20
+ const environment = arrayify(parsed.env).at(-1);
21
+ return scanVarlockFiles(paths.length > 0 ? paths : environment ? (loadPaths.length > 0 ? loadPaths : ['.']) : [], cwd);
22
+ },
23
+ };
24
+ const plugin = {
25
+ title,
26
+ enablers,
27
+ isEnabled,
28
+ args,
29
+ resolve,
30
+ };
31
+ export default plugin;
@@ -0,0 +1,11 @@
1
+ type Directive = {
2
+ name: 'import' | 'plugin';
3
+ descriptor: string;
4
+ enabled?: boolean | null;
5
+ allowMissing?: boolean | null;
6
+ };
7
+ export declare const parseVarlockFile: (source: string) => {
8
+ directives: Directive[];
9
+ disabled: boolean;
10
+ };
11
+ export {};
@@ -0,0 +1,185 @@
1
+ const pairs = { '(': ')', '[': ']', '{': '}' };
2
+ const getRootComments = (source) => {
3
+ const comments = [];
4
+ let block = [];
5
+ let hasConfigItem = false;
6
+ for (const line of source.replace(/^\uFEFF/, '').split(/\r?\n/)) {
7
+ if (!line.trim()) {
8
+ comments.push(...block);
9
+ block = [];
10
+ continue;
11
+ }
12
+ const match = line.match(/^\s*#(.*)$/);
13
+ if (!match) {
14
+ hasConfigItem = true;
15
+ break;
16
+ }
17
+ const content = match[1].trimStart();
18
+ if (/^[-=*#]{3}/.test(content)) {
19
+ comments.push(...block);
20
+ block = [];
21
+ }
22
+ else {
23
+ block.push(content);
24
+ }
25
+ }
26
+ if (!hasConfigItem)
27
+ comments.push(...block);
28
+ return comments.join('\n');
29
+ };
30
+ const readQuoted = (value, start) => {
31
+ const quote = value[start];
32
+ let result = '';
33
+ for (let index = start + 1; index < value.length; index++) {
34
+ const char = value[index];
35
+ if (char === quote)
36
+ return { value: result, end: index + 1 };
37
+ if (char === '\\' && value[index + 1] === quote) {
38
+ result += quote;
39
+ index++;
40
+ }
41
+ else {
42
+ result += char;
43
+ }
44
+ }
45
+ };
46
+ const readArguments = (value, start) => {
47
+ const args = [];
48
+ const stack = [pairs[value[start]]];
49
+ let argument = '';
50
+ for (let index = start + 1; index < value.length; index++) {
51
+ const char = value[index];
52
+ if (char === '"' || char === "'" || char === '`') {
53
+ const quoted = readQuoted(value, index);
54
+ if (!quoted)
55
+ return;
56
+ argument += value.slice(index, quoted.end);
57
+ index = quoted.end - 1;
58
+ }
59
+ else if (char === '#') {
60
+ index = value.indexOf('\n', index);
61
+ if (index === -1)
62
+ return;
63
+ argument += ' ';
64
+ }
65
+ else if (pairs[char]) {
66
+ stack.push(pairs[char]);
67
+ argument += char;
68
+ }
69
+ else if (char === stack.at(-1)) {
70
+ stack.pop();
71
+ if (stack.length === 0) {
72
+ args.push(argument.trim());
73
+ return { args, end: index + 1 };
74
+ }
75
+ argument += char;
76
+ }
77
+ else if (char === ',' && stack.length === 1) {
78
+ args.push(argument.trim());
79
+ argument = '';
80
+ }
81
+ else {
82
+ argument += char;
83
+ }
84
+ }
85
+ };
86
+ const readValueEnd = (value, start) => {
87
+ let index = start;
88
+ while (index < value.length && !/[\s#]/.test(value[index])) {
89
+ const char = value[index];
90
+ if (char === '"' || char === "'" || char === '`') {
91
+ const quoted = readQuoted(value, index);
92
+ if (!quoted)
93
+ return value.length;
94
+ index = quoted.end;
95
+ }
96
+ else if (pairs[char]) {
97
+ const nested = readArguments(value, index);
98
+ if (!nested)
99
+ return value.length;
100
+ index = nested.end;
101
+ }
102
+ else {
103
+ index++;
104
+ }
105
+ }
106
+ return index;
107
+ };
108
+ const getStaticString = (value) => {
109
+ const trimmed = value.trim();
110
+ const quote = trimmed[0];
111
+ if (quote === '"' || quote === "'" || quote === '`') {
112
+ const quoted = readQuoted(trimmed, 0);
113
+ return quoted?.end === trimmed.length ? quoted.value : undefined;
114
+ }
115
+ if (!trimmed || /[\s,)]/.test(trimmed) || trimmed.includes('$') || /^[a-z][a-z\d_]*\(/i.test(trimmed))
116
+ return;
117
+ if (/^(?:true|false|undefined)$/i.test(trimmed))
118
+ return;
119
+ const number = Number(trimmed);
120
+ return Number.isFinite(number) && String(number) === trimmed ? undefined : trimmed;
121
+ };
122
+ const getBoolean = (value) => {
123
+ const trimmed = value.trim();
124
+ return trimmed === 'true' ? true : trimmed === 'false' ? false : null;
125
+ };
126
+ export const parseVarlockFile = (source) => {
127
+ const directives = [];
128
+ const value = getRootComments(source);
129
+ let disabled = false;
130
+ for (let index = 0; index < value.length;) {
131
+ while (value[index] === ' ' || value[index] === '\t')
132
+ index++;
133
+ if (value[index] !== '@') {
134
+ index = value.indexOf('\n', index) + 1 || value.length;
135
+ continue;
136
+ }
137
+ while (index < value.length && value[index] !== '\n' && value[index] !== '#') {
138
+ if (value[index] !== '@' || !/[a-z]/i.test(value[index + 1] ?? '')) {
139
+ index++;
140
+ continue;
141
+ }
142
+ let nameEnd = index + 2;
143
+ while (/[a-z\d_]/i.test(value[nameEnd] ?? ''))
144
+ nameEnd++;
145
+ const name = value.slice(index + 1, nameEnd);
146
+ let cursor = nameEnd;
147
+ while (value[cursor] === ' ' || value[cursor] === '\t')
148
+ cursor++;
149
+ if (value[cursor] === '(') {
150
+ const result = readArguments(value, cursor);
151
+ if (!result)
152
+ break;
153
+ if (name === 'plugin' || name === 'import') {
154
+ const descriptor = getStaticString(result.args[0] ?? '');
155
+ if (descriptor !== undefined) {
156
+ const directive = { name, descriptor };
157
+ for (const arg of result.args.slice(1)) {
158
+ const separator = arg.indexOf('=');
159
+ if (separator === -1)
160
+ continue;
161
+ const key = arg.slice(0, separator).trim();
162
+ if (key === 'enabled' || key === 'allowMissing')
163
+ directive[key] = getBoolean(arg.slice(separator + 1));
164
+ }
165
+ directives.push(directive);
166
+ }
167
+ }
168
+ index = result.end;
169
+ }
170
+ else if (value[cursor] === '=') {
171
+ const end = readValueEnd(value, cursor + 1);
172
+ if (name === 'disable')
173
+ disabled ||= getBoolean(value.slice(cursor + 1, end)) === true;
174
+ index = end;
175
+ }
176
+ else {
177
+ if (name === 'disable')
178
+ disabled = true;
179
+ index = nameEnd;
180
+ }
181
+ }
182
+ index = value.indexOf('\n', index) + 1 || value.length;
183
+ }
184
+ return { directives, disabled };
185
+ };
@@ -0,0 +1,2 @@
1
+ import type { Input } from '../../util/input.ts';
2
+ export declare const scanVarlockFiles: (paths: string[], cwd: string) => Input[];
@@ -0,0 +1,78 @@
1
+ import { readFileSync, readdirSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { toDeferResolve, toDeferResolveProductionEntry, toDependency } from '../../util/input.js';
4
+ import { isDirectory, isFile, tryRealpath } from '../../util/fs.js';
5
+ import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
6
+ import { dirname, isInternal, join, toAbsolute } from '../../util/path.js';
7
+ import { isGitIgnored } from '../../util/glob-core.js';
8
+ import { debugLog } from '../../util/debug.js';
9
+ import { hasUrlScheme } from '../../util/url.js';
10
+ import { parseVarlockFile } from './parse.js';
11
+ const resolvePath = (path, cwd) => path.startsWith('~/') ? join(homedir(), path.slice(2)) : toAbsolute(path, cwd);
12
+ const isExternalUrl = (path) => path.startsWith('//') || hasUrlScheme(path);
13
+ const isLocalPath = (path) => path.startsWith('~/') || isInternal(path);
14
+ const expandLoadPath = (path) => {
15
+ if (!isDirectory(path))
16
+ return [path];
17
+ try {
18
+ const paths = [];
19
+ for (const name of readdirSync(path))
20
+ if (name === '.env' || name.startsWith('.env.'))
21
+ paths.push(join(path, name));
22
+ return paths;
23
+ }
24
+ catch {
25
+ return [];
26
+ }
27
+ };
28
+ export const scanVarlockFiles = (paths, cwd) => {
29
+ const inputs = [];
30
+ const queue = [];
31
+ for (const path of paths)
32
+ queue.push(...expandLoadPath(resolvePath(path, cwd)));
33
+ const visited = new Set();
34
+ for (const path of queue) {
35
+ if (!isFile(path) || isGitIgnored(path))
36
+ continue;
37
+ const realPath = tryRealpath(path);
38
+ if (visited.has(realPath))
39
+ continue;
40
+ visited.add(realPath);
41
+ let source;
42
+ try {
43
+ source = readFileSync(realPath, 'utf8');
44
+ }
45
+ catch (error) {
46
+ debugLog('Varlock', `Unable to read ${realPath} (${error instanceof Error ? error.message : error})`);
47
+ continue;
48
+ }
49
+ const { directives, disabled } = parseVarlockFile(source);
50
+ if (disabled)
51
+ continue;
52
+ for (const { name, descriptor, enabled, allowMissing } of directives) {
53
+ if (!descriptor || descriptor.includes('$') || isExternalUrl(descriptor) || enabled === false)
54
+ continue;
55
+ if (name === 'plugin') {
56
+ if (isLocalPath(descriptor)) {
57
+ inputs.push(toDeferResolveProductionEntry(descriptor.startsWith('~/') ? resolvePath(descriptor, dirname(realPath)) : descriptor, { containingFilePath: realPath }));
58
+ }
59
+ else {
60
+ const packageName = getPackageNameFromModuleSpecifier(descriptor);
61
+ if (packageName) {
62
+ inputs.push({ ...toDependency(packageName, { containingFilePath: realPath }), production: true });
63
+ }
64
+ }
65
+ continue;
66
+ }
67
+ if (!isLocalPath(descriptor))
68
+ continue;
69
+ const importPath = resolvePath(descriptor, dirname(realPath));
70
+ if (isFile(importPath) || isDirectory(importPath))
71
+ queue.push(...expandLoadPath(importPath));
72
+ else if (allowMissing !== true && allowMissing !== null && enabled !== null) {
73
+ inputs.push(toDeferResolve(descriptor, { containingFilePath: realPath }));
74
+ }
75
+ }
76
+ }
77
+ return inputs;
78
+ };
@@ -143,7 +143,9 @@ export const resolveConfig = async (localConfig, options) => {
143
143
  for (const entry of await getIndexHtmlEntries(viteRoot, publicDir))
144
144
  inputs.add(entry);
145
145
  }
146
- const vitestRoot = toAbsolute(cfg.test?.root ?? '.', options.cwd);
146
+ const vitestRoot = cfg.test?.root || !options.isResolvedConfigFile
147
+ ? toAbsolute(cfg.test?.root ?? '.', options.cwd)
148
+ : toAbsolute('.', options.configFileDir);
147
149
  const dir = cfg.test?.dir ? toAbsolute(cfg.test.dir, vitestRoot) : vitestRoot;
148
150
  if (cfg.test) {
149
151
  if (cfg.test?.include) {
@@ -189,7 +191,7 @@ export const resolveConfig = async (localConfig, options) => {
189
191
  inputs.add(dependency);
190
192
  const _entry = cfg.build?.lib?.entry ?? [];
191
193
  const entries = typeof _entry === 'string' ? [_entry] : Array.isArray(_entry) ? _entry : Object.values(_entry).flat();
192
- const deps = entries.map(specifier => join(vitestRoot, specifier)).map(id => toEntry(id));
194
+ const deps = entries.map(specifier => join(viteRoot, specifier)).map(id => toEntry(id));
193
195
  for (const dependency of deps)
194
196
  inputs.add(dependency);
195
197
  }
@@ -1,3 +1,5 @@
1
+ import { IMPORT_STAR } from '../constants.js';
2
+ import { getAmbiguousStarExport } from '../graph-explorer/operations/get-ambiguous-star-export.js';
1
3
  import st from '../util/colors.js';
2
4
  import { toRelative } from '../util/path.js';
3
5
  import { toRegexOrString } from '../util/regex.js';
@@ -33,6 +35,34 @@ export default ({ graph, explorer, options, workspaceFilePathFilter, issues }) =
33
35
  }
34
36
  else {
35
37
  let nodes = explorer.buildExportsTree({ filePath: options.traceFile, identifier: options.traceExport });
38
+ const traceFile = options.traceFile;
39
+ const traceExport = options.traceExport;
40
+ const dotIndex = traceExport?.indexOf('.') ?? -1;
41
+ const resolvedTraceExport = dotIndex === -1 ? traceExport : traceExport?.slice(0, dotIndex);
42
+ const resolution = traceFile && resolvedTraceExport ? explorer.resolveExportOrigins(traceFile, resolvedTraceExport) : undefined;
43
+ const collision = resolution && resolvedTraceExport ? getAmbiguousStarExport(resolution, resolvedTraceExport) : undefined;
44
+ const toRel = (path) => toRelative(path, options.cwd);
45
+ if (collision) {
46
+ collision.origins.sort((a, b) => compareStrings(a.filePath, b.filePath));
47
+ console.log(`${toRel(traceFile ?? '')}:${st.cyanBright(resolvedTraceExport ?? '')} [ambiguous]`);
48
+ for (let i = 0; i < collision.origins.length; i++) {
49
+ const origin = collision.origins[i];
50
+ const connector = i === collision.origins.length - 1 ? '└──' : '├──';
51
+ console.log(`${st.dim(connector)} ${toRel(origin.filePath)}:${st.cyanBright(origin.identifier)}`);
52
+ }
53
+ return;
54
+ }
55
+ if (nodes.length === 0 && resolution && !resolution.hasExplicitExport && resolution.origins.length === 1) {
56
+ const [origin] = resolution.origins;
57
+ const originFile = graph.get(origin.filePath);
58
+ if (originFile && origin.identifier !== IMPORT_STAR && origin.identifier !== 'default') {
59
+ for (const [exportId, exp] of originFile.exports) {
60
+ if (exp.binding !== origin.identifier)
61
+ continue;
62
+ nodes.push(...explorer.buildExportsTree({ filePath: origin.filePath, identifier: exportId }));
63
+ }
64
+ }
65
+ }
36
66
  if (nodes.length === 0 && options.traceExport?.includes('.')) {
37
67
  const nsName = options.traceExport.substring(0, options.traceExport.indexOf('.'));
38
68
  nodes = explorer.buildExportsTree({ filePath: options.traceFile, identifier: nsName });
@@ -56,7 +86,6 @@ export default ({ graph, explorer, options, workspaceFilePathFilter, issues }) =
56
86
  }
57
87
  }
58
88
  nodes.sort((a, b) => compareStrings(a.filePath, b.filePath) || compareStrings(a.identifier, b.identifier));
59
- const toRel = (path) => toRelative(path, options.cwd);
60
89
  if (nodes.length === 0) {
61
90
  if (options.traceFile && !graph.has(options.traceFile)) {
62
91
  console.log(`File not found in module graph: ${toRel(options.traceFile)}`);
@@ -18,6 +18,6 @@ export declare const finalizeConfigurationHints: (results: Results, options: {
18
18
  cwd: string;
19
19
  configFilePath?: string;
20
20
  }) => ProcessedHint[];
21
- export declare const printConfigurationHints: ({ cwd, counters, issues, tagHints, configurationHints, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }: ReporterOptions) => void;
21
+ export declare const printConfigurationHints: ({ cwd, counters, issues, tagHints, configurationHints, hasConfigLoadErrors, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }: ReporterOptions) => void;
22
22
  export declare const printTagHints: ({ cwd, tagHints, isTreatTagHintsAsErrors }: ReporterOptions) => void;
23
23
  export {};
@@ -128,8 +128,17 @@ export const finalizeConfigurationHints = (results, options) => {
128
128
  return row;
129
129
  }));
130
130
  };
131
- export const printConfigurationHints = ({ cwd, counters, issues, tagHints, configurationHints, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }) => {
132
- const rows = finalizeConfigurationHints({ issues, counters, configurationHints, tagHints, includedWorkspaceDirs, selectedWorkspaces, enabledPlugins }, { cwd, configFilePath });
131
+ export const printConfigurationHints = ({ cwd, counters, issues, tagHints, configurationHints, hasConfigLoadErrors, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }) => {
132
+ const rows = finalizeConfigurationHints({
133
+ issues,
134
+ counters,
135
+ configurationHints,
136
+ hasConfigLoadErrors,
137
+ tagHints,
138
+ includedWorkspaceDirs,
139
+ selectedWorkspaces,
140
+ enabledPlugins,
141
+ }, { cwd, configFilePath });
133
142
  if (rows.length > 0) {
134
143
  const getTitle = isTreatConfigHintsAsErrors ? getColoredTitle : getDimmedTitle;
135
144
  console.warn(getTitle('Configuration hints', configurationHints.length));
package/dist/run.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare const run: (options: MainOptions) => Promise<{
7
7
  counters: import("./types/issues.ts").Counters;
8
8
  tagHints: Set<import("./types/issues.ts").TagHint>;
9
9
  configurationHints: import("./types/issues.ts").ConfigurationHint[];
10
+ hasConfigLoadErrors: boolean;
10
11
  selectedWorkspaces: string[] | undefined;
11
12
  includedWorkspaceDirs: string[];
12
13
  enabledPlugins: {
@@ -26,6 +27,7 @@ export declare const run: (options: MainOptions) => Promise<{
26
27
  counters: import("./types/issues.ts").Counters;
27
28
  tagHints: Set<import("./types/issues.ts").TagHint>;
28
29
  configurationHints: import("./types/issues.ts").ConfigurationHint[];
30
+ hasConfigLoadErrors: boolean;
29
31
  };
30
32
  } | undefined;
31
33
  streamer: ConsoleStreamer;
package/dist/run.js CHANGED
@@ -114,7 +114,7 @@ export const run = async (options) => {
114
114
  if (options.isWatch)
115
115
  watch('.', { recursive: true }, session.listener);
116
116
  }
117
- const { issues, counters, tagHints, configurationHints } = collector.getIssues();
117
+ const { issues, counters, tagHints, configurationHints, hasConfigLoadErrors } = collector.getIssues();
118
118
  if (!options.isWatch)
119
119
  streamer.clear();
120
120
  if (options.isCache) {
@@ -127,6 +127,7 @@ export const run = async (options) => {
127
127
  counters,
128
128
  tagHints,
129
129
  configurationHints,
130
+ hasConfigLoadErrors,
130
131
  selectedWorkspaces: chief.selectedWorkspaces ? Array.from(chief.selectedWorkspaces) : undefined,
131
132
  includedWorkspaceDirs: Array.from(chief.workspacesByDir.keys()),
132
133
  enabledPlugins: Object.fromEntries(enabledPluginsStore),
@@ -731,6 +731,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
731
731
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
732
732
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
733
733
  }, z.core.$strip>]>>;
734
+ textlint: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
735
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
736
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
737
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
738
+ }, z.core.$strip>]>>;
734
739
  travis: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
735
740
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
736
741
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -811,6 +816,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
811
816
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
812
817
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
813
818
  }, z.core.$strip>]>>;
819
+ varlock: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
820
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
821
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
822
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
823
+ }, z.core.$strip>]>>;
814
824
  vercel: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
815
825
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
816
826
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1662,6 +1672,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1662
1672
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1663
1673
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1664
1674
  }, z.core.$strip>]>>;
1675
+ textlint: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1676
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1677
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1678
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1679
+ }, z.core.$strip>]>>;
1665
1680
  travis: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1666
1681
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1667
1682
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1742,6 +1757,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1742
1757
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1743
1758
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1744
1759
  }, z.core.$strip>]>>;
1760
+ varlock: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1761
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1762
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1763
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1764
+ }, z.core.$strip>]>>;
1745
1765
  vercel: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1746
1766
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1747
1767
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -2612,6 +2632,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
2612
2632
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2613
2633
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2614
2634
  }, z.core.$strip>]>>;
2635
+ textlint: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
2636
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2637
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2638
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2639
+ }, z.core.$strip>]>>;
2615
2640
  travis: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
2616
2641
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2617
2642
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -2692,6 +2717,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
2692
2717
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2693
2718
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2694
2719
  }, z.core.$strip>]>>;
2720
+ varlock: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
2721
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2722
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2723
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2724
+ }, z.core.$strip>]>>;
2695
2725
  vercel: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
2696
2726
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
2697
2727
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -736,6 +736,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
736
736
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
737
737
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
738
738
  }, z.core.$strip>]>;
739
+ textlint: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
740
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
741
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
742
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
743
+ }, z.core.$strip>]>;
739
744
  travis: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
740
745
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
741
746
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -816,6 +821,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
816
821
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
817
822
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
818
823
  }, z.core.$strip>]>;
824
+ varlock: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
825
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
826
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
827
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
828
+ }, z.core.$strip>]>;
819
829
  vercel: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
820
830
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
821
831
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;