knip 5.82.1 → 5.83.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -0
  2. package/dist/ConfigurationChief.js +1 -1
  3. package/dist/IssueCollector.js +5 -5
  4. package/dist/PrincipalFactory.js +1 -1
  5. package/dist/binaries/plugins.js +1 -0
  6. package/dist/compilers/index.d.ts +10 -0
  7. package/dist/graph/analyze.js +8 -0
  8. package/dist/manifest/helpers.js +1 -2
  9. package/dist/plugins/c8/index.js +1 -1
  10. package/dist/plugins/dotenv/index.js +1 -1
  11. package/dist/plugins/expressive-code/index.d.ts +8 -0
  12. package/dist/plugins/expressive-code/index.js +15 -0
  13. package/dist/plugins/github-actions/index.js +2 -4
  14. package/dist/plugins/index.d.ts +6 -0
  15. package/dist/plugins/index.js +2 -0
  16. package/dist/plugins/nx/index.js +1 -1
  17. package/dist/plugins/simple-git-hooks/index.js +2 -0
  18. package/dist/plugins/vite/helpers.d.ts +2 -0
  19. package/dist/plugins/vite/helpers.js +23 -0
  20. package/dist/plugins/vite/index.js +5 -1
  21. package/dist/plugins/vitest/index.js +24 -9
  22. package/dist/reporters/compact.js +3 -1
  23. package/dist/reporters/index.js +1 -1
  24. package/dist/reporters/util/configuration-hints.js +1 -1
  25. package/dist/reporters/util/util.js +4 -2
  26. package/dist/schema/configuration.d.ts +15 -0
  27. package/dist/schema/plugins.d.ts +5 -0
  28. package/dist/schema/plugins.js +1 -0
  29. package/dist/types/PluginNames.d.ts +2 -2
  30. package/dist/types/PluginNames.js +1 -0
  31. package/dist/typescript/ast-helpers.js +11 -6
  32. package/dist/util/create-input-handler.js +3 -3
  33. package/dist/util/create-options.d.ts +10 -0
  34. package/dist/util/fs.d.ts +1 -1
  35. package/dist/util/fs.js +7 -9
  36. package/dist/util/glob-core.js +2 -2
  37. package/dist/util/loader.js +1 -1
  38. package/dist/util/modules.js +5 -4
  39. package/dist/util/package-json.js +9 -8
  40. package/dist/util/path.js +12 -1
  41. package/dist/util/workspace-selectors.d.ts +1 -1
  42. package/dist/version.d.ts +1 -1
  43. package/dist/version.js +1 -1
  44. package/package.json +1 -1
  45. package/schema.json +4 -0
  46. /package/dist/reporters/{githubActions.d.ts → github-actions.d.ts} +0 -0
  47. /package/dist/reporters/{githubActions.js → github-actions.js} +0 -0
@@ -201,6 +201,11 @@ export declare class ConfigurationChief {
201
201
  entry?: string | string[] | undefined;
202
202
  project?: string | string[] | undefined;
203
203
  } | undefined;
