Giter Site home page Giter Site logo

daylesalmon / deadfile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from m-izadmehr/deadfile

0.0 0.0 0.0 3.01 MB

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

Home Page: https://m-izadmehr.github.io/deadfile/

JavaScript 89.82% Vue 0.51% CSS 6.96% Mustache 2.72%

deadfile's Introduction

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 appearin your package.json

deadfile result deadfile result

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

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

deadfile's People

Contributors

dependabot[bot] avatar leorossi avatar m-izadmehr avatar semantic-release-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.