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

Way to format this on save #110

Open
jaoxford opened this issue Jun 20, 2024 · 1 comment
Open

Way to format this on save #110

jaoxford opened this issue Jun 20, 2024 · 1 comment

Comments

@jaoxford
Copy link

jaoxford commented Jun 20, 2024

Just curious if there's a way of formatting this on save? I am using intelliJ.
I have tried to use the file-watcher plugin, with the following config for my IDE:

Screenshot 2024-06-20 at 15 11 19

When I save my file I get the following error:

//.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.16/prettier-maven-plugin-0.16-prettier-java-0.7.0/prettier-java/node_modules/prettier/bin-prettier.js --write src/main/java/MyFile.java
[error] No matching files. Patterns tried: src/main/javaMyFile.java !**/node_modules/** !./node_modules/** !**/.{git,svn,hg}/** !./.{git,svn,hg}/**

Process finished with exit code 2

Here's the output of print-args:

printWidth=90
tabWidth=4
useTabs=false
noConfig=true
noEditorconfig=true
inputGlob=src/main/java/**/*.java
inputGlob=src/test/java/**/*.java
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.273 s
[INFO] Finished at: 2024-06-20T15:15:03+01:00
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

And if I manually trigger prettier:write that is also fine. Ideally this would be something that runs on every save, so I don't have to think about it!

Any idea or help would be appreciated!

@jaoxford
Copy link
Author

jaoxford commented Jun 21, 2024

Bit of an update:

I managed to get this to work, but there's a few things that don't work exactly as I had hoped.

It seems that running prettier from the file watcher behaves differently than how it's run in the pom.xml file, I think there's a few ways of getting this locked down.

  1. Ideally I'd be able to run mvn prettier:write inside of the file watcher instead of manually providing the prettier location.
  2. If that's not possible, use the .prettierrc in both ways of running prettier: From the file watcher / command line, & the pom / mvn

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

No branches or pull requests

1 participant