knip 2.19.3 → 2.19.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.
package/README.md CHANGED
@@ -32,20 +32,57 @@ Knip shines in both small and large projects. It's a fresh take on keeping your
32
32
  [![An orange cow with scissors, Van Gogh style][7]][6] <sup>_“An orange cow with scissors, Van Gogh style” - generated
33
33
  with OpenAI_</sup>
34
34
 
35
- ## Installation
35
+ 📡 For updates, watch this repository or follow [@webprolific (Twitter)][8] or [@webpro (fosstodon.org)][9].
36
+
37
+ ## Contents
38
+
39
+ - [Getting Started][10]
40
+ - [Installation][11]
41
+ - [Default Configuration][12]
42
+ - [Let's Go!][13]
43
+ - [Configuration][14]
44
+ - [Entry Files][15]
45
+ - [Workspaces][1]
46
+ - [Plugins][2]
47
+ - [Compilers][3]
48
+ - [Ignore files, binaries, dependencies and workspaces][16]
49
+ - [Public exports][17]
50
+ - [Ignore exports used in file][18]
51
+ - [Include exports in entry files][19]
52
+ - [Paths][20]
53
+ - [Production Mode][21]
54
+ - [Strict][22]
55
+ - [Plugins][23]
56
+ - [Output][24]
57
+ - [Screenshots][25]
58
+ - [Reading the report][26]
59
+ - [Rules & Filters][27]
60
+ - [Reporters][4]
61
+ - [Fixing Issues][28]
62
+ - [Command Line Options][29]
63
+ - [Potential boost with `--no-gitignore`][30]
64
+ - [Comparison & Migration][31]
65
+ - [depcheck][32]
66
+ - [unimported][33]
67
+ - [ts-unused-exports][34]
68
+ - [ts-prune][35]
69
+ - [Projects using Knip][36]
70
+ - [Articles, etc.][37]
71
+ - [Why "Knip"?][38]
72
+ - [Really, another unused file/dependency/export finder?][39]
73
+ - [Contributors][40]
74
+
75
+ ## Getting Started
76
+
77
+ ### Installation
36
78
 
37
79
  npm install -D knip
38
80
 
39
81
  Knip supports LTS versions of Node.js, and currently requires at least Node.js v16.17 or v18.6.
40
82
 
41
- ## Experimental: knowledge base
83
+ ### Default Configuration
42
84
 
43
- You might want to ask your questions in the [Knip knowledge base][8] (powered by OpenAI and [7-docs][9]). This is an
44
- experimental knowledge base, answers may be incorrect.
45
-
46
- ## Configuration
47
-
48
- Knip has good defaults and you can run it without any configuration. Here's the default:
85
+ Knip has good defaults and you can run it without any configuration. The (simplified) default config:
49
86
 
50
87
  ```json
51
88
  {
@@ -54,37 +91,7 @@ Knip has good defaults and you can run it without any configuration. Here's the
54
91
  }
55
92
  ```
56
93
 
57
- In addition to `index.js`, the following file names and extensions are also considered entry files:
58
-
59
- - `index`, `main` and `cli`
60
- - `js`, `mjs`, `cjs`, `jsx`, `ts`, `mts`, `cts` and `tsx`
61
-
62
- This means files like `main.cjs` and `src/cli.ts` are automatically added as entry files.
63
-
64
- ### Entry Files
65
-
66
- Knip looks for entry files at those default locations, but also in other places:
67
-
68
- - The `main`, `bin` and `exports` fields of `package.json`.
69
- - [Plugins][2] such as for Next.js, Remix, Gatsby or Svelte add entry files.
70
- - The `scripts` in package.json or other scripts may provide entry files.
71
-
72
- Knip does this for each [workspace][1] it finds, trying to minimize the configuration to suit your project. In a
73
- perfectly boring world where everything is according to defaults you wouldn't even need a `knip.json` file at all.
74
-
75
- Larger projects tend to have more things customized, and therefore probably get more out of Knip with a configuration
76
- file. Let's say you are using `.ts` files exclusively and have all source files only in the `src` directory:
77
-
78
- ```json
79
- {
80
- "$schema": "https://unpkg.com/knip@2/schema.json",
81
- "entry": ["src/index.ts"],
82
- "project": ["src/**/*.ts"]
83
- }
84
- ```
85
-
86
- The `entry` files target the starting point(s) to resolve the rest of the imported code. The `project` files should
87
- contain all files to match against the files resolved from the entry files, including potentially unused files.
94
+ There's more, jump to [Entry Files][15] for details.
88
95
 
89
96
  Places where Knip looks for configuration (ordered by priority):
90
97
 
@@ -96,7 +103,7 @@ Places where Knip looks for configuration (ordered by priority):
96
103
  - `knip.js`
97
104
  - `package.json#knip`
98
105
 
99
- So you can use a dynamic `knip.ts` with TypeScript if you prefer:
106
+ You can use a dynamic `knip.ts` with TypeScript if you prefer:
100
107
 
101
108
  ```ts
102
109
  import type { KnipConfig } from 'knip';
@@ -109,191 +116,59 @@ const config: KnipConfig = {
109
116
  export default config;
110
117
  ```
111
118
 
112
- Then run the checks with `npx knip`. Or first add this script to `package.json`:
113
-
114
- ```json
115
- {
116
- "scripts": {
117
- "knip": "knip"
118
- }
119
- }
120
- ```
121
-
122
- Use `npm run knip` to analyze the project and output unused files, dependencies and exports. Knip works just fine with
123
- `yarn` or `pnpm` as well.
124
-
125
- Using workspaces in a monorepo? Please see [workspaces][1] for more details about configuring them.
126
-
127
- ## Command-line options
128
-
129
- $ npx knip --help
130
- ✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects
131
-
132
- Usage: knip [options]
133
-
134
- Options:
135
- -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)
136
- -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)
137
- --production Analyze only production source files (e.g. no tests, devDependencies, exported types)
138
- --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)
139
- --workspace [dir] Analyze a single workspace (default: analyze all configured workspaces)
140
- --no-gitignore Don't use .gitignore
141
- --include Report only provided issue type(s), can be comma-separated or repeated (1)
142
- --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)
143
- --dependencies Shortcut for --include dependencies,unlisted,unresolved
144
- --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates
145
- --include-entry-exports Include entry files when reporting unused exports
146
- -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)
147
- --reporter Select reporter: symbols, compact, codeowners, json (default: symbols)
148
- --reporter-options Pass extra options to the reporter (as JSON string, see example)
149
- --no-config-hints Suppress configuration hints
150
- --no-exit-code Always exit with code zero (0)
151
- --max-issues Maximum number of issues before non-zero exit code (default: 0)
152
- -d, --debug Show debug output
153
- --debug-file-filter Filter for files in debug output (regex as string)
154
- --performance Measure count and running time of expensive functions and display stats table
155
- -h, --help Print this help text
156
- -V, --version Print version
157
-
158
- (1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates
159
-
160
- Examples:
161
-
162
- $ knip
163
- $ knip --production
164
- $ knip --workspace packages/client --include files,dependencies
165
- $ knip -c ./config/knip.json --reporter compact
166
- $ knip --reporter codeowners --reporter-options '{"path":".github/CODEOWNERS"}'
167
- $ knip --debug --debug-file-filter '(specific|particular)-module'
168
-
169
- More documentation and bug reports: https://github.com/webpro/knip
170
-
171
- ## Screenshots
172
-
173
- Here's an example run using the default reporter:
174
-
175
- <img src="./assets/screenshot-exports.png" alt="example output of exported values and types" width="578">
176
-
177
- This example shows more output related to unused and unlisted dependencies:
178
-
179
- <img src="./assets/screenshot-dependencies.png" alt="example output of dependencies" width="578">
119
+ Use `--config path/to/knip.json` to use a different location.
180
120
 
181
- ## Reading the report
121
+ ### Let's Go!
182
122
 
183
- The report contains the following types of issues:
184
-
185
- | Key | Title | Description |
186
- | :---------------- | :---------------------------------- | :---------------------------------------------------- |
187
- | `files` | Unused files | unable to find references to this file |
188
- | `dependencies` | Unused dependencies | unable to find references to this dependency |
189
- | `devDependencies` | Unused devDependencies | unable to find references to this devDependency |
190
- | `unlisted` | Unlisted dependencies | used dependencies not listed in package.json |
191
- | `binaries` | Unlisted binaries | binaries from dependencies not in package.json |
192
- | `unresolved` | Unresolved imports | unable to resolve this (import) specifier |
193
- | `exports` | Unused exports | unable to find references to this export |
194
- | `nsExports` | Unused exports in namespaces | unable to find direct references to this export _(1)_ |
195
- | `types` | Unused exported types | unable to find references to this exported type |
196
- | `nsTypes` | Unused exported types in namespaces | unable to find direct references to this export _(1)_ |
197
- | `enumMembers` | Unused exported enum members | unable to find references to this enum member |
198
- | `classMembers` | Unused exported class members | unable to find references to this class member |
199
- | `duplicates` | Duplicate exports | the same thing is exported more than once |
200
-
201
- When an issue type has zero issues, it is not shown.
202
-
203
- Getting too many reported issues and false positives? Read more about [handling issues][10].
204
-
205
- _(1)_ The variable or type is not referenced directly and has become a member of a namespace. Knip can't find a
206
- reference to it, so you can _probably_ remove it.
207
-
208
- ## Output
209
-
210
- ### Rules
211
-
212
- Use `rules` in the configuration to customize the issue types that count towards the total error count, or to exclude
213
- them altogether.
214
-
215
- - `error` (default): printed, adds to total error count (similar to the `--include` filter)
216
- - `warn`: printed in faded/grey color, does not add to error count (i.e. the exit code)
217
- - `off`: not printed, does not add to error count (similar to the `--exclude` filter)
218
-
219
- Example:
123
+ Run the checks with `npx knip`. Or first add this script to `package.json`:
220
124
 
221
125
  ```json
222
126
  {
223
- "rules": {
224
- "files": "warn",
225
- "classMembers": "off",
226
- "duplicates": "off"
127
+ "scripts": {
128
+ "knip": "knip"
227
129
  }
228
130
  }
229
131
  ```
230
132
 
231
- See [reading the report][11] for the list of issue types.
232
-
233
- The rules are modeled after the ESLint `rules` configuration, and could be extended in the future. For instance, to
234
- apply filters or configurations only to a specific issue type.
235
-
236
- ### Filters
237
-
238
- You can `--include` or `--exclude` any of the reported issue types to slice & dice the report to your needs.
239
- Alternatively, they can be added to the configuration (e.g. `"exclude": ["dependencies"]`).
240
-
241
- Use `--include` to report only specific issue types (the following example commands do the same):
242
-
243
- knip --include files --include dependencies
244
- knip --include files,dependencies
133
+ Then use `npm run knip` to analyze the project and output unused files, dependencies and exports. Knip works just fine
134
+ with `yarn` or `pnpm` as well.
245
135
 
246
- Use `--exclude` to ignore reports you're not interested in:
136
+ See [Command Line Options][29] for an overview of available CLI options.
247
137
 
248
- knip --include files --exclude classMembers,enumMembers
138
+ ## Configuration
249
139
 
250
- Use `--dependencies` or `--exports` as shortcuts to combine groups of related types.
140
+ ### Entry Files
251
141
 
252
- See [reading the report][11] for the list of issue types.
142
+ In addition to `index.js`, the following file names and extensions are also considered entry files:
253
143
 
254
- ### When to use rules or filters
144
+ - `index`, `main` and `cli`
145
+ - `js`, `mjs`, `cjs`, `jsx`, `ts`, `mts`, `cts` and `tsx`
255
146
 
256
- Filters are meant to be used as command-line flags, rules allow for more fine-grained configuration.
147
+ This means files like `main.cjs` and `src/cli.ts` are automatically added as entry files. Knip looks for entry files at
148
+ those default locations, but also in other places:
257
149
 
258
- - Rules are more fine-grained since they also have "warn".
259
- - Rules could be extended in the future.
260
- - Filters can be set in configuration and from CLI, rules only in configuration.
261
- - Filters have two groups (`--dependencies` and `--types`), rules don't have any grouping.
150
+ - The `main`, `bin` and `exports` fields of `package.json`.
151
+ - [Plugins][2] such as for Next.js, Remix, Gatsby or Svelte add entry files.
152
+ - The `scripts` in package.json or other scripts may provide entry files.
262
153
 
263
- ## Ignore
154
+ Knip does this for each [workspace][1] it finds, trying to minimize the configuration to suit your project. In a
155
+ perfectly boring world where everything is according to defaults you wouldn't even need a `knip.json` file at all.
264
156
 
265
- There are a few ways to tell Knip to ignore certain packages, binaries, dependencies and workspaces. Some examples:
157
+ Larger projects tend to have more things customized, and therefore probably get more out of Knip with a configuration
158
+ file. Let's say you are using `.ts` files exclusively and have all source files only in the `src` directory:
266
159
 
267
160
  ```json
268
161
  {
269
- "ignore": ["**/*.d.ts", "**/fixtures"],
270
- "ignoreBinaries": ["zip", "docker-compose"],
271
- "ignoreDependencies": ["hidden-package"],
272
- "ignoreWorkspaces": ["packages/ignore", "packages/examples/**"]
162
+ "$schema": "https://unpkg.com/knip@2/schema.json",
163
+ "entry": ["src/index.ts"],
164
+ "project": ["src/**/*.ts"]
273
165
  }
274
166
  ```
275
167
 
276
- These can also be configured per workspace (except for `ignoreWorkspaces`).
277
-
278
- ## What's next?
279
-
280
- This is the fun part! Knip, knip, knip ✂️
281
-
282
- As always, make sure to back up files or use Git before deleting files or making changes. Run tests to verify results.
283
-
284
- - Unused files can be removed.
285
- - Unused dependencies can be removed from `package.json`.
286
- - Unlisted dependencies should be added to `package.json`.
287
- - Unresolved imports should be reviewed.
288
- - Unused exports and types: remove the `export` keyword in front of unused exports. Then you can see whether the
289
- variable or type is used within the same file. If this is not the case, it can be removed.
290
- - Duplicate exports can be removed so they're exported only once.
291
-
292
- 🔁 Repeat the process to reveal new unused files and exports. Sometimes it's so liberating to remove things!
293
-
294
- Getting too many reported issues and false positives? Read more about [handling issues][10].
168
+ The `entry` files target the starting point(s) to resolve the rest of the imported code. The `project` files should
169
+ contain all files to match against the files resolved from the entry files, including potentially unused files.
295
170
 
296
- ## Workspaces
171
+ ### Workspaces
297
172
 
298
173
  Workspaces are handled out-of-the-box by Knip. Every workspace is part of the analysis.
299
174
 
@@ -321,22 +196,20 @@ Here's an example `knip.json` configuration with some custom `entry` and `projec
321
196
  ```
322
197
 
323
198
  It might be useful to run Knip first with no or little configuration to see where it needs custom `entry` and/or
324
- `project` files. Each workspace has the same [default configuration][12].
199
+ `project` files. Each workspace has the same [default configuration][14].
325
200
 
326
201
  The root workspace is named `"."` under `workspaces` (like in the example).
327
202
 
328
203
  Knip supports workspaces as defined in three possible locations:
329
204
 
330
205
  - In the `workspaces` array in `package.json` (npm, Yarn, Lerna).
331
- - In the `workspaces.packages` array in `package.json` (legacy).
332
206
  - In the `packages` array in `pnpm-workspace.yaml` (pnpm).
207
+ - In the `workspaces.packages` array in `package.json` (legacy).
333
208
  - In the `workspaces` object in Knip configuration.
334
209
 
335
210
  The `workspaces` in Knip configuration not already defined in the root `package.json` or `pnpm-workspace.yaml` are
336
211
  added. Knip requires a `package.json` file in each workspace directory.
337
212
 
338
- The `ignore`, `ignoreBinaries` and `ignoreDependencies` options are available inside workspace configurations.
339
-
340
213
  Here's some example output when running Knip in a workspace:
341
214
 
342
215
  <img src="./assets/screenshot-workspaces.png" alt="example output in workspaces" width="578">
@@ -345,12 +218,14 @@ Use `--debug` to get more verbose output.
345
218
 
346
219
  Use `--workspace [dir]` to analyze a single workspace (including its ancestors).
347
220
 
348
- ## Plugins
221
+ The `ignore`, `ignoreBinaries` and `ignoreDependencies` options are available inside workspace configurations.
222
+
223
+ ### Plugins
349
224
 
350
225
  Plugins tell Knip where to look for configuration and entry files, and if necessary have a custom dependency finder.
351
226
  Knip plugins are automatically activated, you don't need to install or configure anything.
352
227
 
353
- To explain what they do, here's a quick example from a `.eslintrc.json` configuration file (for ESLint):
228
+ To explain what they do, here's a quick example `.eslintrc.json` configuration file (for ESLint):
354
229
 
355
230
  ```json
356
231
  {
@@ -415,18 +290,18 @@ themselves and/or `entry` files for Knip to analyze.
415
290
 
416
291
  See each plugin's documentation for its default values.
417
292
 
418
- ### `config`
293
+ #### `config`
419
294
 
420
295
  Plugins usually include `config` files. They are handled by the plugin's custom dependency finder, which returns all
421
296
  dependencies referenced in the files it is given. Knip handles the rest to determine which of those dependencies are
422
297
  unused or missing.
423
298
 
424
- ### `entry`
299
+ #### `entry`
425
300
 
426
301
  Other configuration files use `require` or `import` statements to use dependencies, so they don't need special handing
427
302
  and can be analyzed like any other source file. That's why these configuration files are also used as `entry` files.
428
303
 
429
- ### Override plugin configuration
304
+ #### Override plugin configuration
430
305
 
431
306
  Usually, no custom configuration is required for plugins, but if your project uses custom file locations then Knip
432
307
  allows you to override any defaults. Let's take Cypress for example. By default it uses `cypress.config.js`, but your
@@ -441,10 +316,10 @@ has them at `e2e-tests/*.spec.ts`. Here's how to configure this:
441
316
  }
442
317
  ```
443
318
 
444
- ### Multi-project repositories
319
+ #### Multi-project repositories
445
320
 
446
321
  Some repositories have a single `package.json`, but consist of multiple projects with configuration files across the
447
- repository (such as the [Nx "intregrated repo" style][13]). Let's assume some of these projects are apps and have their
322
+ repository (such as the [Nx "intregrated repo" style][41]). Let's assume some of these projects are apps and have their
448
323
  own Cypress configuration and test files. In that case, we could configure the Cypress plugin like this:
449
324
 
450
325
  ```json
@@ -455,24 +330,24 @@ own Cypress configuration and test files. In that case, we could configure the C
455
330
  }
