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

eslint-plugin-prettier possible regression #230

Closed
a-ursino opened this issue Sep 5, 2023 · 6 comments
Closed

eslint-plugin-prettier possible regression #230

a-ursino opened this issue Sep 5, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@a-ursino
Copy link

a-ursino commented Sep 5, 2023

Hi

I'm aware of #128 but noticed a similar behaviour using latest knip.

I've created a demo that uses npx create vue@latest as starting point to reproduce the issue a-ursino/vue-knip-demo#1

@a-ursino a-ursino added the bug Something isn't working label Sep 5, 2023
@webpro
Copy link
Collaborator

webpro commented Sep 5, 2023

Yeah that may seem odd, but when we look at their docs: https://github.com/prettier/eslint-plugin-prettier#recommended-configuration we can see that first eslint-plugin-prettier should be installed, and then it's recommended to also install eslint-config-prettier, but with only this configuration:

{
  "extends": ["plugin:prettier/recommended"]
}

This resolves to only the eslint-plugin-prettier package, while eslint-config-prettier should be installed as well. But it's not a peer dependency, so Knip has no way to figure out what the real intention is.

That's why Knip his this horrible line in the code, leading to your observation (there's no eslint-config-prettier in sight for you):
https://github.com/webpro/knip/blob/b920ad7920c236de2800a6136ff662929003137f/src/plugins/eslint/helpers.ts#L14

So I think it's choosing between two bad options. I went for what I thought would be used most (their recommendation).

@a-ursino
Copy link
Author

a-ursino commented Sep 6, 2023

I've installed both eslint-config-prettier and eslint-plugin-prettier and added plugin:prettier/recommended in the extends in my PR https://github.com/a-ursino/vue-knip-demo/pull/1/files.
Am I missing something else?

@webpro
Copy link
Collaborator

webpro commented Sep 6, 2023

Ah no my apologies, the issue is indeed with the /recommended path. I'll fix it shortly.

@webpro webpro closed this as completed in aa718c2 Sep 7, 2023
@webpro
Copy link
Collaborator

webpro commented Sep 7, 2023

🚀 This issue has been resolved in v2.22.0. See Release 2.22.0 for release notes.

@webpro
Copy link
Collaborator

webpro commented Sep 7, 2023

Thanks for the rep(r)o @a-ursino, very helpful.

@a-ursino
Copy link
Author

a-ursino commented Sep 7, 2023

Thanks for the amazing tool and quick fix.

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