Skip to content

Replace Prettier with formatter-maven-plugin #110

Description

@bertysentry

Context

The project currently formats Java sources with com.hubspot.maven.plugins:prettier-maven-plugin:0.22 and prettier-plugin-java:2.5.0, configured through .prettierrc.yaml.

We want to replace Prettier with net.revelc.code.formatter:formatter-maven-plugin, following the convention already used by:

Both reference projects currently use formatter-maven-plugin:2.29.0, bind its validate goal to Maven's validate phase, and use the same metricshub-eclipse-formatter.xml profile.

Proposed change

  • Remove prettier-maven-plugin from pom.xml.
  • Remove .prettierrc.yaml once it is no longer used.
  • Add net.revelc.code.formatter:formatter-maven-plugin using the Jawk/maven-skin-tools configuration as the baseline:
    • version 2.29.0 (or the current appropriate version at implementation time);
    • validate goal bound to the Maven validate phase;
    • main and test Java source directories included;
    • **/*.java includes;
    • a checked-in metricshub-eclipse-formatter.xml configuration file.
  • Start from the shared Eclipse formatter profile used by Jawk and maven-skin-tools.
  • Adjust the Eclipse profile only where necessary to preserve the effective winrm-java formatting conventions currently expressed by .prettierrc.yaml, notably:
    • tabs with width 2;
    • 120-column line width;
    • no trailing commas;
    • existing lambda/parentheses behavior where Eclipse formatter supports an equivalent;
    • platform-safe line endings and a final newline.
  • Apply the new formatter once and review the resulting repository-wide formatting diff. Keep unavoidable migration-only reformatting separate from functional changes.
  • Update contributor/build documentation if formatter commands are documented or need to be documented.

Acceptance criteria

  • mvn validate fails when Java sources do not match the checked-in Eclipse formatter profile.
  • mvn formatter:format formats both src/main/java and src/test/java.
  • mvn verify succeeds after the migration.
  • Prettier and .prettierrc.yaml are no longer required by the build.
  • The resulting formatting is as close as practical to the current project style and is consistent with the Jawk and maven-skin-tools configuration.
  • CI and local builds use the same formatter configuration.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions