Problem: Sometimes people export internals merely to support unit testing


Problem: Sometimes people export internals merely to support unit testing. But, it's generally recommended to only test the public interface. And sometimes a file or function is only called by a test, so it's needless.

Solution: Use Knip.

If you configure Knip to ignore test files, it finds files and exports that are only used by tests.

https://github.com/webpro/knip

Ah, just found knip has a built-in way to catch such issues.

1. Specify an entry point and mark it with an exclamation to specify that it's a production entry point
2. Run knip with the --production flag

More here: https://github.com/webpro/knip#production-mode

View original on X