knip 2.25.1 → 2.26.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ export * as angular from './angular/index.js';
1
2
  export * as ava from './ava/index.js';
2
3
  export * as babel from './babel/index.js';
3
4
  export * as capacitor from './capacitor/index.js';
@@ -1,3 +1,4 @@
1
+ export * as angular from './angular/index.js';
1
2
  export * as ava from './ava/index.js';
2
3
  export * as babel from './babel/index.js';
3
4
  export * as capacitor from './capacitor/index.js';
@@ -6,7 +6,7 @@ export const ENTRY_FILE_PATTERNS = ['next.config.{js,ts,cjs,mjs}'];
6
6
  const productionEntryFilePatternsWithoutSrc = [
7
7
  'middleware.{js,ts}',
8
8
  'app/**/route.{js,ts}',
9
- 'app/**/{error,layout,loading,not-found,page,template}.{js,jsx,tsx}',
9
+ 'app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
10
10
  'instrumentation.{js,ts}',
11
11
  'app/{manifest,sitemap,robots}.{js,ts}',
12
12
  'app/**/{icon,apple-icon}-image.{js,ts,tsx}',
@@ -3,4 +3,5 @@ export declare const NAME = "TypeScript";
3
3
  export declare const ENABLERS: string[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const CONFIG_FILE_PATTERNS: string[];
6
+ export declare const findTypeScriptDependencies: GenericPluginCallback;
6
7
  export declare const findDependencies: GenericPluginCallback;
@@ -23,7 +23,7 @@ const resolveExtensibleConfig = async (configFilePath) => {
23
23
  return config;
24
24
  };
25
25
  const jsxWithReact = [ts.JsxEmit.React, ts.JsxEmit.ReactJSX, ts.JsxEmit.ReactJSXDev, ts.JsxEmit.ReactNative];
26
- const findTypeScriptDependencies = async (configFilePath) => {
26
+ export const findTypeScriptDependencies = async (configFilePath) => {
27
27
  const compilerOptions = await loadTSConfig(configFilePath);
28
28
  const config = await resolveExtensibleConfig(configFilePath);
29
29
  if (!compilerOptions || !config)
@@ -13,7 +13,7 @@ export default ({ report, issues, isShowProgress }) => {
13
13
  const issuesForType = isSet
14
14
  ? Array.from(issues[reportType])
15
15
  : reportType === 'duplicates'
16
- ? Object.values(issues[reportType]).map(Object.values).flat()
16
+ ? Object.values(issues[reportType]).flatMap(Object.values)
17
17
  : Object.values(issues[reportType]).map(issues => {
18
18
  const items = Object.values(issues);
19
19
  return { ...items[0], symbols: items.map(issue => issue.symbol) };
@@ -13,7 +13,7 @@ export default async ({ report, issues, options }) => {
13
13
  const json = {};
14
14
  const codeownersFilePath = resolve(opts.codeowners ?? '.github/CODEOWNERS');
15
15
  const codeownersEngine = isFile(codeownersFilePath) && OwnershipEngine.FromCodeownersFile(codeownersFilePath);
16
- const flatten = (issues) => Object.values(issues).map(Object.values).flat();
16
+ const flatten = (issues) => Object.values(issues).flatMap(Object.values);
17
17
  const initRow = (filePath) => {
18
18
  const file = relative(filePath);
19
19
  const row = {
@@ -1,9 +1,10 @@
1
1
  import { z } from 'zod';
2
- import { ConfigurationValidator } from '../ConfigurationValidator.js';
2
+ import { ConfigurationValidator, pluginSchema } from '../ConfigurationValidator.js';
3
3
  import * as Plugins from '../plugins/index.js';
4
4
  import type { Rules } from './issues.js';
5
5
  import type { SyncCompilers, AsyncCompilers } from '../types/compilers.js';
6
6
  export type RawConfiguration = z.infer<typeof ConfigurationValidator>;
7
+ export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
7
8
  type NormalizedGlob = string[];
8
9
  export type PluginName = keyof typeof Plugins;
9
10
  export type PluginConfiguration = {
@@ -11,7 +12,7 @@ export type PluginConfiguration = {
11
12
  entry: NormalizedGlob | null;
12
13
  project: NormalizedGlob | null;
13
14
  } | false;
14
- type PluginsConfiguration = Record<PluginName, PluginConfiguration>;
15
+ export type PluginsConfiguration = Record<PluginName, PluginConfiguration>;
15
16
  interface BaseWorkspaceConfiguration {
16
17
  entry: NormalizedGlob;
17
18
  project: NormalizedGlob;
@@ -1,3 +1,3 @@
1
1
  import { z } from 'zod';
2
- import { ConfigurationValidator } from '../ConfigurationValidator.js';
2
+ import { ConfigurationValidator, pluginSchema } from '../ConfigurationValidator.js';
3
3
  import * as Plugins from '../plugins/index.js';
@@ -49,6 +49,7 @@ export type ReporterOptions = {
49
49
  isProduction: boolean;
50
50
  isShowProgress: boolean;
51
51
  options: string;
52
+ preprocessorOptions: string;
52
53
  };
53
54
  export type Reporter = (options: ReporterOptions) => void;
54
55
  export type Preprocessor = (options: ReporterOptions) => ReporterOptions;
@@ -1,4 +1,4 @@
1
- export declare const helpText = "\u2702\uFE0F Find unused files, dependencies and exports in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n --production Analyze only production source files (e.g. no tests, devDependencies, exported types)\n --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n --ignore-internal Ignore exports with tag @internal (JSDoc/TSDoc)\n -W, --workspace [dir] Analyze a single workspace (default: analyze all configured workspaces)\n --no-gitignore Don't use .gitignore\n --include Report only provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,unresolved\n --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates\n --include-entry-exports Include entry files when reporting unused exports\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n --preprocessor Preprocess the results before providing it to the reporter(s), can be repeated\n --reporter Select reporter: symbols, compact, codeowners, json, can be repeated (default: symbols)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --no-config-hints Suppress configuration hints\n --no-exit-code Always exit with code zero (0)\n --max-issues Maximum number of issues before non-zero exit code (default: 0)\n -d, --debug Show debug output\n --debug-file-filter Filter for files in debug output (regex as string)\n --performance Measure count and running time of expensive functions and display stats table\n -h, --help Print this help text\n -V, --version Print version\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n$ knip --debug --debug-file-filter '(specific|particular)-module'\n\nMore documentation and bug reports: https://github.com/webpro/knip";
1
+ export declare const helpText = "\u2702\uFE0F Find unused files, dependencies and exports in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n --production Analyze only production source files (e.g. no tests, devDependencies, exported types)\n --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n --ignore-internal Ignore exports with tag @internal (JSDoc/TSDoc)\n -W, --workspace [dir] Analyze a single workspace (default: analyze all configured workspaces)\n --no-gitignore Don't use .gitignore\n --include Report only provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,unresolved\n --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates\n --include-entry-exports Include entry files when reporting unused exports\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n --preprocessor Preprocess the results before providing it to the reporter(s), can be repeated\n --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)\n --reporter Select reporter: symbols, compact, codeowners, json, can be repeated (default: symbols)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --no-config-hints Suppress configuration hints\n --no-exit-code Always exit with code zero (0)\n --max-issues Maximum number of issues before non-zero exit code (default: 0)\n -d, --debug Show debug output\n --debug-file-filter Filter for files in debug output (regex as string)\n --performance Measure count and running time of expensive functions and display stats table\n -h, --help Print this help text\n -V, --version Print version\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n$ knip --debug --debug-file-filter '(specific|particular)-module'\n\nMore documentation and bug reports: https://github.com/webpro/knip";
2
2
  declare const _default: {
3
3
  config: string | undefined;
4
4
  debug: boolean | undefined;
@@ -18,6 +18,7 @@ declare const _default: {
18
18
  performance: boolean | undefined;
19
19
  production: boolean | undefined;
20
20
  preprocessor: string[] | undefined;
21
+ 'preprocessor-options': string | undefined;
21
22
  reporter: string[] | undefined;
22
23
  'reporter-options': string | undefined;
23
24
  strict: boolean | undefined;
@@ -18,6 +18,7 @@ Options:
18
18
  --include-entry-exports Include entry files when reporting unused exports
19
19
  -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)
20
20
  --preprocessor Preprocess the results before providing it to the reporter(s), can be repeated
21
+ --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)
21
22
  --reporter Select reporter: symbols, compact, codeowners, json, can be repeated (default: symbols)
22
23
  --reporter-options Pass extra options to the reporter (as JSON string, see example)
23
24
  --no-config-hints Suppress configuration hints
@@ -63,6 +64,7 @@ try {
63
64
  performance: { type: 'boolean' },
64
65
  production: { type: 'boolean' },
65
66
  preprocessor: { type: 'string', multiple: true },
67
+ 'preprocessor-options': { type: 'string' },
66
68
  reporter: { type: 'string', multiple: true },
67
69
  'reporter-options': { type: 'string' },
68
70
  strict: { type: 'boolean' },
@@ -22,6 +22,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
22
22
  ignore?: string | string[] | undefined;
23
23
  ignoreBinaries?: string[] | undefined;
24
24
  ignoreDependencies?: string[] | undefined;
25
+ angular?: string | false | string[] | {
26
+ config?: string | string[] | undefined;
27
+ entry?: string | string[] | undefined;
28
+ project?: string | string[] | undefined;
29
+ } | undefined;
25
30
  ava?: string | false | string[] | {
26
31
  config?: string | string[] | undefined;
27
32
  entry?: string | string[] | undefined;
@@ -218,6 +223,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
218
223
  project?: string | string[] | undefined;
219
224
  } | undefined;
220
225
  }> | undefined;
226
+ angular?: string | false | string[] | {
227
+ config?: string | string[] | undefined;
228
+ entry?: string | string[] | undefined;
229
+ project?: string | string[] | undefined;
230
+ } | undefined;
221
231
  ava?: string | false | string[] | {
222
232
  config?: string | string[] | undefined;
223
233
  entry?: string | string[] | undefined;
@@ -1,3 +1,9 @@
1
1
  export { _load as load } from './loader.js';
2
+ import type { RawPluginConfiguration } from 'src/types/config.js';
2
3
  export declare const toCamelCase: (name: string) => string;
3
4
  export declare const hasDependency: (dependencies: Set<string>, values: (string | RegExp)[]) => boolean;
5
+ export declare const normalizePluginConfig: (pluginConfig: RawPluginConfiguration) => false | {
6
+ config: string[] | null;
7
+ entry: string[] | null;
8
+ project: string[] | null;
9
+ };
@@ -1,4 +1,5 @@
1
1
  export { _load as load } from './loader.js';
2
+ import { arrayify } from './array.js';
2
3
  export const toCamelCase = (name) => name.toLowerCase().replace(/(-[a-z])/g, group => group.toUpperCase().replace('-', ''));
3
4
  export const hasDependency = (dependencies, values) => values.some(value => {
4
5
  if (typeof value === 'string') {
@@ -12,3 +13,15 @@ export const hasDependency = (dependencies, values) => values.some(value => {
12
13
  }
13
14
  return false;
14
15
  });
16
+ export const normalizePluginConfig = (pluginConfig) => {
17
+ if (pluginConfig === false) {
18
+ return false;
19
+ }
20
+ else {
21
+ const isObject = typeof pluginConfig !== 'string' && !Array.isArray(pluginConfig);
22
+ const config = isObject ? arrayify(pluginConfig.config) : pluginConfig ? arrayify(pluginConfig) : null;
23
+ const entry = isObject && 'entry' in pluginConfig ? arrayify(pluginConfig.entry) : null;
24
+ const project = isObject && 'project' in pluginConfig ? arrayify(pluginConfig.project) : entry;
25
+ return { config, entry, project };
26
+ }
27
+ };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.25.1";
1
+ export declare const version = "2.26.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.25.1';
1
+ export const version = '2.26.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.25.1",
3
+ "version": "2.26.0",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://github.com/webpro/knip",
6
6
  "repository": "github:webpro/knip",
package/schema.json CHANGED
@@ -220,6 +220,10 @@
220
220
  },
221
221
  "plugins": {
222
222
  "properties": {
223
+ "angular": {
224
+ "title": "angular plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/angular/README.md)",
225
+ "$ref": "#/definitions/plugin"
226
+ },
223
227
  "ava": {
224
228
  "title": "ava plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/ava/README.md)",
225
229
  "$ref": "#/definitions/plugin"