knip 1.0.0-beta.3 → 1.0.0-beta.5

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 (74) hide show
  1. package/README.md +31 -22
  2. package/dist/cli.js +5 -5
  3. package/dist/configuration-chief.d.ts +1 -3
  4. package/dist/configuration-chief.js +14 -12
  5. package/dist/configuration-validator.d.ts +2 -2
  6. package/dist/index.js +8 -4
  7. package/dist/plugins/_template/index.d.ts +3 -1
  8. package/dist/plugins/_template/index.js +3 -3
  9. package/dist/plugins/babel/index.d.ts +3 -1
  10. package/dist/plugins/babel/index.js +3 -6
  11. package/dist/plugins/capacitor/index.d.ts +2 -0
  12. package/dist/plugins/capacitor/index.js +3 -3
  13. package/dist/plugins/changesets/index.d.ts +2 -0
  14. package/dist/plugins/changesets/index.js +3 -1
  15. package/dist/plugins/commitlint/index.d.ts +2 -0
  16. package/dist/plugins/commitlint/index.js +3 -1
  17. package/dist/plugins/cypress/index.d.ts +2 -0
  18. package/dist/plugins/cypress/index.js +3 -1
  19. package/dist/plugins/eslint/index.d.ts +2 -0
  20. package/dist/plugins/eslint/index.js +3 -1
  21. package/dist/plugins/gatsby/index.d.ts +2 -0
  22. package/dist/plugins/gatsby/index.js +3 -3
  23. package/dist/plugins/jest/index.d.ts +2 -0
  24. package/dist/plugins/jest/index.js +3 -3
  25. package/dist/plugins/mocha/index.d.ts +2 -0
  26. package/dist/plugins/mocha/index.js +3 -3
  27. package/dist/plugins/next/index.d.ts +2 -0
  28. package/dist/plugins/next/index.js +3 -3
  29. package/dist/plugins/nx/index.d.ts +2 -0
  30. package/dist/plugins/nx/index.js +3 -3
  31. package/dist/plugins/nyc/index.d.ts +2 -0
  32. package/dist/plugins/nyc/index.js +3 -1
  33. package/dist/plugins/playwright/index.d.ts +2 -0
  34. package/dist/plugins/playwright/index.js +3 -1
  35. package/dist/plugins/postcss/index.d.ts +2 -1
  36. package/dist/plugins/postcss/index.js +3 -2
  37. package/dist/plugins/prettier/index.d.ts +2 -1
  38. package/dist/plugins/prettier/index.js +3 -2
  39. package/dist/plugins/remark/index.d.ts +2 -0
  40. package/dist/plugins/remark/index.js +3 -1
  41. package/dist/plugins/remix/index.d.ts +2 -0
  42. package/dist/plugins/remix/index.js +3 -3
  43. package/dist/plugins/rollup/index.d.ts +2 -0
  44. package/dist/plugins/rollup/index.js +3 -1
  45. package/dist/plugins/sentry/index.d.ts +2 -0
  46. package/dist/plugins/sentry/index.js +3 -1
  47. package/dist/plugins/storybook/index.d.ts +2 -0
  48. package/dist/plugins/storybook/index.js +3 -3
  49. package/dist/plugins/stryker/index.d.ts +2 -0
  50. package/dist/plugins/stryker/index.js +3 -1
  51. package/dist/plugins/typescript/index.d.ts +3 -1
  52. package/dist/plugins/typescript/index.js +4 -2
  53. package/dist/plugins/webpack/index.d.ts +3 -2
  54. package/dist/plugins/webpack/index.js +3 -2
  55. package/dist/source-lab.js +6 -12
  56. package/dist/types/cli.d.ts +1 -0
  57. package/dist/util/cli-arguments.d.ts +26 -0
  58. package/dist/util/cli-arguments.js +58 -0
  59. package/dist/util/debug.js +1 -1
  60. package/dist/util/glob.d.ts +1 -0
  61. package/dist/util/glob.js +6 -3
  62. package/dist/util/loader.js +1 -1
  63. package/dist/util/members.d.ts +2 -3
  64. package/dist/util/members.js +8 -4
  65. package/dist/util/modules.js +2 -1
  66. package/dist/util/path.js +2 -1
  67. package/dist/util/performance.js +1 -1
  68. package/dist/util/resolve-included-issue-types.d.ts +0 -1
  69. package/dist/workspace-worker.js +7 -6
  70. package/package.json +18 -9
  71. package/dist/util/help.d.ts +0 -1
  72. package/dist/util/help.js +0 -35
  73. package/dist/util/parseArgs.d.ts +0 -25
  74. package/dist/util/parseArgs.js +0 -24
