Options
All
  • Public
  • Public/Protected
  • All
Menu

Module hunt-unused

hunt-unused

The CLI for detecting where your file exports are used and potentially afffected by it's changes.

Based on hunt-affected with limited support.

Quick starting

Install globally via npm:

npm i hunt-unused -g

And run the script under your source code path:

hunt-unused

specify entries

A project usually exports a file as entry, like the package main file. This file is not used anywhere within the project. hunt-unused will consider index.js and index.ts as the entry files, you may configure this by your own:

hunt-unused src/index.js src/cli.js

Options

--source

All the .js files will be scanned under the script running path by default. You may change this by --source=<glob> option, e.g.:

hunt-unused --source=src/*.js

--alias

Node module alias for helping solve real file paths.

Example:

hunt-unused --alias="src:./src"

--module-paths

Node module paths.

Example:

hunt-unused --module-paths=node_modules,../../node_modules

--extensions

File extensions to handle with. Defaults to .js, .jsx, .ts, .tsx'.

--parser-plugins

As hunt-unused is using @babel/parser to parse JS files, you may need to take care of the parser configurations. So far it only supports passing plugin option.

Following @babel/parser plugins are enabled on .js|.jsx|.ts|.tsx files by default:

  • dynamicImport
  • classProperties
  • flowComments
  • objectRestSpread
  • functionBind
  • jsx
  • flow (.js and .jsx only)
  • typescript (.ts and .tsx only)

Index

Functions

Functions

huntUnused

  • huntUnused(entries?: string[], options?: Options): Promise<Unused>
  • Parameters

    • Default value entries: string[] = ['index.js', 'index.ts']

      Exclude file entries that hunt unused cannot recognize

    • Default value options: Options = {}

    Returns Promise<Unused>

Generated using TypeDoc