Contributing to Prettier Java
March 14, 2026 ยท View on GitHub
To get up and running, install the dependencies and run the full build:
yarn
yarn ci
You can also inspect the other available dev flows scripts:
yarn run
Testing your changes
If you would like to check the impact of your changes on a sample code, edit the scripts/single-printer-run/_input.java file and run
node scripts/update-test-output.js -single
The prettified code will be output in scripts/single-printer-run/_output.java.
It is also possible to prettify an entire repository by running the following command:
node scripts/update-test-ouput.js -repository relative/path/to/the/repository
It will then be output inside test-samples/repository-name.
To check the stability of the reformating, you can run several times Prettier with the -times flag (e.g. 5 times):
node scripts/update-test-output.js -single -times 5
If you run:
node scripts/update-test-ouput.js
It will simply update all the tests located in test/unit-test folder.
If you would like to run all the tests, simple use the following command:
yarn test
Formatting
The prettier-java source code is (unsurprisingly) formatted using prettier. Make sure to properly format the source code before committing by running:
yarn run format:fix
Unit Testing
All Unit tests in this project are implemented with the Mocha testing framework and the Chai assertion library.