prettier-plugin-groovy
raw JSON → 0.2.1 verified Sat Apr 25 auth: no javascript
A Prettier plugin to format Groovy files, including Jenkinsfiles. Version 0.2.1 requires Node >=20.0.0 || ^18.12.0 and Prettier ^3.3.3. It internally uses groovy-beautify for formatting. Key differentiator: integrates Groovy formatting into the Prettier ecosystem, enabling consistent code style with other languages.
Common errors
error Cannot find module 'prettier-plugin-groovy' ↓
cause Plugin is not installed or not in node_modules.
fix
Run 'npm install prettier-plugin-groovy --save-dev' to install the plugin.
error prettier-plugin-groovy requires prettier@>=3.3.3. Please upgrade. ↓
cause Installed Prettier version is too old.
fix
Update Prettier to version 3.3.3 or later: 'npm install prettier@latest --save-dev'.
error Plugin 'prettier-plugin-groovy' is not found when parsing config. ↓
cause Plugin name in Prettier config is incorrect or not installed.
fix
Ensure the plugin is installed and listed as 'prettier-plugin-groovy' in the plugins array.
Warnings
breaking Requires Node >=20.0.0 or >=18.12.0. Older Node versions are not supported. ↓
fix Upgrade Node to version 18.12.0 LTS or higher.
breaking Requires Prettier ^3.3.3. Incompatible with Prettier v2. ↓
fix Update Prettier to version 3.3.3 or later.
gotcha Plugin uses groovy-beautify internally; formatting behavior may differ from standard Groovy linters. ↓
fix Review formatting output and adjust Prettier options as needed.
gotcha The plugin is designed for Groovy and Jenkinsfiles; testing on other Groovy dialects is limited. ↓
fix Test plugin with your specific Groovy file types.
Install
npm install prettier-plugin-groovy yarn add prettier-plugin-groovy pnpm add prettier-plugin-groovy Imports
- default (plugin registration) wrong
Direct import and use as a modulecorrectAdd to Prettier config plugins array - plugins wrong
require('prettier-plugin-groovy') in configcorrect"plugins": ["prettier-plugin-groovy"] in .prettierrc - CLI usage wrong
Running prettier on non-Groovy files with plugincorrectprettier --write --plugin=prettier-plugin-groovy path/to/file.groovy
Quickstart
// Install the plugin as a dev dependency
npm install prettier-plugin-groovy --save-dev
// Add to .prettierrc (JSON format)
{
"plugins": ["prettier-plugin-groovy"]
}
// Or use CLI with plugin flag
prettier --write --plugin=prettier-plugin-groovy Jenkinsfile