DEV Community

Markus Muinonen
Markus Muinonen

Posted on • Edited on

Find unused exports with this bash script

Are you tired of manually tracking down unused exports in your project? So was I. With power of ChatGPT I, a total bash newbie, created a bash script for modern javascript projects that can help you.

How to use. First, clone the gist. Then, make the script executable by running the command "chmod +x unusedExports.sh" in terminal. Next, navigate to the target directory and run the script using the command "./unusedExports.sh". The script will search your project for unused exports and create a report in a file named unusedExports.txt. Script can be inaccurate with default exported modules, since they can be imported with different name!

To exclude certain files or directories from the search, specify them in the EXCLUDE variable. While there is certainly room for improvement - for example, by making the code less repetitive and allowing for situational EXCLUDE arguments - this script is already a valuable tool for spring cleaning.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay