All Projects → M-Izadmehr → deadfile

M-Izadmehr / deadfile

Licence: other
Simple util to find unused files in any JavaScript project (ES5, ES6, React, Vue, ...)

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
Mustache
554 projects
Vue
7211 projects

Projects that are alternatives of or similar to deadfile

mix unused
Find unused functions in your project
Stars: ✭ 181 (-30.12%)
Mutual labels:  unused
Dropcss
An exceptionally fast, thorough and tiny unused-CSS cleaner
Stars: ✭ 2,102 (+711.58%)
Mutual labels:  unused
Lsunusedresources
A Mac App to find unused images and resources in XCode project.
Stars: ✭ 3,692 (+1325.48%)
Mutual labels:  unused
unimport
A linter, formatter for finding and removing unused import statements.
Stars: ✭ 119 (-54.05%)
Mutual labels:  unused
covid-tracking-dash
Dash app for COVID Tracking Project (https://covidtracking.com/)
Stars: ✭ 26 (-89.96%)
Mutual labels:  unused
unused-webpack-plugin
A webpack plugin to find unused modules/source files.
Stars: ✭ 151 (-41.7%)
Mutual labels:  unused
lint-deps
Lint for unused or missing dependencies in your node.js projects. Customize with plugins or configuration.
Stars: ✭ 48 (-81.47%)
Mutual labels:  unused
covid-data-pipeline
Scan/Trim/Extra Pipeline for State Coronavirus Site
Stars: ✭ 15 (-94.21%)
Mutual labels:  unused
eliminate
Delete files and directories without all the bullshit.
Stars: ✭ 51 (-80.31%)
Mutual labels:  elimination
brackets-viewer.js
A simple library to display tournament brackets (round-robin, single elimination, double elimination).
Stars: ✭ 52 (-79.92%)
Mutual labels:  elimination
CKBracketView
Tournament bracket view for iOS. Developed in swift.
Stars: ✭ 38 (-85.33%)
Mutual labels:  elimination
Piranha
A tool for refactoring code related to feature flag APIs
Stars: ✭ 1,840 (+610.42%)
Mutual labels:  deadcode

deadfile

deadfile

Simple util to find deadcode and unused files in any JavaScript project (ES5, ES6, React, Vue, ...).

  • Easy to use
  • Out of box support for ES5, ES6, React, Vue, ESM, CommonJs.
  • Error tolerant: deadfile uses loose parsing of your code, so if there are errors in your code, it still works. Even if you use some random babel config, it will parse your code and find imports.
  • Syntax support: it supports import/require and even dynamic import.
  • Shows you a warning for the node_modules you import, but do not appear in your package.json

deadfile result deadfile result

Supported Node Versions

This project uses optional chaining, so you need to use Node v14.0 + to be able to use it.

Installation

Install deadfile cli with the following command:

npm

$ npm install -g deadfile

yarn

$ yarn global add deadfile

npx

$ npx deadfile <file>

Usage and Examples

simple:

deadfile ./src/index.js

multiple entry:

deadfile ./src/index.js ./src/entry2.js

with custom directory:

deadfile ./src/index.js --dir /path/to/other/folder

with exclude:

deadfile ./src/index.js --exclude tests  utils/webpack

without the report server or in CI scripts:

deadfile ./src/index.js --ci

What it does

Supported Syntaxes

All major ES Module imports are supported (including dynamic import): Import Syntax

Also the following export (aggregation) syntaxes are also supported: Export Aggregation Syntax

Development Environment

You can use deadfile for any JavaScript project, and go crazy with you code, use the latest features and it still works. Here are some examples:

JSX

React Example

Vue

Vue Example

Reassigned requires

deadfile look for import declarations and calls of the require function. As a result, if you assign require to another var and use it to load a dependency, it will not handle it.

Options

  • entry: all arguments directly after deadfile are considered as entries (yes, deadfile supports multiple entries)
deadfile ./src/index.js ./src/entry2.js
  • --dir: set search in another folder:
deadfile <file> --dir /path/to/other/folder
  • --exclude: list of paths to ignore:

Paths or files to exclude from search. It supports any valid RegExp expression to exclude:

deadfile <file> --exclude ^(\w)png$
deadfile <file> --exclude webpack utils docs

---output: used to write report results in .json file

You can specify the file to write, a json file including file lists:

deadfile <file> --output report.json

Todo

  • handle reassigned require
  • look for dead declarations too
  • Add support AMD
  • be able to include/exclude paths/extentions based on relPath/regex
  • allow file extensions for parsing, should default to (.js/.jsx/.ts/.tsx/.vue)
  • Add SASS import
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].