Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New husky format does not work for binaries without 'npx' #743

Closed
tim-richter opened this issue Jul 29, 2024 · 4 comments
Closed

New husky format does not work for binaries without 'npx' #743

tim-richter opened this issue Jul 29, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@tim-richter
Copy link
Contributor

Reproduction url

https://stackblitz.com/edit/github-jt9pwf?file=package.json,.husky%2Fpre-commit

Description of the issue

husky released a new version 9.1. In that release they removed the necessity to call binaries with npx.
When removing npx, knip does not recognize these binaries anymore and flags them as not used.

Release Notes for husky: https://github.com/typicode/husky/releases/tag/v9.1.1

The reproduction url shows the problem:

  • lint-staged with the 'new' format produces an error, because knip thinks it's not used
  • if we add npx lint-staged knip is happy and runs without an error

I'm guessing knip does search for some form of npx, so removing is does currently not work with the new version.

@tim-richter tim-richter added the bug Something isn't working label Jul 29, 2024
@webpro
Copy link
Collaborator

webpro commented Jul 30, 2024

The issue is that only scripts in package.json#scripts are supposed to reference binaries installed in node_modules. Package managers add node_modules/.bin to the PATH.

My I guess is that husky is doing something similar, but Knip is unaware of that "magic".

For now the best option is to add lint-staged to ignoreDependencies. We might consider treating husky scripts the same as package.json#scripts.

@tim-richter
Copy link
Contributor Author

Yep, fine for me to add it to ignored dependencies for now.

Just wanted to mention it here, since it's new behavior 🙂

@webpro webpro closed this as completed in 57997e5 Nov 10, 2024
@webpro
Copy link
Collaborator

webpro commented Nov 10, 2024

🚀 This issue has been resolved in v5.36.5. See Release 5.36.5 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

@webpro
Copy link
Collaborator

webpro commented Nov 10, 2024

Sorry it took a while, but should be good now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants