-
Notifications
You must be signed in to change notification settings - Fork 456
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
Add Prettier to Maven plugin #555
Conversation
Happy eastern :-) |
Link to the issue stating the discontinuation of J2V8 for non android envs: eclipsesource/J2V8#279 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing, thanks very much! I made some comments. If you get stuck fixing the tests let me know and I will try to take a look.
plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java
Show resolved
Hide resolved
Thx for the comments, I think I addressed all. Still fighting with the failing build, as that does not happen locally. |
Hey finally green... and I don't think I committed anything to fix that ;) |
Published in plugin-maven 1.30.0 |
@source-knights You mentioned in the docs
But it looks to me like our default is actually spotless/lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java Lines 40 to 42 in 608af5c
Did you perhaps mean to commit something that didn't make it? Also, wanted to double-check that |
@nedtwigg Oh yes, good spot. That's a leftover in the doc from a point, where I wanted to up the default to max supported. But I decided against this to not change existing behaviour for people using the gradle plugin and keep it in sync with that. 1.19.0 is in fact the last prettier version working with current spotless. As explained, that is due to the used J2V8. The newer prettier from version 2.0.0 uses ES6 features in the JS, e.g. (...args). J2V8 can't use that and errors then, showing something like: com.eclipsesource.v8.V8ScriptExecutionException: C:\Users\XYZ\AppData\Local\Temp\junit5133972595801156893\target\spotless-node-modules-prettier-format\node_modules\prettier\index.js:1938: SyntaxError: Unexpected token ... |
Roger. No obligation to fix, but just FYI, our policy on default versions is that we always bump the default to latest and note it in the changelog. New users of Spotless get the best formatters available, existing users of Spotless who prefer the old version can easily pin it. |
We don't have any formal system for finding new versions either, it's just if somebody is working on that component or bothers to make a PR. |
This PR adds Prettier to the Maven plugin.
The only limitation (which is also for the Gradle plugin, is that Spotless uses J2V8. As development for J2V8 for non android envs is stopped (for Windows since J2V8 4.6.0 and Unix 4.8.0), therefore Prettier is limited to <= v1.19.0 as newer versions use ES6 feature and that would need a newer J2V8 version.
Please make sure that your PR allows edits from maintainers. Sometimes its faster for us to just fix something than it is to describe how to fix it.
After creating the PR, please add a commit that adds a bullet-point under the
-SNAPSHOT
section of CHANGES.md, plugin-gradle/CHANGES.md, and plugin-maven/CHANGES.md which includes:If your change only affects a build plugin, and not the lib, then you only need to update the
CHANGES.md
for that plugin.If your change affects lib in an end-user-visible way (fixing a bug, updating a version) then you need to update
CHANGES.md
for both the lib and the build plugins. Users of a build plugin shouldn't have to refer to lib to see changes that affect them.This makes it easier for the maintainers to quickly release your changes :)