unused-exports-check
Version:
Generic scanner to detect unused TypeScript exports (API + CLI)
45 lines (34 loc) • 960 B
Markdown
Generic, repo-agnostic scanner to detect unused TypeScript exports. Provides both an API and a CLI.
```bash
npm i -D unused-exports-check
```
```bash
npx unused-exports-check \
--root . \
--glob 'src/**/*.ts' 'src/**/*.tsx' \
--ignore '**/generated/**' '**/*.stories.tsx' \
--fail
```
- Writes a timestamped report to `reports/` by default.
- Use `--report path.txt` to customize output.
```ts
import { scan, assertNone } from 'unused-exports-check';
const unused = await scan({
root: process.cwd(),
globs: ['src/**/*.ts','src/**/*.tsx'],
ignore: ['**/generated/**', '**/*.stories.tsx']
});
assertNone(unused); // throws if any unused exports
```
Add this comment anywhere in a file to skip checking it entirely:
```ts
// unused-exports-check: disable
```
- Uses tsconfig baseUrl/paths when present.
- Ignores node_modules, dist, and .d.ts by default.