knip 4.0.3 → 4.1.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.
@@ -1,5 +1,5 @@
1
1
  import { isBuiltin } from 'node:module';
2
- import { IGNORE_DEFINITELY_TYPED, IGNORED_DEPENDENCIES, IGNORED_GLOBAL_BINARIES, ROOT_WORKSPACE_NAME, } from './constants.js';
2
+ import { IGNORE_DEFINITELY_TYPED, IGNORED_DEPENDENCIES, IGNORED_GLOBAL_BINARIES, IGNORED_RUNTIME_DEPENDENCIES, ROOT_WORKSPACE_NAME, } from './constants.js';
3
3
  import { isDefinitelyTyped, getDefinitelyTypedFor, getPackageFromDefinitelyTyped } from './util/modules.js';
4
4
  import { hasMatch, hasMatchInArray, hasMatchInSet, toRegexOrString, findKey } from './util/regex.js';
5
5
  export class DependencyDeputy {
@@ -111,6 +111,8 @@ export class DependencyDeputy {
111
111
  maybeAddReferencedExternalDependency(workspace, packageName) {
112
112
  if (isBuiltin(packageName))
113
113
  return true;
114
+ if (IGNORED_RUNTIME_DEPENDENCIES.has(packageName))
115
+ return true;
114
116
  if (packageName === workspace.pkgName)
115
117
  return true;
116
118
  const workspaceNames = this.isStrict ? [workspace.name] : [workspace.name, ...[...workspace.ancestors].reverse()];
@@ -132,7 +134,7 @@ export class DependencyDeputy {
132
134
  return false;
133
135
  }
134
136
  maybeAddReferencedBinary(workspace, binaryName) {
135
- if (IGNORED_GLOBAL_BINARIES.includes(binaryName))
137
+ if (IGNORED_GLOBAL_BINARIES.has(binaryName))
136
138
  return true;
137
139
  this.addReferencedBinary(workspace.name, binaryName);
138
140
  const workspaceNames = this.isStrict ? [workspace.name] : [workspace.name, ...[...workspace.ancestors].reverse()];
@@ -269,7 +271,7 @@ export class DependencyDeputy {
269
271
  const peerDependencies = this.getPeerDependencies(workspaceName);
270
272
  ignoreDependencies
271
273
  .filter(packageName => {
272
- if (hasMatchInArray(IGNORED_DEPENDENCIES, packageName))
274
+ if (hasMatchInSet(IGNORED_DEPENDENCIES, packageName))
273
275
  return true;
274
276
  if (this.ignoreDependencies.includes(packageName))
275
277
  return true;
@@ -282,7 +284,7 @@ export class DependencyDeputy {
282
284
  });
283
285
  ignoreBinaries
284
286
  .filter(binaryName => {
285
- if (hasMatchInArray(IGNORED_GLOBAL_BINARIES, binaryName))
287
+ if (hasMatchInSet(IGNORED_GLOBAL_BINARIES, binaryName))
286
288
  return true;
287
289
  if (this.ignoreBinaries.includes(binaryName))
288
290
  return true;
@@ -300,7 +302,7 @@ export class DependencyDeputy {
300
302
  const peerDependencies = this.getPeerDependencies(ROOT_WORKSPACE_NAME);
301
303
  Array.from(rootIgnoreDependencies.keys())
302
304
  .filter(packageName => {
303
- if (hasMatchInArray(IGNORED_DEPENDENCIES, packageName))
305
+ if (hasMatchInSet(IGNORED_DEPENDENCIES, packageName))
304
306
  return true;
305
307
  const isReferenced = rootIgnoreDependencies.get(packageName) !== 0;
306
308
  const isListed = hasMatchInArray(dependencies, packageName) && !hasMatchInArray(peerDependencies, packageName);
@@ -309,7 +311,7 @@ export class DependencyDeputy {
309
311
  .forEach(identifier => configurationHints.add({ workspaceName: ROOT_WORKSPACE_NAME, identifier, type: 'ignoreDependencies' }));
310
312
  Array.from(rootIgnoreBinaries.keys())
311
313
  .filter(binaryName => {
312
- if (hasMatchInArray(IGNORED_GLOBAL_BINARIES, binaryName))
314
+ if (hasMatchInSet(IGNORED_GLOBAL_BINARIES, binaryName))
313
315
  return true;
314
316
  const isReferenced = rootIgnoreBinaries.get(binaryName) !== 0;
315
317
  const isInstalled = hasMatchInArray(Array.from(installedBinaries?.keys() ?? []), binaryName);
@@ -19,7 +19,7 @@ export const getBinariesFromScript = (script, { cwd, manifest, knownGlobalsOnly
19
19
  return [];
20
20
  if (binary.startsWith('-') || binary.startsWith('"') || binary.startsWith('..'))
21
21
  return [];
22
- if (['bun', 'deno'].includes(binary))
22
+ if (['deno'].includes(binary))
23
23
  return [];
24
24
  const args = node.suffix?.map(arg => arg.text) ?? [];
25
25
  if (['!', 'test'].includes(binary))
@@ -0,0 +1,2 @@
1
+ import type { Resolver } from '../types.js';
2
+ export declare const resolve: Resolver;
@@ -0,0 +1,17 @@
1
+ import parseArgs from 'minimist';
2
+ import { tryResolveFilePath } from '../util.js';
3
+ const commands = ['add', 'create', 'init', 'install', 'link', 'pm', 'remove', 'run', 'update'];
4
+ export const resolve = (_binary, args, { manifest, cwd, fromArgs }) => {
5
+ const scripts = manifest.scripts ? Object.keys(manifest.scripts) : [];
6
+ const parsed = parseArgs(args);
7
+ const [command, script] = parsed._;
8
+ if (command === 'run' && scripts.includes(script))
9
+ return [];
10
+ if (commands.includes(command))
11
+ return [];
12
+ const filePath = command === 'run' ? script : command;
13
+ const specifier = tryResolveFilePath(cwd, filePath);
14
+ if (specifier)
15
+ return [specifier];
16
+ return fromArgs(args);
17
+ };
@@ -1,3 +1,4 @@
1
+ export * as bun from './bun.js';
1
2
  export * as c8 from './c8.js';
2
3
  export * as dotenv from './dotenv.js';
3
4
  export * as node from './node.js';
@@ -1,3 +1,4 @@
1
+ export * as bun from './bun.js';
1
2
  export * as c8 from './c8.js';
2
3
  export * as dotenv from './dotenv.js';
3
4
  export * as node from './node.js';
@@ -3,8 +3,9 @@ export declare const ROOT_WORKSPACE_NAME = ".";
3
3
  export declare const KNIP_CONFIG_LOCATIONS: string[];
4
4
  export declare const DEFAULT_EXTENSIONS: string[];
5
5
  export declare const GLOBAL_IGNORE_PATTERNS: string[];
6
- export declare const IGNORED_GLOBAL_BINARIES: string[];
7
- export declare const IGNORED_DEPENDENCIES: string[];
6
+ export declare const IGNORED_GLOBAL_BINARIES: Set<string>;
7
+ export declare const IGNORED_DEPENDENCIES: Set<string>;
8
+ export declare const IGNORED_RUNTIME_DEPENDENCIES: Set<string>;
8
9
  export declare const DUMMY_VIRTUAL_FILE_EXTENSIONS: Set<string>;
9
10
  export declare const IGNORED_FILE_EXTENSIONS: Set<string>;
10
11
  export declare const IGNORE_DEFINITELY_TYPED: string[];
package/dist/constants.js CHANGED
@@ -11,7 +11,7 @@ export const KNIP_CONFIG_LOCATIONS = [
11
11
  ];
12
12
  export const DEFAULT_EXTENSIONS = ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.mts', '.cts'];
13
13
  export const GLOBAL_IGNORE_PATTERNS = ['**/node_modules/**', '.yarn'];
14
- export const IGNORED_GLOBAL_BINARIES = [
14
+ export const IGNORED_GLOBAL_BINARIES = new Set([
15
15
  'bash',
16
16
  'bun',
17
17
  'bunx',
@@ -30,6 +30,8 @@ export const IGNORED_GLOBAL_BINARIES = [
30
30
  'find',
31
31
  'git',
32
32
  'grep',
33
+ 'gzip',
34
+ 'ls',
33
35
  'mkdir',
34
36
  'mv',
35
37
  'node',
@@ -45,8 +47,9 @@ export const IGNORED_GLOBAL_BINARIES = [
45
47
  'true',
46
48
  'yarn',
47
49
  'xargs',
48
- ];
49
- export const IGNORED_DEPENDENCIES = ['knip', 'typescript'];
50
+ ]);
51
+ export const IGNORED_DEPENDENCIES = new Set(['knip', 'typescript']);
52
+ export const IGNORED_RUNTIME_DEPENDENCIES = new Set(['bun']);
50
53
  export const DUMMY_VIRTUAL_FILE_EXTENSIONS = new Set(['.html', '.jpeg', '.jpg', '.png', '.svg', '.webp']);
51
54
  export const IGNORED_FILE_EXTENSIONS = new Set([
52
55
  '.avif',
@@ -0,0 +1,139 @@
1
+ import type { EleventyConfig } from './types.js';
2
+ export declare class DummyEleventyConfig {
3
+ constructor();
4
+ _getUniqueId(): void;
5
+ reset(): void;
6
+ versionCheck(): void;
7
+ on(): void;
8
+ emit(): void;
9
+ _enablePluginExecution(): void;
10
+ addMarkdownHighlighter(): void;
11
+ addLiquidTag(): void;
12
+ addLiquidFilter(): void;
13
+ addNunjucksAsyncFilter(): void;
14
+ addNunjucksFilter(): void;
15
+ addHandlebarsHelper(): void;
16
+ addFilter(): void;
17
+ addAsyncFilter(): void;
18
+ getFilter(): void;
19
+ addNunjucksTag(): void;
20
+ addGlobalData(): void;
21
+ addNunjucksGlobal(): void;
22
+ addTransform(): void;
23
+ addLinter(): void;
24
+ addLayoutAlias(): void;
25
+ setLayoutResolution(): void;
26
+ enableLayoutResolution(): void;
27
+ getCollections(): void;
28
+ addCollection(): void;
29
+ addPlugin(): void;
30
+ _getPluginName(): void;
31
+ _executePlugin(): void;
32
+ getNamespacedName(): void;
33
+ namespace(): void;
34
+ addPassthroughCopy(input: string | Record<string, string>): void;
35
+ _normalizeTemplateFormats(): void;
36
+ setTemplateFormats(): void;
37
+ addTemplateFormats(): void;
38
+ setLibrary(): void;
39
+ amendLibrary(): void;
40
+ setPugOptions(): void;
41
+ setLiquidOptions(): void;
42
+ setNunjucksEnvironmentOptions(): void;
43
+ setNunjucksPrecompiledTemplates(): void;
44
+ setEjsOptions(): void;
45
+ setDynamicPermalinks(): void;
46
+ setUseGitIgnore(): void;
47
+ addShortcode(): void;
48
+ addAsyncShortcode(): void;
49
+ addNunjucksAsyncShortcode(): void;
50
+ addNunjucksShortcode(): void;
51
+ addLiquidShortcode(): void;
52
+ addHandlebarsShortcode(): void;
53
+ addPairedShortcode(): void;
54
+ addPairedAsyncShortcode(): void;
55
+ addPairedNunjucksAsyncShortcode(): void;
56
+ addPairedNunjucksShortcode(): void;
57
+ addPairedLiquidShortcode(): void;
58
+ addPairedHandlebarsShortcode(): void;
59
+ addJavaScriptFunction(): void;
60
+ setDataDeepMerge(): void;
61
+ isDataDeepMergeModified(): void;
62
+ addWatchTarget(): void;
63
+ setWatchJavaScriptDependencies(): void;
64
+ setServerOptions(): void;
65
+ setBrowserSyncConfig(): void;
66
+ setChokidarConfig(): void;
67
+ setWatchThrottleWaitTime(): void;
68
+ setFrontMatterParsingOptions(): void;
69
+ setQuietMode(): void;
70
+ addExtension(): void;
71
+ addDataExtension(): void;
72
+ setUseTemplateCache(): void;
73
+ setPrecompiledCollections(): void;
74
+ setServerPassthroughCopyBehavior(): void;
75
+ addUrlTransform(): void;
76
+ setDataFileSuffixes(): void;
77
+ setDataFileBaseName(): void;
78
+ getMergingConfigObject(): void;
79
+ _uniqueId: {};
80
+ events: {};
81
+ benchmarkManager: {};
82
+ benchmarks: {};
83
+ collections: {};
84
+ precompiledCollections: {};
85
+ templateFormats: {};
86
+ liquidOptions: {};
87
+ liquidTags: {};
88
+ liquidFilters: {};
89
+ liquidShortcodes: {};
90
+ liquidPairedShortcodes: {};
91
+ nunjucksEnvironmentOptions: {};
92
+ nunjucksPrecompiledTemplates: {};
93
+ nunjucksFilters: {};
94
+ nunjucksAsyncFilters: {};
95
+ nunjucksTags: {};
96
+ nunjucksGlobals: {};
97
+ nunjucksShortcodes: {};
98
+ nunjucksAsyncShortcodes: {};
99
+ nunjucksPairedShortcodes: {};
100
+ nunjucksAsyncPairedShortcodes: {};
101
+ javascriptFunctions: {};
102
+ markdownHighlighter: null;
103
+ libraryOverrides: {};
104
+ passthroughCopies: Record<string, Record<never, never>>;
105
+ layoutAliases: {};
106
+ layoutResolution: boolean;
107
+ linters: {};
108
+ transforms: {};
109
+ activeNamespace: string;
110
+ DateTime: {};
111
+ dynamicPermalinks: boolean;
112
+ useGitIgnore: boolean;
113
+ ignores: Set<unknown>;
114
+ watchIgnores: Set<unknown>;
115
+ dataDeepMerge: boolean;
116
+ extensionMap: Set<unknown>;
117
+ watchJavaScriptDependencies: boolean;
118
+ additionalWatchTargets: never[];
119
+ serverOptions: {};
120
+ globalData: {};
121
+ chokidarConfig: {};
122
+ watchThrottleWaitTime: number;
123
+ dataExtensions: Map<any, any>;
124
+ quietMode: boolean;
125
+ plugins: never[];
126
+ _pluginExecution: boolean;
127
+ useTemplateCache: boolean;
128
+ dataFilterSelectors: Set<unknown>;
129
+ libraryAmendments: {};
130
+ serverPassthroughCopyBehavior: string;
131
+ urlTransforms: never[];
132
+ dataFileSuffixesOverride: boolean;
133
+ dataFileDirBaseNameOverride: boolean;
134
+ frontMatterParsingOptions: {
135
+ engines: {};
136
+ };
137
+ templateFormatsAdded: {};
138
+ }
139
+ export declare const defaultEleventyConfig: EleventyConfig;
@@ -0,0 +1,156 @@
1
+ export class DummyEleventyConfig {
2
+ constructor() { }
3
+ _getUniqueId() { }
4
+ reset() { }
5
+ versionCheck() { }
6
+ on() { }
7
+ emit() { }
8
+ _enablePluginExecution() { }
9
+ addMarkdownHighlighter() { }
10
+ addLiquidTag() { }
11
+ addLiquidFilter() { }
12
+ addNunjucksAsyncFilter() { }
13
+ addNunjucksFilter() { }
14
+ addHandlebarsHelper() { }
15
+ addFilter() { }
16
+ addAsyncFilter() { }
17
+ getFilter() { }
18
+ addNunjucksTag() { }
19
+ addGlobalData() { }
20
+ addNunjucksGlobal() { }
21
+ addTransform() { }
22
+ addLinter() { }
23
+ addLayoutAlias() { }
24
+ setLayoutResolution() { }
25
+ enableLayoutResolution() { }
26
+ getCollections() { }
27
+ addCollection() { }
28
+ addPlugin() { }
29
+ _getPluginName() { }
30
+ _executePlugin() { }
31
+ getNamespacedName() { }
32
+ namespace() { }
33
+ addPassthroughCopy(input) {
34
+ if (typeof input === 'string') {
35
+ this.passthroughCopies[input] = {};
36
+ }
37
+ else {
38
+ for (let [inputPath] of Object.entries(input)) {
39
+ this.passthroughCopies[inputPath] = {};
40
+ }
41
+ }
42
+ }
43
+ _normalizeTemplateFormats() { }
44
+ setTemplateFormats() { }
45
+ addTemplateFormats() { }
46
+ setLibrary() { }
47
+ amendLibrary() { }
48
+ setPugOptions() { }
49
+ setLiquidOptions() { }
50
+ setNunjucksEnvironmentOptions() { }
51
+ setNunjucksPrecompiledTemplates() { }
52
+ setEjsOptions() { }
53
+ setDynamicPermalinks() { }
54
+ setUseGitIgnore() { }
55
+ addShortcode() { }
56
+ addAsyncShortcode() { }
57
+ addNunjucksAsyncShortcode() { }
58
+ addNunjucksShortcode() { }
59
+ addLiquidShortcode() { }
60
+ addHandlebarsShortcode() { }
61
+ addPairedShortcode() { }
62
+ addPairedAsyncShortcode() { }
63
+ addPairedNunjucksAsyncShortcode() { }
64
+ addPairedNunjucksShortcode() { }
65
+ addPairedLiquidShortcode() { }
66
+ addPairedHandlebarsShortcode() { }
67
+ addJavaScriptFunction() { }
68
+ setDataDeepMerge() { }
69
+ isDataDeepMergeModified() { }
70
+ addWatchTarget() { }
71
+ setWatchJavaScriptDependencies() { }
72
+ setServerOptions() { }
73
+ setBrowserSyncConfig() { }
74
+ setChokidarConfig() { }
75
+ setWatchThrottleWaitTime() { }
76
+ setFrontMatterParsingOptions() { }
77
+ setQuietMode() { }
78
+ addExtension() { }
79
+ addDataExtension() { }
80
+ setUseTemplateCache() { }
81
+ setPrecompiledCollections() { }
82
+ setServerPassthroughCopyBehavior() { }
83
+ addUrlTransform() { }
84
+ setDataFileSuffixes() { }
85
+ setDataFileBaseName() { }
86
+ getMergingConfigObject() { }
87
+ _uniqueId = {};
88
+ events = {};
89
+ benchmarkManager = {};
90
+ benchmarks = {};
91
+ collections = {};
92
+ precompiledCollections = {};
93
+ templateFormats = {};
94
+ liquidOptions = {};
95
+ liquidTags = {};
96
+ liquidFilters = {};
97
+ liquidShortcodes = {};
98
+ liquidPairedShortcodes = {};
99
+ nunjucksEnvironmentOptions = {};
100
+ nunjucksPrecompiledTemplates = {};
101
+ nunjucksFilters = {};
102
+ nunjucksAsyncFilters = {};
103
+ nunjucksTags = {};
104
+ nunjucksGlobals = {};
105
+ nunjucksShortcodes = {};
106
+ nunjucksAsyncShortcodes = {};
107
+ nunjucksPairedShortcodes = {};
108
+ nunjucksAsyncPairedShortcodes = {};
109
+ javascriptFunctions = {};
110
+ markdownHighlighter = null;
111
+ libraryOverrides = {};
112
+ passthroughCopies = {};
113
+ layoutAliases = {};
114
+ layoutResolution = true;
115
+ linters = {};
116
+ transforms = {};
117
+ activeNamespace = '';
118
+ DateTime = {};
119
+ dynamicPermalinks = true;
120
+ useGitIgnore = true;
121
+ ignores = new Set();
122
+ watchIgnores = new Set();
123
+ dataDeepMerge = true;
124
+ extensionMap = new Set();
125
+ watchJavaScriptDependencies = true;
126
+ additionalWatchTargets = [];
127
+ serverOptions = {};
128
+ globalData = {};
129
+ chokidarConfig = {};
130
+ watchThrottleWaitTime = 0;
131
+ dataExtensions = new Map();
132
+ quietMode = false;
133
+ plugins = [];
134
+ _pluginExecution = false;
135
+ useTemplateCache = true;
136
+ dataFilterSelectors = new Set();
137
+ libraryAmendments = {};
138
+ serverPassthroughCopyBehavior = '';
139
+ urlTransforms = [];
140
+ dataFileSuffixesOverride = false;
141
+ dataFileDirBaseNameOverride = false;
142
+ frontMatterParsingOptions = {
143
+ engines: {},
144
+ };
145
+ templateFormatsAdded = {};
146
+ }
147
+ export const defaultEleventyConfig = {
148
+ dir: {
149
+ input: '.',
150
+ output: '_site',
151
+ includes: '_includes',
152
+ layouts: '_includes',
153
+ data: '_data',
154
+ },
155
+ templateFormats: '11ty.js',
156
+ };
@@ -3,8 +3,10 @@ declare const _default: {
3
3
  NAME: string;
4
4
  ENABLERS: string[];
5
5
  isEnabled: IsPluginEnabledCallback;
6
+ CONFIG_FILE_PATTERNS: string[];
6
7
  ENTRY_FILE_PATTERNS: string[];
7
8
  PRODUCTION_ENTRY_FILE_PATTERNS: string[];
9
+ PROJECT_FILE_PATTERNS: string[];
8
10
  findDependencies: GenericPluginCallback;
9
11
  };
10
12
  export default _default;
@@ -1,23 +1,63 @@
1
+ import { DEFAULT_EXTENSIONS } from '../../constants.js';
2
+ import { isDirectory } from '../../util/fs.js';
3
+ import { dirname, isInternal, join } from '../../util/path.js';
1
4
  import { timerify } from '../../util/Performance.js';
2
- import { hasDependency } from '../../util/plugin.js';
3
- import { toEntryPattern, toProductionEntryPattern } from '../../util/protocols.js';
5
+ import { hasDependency, load } from '../../util/plugin.js';
6
+ import { toProductionEntryPattern } from '../../util/protocols.js';
7
+ import { DummyEleventyConfig, defaultEleventyConfig } from './helpers.js';
4
8
  const NAME = 'Eleventy';
5
9
  const ENABLERS = ['@11ty/eleventy'];
6
10
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
- const ENTRY_FILE_PATTERNS = ['.eleventy.js', 'eleventy.config.{js,cjs}'];
11
+ const CONFIG_FILE_PATTERNS = ['.eleventy.js', 'eleventy.config.{js,cjs}'];
12
+ const ENTRY_FILE_PATTERNS = [];
8
13
  const PRODUCTION_ENTRY_FILE_PATTERNS = ['posts/**/*.11tydata.js', '_data/**/*.{js,cjs,mjs}'];
14
+ const PROJECT_FILE_PATTERNS = [];
9
15
  const findEleventyDependencies = async (configFilePath, options) => {
10
16
  const { config } = options;
11
- return config.entry
12
- ? config.entry.map(toProductionEntryPattern)
13
- : [...ENTRY_FILE_PATTERNS.map(toEntryPattern), ...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern)];
17
+ let localConfig = (await load(configFilePath));
18
+ if (!localConfig)
19
+ return config.entry
20
+ ? config.entry.map(toProductionEntryPattern)
21
+ : PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern);
22
+ const dummyUserConfig = new DummyEleventyConfig();
23
+ if (typeof localConfig === 'function')
24
+ localConfig = await localConfig(dummyUserConfig);
25
+ const inputDir = localConfig?.dir?.input || defaultEleventyConfig.dir.input;
26
+ const dataDir = localConfig?.dir?.data || defaultEleventyConfig.dir.data;
27
+ const templateFormats = localConfig.templateFormats || defaultEleventyConfig.templateFormats;
28
+ const exts = DEFAULT_EXTENSIONS.map(extname => extname.slice(1)).join(',');
29
+ const copiedPackages = new Set();
30
+ const copiedEntries = new Set();
31
+ for (const path of Object.keys(dummyUserConfig.passthroughCopies)) {
32
+ const isDir = !path.includes('*') && isDirectory(join(dirname(configFilePath), path));
33
+ if (isDir) {
34
+ copiedEntries.add(join(path, `**/*.{${exts}}`));
35
+ }
36
+ else if (isInternal(path)) {
37
+ copiedEntries.add(path);
38
+ }
39
+ else {
40
+ copiedPackages.add(path);
41
+ }
42
+ }
43
+ return [
44
+ ...(config?.entry ?? [
45
+ join(inputDir, dataDir, '**/*.js'),
46
+ join(inputDir, `**/*.{${typeof templateFormats === 'string' ? templateFormats : templateFormats.join(',')}}`),
47
+ join(inputDir, '**/*.11tydata.js'),
48
+ ...copiedEntries,
49
+ ]).map(toProductionEntryPattern),
50
+ ...copiedPackages,
51
+ ];
14
52
  };
15
53
  const findDependencies = timerify(findEleventyDependencies);
16
54
  export default {
17
55
  NAME,
18
56
  ENABLERS,
19
57
  isEnabled,
58
+ CONFIG_FILE_PATTERNS,
20
59
  ENTRY_FILE_PATTERNS,
21
60
  PRODUCTION_ENTRY_FILE_PATTERNS,
61
+ PROJECT_FILE_PATTERNS,
22
62
  findDependencies,
23
63
  };
@@ -0,0 +1,10 @@
1
+ export type EleventyConfig = {
2
+ dir: {
3
+ input: string;
4
+ output: string;
5
+ includes: string;
6
+ layouts: string;
7
+ data: string;
8
+ };
9
+ templateFormats: string | string[];
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,6 @@
1
+ import ts from 'typescript';
1
2
  import type { BoundSourceFile } from '../SourceFile.js';
2
3
  export declare const isNotJS: (sourceFile: BoundSourceFile) => boolean;
3
4
  export declare const isJS: (sourceFile: BoundSourceFile) => boolean;
4
5
  export declare function getJSXImplicitImportBase(sourceFile: BoundSourceFile): string | undefined;
6
+ export declare function hasImportSpecifier(node: ts.Statement, name: string): boolean;
@@ -8,3 +8,11 @@ export function getJSXImplicitImportBase(sourceFile) {
8
8
  : jsxImportSourcePragmas;
9
9
  return jsxImportSourcePragma?.arguments.factory;
10
10
  }
11
+ export function hasImportSpecifier(node, name) {
12
+ return (ts.isImportDeclaration(node) &&
13
+ ts.isStringLiteral(node.moduleSpecifier) &&
14
+ node.moduleSpecifier.text === name &&
15
+ !!node.importClause?.namedBindings &&
16
+ ts.isNamedImports(node.importClause.namedBindings) &&
17
+ node.importClause.namedBindings.elements.some(element => element.name.text === '$'));
18
+ }
@@ -0,0 +1,3 @@
1
+ import ts from 'typescript';
2
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../getImportsAndExports.js").GetImportsAndExportsOptions) => string | string[] | undefined;
3
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import ts from 'typescript';
2
+ import { stripQuotes } from '../../ast-helpers.js';
3
+ import { hasImportSpecifier } from '../helpers.js';
4
+ import { scriptVisitor as visit } from '../index.js';
5
+ export default visit(sourceFile => sourceFile.statements.some(node => hasImportSpecifier(node, 'bun')), node => {
6
+ if (ts.isTaggedTemplateExpression(node) && node.tag.getText() === '$') {
7
+ return stripQuotes(node.template.getText());
8
+ }
9
+ });
@@ -1,18 +1,11 @@
1
1
  import ts from 'typescript';
2
2
  import { stripQuotes } from '../../ast-helpers.js';
3
+ import { hasImportSpecifier } from '../helpers.js';
3
4
  import { scriptVisitor as visit } from '../index.js';
4
- export default visit(sourceFile => sourceFile.statements.some(statementImportsExeca$), node => {
5
+ export default visit(sourceFile => sourceFile.statements.some(node => hasImportSpecifier(node, 'execa')), node => {
5
6
  if (ts.isTaggedTemplateExpression(node)) {
6
7
  if (node.tag.getText() === '$' || (ts.isCallExpression(node.tag) && node.tag.expression.getText() === '$')) {
7
8
  return stripQuotes(node.template.getText());
8
9
  }
9
10
  }
10
11
  });
11
- function statementImportsExeca$(node) {
12
- return (ts.isImportDeclaration(node) &&
13
- ts.isStringLiteral(node.moduleSpecifier) &&
14
- node.moduleSpecifier.text === 'execa' &&
15
- !!node.importClause?.namedBindings &&
16
- ts.isNamedImports(node.importClause.namedBindings) &&
17
- node.importClause.namedBindings.elements.some(element => element.name.text === '$'));
18
- }
@@ -1,5 +1,6 @@
1
1
  import ts from 'typescript';
2
+ import bun from './bun.js';
2
3
  import execa from './execa.js';
3
4
  import zx from './zx.js';
4
- const visitors = [execa, zx];
5
+ const visitors = [bun, execa, zx];
5
6
  export default (sourceFile) => visitors.map(v => v(sourceFile));
@@ -118,10 +118,7 @@ export async function globby(patterns, options) {
118
118
  ignore.push(...i.ignores);
119
119
  }
120
120
  const { dir, ...fastGlobOptions } = { ...options, ignore };
121
- debugLogObject(relative(options.cwd, options.dir) || ROOT_WORKSPACE_NAME, `Glob options`, {
122
- patterns,
123
- ...fastGlobOptions,
124
- });
121
+ debugLogObject(relative(options.cwd, dir) || ROOT_WORKSPACE_NAME, `Glob options`, { patterns, ...options });
125
122
  return fastGlob(patterns, fastGlobOptions);
126
123
  }
127
124
  export async function isGitIgnoredFn(options) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "4.0.3";
1
+ export declare const version = "4.1.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '4.0.3';
1
+ export const version = '4.1.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "4.0.3",
3
+ "version": "4.1.0",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {