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.65k stars 155 forks source link

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

Open AlemTuzlak opened 1 day ago

AlemTuzlak commented 1 day 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 2 hours 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.