CLI Arguments
General
--help
Shortcut: -h
Prints a summary of this page.
--version
Shortcut: -V
Print the version number.
--debug
Shortcut: -d
Show debug output.
--no-progress
Shortcut: -n
Don’t show dynamic progress updates. Progress is automatically disabled in CI environments.
--no-config-hints
Suppress configuration hints.
--performance
Use this flag to get the count and execution time of potentially expensive functions in a table. Example:
name
: the internal Knip function namesize
: number of function invocationsmin
: the fastest invocationmax
: the slowest invocationmedian
: the median invocationsum
the accumulated time of all invocations
--isolate-workspaces
By default, Knip optimizes performance by adding eligible workspaces to existing
TypeScript programs, based on the compatibility of their compilerOptions
. Use
this flag to disable this behavior and create one program per workspace.
You can see the behavior in action in debug mode. Look for messages like this:
Configuration
--config [file]
Use an alternative path for the configuration file. Default locations:
knip.json
knip.jsonc
.knip.json
.knip.jsonc
knip.js
knip.ts
package.json#knip
Shortcut: -c
--tsConfig [file]
Use an alternative path for the TypeScript configuration file.
Default location: tsconfig.json
--workspace [dir]
Lint a single workspace including its ancestor and dependent workspaces. The default behavior is to lint all configured workspaces.
Shortcut: -W
--directory [dir]
Default: cwd
(current directory)
Run the process from a different directory.
--no-gitignore
Ignore .gitignore
files.
--include-entry-exports
When a repository is self-contained or private, you may want to include entry files when reporting unused exports:
Also see includeEntryExports.
Modes
--production
Lint only production source files. This excludes:
- entry files defined by plugins:
- test files
- configuration files
- Storybook stories
devDependencies
frompackage.json
Read more at Production Mode.
--strict
Isolate workspaces and consider only direct dependencies.
Read more at Production Mode.
Filters
Available issue types when filtering output using --include
or
--exclude
:
files
dependencies
optionalPeerDependencies
unlisted
unresolved
exports
nsExports
classMembers
types
nsTypes
enumMembers
duplicates
--exclude
Exclude provided issue type(s) from report. Can be comma-separated or repeated.
Example:
--include
Report only provided issue type(s). Can be comma-separated or repeated.
Example:
--dependencies
Shortcut to include all types of dependency issues:
--exports
Shortcut to include all types of export issues:
Reporters & Preprocessors
--reporter [reporter]
Available reporters:
symbols
(default)compact
codeowners
json
jsonExt
Can be repeated. Example:
Also see Reporters & Preprocessors.
--reporter-options [json]
Pass extra options to the preprocessor (as JSON string, see —reporter-options example)
Example:
--preprocessor [preprocessor]
Preprocess the results before providing it to the reporter(s).
Can be repeated. Examples:
--preprocessor-options [json]
Pass extra options to the preprocessor as JSON string.
Also see Reporters & Preprocessors.
Exit code
The default exit codes:
Code | Description |
---|---|
0 | Knip ran successfully, no lint errors |
1 | Knip ran successfully, but there is at least one lint error |
2 | Knip did not run successfully due to bad input or internal error |
--no-exit-code
Always exit with code zero (0
), even when there are lint errors.
--max-issues
Maximum number of issues before non-zero exit code. Default: 0
ISC License © 2024 Lars Kappert