DEV Community

Lumin
Lumin

Posted on

Use Knip for finding unused code in the project

When I start working with legacy project. The first thing I need to do is to identify part of code that are using and unused.

For the using one, I've to learn more about it later on. And for the later one, the unused code, I'll mark it as deprecate AKA I'm going to get rid of you SOON!

The tool that is suitable for this task is Knip, it can list all unused code in the project (you can find out what the unused code is in here).

To use it, just:

npx knip
Enter fullscreen mode Exit fullscreen mode

And then it will generate a list of issues, including file location and line.

All I have to do is just put these files into the technical story, wait for the team to analyze, and delete it!

Top comments (0)