knip 6.0.0-1 → 6.0.0-2

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 (50) hide show
  1. package/dist/ConfigurationChief.d.ts +13 -0
  2. package/dist/ConfigurationChief.js +6 -3
  3. package/dist/DependencyDeputy.js +9 -2
  4. package/dist/IssueFixer.js +2 -1
  5. package/dist/WorkspaceWorker.js +5 -1
  6. package/dist/compilers/index.d.ts +20 -0
  7. package/dist/graph/build.js +2 -0
  8. package/dist/plugins/docusaurus/index.js +15 -0
  9. package/dist/plugins/docusaurus/types.d.ts +16 -0
  10. package/dist/plugins/eslint/helpers.d.ts +1 -0
  11. package/dist/plugins/eslint/helpers.js +2 -1
  12. package/dist/plugins/eslint/index.js +11 -2
  13. package/dist/plugins/eslint/resolveFromAST.d.ts +3 -0
  14. package/dist/plugins/eslint/resolveFromAST.js +43 -0
  15. package/dist/plugins/index.d.ts +2 -0
  16. package/dist/plugins/index.js +4 -0
  17. package/dist/plugins/next-mdx/resolveFromAST.js +18 -21
  18. package/dist/plugins/nuxt/index.js +6 -3
  19. package/dist/plugins/oxfmt/index.js +1 -1
  20. package/dist/plugins/raycast/index.d.ts +3 -0
  21. package/dist/plugins/raycast/index.js +25 -0
  22. package/dist/plugins/raycast/types.d.ts +10 -0
  23. package/dist/plugins/raycast/types.js +1 -0
  24. package/dist/plugins/sanity/index.d.ts +3 -0
  25. package/dist/plugins/sanity/index.js +12 -0
  26. package/dist/plugins/tsdown/index.js +8 -0
  27. package/dist/plugins/tsdown/resolveFromAST.d.ts +2 -0
  28. package/dist/plugins/tsdown/resolveFromAST.js +4 -0
  29. package/dist/plugins/tsup/index.js +8 -0
  30. package/dist/plugins/tsup/resolveFromAST.d.ts +2 -0
  31. package/dist/plugins/tsup/resolveFromAST.js +4 -0
  32. package/dist/plugins/vite/helpers.js +31 -34
  33. package/dist/reporters/json.js +21 -34
  34. package/dist/reporters/util/util.d.ts +1 -0
  35. package/dist/reporters/util/util.js +1 -0
  36. package/dist/schema/configuration.d.ts +30 -0
  37. package/dist/schema/plugins.d.ts +10 -0
  38. package/dist/schema/plugins.js +2 -0
  39. package/dist/types/PluginNames.d.ts +2 -2
  40. package/dist/types/PluginNames.js +2 -0
  41. package/dist/types/config.d.ts +1 -0
  42. package/dist/typescript/ast-helpers.js +19 -25
  43. package/dist/typescript/visitors/walk.js +27 -13
  44. package/dist/util/create-options.d.ts +20 -0
  45. package/dist/util/modules.d.ts +1 -1
  46. package/dist/util/modules.js +15 -4
  47. package/dist/version.d.ts +1 -1
  48. package/dist/version.js +1 -1
  49. package/package.json +1 -1
  50. package/schema.json +4 -0
