A fast tool to detect unused files in JavaScript/TypeScript projects.
Built with oxc for fast parsing and parallel processing with rayon.
npm install muricargo install --path .muri --entry src/index.ts| Option | Description | Default |
|---|---|---|
-e, --entry <PATTERN> |
Entry point files or glob patterns (required) | - |
-p, --project <PATTERN> |
Project files to check | **/*.{ts,tsx,js,jsx,mjs,cjs} |
-C, --cwd <PATH> |
Working directory | . |
-c, --config <PATH> |
Path to config file | - |
--format <FORMAT> |
Output format: text or json |
text |
--ignore <PATTERN> |
Patterns to ignore | - |
Muri supports configuration via muri.json or muri.jsonc files. If no --config flag is provided, muri automatically looks for these files in the working directory.
Supported formats:
- JSON (
.json) - JSON with Comments (
.jsonc)
Example muri.json:
{
"entry": ["src/index.ts", "src/worker.ts"],
"project": ["src/**/*.ts", "src/**/*.tsx"],
"ignore": ["**/*.test.ts", "**/*.spec.ts"]
}Example muri.jsonc (with comments):
| Option | Type | Description |
|---|---|---|
entry |
string[] |
Entry point files or glob patterns |
project |
string[] |
Project files to check |
ignore |
string[] |
Patterns to ignore |
CLI arguments override config file values when both are provided.
Find unused files in a React project:
muri --entry "src/index.tsx"Multiple entry points:
muri --entry "src/main.ts" --entry "src/worker.ts"With custom project scope and ignoring test files:
muri \
--entry "src/index.ts" \
--project "src/**/*.ts" \
--ignore "**/*.test.ts" \
--ignore "**/*.spec.ts"JSON output for CI/tooling:
muri --entry "src/index.ts" --format json0- No unused files found1- Unused files detected or error occurred
Find unused files in a project (async).
const { findUnused } = require('muri');
const report = await findUnused({
entry: 'src/index.ts',
ignore: ['**/*.test.ts'],
});
console.log(`Found ${report.unusedCount} unused files out of ${report.totalFiles}`);
report.unusedFiles.forEach(file => console.log(` ${file}`));Synchronous version of findUnused.
const { findUnusedSync } = require('muri');
const report = findUnusedSync({
entry: ['src/index.ts', 'src/worker.ts'],
project: 'src/**/*.ts',
cwd: '/path/to/project',
});Find all files reachable from entry points (async).
const { findReachable } = require('muri');
const files = await findReachable({
entry: 'src/index.ts',
});
console.log(`${files.length} files are reachable from entry points`);| Option | Type | Description | Default |
|---|---|---|---|
entry |
string | string[] |
Entry point files or glob patterns | (required) |
project |
string | string[] |
Project files to check | **/*.{ts,tsx,js,jsx,mjs,cjs} |
cwd |
string |
Working directory | process.cwd() |
ignore |
string[] |
Patterns to ignore | [] |
- Collects all project files matching the project glob patterns
- Parses entry points and recursively resolves all imports
- Builds a dependency graph of all reachable files
- Reports files that exist in the project but aren't reachable from any entry point
MIT
{ // Entry points for dependency analysis "entry": ["src/index.ts"], // Files to check for unused status "project": ["src/**/*.ts", "src/**/*.tsx"], // Patterns to exclude "ignore": ["**/*.test.ts", "**/*.spec.ts"] }