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:
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:
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:
And run the script under your source code path:
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 considerindex.js
andindex.ts
as the entry files, you may configure this by your own: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:
--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)