456
331
  ```
457
332
 
458
- ### Disable a plugin
333
+ #### Disable a plugin
459
334
 
460
335
  In case a plugin causes issues, it can be disabled by using `false` as its value (e.g. `"webpack": false`).
461
336
 
462
- ### Create a new plugin
337
+ #### Create a new plugin
463
338
 
464
- Getting false positives because a plugin is missing? Want to help out? Please read more at [writing a plugin][14]. This
339
+ Getting false positives because a plugin is missing? Want to help out? Please read more at [writing a plugin][42]. This
465
340
  guide also contains more details if you want to learn more about plugins and why they are useful.
466
341
 
467
- ## Compilers
342
+ ### Compilers
468
343
 
469
- Knip v2 introduces compilers that allow to include files that are not JavaScript or TypeScript in the process of finding
470
- unused or missing dependencies. For instance, `.mdx`, `.vue` and `.svelte` files come to mind.
344
+ Compilers allow to include files that are not JavaScript or TypeScript in the process of finding unused or missing
345
+ dependencies (e.g. `.mdx`, `.vue` and `.svelte` files).
471
346
 
472
- Currently, this is only supported by using `knip.js` or `knip.ts`. Provide a `compilers` object in the configuration
473
- where each key represents the extension and the value is a function that takes the contents of these files as input and
474
- returns JavaScript or TypeScript as output. Here is an example that compiles `.mdx` files to JavaScript so these files
475
- and their imports and exports become part of the analysis:
347
+ This requires using a dynamic `knip.js` or `knip.ts` configuration file. Provide a `compilers` object in the
348
+ configuration where each key represents the extension and the value is a function that takes the contents of these files
349
+ as input and returns JavaScript or TypeScript as output. Here is an example that compiles `.mdx` files to JavaScript so
350
+ these files and their imports and exports become part of the analysis:
476
351
 
477
352
  ```js
