feat: make knip understand yarn pnp
Make knip understand yarn pnp. It can now look into manifest files inside yarn cache, and correctly check peer dependency or bin field.
Maybe we can make this feature to be enabled with yarn plugin made from #864 but I couldn't find how to patch manifest helpers with plugin.
You should see manifest/helpers.ts.
It turns out that running all test code in series global variable in helpers (isPnPEnabled) is unintentionally flagged as false because other fixtures are not yarn pnp workspace. I'll fix it.
Thanks for the PR, @jwoo0122. Without knowing exactly how PnP works, please let my try to understand what support for PnP means to Knip, and what features (i.e. issue types) are still (un)available/relevant.
Some initial questions that pop up in my mind:
- The fixture has only "internal" packages and ignores a bunch of stuff, but perhaps we could see a more realistic example?
- Is there support for monorepos/workspaces (i.e.
package.json#workspaces)? Or is that not relevant cq nothing to worry about? - Since there are no
node_modulesanymore, what about:- Binaries (
node_modules/.bin) e.g. those referenced inpackage.json#scripts - Knip reads
package.json#typesetc. to see if types are included with the package (so e.g.@types/eslintis unused ifeslintis listed).
- Binaries (
Closing this due to inactivity and lack of responses. Feel free to reopen, discuss, or upvote as you see fit.