Shrimpit is a small CLI analysis tool for checking unused JavaScript, JSX & Vue templates ES6 exports in your project.
npm i -g shrimpit
yarn global add shrimpit
shrimpit path/to/your/files /another/path
Globbing patterns are also supported:
shrimpit test/**/*.js
Adding the --tree
flag will output the complete files tree with all the imports and the exports per file:
shrimpit --tree path/to/your/files
Please note that default unnamed exports are rendered as default (unnamed)
:
shrimpit test --tree
Shrimpit!
> Files tree
{ test:
{ core:
{ a:
{ 'a.js':
{ imports:
[ { location: 'test/core/b/b.js',
name: 'test',
unnamedDefault: true },
{ location: 'test/core/b/b.js',
name: 'a',
unnamedDefault: false },
{ location: 'test/core/c/c.js',
name: 'User',
unnamedDefault: true } ],
exports:
[ { location: 'test/core/a/a.js',
name: 'a',
unnamedDefault: false },
{ location: 'test/core/a/a.js',
name: 'c',
unnamedDefault: false },
{ location: 'test/core/a/a.js', name: 'd', unnamedDefault: true } ] } },
b:
{ 'b.js':
{ imports:
[ { location: 'test/core/c/c.js',
name: 'Cat',
unnamedDefault: false },
{ location: 'test/core/d/d.js',
name: 'unamedFunction',
unnamedDefault: true },
{ location: 'test/core/a/a.js',
name: 'a',
unnamedDefault: false },
{ location: 'test/core/a/a.js',
name: 'c',
unnamedDefault: false },
{ location: 'test/core/a/a.js', name: 'd', unnamedDefault: true } ],
exports:
[ { location: 'test/core/b/b.js',
name: 'a',
unnamedDefault: false },
{ location: 'test/core/b/b.js',
name: 'b',
unnamedDefault: false },
{ location: 'test/core/b/b.js',
name: 'default (unnamed)',
unnamedDefault: true } ] } },
c:
{ 'c.js':
{ imports:
[ { location: 'test/core/a/a.js',
name: 'a',
unnamedDefault: false },
{ location: 'test/core/a/a.js',
name: 'c',
unnamedDefault: false },
{ location: 'test/core/a/a.js',
name: 'd',
unnamedDefault: false },
{ location: 'test/core/b/b.js',
name: 'b',
unnamedDefault: false } ],
exports:
[ { location: 'test/core/c/c.js',
name: 'Cat',
unnamedDefault: false },
{ location: 'test/core/c/c.js',
name: 'User',
unnamedDefault: true } ] } },
d:
{ 'd.js':
{ imports: [],
exports:
[ { location: 'test/core/d/d.js',
name: 'test/core/d',
unnamedDefault: true } ] } } } } }
> Unused exports
All Clear Ahead, Captain.
Shrimpit supports Flow annotations and Vue templates out of the box!
Since Babel 7, the TypeScript AST can directly be parsed. You can use the --typescript
flag to enable it:
shrimpit --tree --typescript path/to/your/files
Please note that the Flow and TypeScript parsers are mutually exclusive.
The code quality is checked by the JavaScript Standard Style.
Released under the MIT license by Davy Duperron.