There is no visible harm in having code in the code base, that is never used. Previously this at least would affect bundle size by increasing it without reason. However, introducing tree shaking in Webpack mostly removed even this reason. So, why to bother?
I would name just a few reasons, that I still see in keeping codebase crystal clear:
- do not confuse newcomers. If something exists, but it is not used – why would it be present? Should it be used? etc.
- decrease scopes of potential refactoring. For example, you decide to move from JS to TS, this will mean, that even when code is not actively used it will still contribute to the amount of work, that needs to be done.