9 releases

0.0.28 Jul 7, 2022
0.0.27 May 2, 2022
0.0.26 Apr 19, 2022

#1705 in Command line utilities

Download history 12/week @ 2022-12-06 15/week @ 2022-12-13 19/week @ 2022-12-20 7/week @ 2022-12-27 3/week @ 2023-01-03 8/week @ 2023-01-10 6/week @ 2023-01-17 16/week @ 2023-01-24 17/week @ 2023-01-31 13/week @ 2023-02-07 29/week @ 2023-02-14 31/week @ 2023-02-21 4/week @ 2023-02-28 6/week @ 2023-03-07 23/week @ 2023-03-14 35/week @ 2023-03-21

69 downloads per month
Used in 2 crates

MIT license

30KB
693 lines

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, // ignore the packages with bin entry

  skipMissing: false, // skip calculation of missing dependencies

  ignorePatterns: [

    // files matching these patterns will be ignored

    'sandbox',

    'dist',

    'bower_components',

  ],

  ignoreMatches: [

    // ignore dependencies that matches these globs

    'grunt-*',

  ],

  ignorePath: '/path/to/your/.depcheckignore',
};

depcheck('/path/to/your/project', options).then((result) => {

  console.log(result.unusedDependencies); // an array containing the unused dependencies

  console.log(result.unusedDevDependencies); // an array containing the unused devDependencies

  console.log(result.missingDependencies); // a lookup containing the dependencies missing in `package.json` and where they are used

  console.log(result.usingDependencies); // a lookup indicating each dependency is used by which files

});

License

MIT License.

Dependencies

~10–16MB
~336K SLoC