knip 5.50.5 → 5.51.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 (66) hide show
  1. package/README.md +1 -1
  2. package/dist/ConfigurationChief.d.ts +4 -1
  3. package/dist/ConfigurationChief.js +3 -0
  4. package/dist/binaries/package-manager/bun.js +2 -0
  5. package/dist/cli.js +3 -3
  6. package/dist/compilers/astro.js +5 -1
  7. package/dist/compilers/compilers.js +1 -1
  8. package/dist/compilers/index.d.ts +44 -13
  9. package/dist/compilers/index.js +9 -6
  10. package/dist/compilers/types.d.ts +1 -0
  11. package/dist/graph/build.js +8 -4
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +9 -1
  14. package/dist/plugins/bun/index.d.ts +11 -0
  15. package/dist/plugins/bun/index.js +28 -0
  16. package/dist/plugins/eslint/index.js +1 -2
  17. package/dist/plugins/index.d.ts +37 -10
  18. package/dist/plugins/index.js +8 -2
  19. package/dist/plugins/lint-staged/index.d.ts +0 -1
  20. package/dist/plugins/lint-staged/index.js +0 -2
  21. package/dist/plugins/nano-staged/index.d.ts +10 -0
  22. package/dist/plugins/nano-staged/index.js +33 -0
  23. package/dist/plugins/nano-staged/types.d.ts +7 -0
  24. package/dist/plugins/next/index.js +2 -1
  25. package/dist/plugins/oxlint/index.d.ts +12 -0
  26. package/dist/plugins/oxlint/index.js +16 -0
  27. package/dist/plugins/preconstruct/index.js +2 -2
  28. package/dist/plugins/prettier/index.js +1 -1
  29. package/dist/plugins/relay/index.d.ts +15 -0
  30. package/dist/plugins/relay/index.js +31 -0
  31. package/dist/plugins/relay/types.d.ts +12 -0
  32. package/dist/plugins/relay/types.js +1 -0
  33. package/dist/plugins/tsup/index.js +1 -1
  34. package/dist/plugins/xo/index.js +1 -1
  35. package/dist/schema/configuration.d.ts +241 -70
  36. package/dist/schema/configuration.js +2 -1
  37. package/dist/schema/plugins.d.ts +92 -23
  38. package/dist/schema/plugins.js +4 -1
  39. package/dist/types/PluginNames.d.ts +2 -2
  40. package/dist/types/PluginNames.js +4 -1
  41. package/dist/types/config.d.ts +1 -0
  42. package/dist/typescript/ast-helpers.d.ts +16 -3
  43. package/dist/typescript/ast-helpers.js +21 -15
  44. package/dist/typescript/visitors/dynamic-imports/importCall.js +47 -53
  45. package/dist/typescript/visitors/exports/exportAssignment.js +17 -2
  46. package/dist/typescript/visitors/exports/exportKeyword.js +3 -22
  47. package/dist/util/cli-arguments.d.ts +1 -1
  48. package/dist/util/cli-arguments.js +1 -1
  49. package/dist/util/codeowners.js +1 -1
  50. package/dist/util/glob-core.d.ts +0 -8
  51. package/dist/util/glob-core.js +16 -49
  52. package/dist/util/input.d.ts +3 -1
  53. package/dist/util/parse-and-convert-gitignores.d.ts +8 -0
  54. package/dist/util/parse-and-convert-gitignores.js +40 -0
  55. package/dist/util/to-source-path.d.ts +1 -1
  56. package/dist/util/to-source-path.js +2 -2
  57. package/dist/version.d.ts +1 -1
  58. package/dist/version.js +1 -1
  59. package/package.json +4 -3
  60. package/schema.json +20 -4
  61. package/dist/plugins/tanstack-router/index.d.ts +0 -12
  62. package/dist/plugins/tanstack-router/index.js +0 -46
  63. package/dist/plugins/tanstack-router/resolveFromAST.d.ts +0 -2
  64. package/dist/plugins/tanstack-router/resolveFromAST.js +0 -28
  65. package/dist/plugins/tanstack-router/types.d.ts +0 -7
  66. /package/dist/plugins/{tanstack-router → nano-staged}/types.js +0 -0