478
353
  import { compileSync } from 'mdx-js/mdx';
@@ -484,7 +359,95 @@ export default {
484
359
  };
485
360
  ```
486
361
 
487
- Read [Compilers][15] for more details and examples.
362
+ Read [Compilers][43] for more details and examples.
363
+
364
+ ### Ignore files, binaries, dependencies and workspaces
365
+
366
+ There are a few ways to tell Knip to ignore certain files, binaries, dependencies and workspaces. Some examples:
367
+
368
+ ```json
369
+ {
370
+ "ignore": ["**/*.d.ts", "**/fixtures"],
371
+ "ignoreBinaries": ["zip", "docker-compose"],
372
+ "ignoreDependencies": ["hidden-package"],
373
+ "ignoreWorkspaces": ["packages/ignore", "packages/examples/**"]
374
+ }
375
+ ```
376
+
377
+ These can also be configured per workspace (except for `ignoreWorkspaces`).
378
+
379
+ ### Public exports
380
+
381
+ Sometimes a file that's not an entry file has one or more exports that are public and should not be reported as unused.
382
+ Such variables and types can be marked with the JSDoc `@public` tag:
383
+
384
+ ```js
385
+ /**
386
+ * Merge two objects.
387
+ *
388
+ * @public
389
+ */
390
+
391
+ export const merge = function () {};
392
+
393
+ /** @public */
394
+ export const split = function () {};
395
+ ```
396
+
397
+ Knip does not report public exports and types as unused.
398
+
399
+ ### Ignore exports used in file
400
+
401
+ In files with multiple exports, some of them might be used only internally. If these exports should not be reported,
402
+ there is a `ignoreExportsUsedInFile` option available. With this option enabled, you don't need to mark everything
403
+ `@public` separately and when something is no longer used internally, it will still be reported.
404
+
405
+ ```json
406
+ {
407
+ "ignoreExportsUsedInFile": true
408
+ }
409
+ ```
410
+
411
+ In a more fine-grained manner, you can also ignore only specific issue types:
412
+
413
+ ```json
414
+ {
415
+ "ignoreExportsUsedInFile": {
416
+ "interface": true,
417
+ "type": true
418
+ }
419
+ }
420
+ ```
421
+
422
+ ### Include exports in entry files
423
+
424
+ When a repository is self-contained or private, you may want to include entry files when reporting unused exports:
425
+
426
+ knip --include-entry-exports
427
+
428
+ Knip will also report unused exports in entry source files and scripts (such as those referenced in `package.json`). But
429
+ not in entry and configuration files from plugins, such as `next.config.js` or `src/routes/+page.svelte`.
430
+
431
+ ### Paths
432
+
433
+ Tools like TypeScript, Webpack and Babel support import aliases in various ways. Knip automatically includes
434
+ `compilerOptions.paths` from the TypeScript configuration, but does not (yet) automatically find other types of import
435
+ aliases. They can be configured manually:
436
+
437
+ ```json
438
+ {
439
+ "$schema": "https://unpkg.com/knip@2/schema.json",
440
+ "paths": {
441
+ "@lib": ["./lib/index.ts"],
442
+ "@lib/*": ["./lib/*"]
443
+ }
444
+ }
445
+ ```
446
+
447
+ Each workspace can also have its own `paths` configured. Knip `paths` follow the TypeScript semantics:
448
+
449
+ - Path values are an array of relative paths.
450
+ - Paths without an `*` are exact matches.
488
451
 
489
452
  ## Production Mode
490
453
 
@@ -521,110 +484,192 @@ Additionally, the `--strict` flag can be used to:
521
484
  ### Plugins
522
485
 
523
486
  Plugins also have this distinction. For instance, Next.js entry files for pages (`pages/**/*.tsx`) and Remix routes
524
- (`app/routes/**/*.tsx`) are production code, while Jest and Storybook entry files (e.g. `*.spec.ts` or `*.stories.js`)
525
- are not. All of this is handled automatically by Knip and its plugins.
487
+ (`app/routes/**/*.tsx`) represent production code, while Jest and Storybook entry files (e.g. `*.spec.ts` or
488
+ `*.stories.js`) do not. All of this is handled automatically by Knip and its plugins.
526
489
 
527
- ## Paths
490
+ ## Output
528
491
 
529
- Tools like TypeScript, Webpack and Babel support import aliases in various ways. Knip automatically includes
530
- `compilerOptions.paths` from the TypeScript configuration, but does not (yet) automatically find other types of import
531
- aliases. They can be configured manually:
492
+ ### Screenshots
493
+
494
+ Here's an example run using the default reporter:
495
+
496
+ <img src="./assets/screenshot-exports.png" alt="example output of exported values and types" width="578">
497
+
498
+ This example shows more output related to unused and unlisted dependencies:
499
+
500
+ <img src="./assets/screenshot-dependencies.png" alt="example output of dependencies" width="578">
501
+
502
+ ### Reading the report
503
+
504
+ The report contains the following types of issues:
505
+
506
+ | Title | Description | Key |
507
+ | :---------------------------------- | :---------------------------------------------- | :------------- |
508
+ | Unused files | unable to find references to this file | `files` |
509
+ | Unused dependencies | unable to find references to this dependency | `dependencies` |
510
+ | Unused devDependencies | unable to find references to this devDependency | `dependencies` |
511
+ | Unlisted dependencies | used dependencies not listed in package.json | `unlisted` |
512
+ | Unlisted binaries | binaries from deps not listed in package.json | `binaries` |
513
+ | Unresolved imports | unable to resolve this (import) specifier | `unresolved` |
514
+ | Unused exports | unable to find references to this export | `exports` |
515
+ | Unused exports in namespaces | unable to find direct references to this export | `nsExports` |
516
+ | Unused exported types | unable to find references to this exported type | `types` |
517
+ | Unused exported types in namespaces | unable to find direct references to this export | `nsTypes` |
518
+ | Unused exported enum members | unable to find references to this enum member | `enumMembers` |
519
+ | Unused exported class members | unable to find references to this class member | `classMembers` |
520
+ | Duplicate exports | the same thing is exported more than once | `duplicates` |
521
+
522
+ When an issue type has zero issues, it is not shown.
523
+
524
+ Getting too many reported issues and false positives? Read more about [handling issues][44].
525
+
526
+ ### Rules & Filters
527
+
528
+ Use rules or filters if you don't (yet) want all issue types Knip reports.
529
+
530
+ #### Rules
531
+
532
+ Use `rules` in the configuration to customize the issue types that count towards the total error count, or to exclude
533
+ them altogether.
534
+
535
+ - `error` (default): printed, adds to total error count (similar to the `--include` filter)
536
+ - `warn`: printed in faded/grey color, does not add to error count (i.e. the exit code)
537
+ - `off`: not printed, does not add to error count (similar to the `--exclude` filter)
538
+
539
+ Example:
532
540
 
533
541
  ```json
