Git Product home page Git Product logo

find-dead-modules's Introduction

Installation

npm install -g find-dead-modules

Usage

Navigate to a javascript project of some sort and run find-dead-modules. E.g.

cd ~/my-awesome-project
⨠ find-dead-modules

Interpreting results

When no unused/dead modules are found, the script prints nothing and has an exit code of zero.

Any unused/dead modules that are found are loggged to stdout, one file path per line. An exit code of 1 will signal that one or more of these were found.

Configuration

The script reads your .gitignore file to figure out what can be safely ignored. Apart from that, you can't configure anything right now. This is likely to change when the script has proven to be useful.

How does it work?

On a high level perspective, this is what find-dead-modules does:

  1. Gets a list of all javascript files (js, jsx, json, ts, tsx) from a project, ignoring anything inside a node_modules folder.
  2. Parses all these files for any reference to another file. These include import statements, require expressions, and raw strings that look like they might reference a javascript file.
  3. Compares the list of all files against the list of referenced files. Outputs anything that isn't referenced.

find-dead-modules's People

Contributors

trotzig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

find-dead-modules's Issues

SyntaxError: Unexpected token in 1.0 alpha 2

I was interested in trying the tool in a project and I got an error.

As you will see, using node 8.2.1. Not sure if it matters. Maybe something related to the way babylon is used here?

Error caught { SyntaxError: Unexpected token (1:1)
    at Parser.pp$5.raise (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:4454:13)
    at Parser.pp.unexpected (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:1761:8)
    at Parser.pp$9.jsxParseIdentifier (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:6970:10)
    at Parser.pp$9.jsxParseNamespacedName (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:6981:19)
    at Parser.pp$9.jsxParseElementName (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:6996:19)
    at Parser.pp$9.jsxParseOpeningElementAt (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:7086:20)
    at Parser.pp$9.jsxParseElementAt (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:7110:29)
    at Parser.pp$9.jsxParseElement (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:7165:15)
    at Parser.parseExprAtom (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:7177:21)
    at Parser.pp$3.parseExprSubscripts (/yolo/node/v8.2.1/lib/node_modules/find-dead-modules/node_modules/babylon/lib/index.js:3494:19) pos: 1, loc: Position { line: 1, column: 1 } }

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.