@@ -0,0 +1,33 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ const title = 'Nano Staged';
3
+ const enablers = ['nano-staged'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const config = [
6
+ 'package.json',
7
+ '.nano-staged.{js,cjs,mjs,json}',
8
+ 'nano-staged.{js,cjs,mjs,json}',
9
+ '.nanostagedrc',
10
+ ];
11
+ const resolveConfig = async (config, options) => {
12
+ if (options.isProduction)
13
+ return [];
14
+ if (typeof config === 'function')
15
+ config = config();
16
+ if (!config)
17
+ return [];
18
+ const inputs = new Set();
19
+ for (const entry of Object.values(config).flat()) {
20
+ const api = { filenames: ['./example.js'] };
21
+ const scripts = [typeof entry === 'function' ? await entry(api) : entry].flat();
22
+ for (const id of options.getInputsFromScripts(scripts))
23
+ inputs.add(id);
24
+ }
25
+ return Array.from(inputs);
26
+ };
27
+ export default {
28
+ title,
29
+ enablers,
30
+ isEnabled,
31
+ config,
32
+ resolveConfig,
33
+ };
@@ -0,0 +1,7 @@
1
+ type Script = string | string[];
2
+ type Entry = Script | ((api: {
3
+ filenames: string[];
4
+ }) => Script | Promise<Script>);
5
+ type Config = Record<string, Entry>;
6
+ export type NanoStagedConfig = Config | (() => Config);
7
+ export {};
@@ -7,13 +7,14 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['next.config.{js,ts,cjs,mjs}'];
8
8
  const defaultPageExtensions = ['{js,jsx,ts,tsx}'];
9
9
  const productionEntryFilePatterns = [
10
- '{instrumentation,middleware}.{js,ts}',
10
+ '{instrumentation,instrumentation-client,middleware}.{js,ts}',
11
11
  'app/global-error.{js,jsx,ts,tsx}',
12
12
  'app/**/{error,layout,loading,not-found,page,template,default}.{js,jsx,ts,tsx}',
13
13
  'app/**/route.{js,jsx,ts,tsx}',
14
14
  'app/{manifest,sitemap,robots}.{js,ts}',
15
15
  'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
16
16
  'app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
17
+ 'mdx-components.{js,jsx,ts,tsx}',
17
18
  ];
18
19
  const getEntryFilePatterns = (pageExtensions = defaultPageExtensions) => {
19
20
  const pages = pageExtensions.map(ext => `pages/**/*.${ext}`);
@@ -0,0 +1,12 @@
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
+ args: {
8
+ binaries: string[];
9
+ config: boolean;
10
+ };
11
+ };
12
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ const title = 'Oxlint';
3
+ const enablers = ['oxlint'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const config = ['.oxlintrc.json'];
6
+ const args = {
7
+ binaries: ['oxlint'],
8
+ config: true,
9
+ };
10
+ export default {
11
+ title,
12
+ enablers,
13
+ isEnabled,
14
+ config,
15
+ args,
16
+ };
@@ -1,11 +1,11 @@
1
- import { toEntry } from '../../util/input.js';
1
+ import { toProductionEntry } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'Preconstruct';
4
4
  const enablers = ['@preconstruct/cli'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['package.json'];
7
7
  const resolveEntryPaths = async (config) => {
8
- return (config.entrypoints ?? []).map(id => toEntry(id));
8
+ return (config.entrypoints ?? []).map(id => toProductionEntry(id, { allowIncludeExports: true }));
9
9
  };
10
10
  export default {
11
11
  title,
@@ -2,7 +2,7 @@ import { toDeferResolve, toDependency } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'Prettier';
4
4
  const enablers = ['prettier'];
5
- const isEnabled = ({ dependencies, config }) => hasDependency(dependencies, enablers) || 'prettier' in config;
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = [
7
7
  '.prettierrc',
8
8
  '.prettierrc.{json,js,cjs,mjs,yml,yaml,toml,json5}',
@@ -0,0 +1,15 @@
1
+ import type { IsPluginEnabled, ResolveEntryPaths } from '../../types/config.js';
2
+ import type { RelayConfig } from './types.js';
3
+ declare const _default: {
4
+ title: string;
5
+ enablers: string[];
6
+ isEnabled: IsPluginEnabled;
7
+ config: string[];
8
+ resolveEntryPaths: ResolveEntryPaths<RelayConfig>;
9
+ args: {
10
+ binaries: string[];
11
+ args: (args: string[]) => string[];
12
+ config: boolean;
13
+ };
14
+ };
15
+ export default _default;
@@ -0,0 +1,31 @@
1
+ import parseArgs from 'minimist';
2
+ import { toProductionEntry } from '../../util/input.js';
3
+ import { join } from '../../util/path.js';
4
+ import { hasDependency } from '../../util/plugin.js';
5
+ const title = 'Relay';
6
+ const enablers = ['vite-plugin-relay', '@swc/plugin-relay', 'babel-plugin-relay'];
7
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
+ const config = ['relay.config.json', 'relay.config.js'];
9
+ const resolveEntryPaths = async (config) => {
10
+ const projects = 'projects' in config ? Object.values(config.projects) : [config];
11
+ return projects.map(project => {
12
+ const artifactDirectory = project.artifactDirectory;
13
+ if (artifactDirectory == null) {
14
+ return toProductionEntry('**/__generated__/*');
15
+ }
16
+ return toProductionEntry(join(artifactDirectory, '**'));
17
+ });
18
+ };
19
+ const args = {
20
+ binaries: ['relay-compiler'],
21
+ args: (args) => ['-c', parseArgs(args)._[0]],
22
+ config: true,
23
+ };
24
+ export default {
25
+ title,
26
+ enablers,
27
+ isEnabled,
28
+ config,
29
+ resolveEntryPaths,
30
+ args,
31
+ };
@@ -0,0 +1,12 @@
1
+ type RelayProject = {
2
+ artifactDirectory?: string;
3
+ requireCustomScalarTypes?: boolean;
4
+ customScalarTypes?: Record<string, string | {
5
+ name: string;
6
+ path: string;
7
+ }>;
8
+ };
9
+ export type RelayConfig = RelayProject | {
10
+ projects: Record<string, RelayProject>;
11
+ };
12
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -16,7 +16,7 @@ const resolveConfig = async (config) => {
16
16
  return config.entry;
17
17
  return Object.values(config.entry);
18
18
  })
19
- .map(id => toProductionEntry(id));
19
+ .map(id => toProductionEntry(id, { allowIncludeExports: true }));
20
20
  return entryPatterns;
21
21
  };
22
22
  const args = {
@@ -2,7 +2,7 @@ import { hasDependency } from '../../util/plugin.js';
2
2
  import { getInputs } from '../eslint/helpers.js';
3
3
  const title = 'xo';
4
4
  const enablers = ['xo'];
5
- const isEnabled = ({ dependencies, config }) => hasDependency(dependencies, enablers) || 'xo' in config;
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['package.json', '.xo-config', '.xo-config.{js,cjs,json}', 'xo.config.{js,cjs}'];
7
7
  const entry = ['.xo-config.{js,cjs}', 'xo.config.{js,cjs}'];
8
8
  const resolveConfig = async (config, options) => {