Find dead code in large Javascript Application

2.3k views Asked by At

I have a very large Nodejs application. There is a lot of unused dead code. I have been looking for a solution for this, but Im not able to find the proper tool.

I see there are many tools to check dead pieces of code or unreachable code in the own file (like https://www.npmjs.com/package/babel-plugin-minify-dead-code-elimination or ESLint). What I need is to cover examples like following one, that is most of my code: functions that are exported but never used from outside.

usefulFunctions.js

let self = {

  // This function is used from outside
  usedFunction: () => {
    console.log('This function is used from external file')
  },

  // This function is not used, but still exported. I need to detect it
  unusedFunction: () => {
    console.log('This function is not used')
  },
}

module.exports = self

app.js

const usefulFunctions= require('./usefulFunctions')

usefulFunctions.usedFunction()

What Ive tried:

0

There are 0 answers