-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Do not declare wp-prettier
as a dependency of @wordpress/eslint-plugin
#39208
Comments
In theory, we could make Prettier a peer dependency and mark it as optional. It would be similar to what we did for TypeScript: gutenberg/packages/eslint-plugin/package.json Lines 57 to 61 in 6933f93
We need to evaluate what implications that would have. Many projects use only In general, working with this Prettier's fork has been painful for quite some time as reported in #21872. I shared a proposal so we stop using the fork in WordPress/Gutenberg some time ago: https://make.wordpress.org/core/2022/01/05/proposal-changes-to-javascript-coding-standards-for-full-prettier-compatibility/. I updated my test repository today that uses I saw some warnings because of that ...
Actually, I have to disagree here for the context of WordPress. We use Prettier + ESLint integration to enforce WordPress JavaScript conventions. Anyway, I agree that we can make it more flexible as noted above. |
I thought about the peerDep and making it optional. I just wasn't sure how NPM would handle an optional dep with name of prettier and a different version when other packages also require the same dep name but with a different version. I believe the optional dep idea would be easier if we could tell eslint to use a different prettier binary (unsure if this is possible) .That way you could declare two optional peer deps: wp-prettier (which would expose a wp-prettier bin) and prettier. |
Just confirming that npm 7/8 currently do not resolve aliases defined in dependencies. I have also started to add the alias to the main Related: npm/cli#4197, npm/cli#2800 |
It worked way much better with npm 6, but sometimes it was problematic in Gutenberg so we enforced it to avoid issues. In my testing with npm 6 these npm aliases worked quite well but we had reports about issues. |
as FYI this is what npm ls look like for prettier when using npm 8 on 10up-toolkit. I've had reports where npm install completely fails when using npm 7. npm 8 just gives an ERESOLVE warning. If consumers of |
I think we should just mark a regular |
That makes sense to me re: including |
I opened #39244 to make |
@nicholasio, there is |
@gziolo Thanks! This solved the issue for me |
@nicholasio, this is great news and thank you for reporting back 🎉 |
What problem does this address?
Currently, the
@wordpress/eslint-plugin
is declaring the WordPress fork of prettier as direct dependency and therefore making the wrong assumption that every project using that package is going to use WP fork of prettier.At 10up, we have our own build tool similar to
wp-scripts
but we do not usewp-prettier
, we use prettier original implementation. Our eslint config exports awordpress
config that makes use of the custom@wordpress
eslint rules but depending on@wordpress/eslint-plugin
causes some issues (from npm ERESOLVE warnings to errors in some versions of npm) due to conflicting dependencies of prettier.IMO prettier and wp-prettier have nothing to do with
@wordpress/eslint-plugin
and it should be up to the consumers of the plugin to decide how they want to format their code.What is your proposed solution?
Remove wp-prettier from
package.json
in the eslint-plugin packagegutenberg/packages/eslint-plugin/package.json
Line 49 in ab65bf4
wp-scripts
declare prettier's fork as a direct dependency.The text was updated successfully, but these errors were encountered: