depcheck-rs
Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and which dependencies are missing from package.json
.
It is a port of original depcheck. It uses swc for parsing.
Installation
Install with npm:
npm install --save-dev @depcheck-rs-node/core
Install with yarn:
yarn add --dev @depcheck-rs-node/core
Or use rust to install depcheck-rs cli:
cargo install depcheck-rs-cli
Syntax Support
Depcheck not only recognizes the dependencies in JavaScript files, but also supports these syntaxes:
Usage
USAGE:
depcheck-rs [OPTIONS]
OPTIONS:
-d, --directory <DIRECTORY>
The directory argument is the root directory of your project [default: .]
-h, --help
Print help information
--ignore-bin-package
A flag to indicate if depcheck ignores the packages containing bin entry
--ignore-path <IGNORE_PATH>
Path to a file with patterns describing files to ignore
--ignore-patterns <IGNORE_PATTERNS>
Comma separated patterns describing files or directories to ignore
--ignore_matches <IGNORE_MATCHES>
A comma separated array containing package names to ignore
-q, --quiet
Less output per occurrence
--skip-missing
A flag to indicate if depcheck skips calculation of missing dependencies
-v, --verbose
More output per occurrence
-V, --version
Print version information
API
import {depcheck} from "@depcheck-rs-node/core";
const options = {
ignoreBinPackage: false,
skipMissing: false,
ignorePatterns: [
'sandbox',
'dist',
'bower_components',
],
ignoreMatches: [
'grunt-*',
],
ignorePath: '/path/to/your/.depcheckignore',
};
depcheck('/path/to/your/project', options).then((result) => {
console.log(result.unusedDependencies);
console.log(result.unusedDevDependencies);
console.log(result.missingDependencies);
console.log(result.usingDependencies);
});
License
MIT License.