This guide considers only Javacript/Typescript projects, since the main library used on it detects dead code in this language.
There is a lib that provide this functionality and some recommended configs for it. The lib searches for code that is exported and not imported in other files and list them. It is also easy to ignore some directories and/or files that are ok to contain dead code.