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
7.03k stars 174 forks source link

🐛 Stylelint: "customSyntax" config is not recognised as dependency usage #799

Closed duncan-thacker closed 1 month ago

duncan-thacker commented 1 month ago

Prerequisites

Reproduction url

https://codesandbox.io/p/sandbox/zealous-northcutt-g94nf7

Reproduction access

Description of the issue

Including "customSyntax": "postcss-less" in the stylelint config does not mark postcss-less as a used dependency. knip definitely detects the config file correctly, but there is nothing in the plugin code that checks this field. https://github.com/webpro-nl/knip/blob/main/packages/knip/src/plugins/stylelint/index.ts

Knip produces the following report:

Unused devDependencies (1)
postcss-less  package.json

Workaround

By switching to a JS config, you can do

"customSyntax": require.resolve("postcss-less")

which causes the dependency to be correctly marked as used.

duncan-thacker commented 1 month ago

I'll try to raise a PR for this at some point, for now it's just a nice-to-have so that knip works better out-of-the-box.

webpro commented 1 month ago

Sounds great, thanks in advance! Let me know if you need anything.