https://github.com/devbridge/js-unused-exports
https://github.com/devbridge/js-unused-exports
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devbridge/js-unused-exports
- Owner: devbridge
- License: mit
- Created: 2019-01-11T18:54:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:01:15.000Z (almost 3 years ago)
- Last Synced: 2025-04-17T16:15:39.939Z (8 months ago)
- Language: JavaScript
- Size: 812 KB
- Stars: 49
- Watchers: 5
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Unused Exports
Tool for identifying and reporting unused exports found in ECMAScript/JavaScript code.
You may think of it as ESLint `no-unused-vars` rule, but for the whole project scope.
Tool uses [Babel parser](https://babeljs.io/docs/en/babel-parser) to parse source code. You can provide custom parser options using config file.
## Instalation
```shell
npm install -g js-unused-exports
```
## Usage
```pre
Usage: js-unused-exports [options]
E.g.: js-unused-exports --config "unused-exports-config.json"
Options:
-v, --version output the version number
-c, --config [path] path to the JSON config file
-o --out-dir [path] path to print scan results as JSON
-f, --fix automatically remove "export" directive where possible
-h, --help output usage information
```

## Configuration
```javascript
{
// Root project directory or CWD (default)
projectRoot: '',
// Source paths relative to project root
sourcePaths: ['src/**/*.js'],
// Patterns for files that should be ignored
ignorePaths: [],
// Test file patterns
testPaths: [
'src/**/*.spec.js'
],
// Import patterns to ignore
ignoreImportPatterns: [ '(png|gif|jpg|jpeg|css|scss)$' ],
// Export patterns to ignore
ignoreExportPatterns: [ '(stories)' ],
// If you use alias in you codebase you can specify them here, e.g.:
aliases: {
components: 'src/components'
},
// @babel/parser options for parsing source code
// https://babeljs.io/docs/en/babel-parser
parserOptions: {
sourceType: 'module',
plugins: [
'objectRestSpread',
'jsx',
'flow',
'classProperties',
'decorators-legacy',
'exportDefaultFrom'
]
}
}
```