204
+ 'expressive-code'?: string | boolean | string[] | {
205
+ config?: string | string[] | undefined;
206
+ entry?: string | string[] | undefined;
207
+ project?: string | string[] | undefined;
208
+ } | undefined;
204
209
  gatsby?: string | boolean | string[] | {
205
210
  config?: string | string[] | undefined;
206
211
  entry?: string | string[] | undefined;
@@ -757,6 +762,7 @@ export declare class ConfigurationChief {
757
762
  eleventy?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
758
763
  eslint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
759
764
  expo?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
765
+ "expressive-code"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
760
766
  gatsby?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
761
767
  "github-action"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
762
768
  "github-actions"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -228,7 +228,7 @@ export class ConfigurationChief {
228
228
  for (const dir of this.availableWorkspaceDirs)
229
229
  addDependents(dir);
230
230
  for (const dir of workspaceDirsWithDependents)
231
- ws.add(relative(this.cwd, dir) || ROOT_WORKSPACE_NAME);
231
+ ws.add(relative(this.cwd, dir));
232
232
  }
233
233
  }
234
234
  else {
@@ -66,8 +66,7 @@ export class IssueCollector {
66
66
  const matcher = this.issueMatchers.get(issueType);
67
67
  if (!matcher)
68
68
  return false;
69
- const relativePath = relative(this.cwd, filePath);
70
- return matcher(relativePath);
69
+ return matcher(relative(this.cwd, filePath));
71
70
  }
72
71
  addFileCounts({ processed, unused }) {
73
72
  this.counters.processed += processed;
@@ -99,10 +98,11 @@ export class IssueCollector {
99
98
  return;
100
99
  if (this.shouldIgnoreIssue(issue.filePath, issue.type))
101
100
  return;
101
+ if (this.rules[issue.type] === 'off')
102
+ return;
102
103
  const key = relative(this.cwd, issue.filePath);
103
- const { type } = issue;
104
- issue.severity = this.rules[type];
105
- const issues = this.issues[type];
104
+ issue.severity = this.rules[issue.type];
105
+ const issues = this.issues[issue.type];
106
106
  issues[key] = issues[key] ?? {};
107
107
  const symbol = issue.parentSymbol ? `${issue.parentSymbol}.${issue.symbol}` : issue.symbol;
108
108
  if (!issues[key][symbol]) {
@@ -59,7 +59,7 @@ export class PrincipalFactory {
59
59
  deletePrincipal(principal, cwd) {
60
60
  const p = Array.from(this.principals).find(p => p.principal === principal);
61
61
  if (p) {
62
- debugLog('*', `Deleting principal at ${[...p.wsDirs].map(dir => toRelative(dir, cwd) || '.')} (${[...p.pkgNames]})`);
62
+ debugLog('*', `Deleting principal at ${[...p.wsDirs].map(dir => toRelative(dir, cwd))} (${[...p.pkgNames]})`);
63
63
  this.principals.delete(p);
64
64
  }
65
65
  }
@@ -29,6 +29,7 @@ export const resolve = (binary, _args, options) => {
29
29
  ...(pluginArgs.config === true ? { config: ['c'] } : {}),
30
30
  ...pluginArgs.alias,
31
31
  },
32
+ '--': true,
32
33
  });
33
34
  const positionals = [];
34
35
  if (pluginArgs.positional && parsed._[0]) {
@@ -149,6 +149,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
149
149
  entry?: string | string[] | undefined;
150
150
  project?: string | string[] | undefined;
151
151
  } | undefined;
152
+ 'expressive-code'?: string | boolean | string[] | {
153
+ config?: string | string[] | undefined;
154
+ entry?: string | string[] | undefined;
155
+ project?: string | string[] | undefined;
156
+ } | undefined;
152
157
  gatsby?: string | boolean | string[] | {
153
158
  config?: string | string[] | undefined;
154
159
  entry?: string | string[] | undefined;
@@ -800,6 +805,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
800
805
  entry?: string | string[] | undefined;
801
806
  project?: string | string[] | undefined;
802
807
  } | undefined;
808
+ 'expressive-code'?: string | boolean | string[] | {
809
+ config?: string | string[] | undefined;
810
+ entry?: string | string[] | undefined;
811
+ project?: string | string[] | undefined;
812
+ } | undefined;
803
813
  gatsby?: string | boolean | string[] | {
804
814
  config?: string | string[] | undefined;
805
815
  entry?: string | string[] | undefined;
@@ -11,9 +11,17 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
11
11
  const isReferencedInUsedExport = (exportedItem, filePath, includeEntryExports) => {
12
12
  if (!exportedItem.referencedIn)
13
13
  return false;
14
+ const file = graph.get(filePath);
15
+ if (!file)
16
+ return false;
14
17
  for (const containingExport of exportedItem.referencedIn) {
15
18
  if (explorer.isReferenced(filePath, containingExport, { includeEntryExports })[0])
16
19
  return true;
20
+ const inExport = file.exports.get(containingExport);
21
+ if (!inExport)
22
+ return false;
23
+ if (inExport.hasRefsInFile && (inExport.type === 'type' || inExport.type === 'interface'))
24
+ return true;
17
25
  }
18
26
  return false;
19
27
  };
@@ -17,13 +17,12 @@ export const loadPackageManifest = ({ dir, packageName, cwd }) => {
17
17
  export const getFilteredScripts = (scripts) => {
18
18
  if (!scripts)
19
19
  return [{}, {}];
20
- const scriptFilter = new Set(['start', 'postinstall']);
21
20
  const productionScripts = {};
22
21
  const developmentScripts = {};
23
22
  for (const scriptName in scripts) {
24
23
  if (!/^\w/.test(scriptName))
25
24
  continue;
26
- if (scriptFilter.has(scriptName))
25
+ if (scriptName === 'start')
27
26
  productionScripts[scriptName] = scripts[scriptName];
28
27
  else
29
28
  developmentScripts[scriptName] = scripts[scriptName];
@@ -3,7 +3,7 @@ const title = 'c8';
3
3
  const args = {
4
4
  args: (args) => args.filter(arg => arg !== 'check-coverage'),
5
5
  boolean: ['all', 'check-coverage', 'clean', 'exclude-after-remap', 'per-file', 'skip-full'],
6
- fromArgs: (parsed, args) => argsFrom(args, parsed._[0]),
6
+ fromArgs: (parsed, args) => (parsed._[0] ? argsFrom(args, parsed._[0]) : (parsed['--'] ?? [])),
7
7
  };
8
8
  const plugin = {
9
9
  title,
@@ -1,7 +1,7 @@
1
1
  import { argsFrom } from '../../binaries/util.js';
2
2
  const title = 'dotenv';
3
3
  const args = {
4
- fromArgs: (parsed, args) => argsFrom(args, parsed._[0]),
4
+ fromArgs: (parsed, args) => (parsed._[0] ? argsFrom(args, parsed._[0]) : (parsed['--'] ?? [])),
5
5
  };
6
6
  const plugin = {
7
7
  title,
@@ -0,0 +1,8 @@
1
+ import type { IsPluginEnabled } from '../../types/config.js';
2
+ declare const _default: {
3
+ title: string;
4
+ enablers: string[];
5
+ isEnabled: IsPluginEnabled;
6
+ config: string[];
7
+ };
8
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ const title = 'Expressive Code';
3
+ const enablers = [
4
+ 'astro-expressive-code',
5
+ 'rehype-expressive-code',
6
+ '@astrojs/starlight',
7
+ ];
8
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
9
+ const config = ['ec.config.{js,mjs,cjs,ts}'];
10
+ export default {
11
+ title,
12
+ enablers,
13
+ isEnabled,
14
+ config,
15
+ };
@@ -1,12 +1,10 @@
1
- import { hasFilesWithExtensions } from '../../util/fs.js';
1
+ import { hasFileWithExtension } from '../../util/fs.js';
2
2
  import { isDeferResolveEntry, toEntry } from '../../util/input.js';
3
3
  import { findByKeyDeep } from '../../util/object.js';
4
4
  import { join, relative } from '../../util/path.js';
5
5
  const title = 'GitHub Actions';
6
6
  const enablers = 'This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.';
7
- const isEnabled = ({ cwd }) => {
8
- return hasFilesWithExtensions(cwd, '.github/workflows', ['yml', 'yaml']);
9
- };
7
+ const isEnabled = ({ cwd }) => hasFileWithExtension(cwd, '.github/workflows', ['.yml', '.yaml']);
10
8
  const isRootOnly = true;
11
9
  const config = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];
12
10
  const isString = (value) => typeof value === 'string';
@@ -28,6 +28,12 @@ export declare const Plugins: {
28
28
  eleventy: import("../types/config.js").Plugin;
29
29
  eslint: import("../types/config.js").Plugin;
30
30
  expo: import("../types/config.js").Plugin;
31
+ 'expressive-code': {
32
+ title: string;
33
+ enablers: string[];
34
+ isEnabled: import("../types/config.js").IsPluginEnabled;
35
+ config: string[];
36
+ };
31
37
  gatsby: import("../types/config.js").Plugin;
32
38
  'github-action': import("../types/config.js").Plugin;
33
39
  'github-actions': import("../types/config.js").Plugin;
@@ -27,6 +27,7 @@ import { default as drizzle } from './drizzle/index.js';
27
27
  import { default as eleventy } from './eleventy/index.js';
28
28
  import { default as eslint } from './eslint/index.js';
29
29
  import { default as expo } from './expo/index.js';
30
+ import { default as expressiveCode } from './expressive-code/index.js';
30
31
  import { default as gatsby } from './gatsby/index.js';
31
32
  import { default as githubAction } from './github-action/index.js';
32
33
  import { default as githubActions } from './github-actions/index.js';
@@ -158,6 +159,7 @@ export const Plugins = {
158
159
  eleventy,
159
160
  eslint,
160
161
  expo,
162
+ 'expressive-code': expressiveCode,
161
163
  gatsby,
162
164
  'github-action': githubAction,
163
165
  'github-actions': githubActions,
@@ -71,7 +71,7 @@ const resolveConfig = async (localConfig, options) => {
71
71
  return compact([...executors, ...inputs, ...configInputs]).map(id => typeof id === 'string' ? toDependency(id) : id);
72
72
  };
73
73
  const args = {
74
- fromArgs: (parsed) => (parsed._[0] === 'exec' ? parsed._.slice(1) : []),
74
+ fromArgs: (parsed) => (parsed._[0] === 'exec' ? [...parsed._.slice(1), ...(parsed['--'] ?? [])] : []),
75
75
  };
76
76
  export const docs = {
77
77
  note: `Also see [integrated monorepos](/features/integrated-monorepos) and the note regarding internal workspace dependencies.`,
@@ -5,6 +5,8 @@ const enablers = ['simple-git-hooks'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['.simple-git-hooks.{js,cjs,json}', 'simple-git-hooks.{js,cjs,json}', 'package.json'];
7
7
  const resolveConfig = async (config, options) => {
8
+ if (options.isProduction)
9
+ return [];
8
10
  if (typeof config === 'function')
9
11
  config = config();
10
12
  if (!config)
@@ -1,2 +1,4 @@
1
1
  import ts from 'typescript';
2
+ import { type Input } from '../../util/input.js';
2
3
  export declare const getReactBabelPlugins: (sourceFile: ts.SourceFile) => string[];
4
+ export declare const getIndexHtmlEntries: (rootDir: string) => Promise<Input[]>;
@@ -1,5 +1,8 @@
1
1
  import ts from 'typescript';
2
2
  import { findDescendants, getDefaultImportName, getImportMap, stripQuotes } from '../../typescript/ast-helpers.js';
3
+ import { isFile, loadFile } from '../../util/fs.js';
4
+ import { toProductionEntry } from '../../util/input.js';
5
+ import { join } from '../../util/path.js';
3
6
  export const getReactBabelPlugins = (sourceFile) => {
4
7
  const babelPlugins = [];
5
8
  const importMap = getImportMap(sourceFile);
@@ -74,3 +77,23 @@ export const getReactBabelPlugins = (sourceFile) => {
74
77
  }
75
78
  return babelPlugins;
76
79
  };
80
+ const moduleScriptPattern = /<script\b(?=[^>]*\btype\s*=\s*["']?module["']?)(?=[^>]*\bsrc\s*=\s*["']?([^"' >]+)["']?)[^>]*>/gi;
81
+ const normalizeModuleScriptSrc = (value) => value.trim().replace(/^\//, '');
82
+ const getModuleScriptSources = (html) => {
83
+ const matches = html.matchAll(moduleScriptPattern);
84
+ const sources = [];
85
+ for (const match of matches) {
86
+ const src = normalizeModuleScriptSrc(match[1]);
87
+ if (src)
88
+ sources.push(src);
89
+ }
90
+ return sources;
91
+ };
92
+ export const getIndexHtmlEntries = async (rootDir) => {
93
+ const indexPath = join(rootDir, 'index.html');
94
+ if (!isFile(indexPath))
95
+ return [];
96
+ const html = await loadFile(indexPath);
97
+ const entries = getModuleScriptSources(html).map(src => join(rootDir, src));
98
+ return entries.map(entry => toProductionEntry(entry));
99
+ };
@@ -1,7 +1,7 @@
1
1
  import { toDependency } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
3
  import { resolveConfig } from '../vitest/index.js';
4
- import { getReactBabelPlugins } from './helpers.js';
4
+ import { getIndexHtmlEntries, getReactBabelPlugins } from './helpers.js';
5
5
  const title = 'Vite';
6
6
  const enablers = ['vite', 'vitest'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -10,6 +10,9 @@ const resolveFromAST = (sourceFile) => {
10
10
  const babelPlugins = getReactBabelPlugins(sourceFile);
11
11
  return babelPlugins.map(plugin => toDependency(plugin));
12
12
  };
13
+ const resolve = async (options) => {
14
+ return getIndexHtmlEntries(options.cwd);
15
+ };
13
16
  const args = {
14
17
  config: true,
15
18
  };
@@ -20,6 +23,7 @@ const plugin = {
20
23
  config,
21
24
  resolveConfig,
22
25
  resolveFromAST,
26
+ resolve,
23
27
  args,
24
28
  };
25
29
  export default plugin;
@@ -10,10 +10,8 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
10
10
  const config = ['vitest.config.{js,mjs,ts,cjs,mts,cts}', 'vitest.{workspace,projects}.{js,mjs,ts,cjs,mts,cts,json}'];
11
11
  const mocks = ['**/__mocks__/**/*.[jt]s?(x)'];
12
12
  const entry = ['**/*.{bench,test,test-d,spec}.?(c|m)[jt]s?(x)', ...mocks];
13
- const isVitestCoverageCommand = /vitest(.+)--coverage(?:\.enabled(?:=true)?)?/;
14
- const hasScriptWithCoverage = (scripts) => scripts ? Object.values(scripts).some(script => isVitestCoverageCommand.test(script)) : false;
15
- const findConfigDependencies = (localConfig, options) => {
16
- const { manifest, configFileDir: dir } = options;
13
+ const findConfigDependencies = (localConfig, options, vitestRoot) => {
14
+ const { configFileDir: dir } = options;
17
15
  const testConfig = localConfig.test;
18
16
  if (!testConfig)
19
17
  return [];
@@ -24,21 +22,23 @@ const findConfigDependencies = (localConfig, options) => {
24
22
  : [toDependency(getEnvSpecifier(env))]
25
23
  : [];
26
24
  const reporters = getExternalReporters(testConfig.reporters);
27
- const hasCoverageEnabled = (testConfig.coverage && testConfig.coverage.enabled !== false) || hasScriptWithCoverage(manifest.scripts);
25
+ const hasCoverageEnabled = testConfig.coverage && testConfig.coverage.enabled !== false;
28
26
  const coverage = hasCoverageEnabled ? [`@vitest/coverage-${testConfig.coverage?.provider ?? 'v8'}`] : [];
29
- const setupFiles = [testConfig.setupFiles ?? []].flat().map(specifier => ({ ...toDeferResolve(specifier), dir }));
27
+ const setupFiles = [testConfig.setupFiles ?? []]
28
+ .flat()
29
+ .map(specifier => ({ ...toDeferResolve(specifier), dir: vitestRoot }));
30
30
  const globalSetup = [testConfig.globalSetup ?? []].flat().map(specifier => ({ ...toDeferResolve(specifier), dir }));
31
31
  const workspaceDependencies = [];
32
32
  if (testConfig.workspace !== undefined) {
33
33
  for (const workspaceConfig of testConfig.workspace) {
34
- workspaceDependencies.push(...findConfigDependencies(workspaceConfig, options));
34
+ workspaceDependencies.push(...findConfigDependencies(workspaceConfig, options, vitestRoot));
35
35
  }
36
36
  }
37
37
  const projectsDependencies = [];
38
38
  if (testConfig.projects !== undefined) {
39
39
  for (const projectConfig of testConfig.projects) {
40
40
  if (typeof projectConfig !== 'string') {
41
- projectsDependencies.push(...findConfigDependencies(projectConfig, options));
41
+ projectsDependencies.push(...findConfigDependencies(projectConfig, options, vitestRoot));
42
42
  }
43
43
  }
44
44
  }
@@ -148,7 +148,7 @@ export const resolveConfig = async (localConfig, options) => {
148
148
  inputs.add(toEntry(`src/**/*${ext}`));
149
149
  }
150
150
  }
151
- for (const dependency of findConfigDependencies(cfg, options))
151
+ for (const dependency of findConfigDependencies(cfg, options, dir))
152
152
  inputs.add(dependency);
153
153
  const _entry = cfg.build?.lib?.entry ?? [];
154
154
  const deps = (typeof _entry === 'string' ? [_entry] : Object.values(_entry))
@@ -165,6 +165,21 @@ const args = {
165
165
  const inputs = [];
166
166
  if (parsed['ui'])
167
167
  inputs.push(toDependency('@vitest/ui', { optional: true }));
168
+ if (parsed['coverage']) {
169
+ const provider = typeof parsed['coverage'] === 'object' ? parsed['coverage'].provider : undefined;
170
+ inputs.push(toDependency(`@vitest/coverage-${provider ?? 'v8'}`));
171
+ }
172
+ if (parsed['reporter']) {
173
+ for (const reporter of getExternalReporters([parsed['reporter']].flat())) {
174
+ inputs.push(toDependency(reporter));
175
+ }
176
+ }
177
+ if (parsed['environment'] && parsed['environment'] !== 'node') {
178
+ inputs.push(toDependency(getEnvSpecifier(parsed['environment'])));
179
+ }
180
+ if (typeof parsed['typecheck'] === 'object' && parsed['typecheck'].checker) {
181
+ inputs.push(toDependency(parsed['typecheck'].checker === 'tsc' ? 'typescript' : parsed['typecheck'].checker));
182
+ }
168
183
  return inputs;
169
184
  },
170
185
  };
@@ -20,7 +20,9 @@ export default ({ report, issues, isShowProgress, cwd }) => {
20
20
  ? Array.from(issues[reportType])
21
21
  : reportType === 'duplicates'
22
22
  ? Object.values(issues[reportType]).flatMap(Object.values)
23
- : Object.values(issues[reportType]).map(issues => {
23
+ : Object.values(issues[reportType])
24
+ .filter(issues => Object.keys(issues).length > 0)
25
+ .map(issues => {
24
26
  const items = Object.values(issues);
25
27
  return { ...items[0], symbols: items };
26
28
  });
@@ -2,7 +2,7 @@ import codeclimate from './codeclimate.js';
2
2
  import codeowners from './codeowners.js';
3
3
  import compact from './compact.js';
4
4
  import disclosure from './disclosure.js';
5
- import githubActions from './githubActions.js';
5
+ import githubActions from './github-actions.js';
6
6
  import json from './json.js';
7
7
  import markdown from './markdown.js';
8
8
  import symbols from './symbols.js';
@@ -82,7 +82,7 @@ export const finalizeConfigurationHints = (results, options) => {
82
82
  else {
83
83
  const topWorkspaces = workspaces.sort((a, b) => b.size - a.size).filter(ws => ws.size > 1);
84
84
  for (const { dir, size } of topWorkspaces) {
85
- const identifier = toRelative(dir, options.cwd) || '.';
85
+ const identifier = toRelative(dir, options.cwd);
86
86
  results.configurationHints.push({
87
87
  type: 'workspace-unconfigured',
88
88
  workspaceName: identifier,
@@ -43,12 +43,14 @@ export const getTableForType = (issues, cwd, options = { isUseColors: true }) =>
43
43
  for (const issue of issues.sort(sortByPos)) {
44
44
  table.row();
45
45
  const print = options.isUseColors && (issue.isFixed || issue.severity === 'warn') ? dim : plain;
46
+ const isFileIssue = issue.type === 'files';
46
47
  const symbol = issue.symbols ? issue.symbols.map(s => s.symbol).join(', ') : issue.symbol;
47
- table.cell('symbol', print(symbol), options.isUseColors ? highlightSymbol(issue) : () => symbol);
48
+ if (!isFileIssue)
49
+ table.cell('symbol', print(symbol), options.isUseColors ? highlightSymbol(issue) : () => symbol);
48
50
  table.cell('parentSymbol', issue.parentSymbol && print(issue.parentSymbol));
49
51
  table.cell('symbolType', issue.symbolType && issue.symbolType !== SYMBOL_TYPE.UNKNOWN && print(issue.symbolType));
50
52
  const pos = issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`;
51
- const cell = issue.type === 'files' ? '' : `${relative(cwd, issue.filePath)}${pos}`;
53
+ const cell = isFileIssue ? relative(cwd, symbol) : `${relative(cwd, issue.filePath)}${pos}`;
52
54
  table.cell('filePath', print(cell));
53
55
  table.cell('fixed', issue.isFixed && print('(removed)'));
54
56
  }
@@ -147,6 +147,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
147
147
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
148
148
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
149
149
  }, z.core.$strip>]>>;
150
+ 'expressive-code': z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
151
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
152
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
153
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
154
+ }, z.core.$strip>]>>;
150
155
  gatsby: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
151
156
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
152
157
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -809,6 +814,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
809
814
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
810
815
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
811
816
  }, z.core.$strip>]>>;
817
+ 'expressive-code': z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
818
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
819
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
820
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
821
+ }, z.core.$strip>]>>;
812
822
  gatsby: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
813
823
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
814
824
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1460,6 +1470,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1460
1470
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1461
1471
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1462
1472
  }, z.core.$strip>]>>;
1473
+ 'expressive-code': z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1474
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1475
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1476
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1477
+ }, z.core.$strip>]>>;
1463
1478
  gatsby: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1464
1479
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1465
1480
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -151,6 +151,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
151
151
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
152
152
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
153
153
  }, z.core.$strip>]>;
154
+ 'expressive-code': z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
155
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
156
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
157
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
158
+ }, z.core.$strip>]>;
154
159
  gatsby: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
155
160
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
156
161
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -39,6 +39,7 @@ export const pluginsSchema = z.object({
39
39
  eleventy: pluginSchema,
40
40
  eslint: pluginSchema,
41
41
  expo: pluginSchema,
42
+ 'expressive-code': pluginSchema,
42
43
  gatsby: pluginSchema,
43
44
  'github-action': pluginSchema,
44
45
  'github-actions': pluginSchema,
@@ -1,2 +1,2 @@
1
- export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'parcel' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
- export declare const pluginNames: readonly ["angular", "astro", "astro-db", "astro-og-canvas", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "knex", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "nitro", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "parcel", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "sveltekit", "svgo", "svgr", "swc", "syncpack", "tailwind", "tanstack-router", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitepress", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
1
+ export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'expressive-code' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'parcel' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
+ export declare const pluginNames: readonly ["angular", "astro", "astro-db", "astro-og-canvas", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "expressive-code", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "knex", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "nitro", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "parcel", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "sveltekit", "svgo", "svgr", "swc", "syncpack", "tailwind", "tanstack-router", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitepress", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
@@ -28,6 +28,7 @@ export const pluginNames = [
28
28
  'eleventy',
29
29
  'eslint',
30
30
  'expo',
31
+ 'expressive-code',
31
32
  'gatsby',
32
33
  'github-action',
33
34
  'github-actions',
@@ -239,14 +239,19 @@ const getContainingExportDeclaration = (node) => {
239
239
  return node;
240
240
  return node.parent ? getContainingExportDeclaration(node.parent) : undefined;
241
241
  };
242
+ const isTypeExport = (node) => ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node);
242
243
  export const isReferencedInExport = (node) => {
243
244
  const parent = node.parent;
244
- if ((ts.isTypeQueryNode(parent) || ts.isTypeReferenceNode(parent)) && parent.parent) {
245
- const exportDecl = getContainingExportDeclaration(parent.parent);
246
- if (exportDecl)
247
- return exportDecl.name?.getText();
248
- }
249
- return undefined;
245
+ if (!parent?.parent)
246
+ return;
247
+ const isTypeQuery = ts.isTypeQueryNode(parent);
248
+ if (!isTypeQuery && !ts.isTypeReferenceNode(parent))
249
+ return;
250
+ const exportDecl = getContainingExportDeclaration(parent.parent);
251
+ if (!exportDecl)
252
+ return;
253
+ if (isTypeQuery || isTypeExport(exportDecl))
254
+ return exportDecl.name?.getText();
250
255
  };
251
256
  export const getExportKeywordNode = (node) => node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.ExportKeyword);
252
257
  export const getDefaultKeywordNode = (node) => node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.DefaultKeyword);
@@ -60,8 +60,8 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
60
60
  type: 'unlisted',
61
61
  filePath: containingFilePath,
62
62
  workspace: inputWorkspace.name,
63
- symbol: packageName ?? specifier,
64
- specifier,
63
+ symbol: packageName,
64
+ specifier: packageName,
65
65
  fixes: [],
66
66
  });
67
67
  }
@@ -92,7 +92,7 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
92
92
  filePath: containingFilePath,
93
93
  workspace: workspace.name,
94
94
  symbol: packageName ?? specifier,
95
- specifier,
95
+ specifier: packageName ?? specifier,
96
96
  fixes: [],
97
97
  });
98
98
  }
@@ -190,6 +190,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
190
190
  entry?: string | string[] | undefined;
191
191
  project?: string | string[] | undefined;
192
192
  } | undefined;
193
+ 'expressive-code'?: string | boolean | string[] | {
194
+ config?: string | string[] | undefined;
195
+ entry?: string | string[] | undefined;
196
+ project?: string | string[] | undefined;
197
+ } | undefined;
193
198
  gatsby?: string | boolean | string[] | {
194
199
  config?: string | string[] | undefined;
195
200
  entry?: string | string[] | undefined;
@@ -841,6 +846,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
841
846
  entry?: string | string[] | undefined;
842
847
  project?: string | string[] | undefined;
843
848
  } | undefined;
849
+ 'expressive-code'?: string | boolean | string[] | {
850
+ config?: string | string[] | undefined;
851
+ entry?: string | string[] | undefined;
852
+ project?: string | string[] | undefined;
853
+ } | undefined;
844
854
  gatsby?: string | boolean | string[] | {
845
855
  config?: string | string[] | undefined;
846
856
  entry?: string | string[] | undefined;
package/dist/util/fs.d.ts CHANGED
@@ -2,7 +2,7 @@ export declare const isDirectory: (cwdOrPath: string, name?: string) => boolean;
2
2
  export declare const isFile: (cwdOrPath: string, name?: string) => boolean;
3
3
  export declare const findFile: (cwd: string, fileName: string) => string | undefined;
4
4
  export declare const loadFile: (filePath: string) => Promise<string>;
5
- export declare const hasFilesWithExtensions: (cwd: string, dirName: string, extensions: string[]) => boolean;
5
+ export declare const hasFileWithExtension: (cwd: string, dirName: string, extensions: string[]) => boolean;
6
6
  export declare const loadJSON: (filePath: string) => Promise<any>;
7
7
  export declare const loadJSONC: (filePath: string) => Promise<any>;
8
8
  export declare const loadYAML: (filePath: string) => Promise<unknown>;
package/dist/util/fs.js CHANGED
@@ -34,19 +34,17 @@ export const loadFile = async (filePath) => {
34
34
  throw new LoaderError(`Error loading ${filePath}`, { cause: error });
35
35
  }
36
36
  };
37
- export const hasFilesWithExtensions = (cwd, dirName, extensions) => {
37
+ export const hasFileWithExtension = (cwd, dirName, extensions) => {
38
38
  if (!isDirectory(cwd, dirName))
39
39
  return false;
40
40
  try {
41
- const files = readdirSync(join(cwd, dirName));
42
- return files.some(file => {
43
- const ext = extname(file).slice(1);
44
- return extensions.includes(ext);
45
- });
46
- }
47
- catch {
48
- return false;
41
+ for (const file of readdirSync(join(cwd, dirName))) {
42
+ if (extensions.includes(extname(file)))
43
+ return true;
44
+ }
49
45
  }
46
+ catch { }
47
+ return false;
50
48
  };
51
49
  export const loadJSON = async (filePath) => {
52
50
  const contents = await loadFile(filePath);
@@ -3,7 +3,7 @@ import { promisify } from 'node:util';
3
3
  import { walk as _walk } from '@nodelib/fs.walk';
4
4
  import fg, {} from 'fast-glob';
5
5
  import picomatch from 'picomatch';
6
- import { GLOBAL_IGNORE_PATTERNS, ROOT_WORKSPACE_NAME } from '../constants.js';
6
+ import { GLOBAL_IGNORE_PATTERNS } from '../constants.js';
7
7
  import { compact, partition } from './array.js';
8
8
  import { debugLogObject } from './debug.js';
9
9
  import { isDirectory, isFile } from './fs.js';
@@ -174,7 +174,7 @@ export async function glob(_patterns, options) {
174
174
  const ignorePatterns = (cachedIgnores || _ignore).concat(negatedPatterns.map(pattern => pattern.slice(1)));
175
175
  const { dir, label, ...fgOptions } = { ...options, ignore: ignorePatterns };
176
176
  const paths = await fg.glob(patterns, fgOptions);
177
- debugLogObject(relative(options.cwd, dir) || ROOT_WORKSPACE_NAME, label ? `Finding ${label}` : 'Finding paths', () => ({
177
+ debugLogObject(relative(options.cwd, dir), label ? `Finding ${label}` : 'Finding paths', () => ({
178
178
  patterns,
179
179
  ...fgOptions,
180
180
  ignore: hasCache && ignorePatterns.length === (cachedIgnores || _ignore).length
@@ -27,7 +27,7 @@ const load = async (filePath) => {
27
27
  if (ext === '.jsonc' || ext === '.json5') {
28
28
  return await loadJSONC(filePath);
29
29
  }
30
- if (typeof Bun !== 'undefined') {
30
+ if ('Bun' in globalThis) {
31
31
  const imported = await import(filePath);
32
32
  return imported.default ?? imported;
33
33
  }
@@ -9,12 +9,13 @@ export const getPackageNameFromModuleSpecifier = (moduleSpecifier) => {
9
9
  };
10
10
  const lastPackageNameMatch = /(?<=node_modules\/)(@[^/]+\/[^/]+|[^/]+)/g;
11
11
  export const getPackageNameFromFilePath = (value) => {
12
- if (value.includes('node_modules/.bin/'))
13
- return extractBinary(value);
14
- const match = toPosix(value).match(lastPackageNameMatch);
12
+ const name = value.startsWith('file://') ? value.slice(7) : value;
13
+ if (name.includes('node_modules/.bin/'))
14
+ return extractBinary(name);
15
+ const match = toPosix(name).match(lastPackageNameMatch);
15
16
  if (match)
16
17
  return match[match.length - 1];
17
- return value;
18
+ return name;
18
19
  };
19
20
  export const getPackageNameFromSpecifier = (specifier) => isInNodeModules(specifier) ? getPackageNameFromFilePath(specifier) : getPackageNameFromModuleSpecifier(specifier);
20
21
  const matchPackageNameStart = /^(@[a-z0-9._]|[a-z0-9])/i;
@@ -48,24 +48,25 @@ export const save = async (filePath, content) => {
48
48
  export const getEntrySpecifiersFromManifest = (manifest) => {
49
49
  const { main, module, browser, bin, exports, types, typings } = manifest;
50
50
  const entryPaths = new Set();
51
- if (typeof main === 'string')
51
+ if (typeof main === 'string' && main)
52
52
  entryPaths.add(main);
53
- if (typeof module === 'string')
53
+ if (typeof module === 'string' && module)
54
54
  entryPaths.add(module);
55
- if (typeof browser === 'string')
55
+ if (typeof browser === 'string' && browser)
56
56
  entryPaths.add(browser);
57
- if (typeof bin === 'string')
57
+ if (typeof bin === 'string' && bin)
58
58
  entryPaths.add(bin);
59
59
  if (bin && typeof bin === 'object')
60
60
  for (const id of Object.values(bin))
61
- entryPaths.add(id);
62
- if (typeof types === 'string')
61
+ if (id)
62
+ entryPaths.add(id);
63
+ if (typeof types === 'string' && types)
63
64
  entryPaths.add(types);
64
- if (typeof typings === 'string')
65
+ if (typeof typings === 'string' && typings)
65
66
  entryPaths.add(typings);
66
67
  if (exports) {
67
68
  for (const item of getEntriesFromExports(exports)) {
68
- if (item === './*')
69
+ if (item === './*' || item.trim() === '')
69
70
  continue;
70
71
  const expanded = item
71
72
  .replace(/\/\*$/, '/**')
package/dist/util/path.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import path from 'node:path';
2
+ const isWin = process.platform === 'win32';
2
3
  export const isAbsolute = path.isAbsolute;
3
4
  export const dirname = path.posix.dirname;
4
5
  export const extname = path.posix.extname;
@@ -6,7 +7,17 @@ export const basename = path.posix.basename;
6
7
  export const join = path.posix.join;
7
8
  export const toPosix = (value) => value.split(path.sep).join(path.posix.sep);
8
9
  export const resolve = path.posix.resolve;
9
- export const relative = (from, to) => toPosix(path.relative(from, to));
10
+ export const relative = (from, to) => {
11
+ if (to.startsWith(from)) {
12
+ const next = to[from.length];
13
+ if (next === '/')
14
+ return to.substring(from.length + 1);
15
+ if (next === undefined)
16
+ return '.';
17
+ }
18
+ const result = path.relative(from, to);
19
+ return isWin ? toPosix(result) : result || '.';
20
+ };
10
21
  export const isInNodeModules = (filePath) => filePath.includes('node_modules');
11
22
  export const toAbsolute = (id, base) => (isAbsolute(id) ? id : join(base, id));
12
23
  export const toRelative = (id, base) => (isAbsolute(id) ? relative(base, id) : id);
@@ -1,6 +1,6 @@
1
1
  import type { WorkspacePackage } from '../types/package-json.js';
2
2
  type WorkspaceSelectorType = 'pkg-name' | 'dir-path' | 'dir-glob';
3
- export interface ParsedSelector {
3
+ interface ParsedSelector {
4
4
  type: WorkspaceSelectorType;
5
5
  pattern: string;
6
6
  isNegated: boolean;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.82.1";
1
+ export declare const version = "5.83.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.82.1';
1
+ export const version = '5.83.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.82.1",
3
+ "version": "5.83.1",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
package/schema.json CHANGED
@@ -453,6 +453,10 @@
453
453
  "title": "Expo plugin configuration (https://knip.dev/reference/plugins/expo)",
454
454
  "$ref": "#/definitions/plugin"
455
455
  },
456
+ "expressive-code": {
457
+ "title": "expressive-code plugin configuration (https://knip.dev/reference/plugins/expressive-code)",
458
+ "$ref": "#/definitions/plugin"
459
+ },
456
460
  "gatsby": {
457
461
  "title": "Gatsby plugin configuration (https://knip.dev/reference/plugins/gatsby)",
458
462
  "$ref": "#/definitions/plugin"