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

Add Prettier to Maven plugin #555

Merged
merged 14 commits into from
Apr 10, 2020
Merged

Conversation

source-knights
Copy link
Contributor

@source-knights source-knights commented Apr 9, 2020

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.

Allow edits from maintainers

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:

  • a summary of the change
  • either
    • a link to the issue you are resolving (for small changes)
    • a link to the PR you just created (for big changes likely to have discussion)

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

@source-knights
Copy link
Contributor Author

Happy eastern :-)

@source-knights
Copy link
Contributor Author

Link to the issue stating the discontinuation of J2V8 for non android envs: eclipsesource/J2V8#279

Copy link
Member

@nedtwigg nedtwigg left a 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.

CHANGES.md Outdated Show resolved Hide resolved
plugin-maven/CHANGES.md Outdated Show resolved Hide resolved
plugin-maven/CHANGES.md Outdated Show resolved Hide resolved
plugin-maven/README.md Show resolved Hide resolved
plugin-maven/README.md Show resolved Hide resolved
plugin-maven/README.md Show resolved Hide resolved
@source-knights
Copy link
Contributor Author

Thx for the comments, I think I addressed all. Still fighting with the failing build, as that does not happen locally.

@source-knights
Copy link
Contributor Author

Hey finally green... and I don't think I committed anything to fix that ;)

@nedtwigg nedtwigg merged commit 3e3c969 into diffplug:master Apr 10, 2020
@nedtwigg
Copy link
Member

Published in plugin-maven 1.30.0

@nedtwigg
Copy link
Member

nedtwigg commented Apr 11, 2020

@source-knights You mentioned in the docs

Specify either simple prettier version (1.19.0 is max supported, which is also default) or whole devDependencies

But it looks to me like our default is actually 1.16.4

public static final Map<String, String> defaultDevDependencies() {
return defaultDevDependenciesWithPrettier("1.16.4");
}

Did you perhaps mean to commit something that didn't make it? Also, wanted to double-check that 1.19.0 is really the max supported, was that what you found in testing? See #556

@source-knights
Copy link
Contributor Author

source-knights commented Apr 12, 2020

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

@nedtwigg
Copy link
Member

I decided against this to not change existing behaviour for people using the gradle plugin and keep it in sync with that.

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.

@nedtwigg
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants