Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Unable to disable plugin config loaded from scripts #947

Closed
6 tasks done
fbjaras opened this issue Feb 18, 2025 · 4 comments
Closed
6 tasks done

🐛 Unable to disable plugin config loaded from scripts #947

fbjaras opened this issue Feb 18, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@fbjaras
Copy link

fbjaras commented Feb 18, 2025

Prerequisites

Reproduction url

https://codesandbox.io/p/sandbox/knip-bug-reproduce-yl7hvw

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

Bug description

Providing a config to a script in package.json will make knip evaluate the config for the plugin, even if the plugin is set as false

Example: (see repro as well)

"playwright-test": "playwright test --config=playwright.config.ts
results in the config to be evaluated, even if plugin is disabled in knip.json etc.

Ran into this when adding knip to a big monorepo and there were some errors that got thrown in a config file.
Wanted to get knip running by excluding files/etc, before modifying/fixing any issues.

Expected:

Possible to either exclude the config from being evaluated by some config as well as when disabling the plugin.

Note

I am a quite new user of Knip, so i might have missed some option. But i experimented a lot and could not find a solution

@fbjaras fbjaras added the bug Something isn't working label Feb 18, 2025
@webpro
Copy link
Member

webpro commented Feb 18, 2025

Thanks for the report, @fbjaras!

I think the fix in this prerelease should help you out. Any chance you could try this version to see if it works as expected before I publish a new GA version of Knip? Like so:

npm i -D https://pkg.pr.new/knip@383c4aa

If a plugin isn't listed in (an ancestor) package.json you shouldn't even need to disable at all anymore. If it's listed you'd need to disable as you're doing indeed.

There's something funky going on with the playwright and playwright-ct keys as well (as you found out), but that's for another day.

@fbjaras
Copy link
Author

fbjaras commented Feb 18, 2025

Thanks for the report, @fbjaras!

I think the fix in this prerelease should help you out. Any chance you could try this version to see if it works as expected before I publish a new GA version of Knip? Like so:

npm i -D https://pkg.pr.new/knip@383c4aa

If a plugin isn't listed in (an ancestor) package.json you shouldn't even need to disable at all anymore. If it's listed you'd need to disable as you're doing indeed.

There's something funky going on with the playwright and playwright-ct keys as well (as you found out), but that's for another day.

Wow, thanks for the quick detective work! @webpro
Your fix checking enabledPlugins did the trick for me 🙏

Yeah, i got kind of confused by the inconsistency there, but as you say, one step at a time!

Looking forward to when the fix is released 🚀

@webpro webpro closed this as completed in 8209917 Feb 18, 2025
@webpro
Copy link
Member

webpro commented Feb 18, 2025

🚀 This issue has been resolved in v5.44.2. See Release 5.44.2 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

@webpro
Copy link
Member

webpro commented Feb 18, 2025

Thanks again @fbjaras, LFG 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants