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

Request new plugins here #483

Open
webpro opened this issue Jan 29, 2024 · 50 comments
Open

Request new plugins here #483

webpro opened this issue Jan 29, 2024 · 50 comments
Labels
plugin An issue or enhancement in a plugin

Comments

@webpro
Copy link
Collaborator

webpro commented Jan 29, 2024

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 webpro added the plugin An issue or enhancement in a plugin label Jan 29, 2024
@webpro webpro pinned this issue Jan 29, 2024
@webpro
Copy link
Collaborator Author

webpro commented Jan 29, 2024

Ladle (#268)

@webpro
Copy link
Collaborator Author

webpro commented Jan 29, 2024

Vike (#275)

@birtles
Copy link
Contributor

birtles commented Jan 30, 2024

React cosmos

Includes:

/cc @ovidiuch

@Faithfinder
Copy link
Contributor

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.

@webpro
Copy link
Collaborator Author

webpro commented Feb 4, 2024

WebdriverIO (#464)

@justingrant
Copy link

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

@webpro
Copy link
Collaborator Author

webpro commented Feb 5, 2024

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

@netner-d
Copy link

netner-d commented Feb 9, 2024

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)

@webpro
Copy link
Collaborator Author

webpro commented Feb 9, 2024

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.

@netner-d
Copy link

netner-d commented Feb 9, 2024

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

@webpro
Copy link
Collaborator Author

webpro commented Mar 24, 2024

tsd (#535)

@DaniFoldi
Copy link
Contributor

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

@webpro
Copy link
Collaborator Author

webpro commented Mar 24, 2024

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

@guy-borderless
Copy link

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

@sifferhans
Copy link

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.

@auvred
Copy link
Contributor

auvred commented Apr 23, 2024

Docusaurus - https://docusaurus.io/

@webpro
Copy link
Collaborator Author

webpro commented Apr 29, 2024

Ionic (#604)

@bbeesley
Copy link
Contributor

bbeesley commented May 3, 2024

I was gonna request xo, but I've just opened a PR for it instead since I was interested in how they work.
#621

@webpro
Copy link
Collaborator Author

webpro commented May 7, 2024

Plugins added recently:

@emmanuelchucks
Copy link

Expo (expo.dev)

@tmm
Copy link
Contributor

tmm commented Jun 5, 2024

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

@webpro
Copy link
Collaborator Author

webpro commented Jun 6, 2024

For everyone interested in support for Expo, please see #126. Looking for feedback!

@jerone
Copy link
Contributor

jerone commented Jun 11, 2024

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

@webpro
Copy link
Collaborator Author

webpro commented Jun 11, 2024

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.)

@jerone
Copy link
Contributor

jerone commented Jun 12, 2024

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! 🇳🇱

@webpro
Copy link
Collaborator Author

webpro commented Jun 17, 2024

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!

@shawnmcknight
Copy link

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:

@Suver1
Copy link

Suver1 commented Jul 8, 2024

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

@webpro
Copy link
Collaborator Author

webpro commented Jul 15, 2024

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.

@birtles
Copy link
Contributor

birtles commented Jul 15, 2024

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!

@shawnmcknight
Copy link

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.

@STORIS does its sponsorships as recurring monthly rather than one-time. A monthly recurring contribution through open collective has been added, although there's no condition for that with respect to the plugin request.

@webpro
Copy link
Collaborator Author

webpro commented Jul 15, 2024

@birtles @birchill @shawnmcknight @STORIS Thank you so much! Truly appreciated.

@webpro
Copy link
Collaborator Author

webpro commented Jul 19, 2024

Added plugins:

  • React Cosmos
  • Rspack
  • Rsbuild (placeholder)

Not yet GA. Can be tested with npm i -D https://pkg.pr.new/knip@2de3924 (or any package manager). Would be very useful if you could try it out to increase coverage and improve the plugins.

Please file bugs in new GitHub issues.

@birtles
Copy link
Contributor

birtles commented Jul 19, 2024

Can be tested with npm i -D https://pkg.pr.new/knip@2de3924 (or any package manager). Would be very useful if you could try it out to increase coverage and improve the plugins.

Works great for me. Thank you!

@silverwind
Copy link

silverwind commented Jul 26, 2024

Makefile:

lint:
	npx eslint

Should mark eslint as used. I would say this should be core functionality, e.g not a plugin.

@BMFreed
Copy link

BMFreed commented Aug 6, 2024

@webpro I know this was already requested, but are there plans to add a Nuxt plugin?

@webpro
Copy link
Collaborator Author

webpro commented Aug 6, 2024

Re. Nuxt plugin: Usually "auto-imports" might be hard to track indeed during static or even dynamic analysis.

In general not doing much of new features myself at the moment. Sponsored might be an option (DM me). Open to pull requests!

@BMFreed
Copy link

BMFreed commented Aug 6, 2024

Re. Nuxt plugin: Usually "auto-imports" might be hard to track indeed during static or even dynamic analysis.

In general not doing much of new features myself at the moment. Sponsored might be an option (DM me). Open to pull requests!

Thank you for your reply!

@with-heart
Copy link

preconstruct allows multiple entrypoints to be defined in a package's package.json file. Standalone entrypoints currently have to be manually defined using entry.

@webpro
Copy link
Collaborator Author

webpro commented Aug 23, 2024

VitePress (Site Config)

@webpro
Copy link
Collaborator Author

webpro commented Aug 23, 2024

Karma (Configuration File)

@webpro
Copy link
Collaborator Author

webpro commented Aug 31, 2024

Added a few plugins in v5.28.0:

NOTE: the Nuxt plugin has no support for auto-import magic, except for defineNuxtConfig (to prevent insta-throw/offs). Should probably add a warning on the plugin page.

@flip-it
Copy link

flip-it commented Sep 24, 2024

package.json:

{
  …
  "dependencies": {
    …
    "@company/browserslist-config": "2.0.0",
  },
  "browserslist": [
    "extends @company/browserslist-config"
  ],
  …
}

should not throw Unused dependencies for @company/browserslist-config

@Faithfinder
Copy link
Contributor

Panda CSS (I think just the config file?)
PostCSS, should be included with Vite plugin

@RafalFilipek
Copy link

tsx.

Currently

// ./bin/index.ts

#!/usr/bin/env tsx

const x: string = 'Hello knip';

is not detected.

// ./package.json

{
  "bin": {
    "app": "./bin/index.ts"
  },

  "dependencies": {
    "tsx": "4.7.1",
  },

}

@webpro
Copy link
Collaborator Author

webpro commented Oct 23, 2024

Does #!/usr/bin/env tsx point to the tsx dependency executable (in the project's node_modules)? Please file a separate bug report if you think Knip should handle this better as this is rather core area (not so much plugin-specific).

@FrankiePo
Copy link

FrankiePo commented Oct 28, 2024

Vinxi

@FrankiePo
Copy link

Nitro

@roduyemi
Copy link

roduyemi commented Oct 31, 2024

Flow

Getting some false positives for type exports. unimported used to have an option to remove flow types and I wonder if that's needed or I need to add any additional configuration to detect unused flow types?

Thanks!

@bigpopakap
Copy link

bigpopakap commented Nov 14, 2024

Prisma ORM

Maybe this specific issue isn't in scope for a Prisma plugin, but my prisma/seed.ts file is getting flagged but is used in a package.json script:

"prisma": {
    "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin An issue or enhancement in a plugin
Projects
None yet
Development

No branches or pull requests