package/README.md CHANGED
@@ -57,7 +57,9 @@ Knip supports LTS versions of Node.js, and currently requires at least Node.js v
57
57
 
58
58
  ## Usage
59
59
 
60
- Create a configuration file, let's give it the default name `knip.json` with these contents:
60
+ Knip has good defaults and you can run it without any configuration, but especially larger projects get more out of Knip
61
+ with a configuration file (or a `knip` property in `package.json`). Let's name this file `knip.json` with these contents
62
+ (you might want to adjust right away for your project):
61
63
 
62
64
  ```json
63
65
  {
@@ -78,29 +80,30 @@ This will analyze the project and output unused files, dependencies and exports.
78
80
 
79
81
  ## Options
80
82
 
81
- npx knip
83
+ $ npx knip --help
82
84
  knip [options]
83
85
 
84
86
  Options:
85
- -c/--config [file] Configuration file path (default: ./knip.json, knip.jsonc or package.json#knip)
86
- -t/--tsConfig [file] TypeScript configuration path (default: ./tsconfig.json)
87
- --production Analyze only production source files (e.g. no tests, devDependencies, exported types)
88
- --strict Consider only direct dependencies of workspaces. Not devDependencies, not ancestor workspaces.
89
- --workspace Analyze a single workspace (default: analyze all configured workspaces)
90
- --include Report only listed issue type(s), can be comma-separated or repeated
91
- --exclude Exclude issue type(s) from report, can be comma-separated or repeated
92
- --ignore Ignore files matching this glob pattern, can be repeated
93
- --no-gitignore Don't use .gitignore
94
- --no-progress Don't show dynamic progress updates
95
- --no-exit-code Always exit with code zero (0)
96
- --max-issues Maximum number of issues before non-zero exit code (default: 0)
97
- --reporter Select reporter: symbols, compact, codeowners, json (default: symbols)
98
- --reporter-options Pass extra options to the reporter (as JSON string, see example)
99
- --debug Show debug output
100
- --debug-file-filter Filter for files in debug output (regex as string)
101
- --performance Measure running time of expensive functions and display stats table
102
-
103
- Issue types: files, dependencies, unlisted, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates
87
+ -c/--config [file] Configuration file path (default: knip.json, knip.jsonc or package.json#knip)
88
+ -t/--tsConfig [file] TypeScript configuration path (default: tsconfig.json)
89
+ --production Analyze only production source files (e.g. no tests, devDependencies, exported types)
90
+ --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)
91
+ --workspace Analyze a single workspace (default: analyze all configured workspaces)
92
+ --include-entry-exports Include unused exports in entry files (without `@public`)
93
+ --ignore Ignore files matching this glob pattern, can be repeated
94
+ --no-gitignore Don't use .gitignore
95
+ --include Report only provided issue type(s), can be comma-separated or repeated (1)
96
+ --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)
97
+ --no-progress Don't show dynamic progress updates
98
+ --reporter Select reporter: symbols, compact, codeowners, json (default: symbols)
99
+ --reporter-options Pass extra options to the reporter (as JSON string, see example)
100
+ --no-exit-code Always exit with code zero (0)
101
+ --max-issues Maximum number of issues before non-zero exit code (default: 0)
102
+ --debug Show debug output
103
+ --debug-file-filter Filter for files in debug output (regex as string)
104
+ --performance Measure running time of expensive functions and display stats table
105
+
106
+ (1) Issue types: files, dependencies, unlisted, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates
104
107
 
105
108
  Examples:
106
109
 
@@ -269,6 +272,12 @@ rest to find which of those dependencies are unused or missing.
269
272
  Other configuration files use `require` or `import` statements to use dependencies, so they can be analyzed like the
270
273
  rest of the source files. These configuration files are also considered `entry` files.
271
274
 
275
+ ### Create a new plugin
276
+
277
+ Getting false positives because a plugin is missing? Want to help out? Feel free to add your own plugin! Get started:
278
+
279
+ npm run create-plugin -- --name [myplugin]
280
+
272
281
  ## Configuration
273
282
 
274
283
  ### Libraries versus Applications
@@ -405,7 +414,7 @@ The following commands are similar:
405
414
  unimported
406
415
  knip --production --include files,dependencies,unlisted
407
416
 
408
- See [production mode](#production-mode).
417
+ See [production mode][7].
409
418
 
410
419
  ## TypeScript language services
411
420
 
package/dist/cli.js CHANGED
@@ -2,15 +2,14 @@
2
2
  import path from 'node:path';
3
3
  import { register } from 'esbuild-register/dist/node.js';
4
4
  import reporters from './reporters/index.js';
5
+ import parsedArgs, { helpText } from './util/cli-arguments.js';
5
6
  import { ConfigurationError } from './util/errors.js';
6
- import { printHelp } from './util/help.js';
7
- import parsedArgs from './util/parseArgs.js';
8
7
  import { measure } from './util/performance.js';
9
8
  import { main } from './index.js';
10
9
  register();
11
- const { values: { debug: isDebug = false, help, 'max-issues': maxIssues = '0', 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': noProgress = false, production: isProduction = false, reporter = 'symbols', 'reporter-options': reporterOptions = '', strict: isStrict = false, tsConfig, }, } = parsedArgs;
10
+ const { values: { debug: isDebug = false, help, 'include-entry-exports': isIncludeEntryExports = false, 'max-issues': maxIssues = '0', 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': noProgress = false, production: isProduction = false, reporter = 'symbols', 'reporter-options': reporterOptions = '', strict: isStrict = false, tsConfig, }, } = parsedArgs;
12
11
  if (help) {
13
- printHelp();
12
+ console.log(helpText);
14
13
  process.exit(0);
15
14
  }
16
15
  const cwd = process.cwd();
@@ -25,6 +24,7 @@ const run = async () => {
25
24
  isStrict,
26
25
  isProduction,
27
26
  isShowProgress,
27
+ isIncludeEntryExports,
28
28
  });
29
29
  await printReport({ report, issues, cwd, isProduction, options: reporterOptions });
30
30
  const totalErrorCount = Object.keys(report)
@@ -38,7 +38,7 @@ const run = async () => {
38
38
  catch (error) {
39
39
  if (error instanceof ConfigurationError) {
40
40
  console.error(error.message + '\n');
41
- printHelp();
41
+ console.log(helpText);
42
42
  process.exit(1);
43
43
  }
44
44
  throw error;
@@ -5,18 +5,16 @@ import type { Configuration, WorkspaceConfiguration } from './types/config.js';
5
5
  import type { PackageJson } from '@npmcli/package-json';
6
6
  type ConfigurationManagerOptions = {
7
7
  cwd?: string;
8
- isStrict: boolean;
9
8
  isProduction: boolean;
10
9
  };
11
10
  export default class ConfigurationChief {
12
11
  cwd: string;
13
- isStrict: boolean;
14
12
  isProduction: boolean;
15
13
  config: Configuration;
16
14
  manifestPath: undefined | string;
17
15
  manifest: undefined | PackageJson;
18
16
  manifestWorkspaces: undefined | string[];
19
- constructor({ cwd, isStrict, isProduction }: ConfigurationManagerOptions);
17
+ constructor({ cwd, isProduction }: ConfigurationManagerOptions);
20
18
  loadLocalConfig(): Promise<void>;
21
19
  normalize(rawLocalConfig: z.infer<typeof ConfigurationValidator>): {
22
20
  include: string[];
@@ -5,9 +5,10 @@ import { ConfigurationValidator } from './configuration-validator.js';
5
5
  import { ROOT_WORKSPACE_NAME } from './constants.js';
6
6
  import * as plugins from './plugins/index.js';
7
7
  import { arrayify } from './util/array.js';
8
+ import parsedArgs from './util/cli-arguments.js';
8
9
  import { ConfigurationError } from './util/errors.js';
9
10
  import { findFile, loadJSON } from './util/fs.js';
10
- import parsedArgs from './util/parseArgs.js';
11
+ import { ensurePosixPath } from './util/glob.js';
11
12
  import { resolveIncludedIssueTypes } from './util/resolve-included-issue-types.js';
12
13
  import { byPathDepth } from './util/workspace.js';
13
14
  const { values: { config: rawConfigArg, workspace: rawWorkspaceArg, include = [], exclude = [] }, } = parsedArgs;
@@ -30,15 +31,13 @@ const defaultConfig = {
30
31
  const PLUGIN_NAMES = Object.keys(plugins);
31
32
  export default class ConfigurationChief {
32
33
  cwd = process.cwd();
33
- isStrict = false;
34
34
  isProduction = false;
35
35
  config;
36
36
  manifestPath;
37
37
  manifest;
38
38
  manifestWorkspaces;
39
- constructor({ cwd, isStrict, isProduction }) {
39
+ constructor({ cwd, isProduction }) {
40
40
  this.cwd = cwd ?? this.cwd;
41
- this.isStrict = isStrict;
42
41
  this.isProduction = isProduction;
43
42
  this.config = defaultConfig;
44
43
  }
@@ -84,13 +83,14 @@ export default class ConfigurationChief {
84
83
  .reduce((workspaces, workspace) => {
85
84
  const [workspaceName, workspaceConfig] = workspace;
86
85
  const entry = workspaceConfig.entry ? arrayify(workspaceConfig.entry) : defaultWorkspaceConfig.entry;
86
+ const project = workspaceConfig.project
87
+ ? arrayify(workspaceConfig.project)
88
+ : workspaceConfig.entry
89
+ ? entry
90
+ : defaultWorkspaceConfig.project;
87
91
  workspaces[workspaceName] = {
88
92
  entry,
89
- project: workspaceConfig.project
90
- ? arrayify(workspaceConfig.project)
91
- : workspaceConfig.entry
92
- ? entry
93
- : defaultWorkspaceConfig.project,
93
+ project,
94
94
  ignore: arrayify(workspaceConfig.ignore),
95
95
  };
96
96
  for (const [pluginName, pluginConfig] of Object.entries(workspaceConfig)) {
@@ -125,7 +125,9 @@ export default class ConfigurationChief {
125
125
  ignore: this.config.ignoreWorkspaces,
126
126
  absolute: false,
127
127
  });
128
- this.manifestWorkspaces = Array.from(workspaces.values()).map(dir => path.relative(this.cwd, dir));
128
+ this.manifestWorkspaces = Array.from(workspaces.values())
129
+ .map(dir => path.relative(this.cwd, dir))
130
+ .map(ensurePosixPath);
129
131
  return this.manifestWorkspaces;
130
132
  }
131
133
  return [];
@@ -185,8 +187,9 @@ export default class ConfigurationChief {
185
187
  }
186
188
  async getNegatedWorkspacePatterns(name) {
187
189
  const descendentWorkspaces = await this.getDescendentWorkspaces(name);
190
+ const matchName = new RegExp(`^${name}/`);
188
191
  return descendentWorkspaces
189
- .map(workspaceName => path.relative(path.join(this.cwd, name), workspaceName))
192
+ .map(workspaceName => workspaceName.replace(matchName, ''))
190
193
  .map(workspaceName => `!${workspaceName}`);
191
194
  }
192
195
  getConfigKeyForWorkspace(workspaceName) {
@@ -210,7 +213,6 @@ export default class ConfigurationChief {
210
213
  include: this.config.include ?? [],
211
214
  exclude: this.config.exclude ?? [],
212
215
  isProduction: this.isProduction,
213
- isStrict: this.isStrict,
214
216
  });
215
217
  }
216
218
  }
@@ -856,10 +856,10 @@ export declare const ConfigurationValidator: z.ZodObject<z.extendShape<z.extendS
856
856
  }>, "strip", z.ZodTypeAny, {
857
857
  exclude?: string[] | undefined;
858
858
  ignore?: string | string[] | undefined;
859
- ignoreBinaries?: string[] | undefined;
860
859
  include?: string[] | undefined;
861
860
  entry?: string | string[] | undefined;
862
861
  project?: string | string[] | undefined;
862
+ ignoreBinaries?: string[] | undefined;
863
863
  ignoreDependencies?: string[] | undefined;
864
864
  ignoreWorkspaces?: string[] | undefined;
865
865
  babel?: string | false | string[] | {
@@ -1100,10 +1100,10 @@ export declare const ConfigurationValidator: z.ZodObject<z.extendShape<z.extendS
1100
1100
  }, {
1101
1101
  exclude?: string[] | undefined;
1102
1102
  ignore?: string | string[] | undefined;
1103
- ignoreBinaries?: string[] | undefined;
1104
1103
  include?: string[] | undefined;
1105
1104
  entry?: string | string[] | undefined;
1106
1105
  project?: string | string[] | undefined;
1106
+ ignoreBinaries?: string[] | undefined;
1107
1107
  ignoreDependencies?: string[] | undefined;
1108
1108
  ignoreWorkspaces?: string[] | undefined;
1109
1109
  babel?: string | false | string[] | {
package/dist/index.js CHANGED
@@ -9,15 +9,15 @@ import { compact } from './util/array.js';
9
9
  import { debugLogObject, debugLogFiles } from './util/debug.js';
10
10
  import { _findImportModuleSpecifiers } from './util/find-import-specifiers.js';
11
11
  import { findFile, loadJSON } from './util/fs.js';
12
- import { _glob } from './util/glob.js';
12
+ import { _glob, ensurePosixPath } from './util/glob.js';
13
13
  import { getPackageNameFromModuleSpecifier } from './util/modules.js';
14
14
  import { _findDuplicateExportedNames } from './util/project.js';
15
15
  import { loadTSConfig } from './util/tsconfig-loader.js';
16
16
  import { byPathDepth } from './util/workspace.js';
17
17
  import WorkspaceWorker from './workspace-worker.js';
18
18
  export const main = async (unresolvedConfiguration) => {
19
- const { cwd, tsConfigFile, gitignore, isStrict, isProduction, isShowProgress } = unresolvedConfiguration;
20
- const chief = new ConfigurationChief({ cwd, isStrict, isProduction });
19
+ const { cwd, tsConfigFile, gitignore, isStrict, isProduction, isShowProgress, isIncludeEntryExports } = unresolvedConfiguration;
20
+ const chief = new ConfigurationChief({ cwd, isProduction });
21
21
  debugLogObject('Unresolved configuration', unresolvedConfiguration);
22
22
  const collector = new IssueCollector({ cwd, isShowProgress });
23
23
  collector.updateMessage('Reading configuration and manifest files...');
@@ -81,6 +81,8 @@ export const main = async (unresolvedConfiguration) => {
81
81
  });
82
82
  debugLogFiles(`Globbed entry paths${suffix}`, workspaceEntryPaths);
83
83
  workspaceEntryPaths.forEach(entryPath => principal.addEntryPath(entryPath));
84
+ if (!isIncludeEntryExports)
85
+ workspaceEntryPaths.forEach(entryPath => lab.skipExportsAnalysisFor(entryPath));
84
86
  collector.updateMessage(`Resolving production plugin entry files${suffix}...`);
85
87
  const pluginWorkspaceEntryPaths = await _glob({
86
88
  cwd,
@@ -120,6 +122,8 @@ export const main = async (unresolvedConfiguration) => {
120
122
  });
121
123
  debugLogFiles(`Globbed entry paths${suffix}`, workspaceEntryPaths);
122
124
  workspaceEntryPaths.forEach(entryPath => principal.addEntryPath(entryPath));
125
+ if (!isIncludeEntryExports)
126
+ workspaceEntryPaths.forEach(entryPath => lab.skipExportsAnalysisFor(entryPath));
123
127
  }
124
128
  {
125
129
  collector.updateMessage(`Resolving project files${suffix}...`);
@@ -232,7 +236,7 @@ export const main = async (unresolvedConfiguration) => {
232
236
  const filePath = sourceFile.getFilePath();
233
237
  if (report.dependencies || report.unlisted) {
234
238
  const filePath = sourceFile.getFilePath();
235
- const workspaceDir = workspaceDirs.find(workspaceDir => filePath.startsWith(workspaceDir));
239
+ const workspaceDir = workspaceDirs.find(workspaceDir => filePath.startsWith(ensurePosixPath(workspaceDir)));
236
240
  const workspace = workspaces.find(workspace => workspace.dir === workspaceDir);
237
241
  if (workspace) {
238
242
  const [, externalModuleSpecifiers] = moduleSpecifierCache.get(sourceFile) ?? _findImportModuleSpecifiers(sourceFile, { skipInternal: true });
@@ -1,7 +1,9 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "";
3
+ export declare const ENABLERS: string[];
4
+ export declare const isEnabled: IsPluginEnabledCallback;
2
5
  export declare const CONFIG_FILE_PATTERNS: never[];
3
6
  export declare const ENTRY_FILE_PATTERNS: never[];
4
7
  export declare const PRODUCTION_ENTRY_FILE_PATTERNS: never[];
5
8
  export declare const PROJECT_FILE_PATTERNS: never[];
6
- export declare const isEnabled: IsPluginEnabledCallback;
7
9
  export declare const findDependencies: GenericPluginCallback;
@@ -1,12 +1,12 @@
1
1
  import { _load } from '../../util/loader.js';
2
2
  import { timerify } from '../../util/performance.js';
3
+ export const NAME = '';
4
+ export const ENABLERS = [''];
5
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
3
6
  export const CONFIG_FILE_PATTERNS = [];
4
7
  export const ENTRY_FILE_PATTERNS = [];
5
8
  export const PRODUCTION_ENTRY_FILE_PATTERNS = [];
6
9
  export const PROJECT_FILE_PATTERNS = [];
7
- export const isEnabled = ({ dependencies }) => {
8
- return dependencies.has('[pkg]');
9
- };
10
10
  const findPluginDependencies = async (configFilePath, { manifest }) => {
11
11
  const config = configFilePath.endsWith('package.json') ? manifest.plugin : await _load(configFilePath);
12
12
  return config?.plugins ?? [];
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
- export declare const CONFIG_FILE_PATTERNS: string[];
2
+ export declare const NAME = "Babel";
3
+ export declare const ENABLERS: string[];
3
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
+ export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const findDependencies: GenericPluginCallback;
@@ -3,6 +3,9 @@ import { _load } from '../../util/loader.js';
3
3
  import { getPackageName } from '../../util/modules.js';
4
4
  import { timerify } from '../../util/performance.js';
5
5
  import { resolvePresetName, resolvePluginName } from './helpers.js';
6
+ export const NAME = 'Babel';
7
+ export const ENABLERS = ['@babel/cli', '@babel/core', '@babel/preset-env', '@babel/register'];
8
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
6
9
  export const CONFIG_FILE_PATTERNS = [
7
10
  'babel.config.json',
8
11
  'babel.config.js',
@@ -11,12 +14,6 @@ export const CONFIG_FILE_PATTERNS = [
11
14
  '.babelrc',
12
15
  'package.json',
13
16
  ];
14
- export const isEnabled = ({ dependencies }) => {
15
- return (dependencies.has('@babel/cli') ||
16
- dependencies.has('@babel/core') ||
17
- dependencies.has('@babel/preset-env') ||
18
- dependencies.has('@babel/register'));
19
- };
20
17
  const api = {
21
18
  caller: () => true,
22
19
  };
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Capacitor";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const findDependencies: GenericPluginCallback;
@@ -1,8 +1,8 @@
1
1
  import { _load } from '../../util/loader.js';
2
2
  import { timerify } from '../../util/performance.js';
3
- export const isEnabled = ({ dependencies }) => {
4
- return dependencies.has('@capacitor/core') || dependencies.has('@capacitor/cli');
5
- };
3
+ export const NAME = 'Capacitor';
4
+ export const ENABLERS = ['@capacitor/core', '@capacitor/cli'];
5
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
6
6
  export const CONFIG_FILE_PATTERNS = ['capacitor.config.ts'];
7
7
  const findCapacitorDependencies = async (configFilePath) => {
8
8
  const config = await _load(configFilePath);
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Changesets";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const findDependencies: GenericPluginCallback;
@@ -1,6 +1,8 @@
1
1
  import { _load } from '../../util/loader.js';
2
2
  import { timerify } from '../../util/performance.js';
3
- export const isEnabled = ({ dependencies }) => dependencies.has('@changesets/cli');
3
+ export const NAME = 'Changesets';
4
+ export const ENABLERS = ['@changesets/cli'];
5
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
4
6
  export const CONFIG_FILE_PATTERNS = ['.changeset/config.json'];
5
7
  const findChangesetsDependencies = async (configFilePath) => {
6
8
  const config = await _load(configFilePath);
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "commitlint";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const findDependencies: GenericPluginCallback;
@@ -1,6 +1,8 @@
1
1
  import { _load } from '../../util/loader.js';
2
2
  import { timerify } from '../../util/performance.js';
3
- export const isEnabled = ({ dependencies }) => dependencies.has('@commitlint/cli');
3
+ export const NAME = 'commitlint';
4
+ export const ENABLERS = ['@commitlint/cli'];
5
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
4
6
  export const CONFIG_FILE_PATTERNS = ['commitlint.config.{js,ts}'];
5
7
  const findCommitLintDependencies = async (configFilePath) => {
6
8
  const config = await _load(configFilePath);
@@ -1,3 +1,5 @@
1
1
  import type { IsPluginEnabledCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Cypress";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const ENTRY_FILE_PATTERNS: string[];
@@ -1,4 +1,6 @@
1
- export const isEnabled = ({ dependencies }) => dependencies.has('cypress');
1
+ export const NAME = 'Cypress';
2
+ export const ENABLERS = ['cypress'];
3
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
2
4
  export const ENTRY_FILE_PATTERNS = [
3
5
  'cypress.config.{js,ts,mjs,cjs}',
4
6
  'cypress/support/e2e.{js,jsx,ts,tsx}',
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "ESLint";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const ENTRY_FILE_PATTERNS: string[];
@@ -6,7 +6,9 @@ import { _load } from '../../util/loader.js';
6
6
  import { getPackageName } from '../../util/modules.js';
7
7
  import { timerify } from '../../util/performance.js';
8
8
  import { resolvePluginPackageName, customResolvePluginPackageNames, getDependenciesFromSettings } from './helpers.js';
9
- export const isEnabled = ({ dependencies }) => dependencies.has('eslint');
9
+ export const NAME = 'ESLint';
10
+ export const ENABLERS = ['eslint'];
11
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
10
12
  export const CONFIG_FILE_PATTERNS = ['.eslintrc', '.eslintrc.{js,json,cjs}', '.eslintrc.{yml,yaml}', 'package.json'];
11
13
  export const ENTRY_FILE_PATTERNS = ['eslint.config.js'];
12
14
  const findESLintDependencies = async (configFilePath, { cwd, manifest, workspaceConfig }) => {
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Gatsby";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const PRODUCTION_ENTRY_FILE_PATTERNS: string[];
@@ -1,8 +1,8 @@
1
1
  import { _load } from '../../util/loader.js';
2
2
  import { timerify } from '../../util/performance.js';
3
- export const isEnabled = ({ dependencies }) => {
4
- return dependencies.has('gatsby') || dependencies.has('gatsby-cli');
5
- };
3
+ export const NAME = 'Gatsby';
4
+ export const ENABLERS = ['gatsby', 'gatsby-cli'];
5
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
6
6
  export const CONFIG_FILE_PATTERNS = ['gatsby-{config,node}.{js,jsx,ts,tsx}'];
7
7
  export const PRODUCTION_ENTRY_FILE_PATTERNS = [
8
8
  'gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Jest";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const ENTRY_FILE_PATTERNS: string[];
@@ -2,9 +2,9 @@ import path from 'node:path';
2
2
  import { _load } from '../../util/loader.js';
3
3
  import { getPackageName } from '../../util/modules.js';
4
4
  import { timerify } from '../../util/performance.js';
5
- export const isEnabled = ({ dependencies }) => {
6
- return dependencies.has('jest');
7
- };
5
+ export const NAME = 'Jest';
6
+ export const ENABLERS = ['jest'];
7
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
8
8
  export const CONFIG_FILE_PATTERNS = ['jest.config.{js,ts,mjs,cjs,json}'];
9
9
  export const ENTRY_FILE_PATTERNS = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
10
10
  const resolveExtensibleConfig = async (configFilePath) => {
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Mocha";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const ENTRY_FILE_PATTERNS: string[];
@@ -1,9 +1,9 @@
1
1
  import { _load } from '../../util/loader.js';
2
2
  import { getPackageName } from '../../util/modules.js';
3
3
  import { timerify } from '../../util/performance.js';
4
- export const isEnabled = ({ dependencies }) => {
5
- return dependencies.has('mocha');
6
- };
4
+ export const NAME = 'Mocha';
5
+ export const ENABLERS = ['mocha'];
6
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
7
7
  export const CONFIG_FILE_PATTERNS = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
8
8
  export const ENTRY_FILE_PATTERNS = ['test/**/*.{js,cjs,mjs}'];
9
9
  const findMochaDependencies = async (configFilePath, { manifest }) => {
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Next.js";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const ENTRY_FILE_PATTERNS: string[];
4
6
  export declare const PRODUCTION_ENTRY_FILE_PATTERNS: string[];
@@ -1,5 +1,5 @@
1
- export const isEnabled = ({ dependencies }) => {
2
- return dependencies.has('next');
3
- };
1
+ export const NAME = 'Next.js';
2
+ export const ENABLERS = ['next'];
3
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
4
4
  export const ENTRY_FILE_PATTERNS = ['next.config.{js,ts}'];
5
5
  export const PRODUCTION_ENTRY_FILE_PATTERNS = ['pages/**/*.{js,jsx,ts,tsx}', 'src/pages/**/*.{js,jsx,ts,tsx}'];
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Nx";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const findDependencies: GenericPluginCallback;
@@ -1,9 +1,9 @@
1
1
  import { compact } from '../../util/array.js';
2
2
  import { _load } from '../../util/loader.js';
3
3
  import { timerify } from '../../util/performance.js';
4
- export const isEnabled = ({ dependencies }) => {
5
- return dependencies.has('@nrwl/workspace');
6
- };
4
+ export const NAME = 'Nx';
5
+ export const ENABLERS = ['@nrwl/workspace'];
6
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
7
7
  export const CONFIG_FILE_PATTERNS = ['{apps,libs}/**/project.json'];
8
8
  const findNxDependencies = async (configFilePath) => {
9
9
  const config = await _load(configFilePath);
@@ -1,4 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "nyc";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
6
  export declare const findDependencies: GenericPluginCallback;
@@ -1,6 +1,8 @@
1
1
  import { _load } from '../../util/loader.js';
2
2
  import { timerify } from '../../util/performance.js';
3
- export const isEnabled = ({ dependencies }) => dependencies.has('nyc');
3
+ export const NAME = 'nyc';
4
+ export const ENABLERS = ['nyc'];
5
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
4
6
  export const CONFIG_FILE_PATTERNS = ['.nycrc', '.nycrc.json', '.nycrc.{yml,yaml}', 'nyc.config.js'];
5
7
  const findNycDependencies = async (configFilePath) => {
6
8
  const config = await _load(configFilePath);
@@ -1,3 +1,5 @@
1
1
  import type { IsPluginEnabledCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Playwright";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const ENTRY_FILE_PATTERNS: string[];
@@ -1,2 +1,4 @@
1
- export const isEnabled = ({ dependencies }) => dependencies.has('@playwright/test');
1
+ export const NAME = 'Playwright';
2
+ export const ENABLERS = ['@playwright/test'];
3
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
2
4
  export const ENTRY_FILE_PATTERNS = ['playwright.config.{js,ts}', '.*{test,spec}.{js,ts,mjs}'];
@@ -1,5 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "PostCSS";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
- export declare const ENTRY_FILE_PATTERNS: string[];
5
6
  export declare const findDependencies: GenericPluginCallback;
@@ -1,9 +1,10 @@
1
1
  import { _load } from '../../util/loader.js';
2
2
  import { getPackageName } from '../../util/modules.js';
3
3
  import { timerify } from '../../util/performance.js';
4
- export const isEnabled = ({ dependencies }) => dependencies.has('postcss');
4
+ export const NAME = 'PostCSS';
5
+ export const ENABLERS = ['postcss'];
6
+ export const isEnabled = ({ dependencies }) => ENABLERS.some(enabler => dependencies.has(enabler));
5
7
  export const CONFIG_FILE_PATTERNS = ['postcss.config.js', 'package.json'];
6
- export const ENTRY_FILE_PATTERNS = ['postcss.config.js'];
7
8
  const findPostCSSDependencies = async (configFilePath, { manifest }) => {
8
9
  const config = configFilePath.endsWith('package.json')
9
10
  ? manifest?.postcss
@@ -1,5 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Prettier";
3
+ export declare const ENABLERS: string[];
2
4
  export declare const isEnabled: IsPluginEnabledCallback;
3
5
  export declare const CONFIG_FILE_PATTERNS: string[];
4
- export declare const ENTRY_FILE_PATTERNS: string[];
5
6
  export declare const findDependencies: GenericPluginCallback;