webpro-nl / knip

✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects. Knip it before you ship it!
https://knip.dev
ISC License
6.97k stars 173 forks source link

🐛 There seems to be a false positive with config files #791

Closed AlemTuzlak closed 3 weeks ago

AlemTuzlak commented 1 month ago

Prerequisites

Reproduction url

https://github.com/forge42dev/Remix-Dev-Tools/pull/150

Reproduction access

Description of the issue

Hey Lars! Hope you're well, so if you open up the url I sent and clone the PR and delete the "tsup*.ts" from the ignore list you'll get reports of unused files which are indeed used to bundle the client and server parts of RDT. They are located in the root package.json. Maybe it can help make the detection better, or maybe I missed something

webpro commented 1 month ago

The default tsup plugin is here: https://knip.dev/reference/plugins/tsup and you can override it by setting e.g tsup.config: ["tsup*.ts"]

In general, if you customize the location of a config file, that should probably also happen in Knip config. Knip tries to follow the defaults of the tool or framework as much as possible (and those defaults might change over time).

Knip has custom parsers to find entry files from package.json#scripts and this covers a good deal of cases generally speaking, but there's no support for config files yet. That's a bit different, since it has to be done in the plugin itself.

webpro commented 1 month ago

Doing a large refactor, which will also unlock this feature. You could try it out if you like:

pnpm add -D https://pkg.pr.new/knip@d288779

(just fyi, what this takes inside Knip plugins)

webpro commented 3 weeks ago

Going to close with the release of v5.34.0

AlemTuzlak commented 3 weeks ago

indeed fixed