Skip to content

Commit 6ce3908

Browse files
committed
Edit some docs re. handling binaries (closes #1107)
1 parent 8aa2f13 commit 6ce3908

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

packages/docs/src/content/docs/guides/handling-issues.mdx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,29 +314,28 @@ control, security and stability.
314314
### Unlisted binaries
315315

316316
Binaries are executable Node.js scripts. Some npm packages, when installed, add
317-
one or more executable files to use from scripts in `package.json`. Examples
317+
one or more executable files to be used from scripts in `package.json`. Examples
318318
include TypeScript that comes with the `tsc` binary, ESLint comes with `eslint`,
319319
Next.js with `next`, and so on.
320320

321321
Knip detects such binaries in scripts and checks whether there's a package
322322
installed that includes that binary. It looks up the `bin` field in the
323323
`package.json` file of installed packages. If it doesn't find it, it will be
324-
reported as an unlisted binary as there is no package listed that contains it.
324+
reported as an unlisted binary as there is no package that contains it.
325325

326326
Binaries that are installed on the OS already and thus likely not meant to be
327327
installed from npm are not reported as unlisted (details: [list of ignored
328328
binaries in source][30]).
329329

330-
### Missing binaries
330+
#### Missing binaries
331331

332-
In case unused (dev) dependencies look like a match against unlisted binaries,
333-
then this might be caused by `node_modules` not containing the packages. And
334-
this might have been caused by either the way your package manager installs
335-
dependencies and binaries, or by not running Knip from the root of the
336-
repository.
332+
An unused dependency and an unlisted binary with the same name indicates
333+
`node_modules` not containing the relevant package. And this might be caused by
334+
either the way your package manager installs dependencies and binaries, or by
335+
not running Knip from the root of the repository.
337336

338-
**Solution**: run Knip from the project root. From there you can [lint
339-
individual workspaces][31].
337+
**Solution**: run Knip from the project root. If needed, [lint workspaces
338+
individually][31].
340339

341340
Sometimes binaries and how they're reported can be a bit confusing. See this
342341
example:
@@ -357,8 +356,15 @@ This example works fine without anything reported, as the `@commitlint/cli`
357356
package includes the `commitlint` binary. However, some script may contain
358357
`npx commitlint` and here Knip assumes `commitlint` is the name of the package.
359358
This technically works, as `commitlint` is a transitive dependency of
360-
`@commitlint/cli`. However, correct and recommeded usage is by the package name:
361-
`npx @commitlint/cli`.
359+
`@commitlint/cli`.
360+
361+
**Solution**: use `npx @commitlint/cli`
362+
363+
In some cases, using `npx` in a script may result in Knip not understanding
364+
intention without an explicit `--yes` or `--no-install` flag.
365+
366+
**Solution**: use `npx --yes` or `npx --no-install` so Knip will either ignore
367+
or consider the binary and package(s) referenced, respectively.
362368

363369
## Unresolved imports
364370

0 commit comments

Comments
 (0)