@n3rd1n/unused-files-seeker
v1.0.0
Published
A tool to find unused files in JavaScript/TypeScript projects
Downloads
6
Maintainers
Readme
Unused Files Seeker
An npm package for finding unused files in JavaScript/TypeScript projects.
Installation
npm install -g unused-files-seekerUsage
CLI Commands
Scan project
unused-files-seeker scanWith custom options
unused-files-seeker scan --config ./my-config.json --project ./my-projectCreate configuration file
unused-files-seeker initConfiguration
Create an unused-files-seeker.config.json file in your project:
{
"entryPoint": "index.js",
"scanFolder": "src",
"ignorePaths": [
"node_modules",
"dist",
"build",
".git",
"coverage"
],
"extensions": [
".js",
".ts",
".jsx",
".tsx"
]
}Configuration Options
entryPoint(optional): The entry point of your project. Default:index.jsscanFolder(optional): The folder to be scanned. Default:srcignorePaths(optional): Array of paths to be ignoredextensions(optional): Array of file extensions to be scanned
Programming
import { UnusedFilesSeeker, loadConfig } from 'unused-files-seeker';
const config = loadConfig('./my-config.json');
const seeker = new UnusedFilesSeeker(config, './my-project');
const result = await seeker.findUnusedFiles();
console.log(result.unusedFiles); // Array of unused filesHow it works
- File Collection: The tool collects all files in the specified scan folder
- Entry Point: Starts at the configured entry point (or
index.js/index.ts) - Import Analysis: Analyzes all import statements in the files
- Dependency Graph: Builds a graph of file dependencies
- Unused Files: Identifies files that are not imported by other files
Supported Import Formats
- ES6 Imports:
import ... from '...' - CommonJS:
require('...') - Dynamic Imports:
import('...') - TypeScript Triple-Slash Directives:
/// <reference path="..." />
Exit Codes
0: No unused files found1: Unused files found or error occurred
License
MIT
