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:
https://marketplace.visualstudio.com/items?itemName=ky6uk.zero-reference: This VSCode plugin just display all function that has no references. This would be perfect, but I realized 'No references' VSCode algoritm is not that accurate.
https://github.com/google/closure-compiler: This compiler seems not working with last ECMAScript features. Also I prefer a linter over a compiler.