knip icon indicating copy to clipboard operation
knip copied to clipboard

Request new plugins here

Open webpro opened this issue 1 year ago • 42 comments

Please add one comment per plugin (please link to website/repo/docs), which others can then upvote using reactions like 👍 (not more comments).

The idea is that you can request/upvote plugins here. Contributors/me can implement them.

Please make sure the plugin isn't already available/listed on https://knip.dev/reference/plugins

webpro avatar Jan 29 '24 14:01 webpro

Ladle (https://github.com/webpro/knip/issues/268)

webpro avatar Jan 29 '24 14:01 webpro

Vike (https://github.com/webpro/knip/issues/275)

webpro avatar Jan 29 '24 14:01 webpro

React cosmos

Includes:

/cc @ovidiuch

birtles avatar Jan 30 '24 02:01 birtles

NestJS, maybe?

It's very class based, so it would be focused on classMembers rules.

It would need to detect usage of class members by decorators, basically - e.g, something decorated with @ResolveField is used.

Faithfinder avatar Jan 30 '24 14:01 Faithfinder

WebdriverIO (#464)

webpro avatar Feb 04 '24 13:02 webpro

Not sure if this is a plugin or core, but support for .mdx files. (used by Storybook and other docs generators)

justingrant avatar Feb 04 '24 21:02 justingrant

@justingrant Please file a separate issue for this (as it's not a plugin).

webpro avatar Feb 05 '24 06:02 webpro

Serverless framework (1 183 585 downloads a week). It uses serverless.yml files for config and includes :

  • Plugins (docs/eg)
  • Serverless function definitions, so entries (docs/eg, under functions.*.handler field)

netner-d avatar Feb 09 '24 09:02 netner-d

Please don't dump words here. It'll be a lot more convincing if you'd be more precise and provide one or two links to the library and/or configuration pages to avoid any ambiguity.

webpro avatar Feb 09 '24 09:02 webpro

Please don't dump words here. It'll be a lot more convincing if you'd be more precise and provide one or two links to the library and/or configuration pages to avoid any ambiguity.

Yeah, absolutely sorry about that, I thought it was the method to collect people opinion as I saw similar comments above... I'm rectifying

netner-d avatar Feb 09 '24 09:02 netner-d

tsd (#535)

webpro avatar Mar 24 '24 10:03 webpro

wrangler ideas: find wrangler.toml/json and set main as entrypoint, and exclude from unused dependencies

DaniFoldi avatar Mar 24 '24 10:03 DaniFoldi

Just saying, for anyone interested, it's now more fun and easier than ever to write a plugin: https://knip.dev/guides/writing-a-plugin

webpro avatar Mar 24 '24 10:03 webpro

is deno compat a plugin? If so, what would it take? Deno uses the web standard import_map.json

guy-borderless avatar Apr 10 '24 21:04 guy-borderless

Would it be possible to create a Nuxt plugin? Nuxt heavily uses auto-imports, so I imagine it could be harder to trace down what is being used.

sifferhans avatar Apr 11 '24 11:04 sifferhans

Docusaurus - https://docusaurus.io/

auvred avatar Apr 23 '24 17:04 auvred

Ionic (https://github.com/webpro/knip/issues/604)

webpro avatar Apr 29 '24 06:04 webpro

I was gonna request xo, but I've just opened a PR for it instead since I was interested in how they work. https://github.com/webpro/knip/pull/621

bbeesley avatar May 03 '24 12:05 bbeesley

Plugins added recently:

  • Wrangler - thanks @DaniFoldi!
  • xo - thanks @bbeesley!
  • improved Ionic/Capacitor - thanks @ptmkenny!

webpro avatar May 07 '24 11:05 webpro

Expo (expo.dev)

emmanuelchucks avatar May 13 '24 23:05 emmanuelchucks

size-limit (and related packages @size-limit/*)

tmm avatar Jun 05 '24 16:06 tmm

For everyone interested in support for Expo, please see https://github.com/webpro-nl/knip/issues/126. Looking for feedback!

webpro avatar Jun 06 '24 07:06 webpro

lockfile linting

lint lockfiles for improved security and trust policies

https://github.com/lirantal/lockfile-lint https://github.com/lirantal/lockfile-lint/blob/main/packages/lockfile-lint/README.md

jerone avatar Jun 11 '24 13:06 jerone

lockfile linting

lint lockfiles for improved security and trust policies

https://github.com/lirantal/lockfile-lint https://github.com/lirantal/lockfile-lint/blob/main/packages/lockfile-lint/README.md

I guess a file-based configuration for the lockfile-lint package potentially leaves e.g. lockfile-lint.js as an unused file. The lockfile-lint configuration doesn't seem to contain options that can reference other packages or files, so a plugin doesn't add much other than Knip users not having to add !lockfile-lint.js to project: [] (or alternatively not having to add lockfile-lint.js to ignore: []). Maybe Knip should have another more light-weight type of plugins that basically just ignores this type of configuration files.

(For completeness sake: the act of linting lockfiles is outside the scope of Knip, and apparently there's a package that does exactly that.)

webpro avatar Jun 11 '24 16:06 webpro

I guess a file-based configuration for the lockfile-lint package potentially leaves e.g. lockfile-lint.js as an unused file.

Correct. That was the reason for creating this suggestion.

The lockfile-lint configuration doesn't seem to contain options that can reference other packages or files [..]

Also correct. It's just an configuration file. It references no other dependencies/extension/extends/plugins/etc...

[..] so a plugin doesn't add much other than Knip users not having to add !lockfile-lint.js to project: [] (or alternatively not having to add lockfile-lint.js to ignore: []).

Yes, adding it to the ignore setting is my current "work-around".

Maybe Knip should have another more light-weight type of plugins that basically just ignores this type of configuration files.

Lockfile-linting uses https://github.com/cosmiconfig/cosmiconfig (v8) for their config file, as do many other tooling. Maybe these config files can be ignored by default somehow.

Sadly, custom local plugins are not on the roadmap. But the ignore setting is sufficient in this case.

Keep up the great work! 🇳🇱

jerone avatar Jun 12 '24 10:06 jerone

Knip v5.21.0 contains a few new plugins:

Especially the latter is a bit rudimentary, feel free to open issues if you have any!

webpro avatar Jun 17 '24 13:06 webpro

I'd like to request support for rspack. Since rspack's configuration is roughly equivalent to webpack's configuration, it's possible that the webpack plugin could either be cloned or just tweaked to accommodate rspack instead.

I actually tried just changing the knip.json file to have the webpack plugin point to the rspack configuration file and it worked fine with one exception. The rspack configuration allows specification of a builtin: prefix on the loader property (see here) and an "Unlisted dependency" of builtin:swc-loader is being reported by knip.

So, I think it's possible that the webpack plugin could simply be adjusted to:

  • Change the detection to include @rspack/core and @rspack/cli as the enablers
  • Add rspack.config*.{js,ts,mjs,cjs,mts,cts} as valid config files
  • Ignore loaders prefixed with builtin:

shawnmcknight avatar Jul 03 '24 22:07 shawnmcknight

Similar to rspack, I'd like plugin support for rsbuild: https://rsbuild.dev/guide/start/index https://github.com/web-infra-dev/rsbuild

Suver1 avatar Jul 08 '24 08:07 Suver1

Since some of you have requested plugins for React Cosmos and Rspack, let's make it happen. Would be great if you could share and show some support with a one-time sponsorship? 🙏 I can work on the 2 plugins in the coming weekend.

Rsbuild should have lower threshold after that.

webpro avatar Jul 15 '24 07:07 webpro

Since some of you have requested plugins for React Cosmos and Rspack, let's make it happen. Would be great if you could share and show some support with a one-time sponsorship?

@birchill has just made a one time sponsorship to see this happen. Hopefully others can join in too!

birtles avatar Jul 15 '24 14:07 birtles