@@ -37,6 +37,7 @@ export declare class ConfigurationChief {
37
37
  availableWorkspacePkgNames: Set<string>;
38
38
  availableWorkspaceDirs: string[];
39
39
  workspaceGraph: WorkspaceGraph;
40
+ private workspaceByFileCache;
40
41
  constructor(options: MainOptions);
41
42
  getConfigurationHints(): ConfigurationHint[];
42
43
  private normalize;
@@ -486,6 +487,11 @@ export declare class ConfigurationChief {
486
487
  entry?: string | string[] | undefined;
487
488
  project?: string | string[] | undefined;
488
489
  } | undefined;
490
+ raycast?: string | boolean | string[] | {
491
+ config?: string | string[] | undefined;
492
+ entry?: string | string[] | undefined;
493
+ project?: string | string[] | undefined;
494
+ } | undefined;
489
495
  'react-cosmos'?: string | boolean | string[] | {
490
496
  config?: string | string[] | undefined;
491
497
  entry?: string | string[] | undefined;
@@ -546,6 +552,11 @@ export declare class ConfigurationChief {
546
552
  entry?: string | string[] | undefined;
547
553
  project?: string | string[] | undefined;
548
554
  } | undefined;
555
+ sanity?: string | boolean | string[] | {
556
+ config?: string | string[] | undefined;
557
+ entry?: string | string[] | undefined;
558
+ project?: string | string[] | undefined;
559
+ } | undefined;
549
560
  'semantic-release'?: string | boolean | string[] | {
550
561
  config?: string | string[] | undefined;
551
562
  entry?: string | string[] | undefined;
@@ -856,6 +867,7 @@ export declare class ConfigurationChief {
856
867
  prettier?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
857
868
  prisma?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
858
869
  qwik?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
870
+ raycast?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
859
871
  "react-cosmos"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
860
872
  "react-native"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
861
873
  "react-router"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -868,6 +880,7 @@ export declare class ConfigurationChief {
868
880
  rslib?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
869
881
  rspack?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
870
882
  rstest?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
883
+ sanity?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
871
884
  "semantic-release"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
872
885
  sentry?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
873
886
  "simple-git-hooks"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -64,6 +64,7 @@ export class ConfigurationChief {
64
64
  availableWorkspacePkgNames = new Set();
65
65
  availableWorkspaceDirs = [];
66
66
  workspaceGraph = new Map();
67
+ workspaceByFileCache = new Map();
67
68
  constructor(options) {
68
69
  this.cwd = options.cwd;
69
70
  this.isProduction = options.isProduction;
@@ -344,10 +345,12 @@ export class ConfigurationChief {
344
345
  return { entry, project, paths, ignore, ignoreFiles, isIncludeEntryExports, ...plugins };
345
346
  }
346
347
  findWorkspaceByFilePath(filePath) {
348
+ if (this.workspaceByFileCache.has(filePath))
349
+ return this.workspaceByFileCache.get(filePath);
347
350
  const workspaceDir = this.availableWorkspaceDirs.find(workspaceDir => filePath.startsWith(`${workspaceDir}/`));
348
- if (!workspaceDir)
349
- return undefined;
350
- return this.workspacesByDir.get(workspaceDir);
351
+ const workspace = workspaceDir ? this.workspacesByDir.get(workspaceDir) : undefined;
352
+ this.workspaceByFileCache.set(filePath, workspace);
353
+ return workspace;
351
354
  }
352
355
  getUnusedIgnoredWorkspaces() {
353
356
  const ignoredWorkspaceNames = this.config.ignoreWorkspaces.map(removeProductionSuffix);
@@ -224,11 +224,13 @@ export class DependencyDeputy {
224
224
  const position = peeker.getLocation('dependencies', symbol);
225
225
  dependencyIssues.push({ type: 'dependencies', workspace, filePath, symbol, fixes: [], ...position });
226
226
  }
227
- for (const symbol of this.getDevDependencies(workspace).filter(isNotReferencedDependency)) {
227
+ const manifest = this._manifests.get(workspace);
228
+ for (const symbol of this.getDevDependencies(workspace)) {
229
+ if (!manifest.dependencies.includes(symbol) && !isNotReferencedDependency(symbol))
230
+ continue;
228
231
  const position = peeker.getLocation('devDependencies', symbol);
229
232
  devDependencyIssues.push({ type: 'devDependencies', filePath, workspace, symbol, fixes: [], ...position });
230
233
  }
231
- const manifest = this._manifests.get(workspace);
232
234
  for (const symbol of this.getOptionalPeerDependencies(workspace)) {
233
235
  if (!isReferencedDependency(symbol))
234
236
  continue;
@@ -256,6 +258,11 @@ export class DependencyDeputy {
256
258
  if (!packageName)
257
259
  continue;
258
260
  if (IGNORED_DEPENDENCIES.has(packageName)) {
261
+ if (type === 'devDependencies') {
262
+ const manifest = this.getWorkspaceManifest(issue.workspace);
263
+ if (manifest?.dependencies.includes(packageName))
264
+ continue;
265
+ }
259
266
  delete issueSet[issueKey];
260
267
  counters[type]--;
261
268
  }
@@ -12,10 +12,11 @@ export const fix = async (issues, counters, options) => {
12
12
  const group = issues[type];
13
13
  if (group instanceof Set)
14
14
  continue;
15
+ const counterType = (type === '_files' ? 'files' : type);
15
16
  for (const filePath in group)
16
17
  for (const key in group[filePath])
17
18
  if (group[filePath][key].isFixed)
18
- counters[type]--;
19
+ counters[counterType]--;
19
20
  }
20
21
  if (options.isFormat) {
21
22
  const report = await formatly(Array.from(touchedFiles));
@@ -171,9 +171,13 @@ export class WorkspaceWorker {
171
171
  }
172
172
  registerVisitors(options) {
173
173
  for (const pluginName of this.enabledPlugins) {
174
+ if (options.registeredPlugins.has(pluginName))
175
+ continue;
174
176
  const plugin = Plugins[pluginName];
175
- if (plugin.registerVisitors)
177
+ if (plugin.registerVisitors) {
178
+ options.registeredPlugins.add(pluginName);
176
179
  plugin.registerVisitors(options);
180
+ }
177
181
  }
178
182
  }
179
183
  async runPlugins() {
@@ -435,6 +435,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
435
435
  entry?: string | string[] | undefined;
436
436
  project?: string | string[] | undefined;
437
437
  } | undefined;
438
+ raycast?: string | boolean | string[] | {
439
+ config?: string | string[] | undefined;
440
+ entry?: string | string[] | undefined;
441
+ project?: string | string[] | undefined;
442
+ } | undefined;
438
443
  'react-cosmos'?: string | boolean | string[] | {
439
444
  config?: string | string[] | undefined;
440
445
  entry?: string | string[] | undefined;
@@ -495,6 +500,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
495
500
  entry?: string | string[] | undefined;
496
501
  project?: string | string[] | undefined;
497
502
  } | undefined;
503
+ sanity?: string | boolean | string[] | {
504
+ config?: string | string[] | undefined;
505
+ entry?: string | string[] | undefined;
506
+ project?: string | string[] | undefined;
507
+ } | undefined;
498
508
  'semantic-release'?: string | boolean | string[] | {
499
509
  config?: string | string[] | undefined;
500
510
  entry?: string | string[] | undefined;
@@ -1131,6 +1141,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1131
1141
  entry?: string | string[] | undefined;
1132
1142
  project?: string | string[] | undefined;
1133
1143
  } | undefined;
1144
+ raycast?: string | boolean | string[] | {
1145
+ config?: string | string[] | undefined;
1146
+ entry?: string | string[] | undefined;
1147
+ project?: string | string[] | undefined;
1148
+ } | undefined;
1134
1149
  'react-cosmos'?: string | boolean | string[] | {
1135
1150
  config?: string | string[] | undefined;
1136
1151
  entry?: string | string[] | undefined;
@@ -1191,6 +1206,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1191
1206
  entry?: string | string[] | undefined;
1192
1207
  project?: string | string[] | undefined;
1193
1208
  } | undefined;
1209
+ sanity?: string | boolean | string[] | {
1210
+ config?: string | string[] | undefined;
1211
+ entry?: string | string[] | undefined;
1212
+ project?: string | string[] | undefined;
1213
+ } | undefined;
1194
1214
  'semantic-release'?: string | boolean | string[] | {
1195
1215
  config?: string | string[] | undefined;
1196
1216
  entry?: string | string[] | undefined;
@@ -18,6 +18,7 @@ import { WorkspaceWorker } from "../WorkspaceWorker.js";
18
18
  export async function build({ chief, collector, counselor, deputy, principal, isGitIgnored, streamer, workspaces, options, }) {
19
19
  const configFilesMap = new Map();
20
20
  const enabledPluginsStore = new Map();
21
+ const registeredVisitorPlugins = new Set();
21
22
  const toSourceFilePaths = getToSourcePathsHandler(chief);
22
23
  const addIssue = (issue) => collector.addIssue(issue) && options.isWatch && collector.retainIssue(issue);
23
24
  const externalRefsFromInputs = options.isSession ? new Map() : undefined;
@@ -122,6 +123,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
122
123
  worker.registerVisitors({
123
124
  ctx: principal.pluginCtx,
124
125
  registerVisitor: visitors => principal.pluginVisitorObjects.push(visitors),
126
+ registeredPlugins: registeredVisitorPlugins,
125
127
  });
126
128
  const DEFAULT_GROUP = 'default';
127
129
  const createPatternMap = () => new Map([[DEFAULT_GROUP, new Set()]]);
@@ -1,4 +1,5 @@
1
1
  import { toAlias, toDependency, toEntry, toIgnore, toProductionEntry } from "../../util/input.js";
2
+ import { join } from "../../util/path.js";
2
3
  import { hasDependency } from "../../util/plugin.js";
3
4
  import { CORE_CLIENT_API, resolveConfigItems } from "./helpers.js";
4
5
  const title = 'Docusaurus';
@@ -7,22 +8,36 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
8
  const config = ['docusaurus.config.{js,mjs,ts}'];
8
9
  const production = ['src/pages/**/*.{js,ts,jsx,tsx}', '{blog,docs}/**/*.mdx', 'versioned_docs/**/*.{mdx,jsx,tsx}'];
9
10
  const entry = ['babel.config.{js,cjs,mjs,cts}'];
11
+ const resolveStaticAssets = (items, cwd) => {
12
+ const entries = [];
13
+ for (const item of items ?? []) {
14
+ const value = typeof item === 'string' ? item : (item.src ?? item.href);
15
+ if (typeof value === 'string' && !value.includes('://'))
16
+ entries.push(toProductionEntry(join(cwd, 'static', value)));
17
+ }
18
+ return entries;
19
+ };
10
20
  const resolveConfig = async (config, options) => {
11
21
  const themes = await resolveConfigItems(config.themes ?? [], 'theme', options);
12
22
  const plugins = await resolveConfigItems(config.plugins ?? [], 'plugin', options);
13
23
  const presets = await resolveConfigItems(config.presets ?? [], 'preset', options);
14
24
  const hasClassicTheme = options.manifest.dependencies?.['@docusaurus/theme-classic'] ||
15
25
  options.manifest.dependencies?.['@docusaurus/preset-classic'];
26
+ const scripts = resolveStaticAssets(config.scripts ?? [], options.cwd);
27
+ const stylesheets = resolveStaticAssets(config.stylesheets ?? [], options.cwd);
16
28
  return [
17
29
  toAlias('@site/*', './*'),
18
30
  toDependency('@docusaurus/module-type-aliases', { optional: true }),
19
31
  ...(hasClassicTheme ? [toIgnore('(@theme|@theme-init|@theme-original)/*', 'dependencies')] : []),
20
32
  toIgnore(`@docusaurus/(${CORE_CLIENT_API.join('|')})`, 'dependencies'),
33
+ ...(config.future?.experimental_faster ? [toDependency('@docusaurus/faster')] : []),
21
34
  ...production.map(id => toProductionEntry(id)),
22
35
  ...entry.map(id => toEntry(id)),
23
36
  ...themes,
24
37
  ...plugins,
25
38
  ...presets,
39
+ ...scripts,
40
+ ...stylesheets,
26
41
  ];
27
42
  };
28
43
  const plugin = {
@@ -30,11 +30,27 @@ type PluginConfig = string | [string, PluginOptions] | false | null | {
30
30
  type PresetConfig = string | [string, PresetOptions] | false | null;
31
31
  type Config = PresetConfig | PluginConfig;
32
32
  export type ConfigItem = Config | (() => Config);
33
+ type ScriptTag = {
34
+ src: string;
35
+ [key: string]: unknown;
36
+ };
37
+ type StylesheetLink = {
38
+ href: string;
39
+ [key: string]: unknown;
40
+ };
33
41
  export type DocusaurusConfig = {
34
42
  title: string;
35
43
  url: string;
36
44
  themes?: PluginConfig[];
37
45
  plugins?: PluginConfig[];
38
46
  presets: PresetConfig[];
47
+ scripts?: (string | ScriptTag)[];
48
+ stylesheets?: (string | StylesheetLink)[];
49
+ future?: {
50
+ experimental_faster?: boolean | {
51
+ [key: string]: unknown;
52
+ };
53
+ [key: string]: unknown;
54
+ };
39
55
  };
40
56
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { PluginOptions } from '../../types/config.ts';
2
2
  import { type ConfigInput, type Input } from '../../util/input.ts';
3
3
  import type { ESLintConfig, ESLintConfigDeprecated, OverrideConfigDeprecated } from './types.ts';
4
+ export declare const isFlatConfig: (fileName: string) => boolean;
4
5
  export declare const getInputs: (config: ESLintConfigDeprecated | OverrideConfigDeprecated | ESLintConfig, options: PluginOptions) => (Input | ConfigInput)[];
5
6
  export declare const resolveFormatters: (formatters: string | string[]) => Set<Input>;
@@ -3,9 +3,10 @@ import { toConfig, toDeferResolve, toDependency } from "../../util/input.js";
3
3
  import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier } from "../../util/modules.js";
4
4
  import { extname, isAbsolute, isInternal } from "../../util/path.js";
5
5
  import { getDependenciesFromConfig } from "../babel/index.js";
6
+ export const isFlatConfig = (fileName) => /eslint\.config/.test(fileName);
6
7
  export const getInputs = (config, options) => {
7
8
  const { configFileName } = options;
8
- if (extname(configFileName) === '.json' || !/eslint\.config/.test(configFileName)) {
9
+ if (extname(configFileName) === '.json' || !isFlatConfig(configFileName)) {
9
10
  return getInputsDeprecated(config, options);
10
11
  }
11
12
  const configArray = Array.isArray(config) ? config : [config];
@@ -1,6 +1,7 @@
1
1
  import { toDependency } from "../../util/input.js";
2
2
  import { hasDependency } from "../../util/plugin.js";
3
- import { getInputs, resolveFormatters } from "./helpers.js";
3
+ import { getInputs, isFlatConfig, resolveFormatters } from "./helpers.js";
4
+ import { getInputsFromFlatConfigAST } from "./resolveFromAST.js";
4
5
  const title = 'ESLint';
5
6
  const enablers = ['eslint', '@eslint/js'];
6
7
  const isEnabled = ({ dependencies, manifest }) => hasDependency(dependencies, enablers) ||
@@ -13,7 +14,9 @@ const config = [
13
14
  '.eslintrc.{yml,yaml}',
14
15
  'package.json',
15
16
  ];
16
- const isLoadConfig = ({ manifest }, dependencies) => {
17
+ const isLoadConfig = ({ configFileName, manifest }, dependencies) => {
18
+ if (isFlatConfig(configFileName))
19
+ return false;
17
20
  const version = manifest.devDependencies?.['eslint'] || manifest.dependencies?.['eslint'];
18
21
  if (version) {
19
22
  const major = version.match(/\d+/);
@@ -24,6 +27,11 @@ const isLoadConfig = ({ manifest }, dependencies) => {
24
27
  return true;
25
28
  };
26
29
  const resolveConfig = (localConfig, options) => getInputs(localConfig, options);
30
+ const resolveFromAST = (program, options) => {
31
+ if (isFlatConfig(options.configFileName))
32
+ return getInputsFromFlatConfigAST(program);
33
+ return [];
34
+ };
27
35
  const note = `### ESLint v9
28
36
 
29
37
  The ESLint plugin config resolver is disabled when using \`eslint-config-next\` (\`next lint\`).
@@ -65,5 +73,6 @@ const plugin = {
65
73
  args,
66
74
  isLoadConfig,
67
75
  resolveConfig,
76
+ resolveFromAST,
68
77
  };
69
78
  export default plugin;
@@ -0,0 +1,3 @@
1
+ import type { Program } from 'oxc-parser';
2
+ import { type Input } from '../../util/input.ts';
3
+ export declare const getInputsFromFlatConfigAST: (program: Program) => Input[];
@@ -0,0 +1,43 @@
1
+ import { Visitor } from 'oxc-parser';
2
+ import { toDeferResolve } from "../../util/input.js";
3
+ import { findProperty } from "../../typescript/ast-helpers.js";
4
+ import { isInternal } from "../../util/path.js";
5
+ export const getInputsFromFlatConfigAST = (program) => {
6
+ const inputs = [];
7
+ const visitor = new Visitor({
8
+ ObjectExpression(node) {
9
+ const settingsNode = findProperty(node, 'settings');
10
+ if (!settingsNode || settingsNode.type !== 'ObjectExpression')
11
+ return;
12
+ for (const prop of settingsNode.properties ?? []) {
13
+ if (prop.type !== 'Property')
14
+ continue;
15
+ const key = prop.key?.name ?? prop.key?.value;
16
+ if (key === 'import/resolver' || key === 'import/parsers') {
17
+ if (prop.value?.type === 'ObjectExpression') {
18
+ for (const p of prop.value.properties ?? []) {
19
+ if (p.type !== 'Property')
20
+ continue;
21
+ const resolver = p.key?.name ?? p.key?.value;
22
+ if (resolver && resolver !== 'node' && !isInternal(resolver)) {
23
+ const dep = key === 'import/resolver' ? `eslint-import-resolver-${resolver}` : resolver;
24
+ inputs.push(toDeferResolve(dep, { optional: true }));
25
+ }
26
+ }
27
+ }
28
+ else if (prop.value?.type === 'StringLiteral' ||
29
+ (prop.value?.type === 'Literal' && typeof prop.value.value === 'string')) {
30
+ const resolver = prop.value.value;
31
+ if (resolver && resolver !== 'node' && !isInternal(resolver)) {
32
+ const dep = key === 'import/resolver' ? `eslint-import-resolver-${resolver}` : resolver;
33
+ inputs.push(toDeferResolve(dep, { optional: true }));
34
+ }
35
+ }
36
+ }
37
+ }
38
+ },
39
+ });
40
+ visitor.visit(program);
41
+ inputs.push(toDeferResolve('eslint-import-resolver-typescript', { optional: true }));
42
+ return inputs;
43
+ };
@@ -90,6 +90,7 @@ export declare const Plugins: {
90
90
  prettier: import("../types/config.ts").Plugin;
91
91
  prisma: import("../types/config.ts").Plugin;
92
92
  qwik: import("../types/config.ts").Plugin;
93
+ raycast: import("../types/config.ts").Plugin;
93
94
  'react-cosmos': import("../types/config.ts").Plugin;
94
95
  'react-native': import("../types/config.ts").Plugin;
95
96
  'react-router': import("../types/config.ts").Plugin;
@@ -102,6 +103,7 @@ export declare const Plugins: {
102
103
  rslib: import("../types/config.ts").Plugin;
103
104
  rspack: import("../types/config.ts").Plugin;
104
105
  rstest: import("../types/config.ts").Plugin;
106
+ sanity: import("../types/config.ts").Plugin;
105
107
  'semantic-release': import("../types/config.ts").Plugin;
106
108
  sentry: import("../types/config.ts").Plugin;
107
109
  'simple-git-hooks': import("../types/config.ts").Plugin;
@@ -84,6 +84,7 @@ import { default as preconstruct } from "./preconstruct/index.js";
84
84
  import { default as prettier } from "./prettier/index.js";
85
85
  import { default as prisma } from "./prisma/index.js";
86
86
  import { default as qwik } from "./qwik/index.js";
87
+ import { default as raycast } from "./raycast/index.js";
87
88
  import { default as reactCosmos } from "./react-cosmos/index.js";
88
89
  import { default as reactNative } from "./react-native/index.js";
89
90
  import { default as reactRouter } from "./react-router/index.js";
@@ -96,6 +97,7 @@ import { default as rsbuild } from "./rsbuild/index.js";
96
97
  import { default as rslib } from "./rslib/index.js";
97
98
  import { default as rspack } from "./rspack/index.js";
98
99
  import { default as rstest } from "./rstest/index.js";
100
+ import { default as sanity } from "./sanity/index.js";
99
101
  import { default as semanticRelease } from "./semantic-release/index.js";
100
102
  import { default as sentry } from "./sentry/index.js";
101
103
  import { default as simpleGitHooks } from "./simple-git-hooks/index.js";
@@ -224,6 +226,7 @@ export const Plugins = {
224
226
  prettier,
225
227
  prisma,
226
228
  qwik,
229
+ raycast,
227
230
  'react-cosmos': reactCosmos,
228
231
  'react-native': reactNative,
229
232
  'react-router': reactRouter,
@@ -236,6 +239,7 @@ export const Plugins = {
236
239
  rslib,
237
240
  rspack,
238
241
  rstest,
242
+ sanity,
239
243
  'semantic-release': semanticRelease,
240
244
  sentry,
241
245
  'simple-git-hooks': simpleGitHooks,
@@ -2,26 +2,23 @@ import { Visitor } from 'oxc-parser';
2
2
  import { findProperty, getDefaultImportName, getImportMap, getStringValues } from "../../typescript/ast-helpers.js";
3
3
  export const getMdxPlugins = (program) => {
4
4
  const plugins = new Set();
5
- try {
6
- const importMap = getImportMap(program);
7
- const mdxImportName = getDefaultImportName(importMap, '@next/mdx');
8
- if (!mdxImportName)
9
- return plugins;
10
- const visitor = new Visitor({
11
- CallExpression(node) {
12
- if (node.callee?.type !== 'Identifier' || node.callee.name !== mdxImportName)
13
- return;
14
- const options = findProperty(node.arguments?.[0], 'options');
15
- if (options?.type !== 'ObjectExpression')
16
- return;
17
- for (const pluginType of ['remarkPlugins', 'rehypePlugins', 'recmaPlugins']) {
18
- for (const v of getStringValues(findProperty(options, pluginType)))
19
- plugins.add(v);
20
- }
21
- },
22
- });
23
- visitor.visit(program);
24
- }
25
- catch { }
5
+ const importMap = getImportMap(program);
6
+ const mdxImportName = getDefaultImportName(importMap, '@next/mdx');
7
+ if (!mdxImportName)
8
+ return plugins;
9
+ const visitor = new Visitor({
10
+ CallExpression(node) {
11
+ if (node.callee?.type !== 'Identifier' || node.callee.name !== mdxImportName)
12
+ return;
13
+ const options = findProperty(node.arguments?.[0], 'options');
14
+ if (options?.type !== 'ObjectExpression')
15
+ return;
16
+ for (const pluginType of ['remarkPlugins', 'rehypePlugins', 'recmaPlugins']) {
17
+ for (const v of getStringValues(findProperty(options, pluginType)))
18
+ plugins.add(v);
19
+ }
20
+ },
21
+ });
22
+ visitor.visit(program);
26
23
  return plugins;
27
24
  };
@@ -163,9 +163,12 @@ const resolveConfig = async (localConfig, options) => {
163
163
  }
164
164
  for (const ext of localConfig.extends ?? []) {
165
165
  const resolved = resolveAlias(ext, srcDir, cwd);
166
- for (const cfg of _syncGlob({ cwd: resolved, patterns: config })) {
167
- inputs.push(toConfig('nuxt', join(resolved, cfg)));
168
- }
166
+ const configs = _syncGlob({ cwd: resolved, patterns: config });
167
+ if (configs.length > 0)
168
+ for (const cfg of configs)
169
+ inputs.push(toConfig('nuxt', join(resolved, cfg)));
170
+ else
171
+ inputs.push(toDependency(ext));
169
172
  }
170
173
  for (const layerConfig of findLayerConfigs(cwd)) {
171
174
  inputs.push(toConfig('nuxt', layerConfig));
@@ -2,7 +2,7 @@ import { hasDependency } from "../../util/plugin.js";
2
2
  const title = 'Oxfmt';
3
3
  const enablers = ['oxfmt'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const config = ['.oxfmtrc.json', '.oxfmtrc.jsonc'];
5
+ const config = ['.oxfmtrc.json', '.oxfmtrc.jsonc', 'oxfmt.config.ts'];
6
6
  const args = {
7
7
  config: true,
8
8
  };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,25 @@
1
+ import { compact } from "../../util/array.js";
2
+ import { toProductionEntry } from "../../util/input.js";
3
+ import { hasDependency } from "../../util/plugin.js";
4
+ const title = 'Raycast';
5
+ const enablers = ['@raycast/api'];
6
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
+ const config = ['package.json'];
8
+ const packageJsonPath = (manifest) => manifest;
9
+ const mapEntries = (items, directory) => {
10
+ const names = compact((items ?? []).map(item => (typeof item.name === 'string' ? item.name : undefined)));
11
+ return names.map(name => toProductionEntry(`${directory}${name}.{js,jsx,ts,tsx}`));
12
+ };
13
+ const resolveConfig = async (manifest) => [
14
+ ...mapEntries(manifest.commands, 'src/'),
15
+ ...mapEntries(manifest.tools, 'src/tools/'),
16
+ ];
17
+ const plugin = {
18
+ title,
19
+ enablers,
20
+ isEnabled,
21
+ config,
22
+ packageJsonPath,
23
+ resolveConfig,
24
+ };
25
+ export default plugin;
@@ -0,0 +1,10 @@
1
+ export type RaycastManifestCommand = {
2
+ name?: unknown;
3
+ };
4
+ export type RaycastManifestTool = {
5
+ name?: unknown;
6
+ };
7
+ export type RaycastManifest = {
8
+ commands?: RaycastManifestCommand[];
9
+ tools?: RaycastManifestTool[];
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,12 @@
1
+ import { hasDependency } from "../../util/plugin.js";
2
+ const title = 'Sanity';
3
+ const enablers = ['sanity'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const entry = ['sanity.config.{js,jsx,ts,tsx}', 'sanity.cli.{ts,js}', 'sanity.blueprint.{ts,js,json}'];
6
+ const plugin = {
7
+ title,
8
+ enablers,
9
+ isEnabled,
10
+ entry,
11
+ };
12
+ export default plugin;
@@ -1,9 +1,11 @@
1
1
  import { toProductionEntry } from "../../util/input.js";
2
2
  import { hasDependency } from "../../util/plugin.js";
3
+ import { getEntryFromAST } from "./resolveFromAST.js";
3
4
  const title = 'tsdown';
4
5
  const enablers = ['tsdown'];
5
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
7
  const config = ['tsdown.config.{ts,mts,cts,js,mjs,cjs,json}', 'package.json'];
8
+ const isLoadConfig = ({ configFileName }) => configFileName === 'package.json' || configFileName.endsWith('.json');
7
9
  const normalizeEntry = (entry) => {
8
10
  if (!entry)
9
11
  return [];
@@ -24,6 +26,10 @@ const resolveConfig = async (config) => {
24
26
  .map(id => toProductionEntry(id, { allowIncludeExports: true }));
25
27
  return entryPatterns;
26
28
  };
29
+ const resolveFromAST = program => {
30
+ const entries = getEntryFromAST(program);
31
+ return [...entries].map(id => toProductionEntry(id, { allowIncludeExports: true }));
32
+ };
27
33
  const args = {
28
34
  config: true,
29
35
  };
@@ -32,7 +38,9 @@ const plugin = {
32
38
  enablers,
33
39
  isEnabled,
34
40
  config,
41
+ isLoadConfig,
35
42
  resolveConfig,
43
+ resolveFromAST,
36
44
  args,
37
45
  };
38
46
  export default plugin;
@@ -0,0 +1,2 @@
1
+ import type { Program } from 'oxc-parser';
2
+ export declare const getEntryFromAST: (program: Program) => Set<string>;
@@ -0,0 +1,4 @@
1
+ import { collectPropertyValues } from "../../typescript/ast-helpers.js";
2
+ export const getEntryFromAST = (program) => {
3
+ return collectPropertyValues(program, 'entry');
4
+ };
@@ -1,9 +1,11 @@
1
1
  import { toProductionEntry } from "../../util/input.js";
2
2
  import { hasDependency } from "../../util/plugin.js";
3
+ import { getEntryFromAST } from "./resolveFromAST.js";
3
4
  const title = 'tsup';
4
5
  const enablers = ['tsup'];
5
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
7
  const config = ['tsup.config.{js,ts,cjs,mjs,json}', 'package.json'];
8
+ const isLoadConfig = ({ configFileName }) => configFileName === 'package.json' || configFileName.endsWith('.json');
7
9
  const resolveConfig = async (config) => {
8
10
  if (typeof config === 'function')
9
11
  config = await config({});
@@ -19,6 +21,10 @@ const resolveConfig = async (config) => {
19
21
  .map(id => toProductionEntry(id, { allowIncludeExports: true }));
20
22
  return entryPatterns;
21
23
  };
24
+ const resolveFromAST = program => {
25
+ const entries = getEntryFromAST(program);
26
+ return [...entries].map(id => toProductionEntry(id, { allowIncludeExports: true }));
27
+ };
22
28
  const args = {
23
29
  config: true,
24
30
  };
@@ -27,7 +33,9 @@ const plugin = {
27
33
  enablers,
28
34
  isEnabled,
29
35
  config,
36
+ isLoadConfig,
30
37
  resolveConfig,
38
+ resolveFromAST,
31
39
  args,
32
40
  };
33
41
  export default plugin;
@@ -0,0 +1,2 @@
1
+ import type { Program } from 'oxc-parser';
2
+ export declare const getEntryFromAST: (program: Program) => Set<string>;