spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Allow `npm`-Based Formatters to Pin Transitive Dependencies by Populating `overrides` in `package.json`

Open jGleitz opened this issue 6 months ago • 1 comments

When using an npm package to format code, and that npm package has a range dependency onto another library, the formatting output can change silently. This just happened to us: we use prettier-plugin-sql, which has a ^-dependency on sql-formatter. sql-formatter released a new version that changed the formatting output, and our project’s build broke because the checked-in SQL files didn’t match the expected format.

Proposal: add the configuration method dependencyOverrides to PrettierFormatterStep. This method accepts a Map<String, String> to populate the overrides field in the generated package.json. This mechanism could work exactly like the one populating the devDependencies.

jGleitz avatar Jun 26 '25 11:06 jGleitz

Seems like a reasonable proposal. I'd suggest to add the dependencyOverrides to all npm-based formatters and keep it in sync with devDependencies configuration.

Will do this as soon as I find time - or, feel free to create a PR yourself if I'm taking to long ❤️

simschla avatar Jul 07 '25 20:07 simschla