I'm trying to figure out how to detect when a exported variable (const, function, ...) is not used and therefore could be deleted. I have a React App with ESLint configured.
In the following example, MAGIC_NUMBER
is exported and used in file2.js but doMagic
is never imported or used in any other file.
file1.js
export const MAGIC_NUMBER = 7;
file2.js
import { MAGIC_NUMBER } from "./file1.js"
export function doMagic() {
return MAGIC_NUMBER + 1;
}
I would like to know if there is any way to detect that doMagic
is unused.
Right now, I'm using ESLint with the the default rule :
"no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }]
It detects unused variables inside the same file, but not across multiple files.
Thank you very much!