534
542
  {
535
- "$schema": "https://unpkg.com/knip@2/schema.json",
536
- "paths": {
537
- "@lib": ["./lib/index.ts"],
538
- "@lib/*": ["./lib/*"]
543
+ "rules": {
544
+ "files": "warn",
545
+ "classMembers": "off",
546
+ "duplicates": "off"
539
547
  }
540
548
  }
541
549
  ```
542
550
 
543
- Each workspace can also have its own `paths` configured. Note that Knip `paths` follow the TypeScript semantics:
551
+ See [reading the report][26] for the list of issue types.
544
552
 
545
- - Path values are an array of relative paths.
546
- - Paths without an `*` are exact matches.
553
+ The rules are modeled after the ESLint `rules` configuration, and could be extended in the future. For instance, to
554
+ apply filters or configurations only to a specific issue type.
555
+
556
+ #### Filters
557
+
558
+ You can `--include` or `--exclude` any of the reported issue types to slice & dice the report to your needs.
559
+ Alternatively, they can be added to the configuration (e.g. `"exclude": ["dependencies"]`).
560
+
561
+ Use `--include` to report only specific issue types (the following example commands do the same):
547
562
 
548
- ## Reporters
563
+ knip --include files --include dependencies
564
+ knip --include files,dependencies
565
+
566
+ Use `--exclude` to ignore reports you're not interested in:
567
+
568
+ knip --include files --exclude classMembers,enumMembers
569
+
570
+ Use `--dependencies` or `--exports` as shortcuts to combine groups of related types.
571
+
572
+ See [reading the report][26] for the list of issue types.
573
+
574
+ #### When to use rules or filters
575
+
576
+ Filters are meant to be used as command-line flags, rules allow for more fine-grained configuration.
577
+
578
+ - Rules are more fine-grained since they also have "warn".
579
+ - Rules could be extended in the future.
580
+ - Filters can be set in configuration and from CLI, rules only in configuration.
581
+ - Filters have two groups (`--dependencies` and `--exports`), rules don't have any grouping.
582
+
583
+ ### Reporters
549
584
 
550
585
  Knip provides the following built-in reporters:
551
586
 
552
587
  - codeowners
553
588
  - compact
554
589
  - json
555
- - symbol
590
+ - symbol (default)
556
591
 
557
- ### Custom Reporters
592
+ #### Custom Reporters
558
593
 
559
594
  When the provided built-in reporters are not sufficient, a custom reporter can be implemented.
560
595
 
561
- Pass `--reporter ./my-reporter` from the command line. The data can then be used to write issues to `stdout`, a JSON or
562
- CSV file, or sent to a service.
596
+ Pass something like `--reporter ./my-reporter` from the command line. The results are passed to the function from its
597
+ default export and can be used to write issues to `stdout`, a JSON or CSV file, or sent to a service.
563
598
 
564
- Find more details and ideas in [custom reporters][16].
599
+ Find more details and ideas in [custom reporters][45].
565
600
 
566
- ## Public exports
567
-
568
- Sometimes a file that's not an entry file has one or more exports that are public and should not be reported as unused.
569
- Such variables and types can be marked with the JSDoc `@public` tag:
601
+ ## Fixing Issues
570
602
 
571
- ```js
572
- /**
573
- * Merge two objects.
574
- *
575
- * @public
576
- */
603
+ This is the fun part! Knip, knip, knip ✂️
577
604
 
578
- export const merge = function () {};
605
+ Tip: back up files or use an VCS like Git before deleting files or making changes. Run tests to verify results.
579
606
 
580
- /** @public */
581
- export const split = function () {};
582
- ```
607
+ - Unused files can be removed.
608
+ - Unused dependencies can be removed from `package.json`.
609
+ - Unlisted dependencies should be added to `package.json`.
610
+ - Unresolved imports should be reviewed.
611
+ - Unused exports and types: remove the `export` keyword in front of unused exports. Then you can see whether the
612
+ variable or type is used within the same file. If this is not the case, it can be removed.
613
+ - Duplicate exports can be removed so they're exported only once.
583
614
 
584
- Knip does not report public exports and types as unused.
615
+ Repeat the process to reveal new unused files and exports. It's so liberating to remove unused things!
585
616
 
586
- ## Ignore exports used in file
617
+ Getting too many reported issues and false positives? Read more about [handling issues][46] describing potential causes
618
+ for false positives, and how to handle them.
587
619
 
588
- In files with multiple exports, some of them might be used only internally. If these exports should not be reported,
589
- there is a `ignoreExportsUsedInFile` option available. With this option enabled, you don't need to mark everything
590
- `@public` separately and when something is no longer used internally, it will still be reported.
620
+ ## Command Line Options
591
621
 
592
- ```json
593
- {
594
- "ignoreExportsUsedInFile": true
595
- }
596
- ```
622
+ $ npx knip --help
623
+ ✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects
597
624
 
598
- In a more fine-grained manner, you can also ignore only specific issue types:
625
+ Usage: knip [options]
599
626
 
600
- ```json
601
- {
602
- "ignoreExportsUsedInFile": {
603
- "interface": true,
604
- "type": true
605
- }
606
- }
607
- ```
627
+ Options:
628
+ -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)
629
+ -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)
630
+ --production Analyze only production source files (e.g. no tests, devDependencies, exported types)
631
+ --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)
632
+ --workspace [dir] Analyze a single workspace (default: analyze all configured workspaces)
633
+ --no-gitignore Don't use .gitignore
634
+ --include Report only provided issue type(s), can be comma-separated or repeated (1)
635
+ --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)
636
+ --dependencies Shortcut for --include dependencies,unlisted,unresolved
637
+ --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates
638
+ --include-entry-exports Include entry files when reporting unused exports
639
+ -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)
640
+ --reporter Select reporter: symbols, compact, codeowners, json (default: symbols)
641
+ --reporter-options Pass extra options to the reporter (as JSON string, see example)
642
+ --no-config-hints Suppress configuration hints
643
+ --no-exit-code Always exit with code zero (0)
644
+ --max-issues Maximum number of issues before non-zero exit code (default: 0)
645
+ -d, --debug Show debug output
646
+ --debug-file-filter Filter for files in debug output (regex as string)
647
+ --performance Measure count and running time of expensive functions and display stats table
648
+ -h, --help Print this help text
649
+ -V, --version Print version
608
650
 
609
- ## Include exports in entry files
651
+ (1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates
610
652
 
611
- When a repository is self-contained or private, you may want to include entry files when reporting unused exports:
653
+ Examples:
612
654
 
613
- knip --include-entry-exports
655
+ $ knip
656
+ $ knip --production
657
+ $ knip --workspace packages/client --include files,dependencies
658
+ $ knip -c ./config/knip.json --reporter compact
659
+ $ knip --reporter codeowners --reporter-options '{"path":".github/CODEOWNERS"}'
660
+ $ knip --debug --debug-file-filter '(specific|particular)-module'
614
661
 
615
- Knip will also report unused exports in entry source files and scripts (such as those referenced in `package.json`). But
616
- not in entry and configuration files from plugins, such as `next.config.js` or `src/routes/+page.svelte`.
662
+ More documentation and bug reports: https://github.com/webpro/knip
617
663
 
618
- ## Handling Issues
664
+ ## Potential boost with `--no-gitignore`
619
665
 
620
- How to handle a long list of reported issues? Seeing too many false positives? Read more about [handling issues][17]
621
- describing potential causes for false positives, and how to handle them.
666
+ To increase performance in a large monorepo, check out [Potential boost with `--no-gitignore`][47].
622
667
 
623
- ## Comparison
668
+ ## Comparison & Migration
624
669
 
625
670
  This table is an ongoing comparison. Based on their docs (please report any mistakes):
626
671
 
627
- | Feature | **knip** | [depcheck][18] | [unimported][19] | [ts-unused-exports][20] | [ts-prune][21] |
672
+ | Feature | **knip** | [depcheck][48] | [unimported][49] | [ts-unused-exports][50] | [ts-prune][51] |
628
673
  | :---------------------- | :------: | :------------: | :--------------: | :---------------------: | :------------: |
629
674
  | Unused files | ✅ | - | ✅ | - | - |
630
675
  | Unused dependencies | ✅ | ✅ | ✅ | - | - |
@@ -644,7 +689,7 @@ This table is an ongoing comparison. Based on their docs (please report any mist
644
689
 
645
690
  ✅ = Supported, ❌ = Not supported, - = Out of scope
646
691
 
647
- ### Migrating from other tools
692
+ Below some similar commands to get another idea of what Knip does in comparison:
648
693
 
649
694
  ### depcheck
650
695
 
@@ -660,7 +705,7 @@ The following commands are similar:
660
705
  unimported
661
706
  knip --production --dependencies --include files
662
707
 
663
- Also see [production mode][22].
708
+ Also see [production mode][21].
664
709
 
665
710
  ### ts-unused-exports
666
711
 
@@ -682,37 +727,25 @@ The following commands are similar:
682
727
 
683
728
  Many thanks to some of the early adopters of Knip:
684
729
 
685
- - [Block Protocol][23]
686
- - [DeepmergeTS][24]
687
- - [eslint-plugin-functional][25]
688
- - [freeCodeCamp.org][26]
689
- - [is-immutable-type][27]
690
- - [IsaacScript][28]
691
- - [Owncast][29]
692
- - [release-it][30]
693
- - [Template TypeScript Node Package][31]
694
-
695
- ## Potential boost with `--no-gitignore`
696
-
697
- Running Knip on large workspaces with many packages may feel a bit sluggish. Knip looks up `.gitignore` files and uses
698
- them to filter out matching entry and project files. This increases correctness. However, you might want to disable that
699
- with `--no-gitignore` and enjoy a significant performance boost. Depending on the contents of the `.gitignore` files,
700
- the reported issues may be the same. To help determine whether this trade-off might be worth it for you, first check the
701
- difference in unused files:
702
-
703
- ```shell
704
- diff <(knip --no-gitignore --include files) <(knip --include files)
705
- ```
706
-
707
- And to measure the difference of this flag in seconds:
730
+ - [Block Protocol][52]
731
+ - [DeepmergeTS][53]
732
+ - [eslint-plugin-functional][54]
733
+ - [freeCodeCamp.org][55]
734
+ - [is-immutable-type][56]
735
+ - [IsaacScript][57]
736
+ - [Nuxt][58]
737
+ - [Owncast][59]
738
+ - [release-it][60]
739
+ - [Template TypeScript Node Package][61]
740
+ - [Tipi][62]
708
741
 
709
- ```shell
710
- SECONDS=0; knip > /dev/null; t1=$SECONDS; SECONDS=0; knip --no-gitignore > /dev/null; t2=$SECONDS; echo "Difference: $((t1 - t2)) seconds"
711
- ```
742
+ ## Articles, etc.
712
743
 
713
- ⏲️ Analysis on a large project went from 33 down to 9 seconds (that's >70% faster).
744
+ - Ask your questions in the [Knip knowledge base][63] (powered by OpenAI and [7-docs][64], experimental!)
745
+ - Smashing Magazine: [Knip: An Automated Tool For Finding Unused Files, Exports, And Dependencies][65]
746
+ - Effective TypeScript: [Recommendation Update: ✂️ Use knip to detect dead code and types][66]
714
747
 
715
- ## Knip
748
+ ## Why "Knip"?
716
749
 
717
750
  Knip is Dutch for a "cut". A Dutch expression is "to be ge**knip**t for something", which means to be perfectly suited
718
751
  for the job. I'm motivated to make Knip perfectly suited for the job of cutting projects to perfection! ✂️
@@ -728,7 +761,7 @@ each file, and traversing all of this, why not collect the various issues in one
728
761
 
729
762
  Special thanks to the wonderful people who have contributed to this project:
730
763
 
731
- [![Contributors][33]][32]
764
+ [![Contributors][68]][67]
732
765
 
733
766
  [1]: #workspaces
734
767
  [2]: #plugins
@@ -737,32 +770,67 @@ Special thanks to the wonderful people who have contributed to this project:
737
770
  [5]: #custom-reporters
738
771
  [6]: https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC
739
772
  [7]: ./assets/cow-with-orange-scissors-van-gogh-style.webp
740
- [8]: https://knip.deno.dev
741
- [9]: https://github.com/7-docs/7-docs
742
- [10]: #handling-issues
743
- [11]: #reading-the-report
744
- [12]: #configuration
745
- [13]: https://nx.dev/concepts/integrated-vs-package-based
746
- [14]: ./docs/writing-a-plugin.md
747
- [15]: ./docs/compilers.md
748
- [16]: ./docs/custom-reporters.md
749
- [17]: ./docs/handling-issues.md
750
- [18]: https://github.com/depcheck/depcheck
751
- [19]: https://github.com/smeijer/unimported
752
- [20]: https://github.com/pzavolinsky/ts-unused-exports
753
- [21]: https://github.com/nadeesha/ts-prune
754
- [22]: #production-mode
755
- [23]: https://github.com/blockprotocol/blockprotocol
756
- [24]: https://github.com/RebeccaStevens/deepmerge-ts
757
- [25]: https://github.com/eslint-functional/eslint-plugin-functional
758
- [26]: https://github.com/freeCodeCamp/freeCodeCamp
759
- [27]: https://github.com/RebeccaStevens/is-immutable-type
760
- [28]: https://github.com/IsaacScript/isaacscript
761
- [29]: https://github.com/owncast/owncast
762
- [30]: https://github.com/release-it/release-it
763
- [31]: https://github.com/JoshuaKGoldberg/template-typescript-node-package
764
- [32]: https://github.com/webpro/knip/graphs/contributors
765
- [33]: https://contrib.rocks/image?repo=webpro/knip
773
+ [8]: https://twitter.com/webprolific
774
+ [9]: https://fosstodon.org/@webpro
775
+ [10]: #getting-started
776
+ [11]: #installation
777
+ [12]: #default-configuration
778
+ [13]: #lets-go
779
+ [14]: #configuration
780
+ [15]: #entry-files
781
+ [16]: #ignore-files-binaries-dependencies-and-workspaces
782
+ [17]: #public-exports
783
+ [18]: #ignore-exports-used-in-file
784
+ [19]: #include-exports-in-entry-files
785
+ [20]: #paths
786
+ [21]: #production-mode
787
+ [22]: #strict
788
+ [23]: #plugins-1
789
+ [24]: #output
790
+ [25]: #screenshots
791
+ [26]: #reading-the-report
792
+ [27]: #rules--filters
793
+ [28]: #fixing-issues
794
+ [29]: #command-line-options
795
+ [30]: #potential-boost-with---no-gitignore
796
+ [31]: #comparison--migration
797
+ [32]: #depcheck
798
+ [33]: #unimported
799
+ [34]: #ts-unused-exports
800
+ [35]: #ts-prune
801
+ [36]: #projects-using-knip
802
+ [37]: #articles-etc
803
+ [38]: #why-knip
804
+ [39]: #really-another-unused-filedependencyexport-finder
805
+ [40]: #contributors
806
+ [41]: https://nx.dev/concepts/integrated-vs-package-based
807
+ [42]: ./docs/writing-a-plugin.md
808
+ [43]: ./docs/compilers.md
809
+ [44]: #handling-issues
810
+ [45]: ./docs/custom-reporters.md
811
+ [46]: ./docs/handling-issues.md
812
+ [47]: ./docs/perf-boost-with-no-gitignore.md
813
+ [48]: https://github.com/depcheck/depcheck
814
+ [49]: https://github.com/smeijer/unimported
815
+ [50]: https://github.com/pzavolinsky/ts-unused-exports
816
+ [51]: https://github.com/nadeesha/ts-prune
817
+ [52]: https://github.com/blockprotocol/blockprotocol
818
+ [53]: https://github.com/RebeccaStevens/deepmerge-ts
819
+ [54]: https://github.com/eslint-functional/eslint-plugin-functional
820
+ [55]: https://github.com/freeCodeCamp/freeCodeCamp
821
+ [56]: https://github.com/RebeccaStevens/is-immutable-type
822
+ [57]: https://github.com/IsaacScript/isaacscript
823
+ [58]: https://github.com/nuxt/nuxt
824
+ [59]: https://github.com/owncast/owncast
825
+ [60]: https://github.com/release-it/release-it
826
+ [61]: https://github.com/JoshuaKGoldberg/template-typescript-node-package
827
+ [62]: https://github.com/meienberger/runtipi
828
+ [63]: https://knip.deno.dev
829
+ [64]: https://github.com/7-docs/7-docs
830
+ [65]: https://www.smashingmagazine.com/2023/08/knip-automated-tool-find-unused-files-exports-dependencies/
831
+ [66]: https://effectivetypescript.com/2023/07/29/knip/
832
+ [67]: https://github.com/webpro/knip/graphs/contributors
833
+ [68]: https://contrib.rocks/image?repo=webpro/knip
766
834
  [plugin-ava]: ./src/plugins/ava
767
835
  [plugin-babel]: ./src/plugins/babel
768
836
  [plugin-capacitor]: ./src/plugins/capacitor
@@ -21,6 +21,17 @@ const issueTypeSchema = z.union([
21
21
  z.literal('classMembers'),
22
22
  ]);
23
23
  const rulesSchema = z.record(issueTypeSchema, z.enum(['error', 'warn', 'off']));
24
+ const ignoreExportsUsedInFileSchema = z.union([
25
+ z.boolean(),
26
+ z.record(z.union([
27
+ z.literal('class'),
28
+ z.literal('enum'),
29
+ z.literal('function'),
30
+ z.literal('interface'),
31
+ z.literal('member'),
32
+ z.literal('type'),
33
+ ]), z.boolean()),
34
+ ]);
24
35
  const rootConfigurationSchema = z.object({
25
36
  rules: rulesSchema.optional(),
26
37
  entry: globSchema.optional(),
@@ -28,19 +39,7 @@ const rootConfigurationSchema = z.object({
28
39
  paths: pathsSchema.optional(),
29
40
  ignore: globSchema.optional(),
30
41
  ignoreBinaries: z.array(z.string()).optional(),
31
- ignoreExportsUsedInFile: z
32
- .union([
33
- z.boolean(),
34
- z.record(z.union([
35
- z.literal('class'),
36
- z.literal('enum'),
37
- z.literal('function'),
38
- z.literal('interface'),
39
- z.literal('member'),
40
- z.literal('type'),
41
- ]), z.boolean()),
42
- ])
43
- .optional(),
42
+ ignoreExportsUsedInFile: ignoreExportsUsedInFileSchema.optional(),
44
43
  ignoreDependencies: z.array(z.string()).optional(),
45
44
  ignoreWorkspaces: z.array(z.string()).optional(),
46
45
  compilers: compilersSchema.optional(),
@@ -1,3 +1,4 @@
1
+ import { isGitIgnoredSync } from 'globby';
1
2
  import ts from 'typescript';
2
3
  import { DEFAULT_EXTENSIONS } from './constants.js';
3
4
  import { IGNORED_FILE_EXTENSIONS } from './constants.js';
@@ -6,7 +7,7 @@ import { createHosts } from './typescript/createHosts.js';
6
7
  import { getImportsAndExports } from './typescript/getImportsAndExports.js';
7
8
  import { SourceFileManager } from './typescript/SourceFileManager.js';
8
9
  import { isMaybePackageName } from './util/modules.js';
9
- import { extname, isInNodeModules } from './util/path.js';
10
+ import { extname, isInNodeModules, join } from './util/path.js';
10
11
  import { timerify } from './util/Performance.js';
11
12
  const baseCompilerOptions = {
12
13
  allowJs: true,
@@ -22,6 +23,7 @@ const baseCompilerOptions = {
22
23
  moduleResolution: ts.ModuleResolutionKind.NodeNext,
23
24
  };
24
25
  const tsCreateProgram = timerify(ts.createProgram);
26
+ const isGitIgnored = isGitIgnoredSync();
25
27
  export class ProjectPrincipal {
26
28
  entryPaths = new Set();
27
29
  projectPaths = new Set();
@@ -125,13 +127,17 @@ export class ProjectPrincipal {
125
127
  }
126
128
  }
127
129
  else {
128
- if (isMaybePackageName(specifier)) {
129
- external.add(specifier);
130
+ const sanitizedSpecifier = specifier.replace(/^([?!|-]+)?([^!?]+).*/, '$2');
131
+ if (isMaybePackageName(sanitizedSpecifier)) {
132
+ external.add(sanitizedSpecifier);
130
133
  }
131
134
  else {
132
- const ext = extname(specifier);
133
- if (!ext || (ext !== '.json' && !IGNORED_FILE_EXTENSIONS.includes(ext))) {
134
- unresolvedImports.add(specifier);
135
+ const isIgnored = isGitIgnored(join(filePath, sanitizedSpecifier));
136
+ if (!isIgnored) {
137
+ const ext = extname(sanitizedSpecifier);
138
+ if (!ext || (ext !== '.json' && !IGNORED_FILE_EXTENSIONS.includes(ext))) {
139
+ unresolvedImports.add(specifier);
140
+ }
135
141
  }
136
142
  }
137
143
  }
@@ -3,7 +3,7 @@ import { hasDependency, load } from '../../util/plugin.js';
3
3
  export const NAME = 'Commitizen';
4
4
  export const ENABLERS = ['commitizen'];
5
5
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
- export const CONFIG_FILE_PATTERNS = ['.czrc', 'package.json'];
6
+ export const CONFIG_FILE_PATTERNS = ['.czrc', '.cz.json', 'package.json'];
7
7
  const findPluginDependencies = async (configFilePath, { manifest }) => {
8
8
  const config = configFilePath.endsWith('package.json')
9
9
  ? manifest.config?.commitizen
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.19.3";
1
+ export declare const version = "2.19.5";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.19.3';
1
+ export const version = '2.19.5';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.19.3",
3
+ "version": "2.19.5",
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",
@@ -62,26 +62,26 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@jest/types": "29.6.1",
65
- "@npmcli/package-json": "4.0.1",
65
+ "@npmcli/package-json": "5.0.0",
66
66
  "@release-it/bumper": "5.1.0",
67
67
  "@swc/cli": "0.1.62",
68
- "@swc/core": "1.3.76",
68
+ "@swc/core": "1.3.77",
69
69
  "@types/eslint": "8.44.2",
70
70
  "@types/js-yaml": "4.0.5",
71
71
  "@types/micromatch": "4.0.2",
72
72
  "@types/minimist": "1.2.2",
73
- "@types/node": "20.4.9",
73
+ "@types/node": "20.5.0",
74
74
  "@types/npmcli__map-workspaces": "3.0.1",
75
75
  "@types/webpack": "5.28.1",
76
- "@typescript-eslint/eslint-plugin": "6.3.0",
77
- "@typescript-eslint/parser": "6.3.0",
76
+ "@typescript-eslint/eslint-plugin": "6.4.0",
77
+ "@typescript-eslint/parser": "6.4.0",
78
78
  "c8": "8.0.1",
79
- "eslint": "8.46.0",
79
+ "eslint": "8.47.0",
80
80
  "eslint-import-resolver-typescript": "3.6.0",
81
81
  "eslint-plugin-import": "2.28.0",
82
82
  "eslint-plugin-n": "16.0.1",
83
- "prettier": "3.0.1",
84
- "release-it": "16.1.4",
83
+ "prettier": "3.0.2",
84
+ "release-it": "16.1.5",
85
85
  "remark-cli": "11.0.0",
86
86
  "remark-preset-webpro": "0.0.3",
87
87
  "tsx": "3.12.7",