๐ Knip recognizes argument of custom script as an unlisted dependency
baloghroli opened this issue ยท 3 comments
Prerequisites
- I'm using the latest version
- I've read the relevant documentation
- I've searched for existing issues
- I've checked the list of known issues
- I've read the issue reproduction guide
Reproduction url
https://codesandbox.io/p/devbox/6yrhqx?migrateFrom=g4rh6k
Reproduction access
- I've made sure the reproduction is publicly accessible
Description of the issue
First of all, thanks for your work, this is a really nice and handy tool!
Problem
There is an execution of a custom shell script included in the scripts
object in the package.json
with custom arguments like this: "waitDB": "./wait-for-postgres.sh -h localhost -p 5433 -U dev -r 10"
(another example is in the repro link). Knip recognizes the argument -r 10 as an unlisted dependency.
Interesting thing is that if I change it to something else like max_retries
the problem goes away. I guess it is because it recognizes a set of arg names.
A solution could be that I change the naming, but it feels wrong to change naming just because it's not recognized by third party.
Knip has a "fallback binary resolver" and that one indeed recognizes -r
as the often-used --require
or --loader
argument in Node.js based programs. That fallback should not be activated for such shell script programs and its arguments.
Until it's fixed you should be able to suppress with ignoreDependencies: ["10"]
Doing some refactoring, and in the next version this should be sorted. You could try an early version if you like:
npm install -D https://pkg.pr.new/knip@f1349c2
Going to close with the release of v5.34.0