Lint for unused frontend dependencies

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

The following discussion from !33264 (merged) should be addressed:

Is there a good way to lint for modules within our package.json dependencies which are not being utilized anywhere in our production code (or within our build/test tooling)?

In the above context, we were inadvertently installing chart.js among our dependencies when it was, in fact, not utilized anywhere in our codebase. We ought to have a way where we can identify future cases of orphaned dependencies.

I could imagine some sort of linter that will search our package.json dependencies (perhaps excluding devDependencies in the initial implementation) and check for modules which are not imported anywhere. If there are some dependencies which are needed by our build tooling but not necessarily contained within our business logic, we could maintain a list of manual exclusions.

/cc @leipert WDYT?

Edited by 🤖 GitLab Bot 🤖