You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow npm-Based Formatters to Pin Transitive Dependencies by Populating overrides in package.json #2534
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.
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 ❤️
@jGleitz@simschla I opened #3178 for this, following the proposal here and @simschla's suggestion: dependencyOverrides is available on all npm-based formatters (prettier, ESLint, tsfmt), for both Gradle and Maven, and configured just like devDependencies. The entries go into the overrides field of the generated package.json.
Your prettier-plugin-sql case is covered by an end-to-end test:
Without the override, npm currently resolves sql-formatter 15.9.0; with it, exactly 15.7.0 is installed. If no overrides are configured, the generated package.json stays byte-identical to before, so existing setups don't reinstall anything.
@simschla: Maven can't express scoped packages (@scope/pkg) as XML element names, same as <devDependencies>. Should I add a dependencyOverrideProperties counterpart to devDependencyProperties in this PR, or as a follow-up?
Activity
simschla commentedon Jul 7, 2025
Seems like a reasonable proposal. I'd suggest to add the dependencyOverrides to all npm-based formatters and keep it in sync with
devDependenciesconfiguration.Will do this as soon as I find time - or, feel free to create a PR yourself if I'm taking to long ❤️
Pankraz76 commentedon Nov 8, 2026
@jGleitz @simschla I opened #3178 for this, following the proposal here and @simschla's suggestion:
dependencyOverridesis available on all npm-based formatters (prettier, ESLint, tsfmt), for both Gradle and Maven, and configured just likedevDependencies. The entries go into theoverridesfield of the generatedpackage.json.Your
prettier-plugin-sqlcase is covered by an end-to-end test:Without the override, npm currently resolves
sql-formatter15.9.0; with it, exactly 15.7.0 is installed. If no overrides are configured, the generatedpackage.jsonstays byte-identical to before, so existing setups don't reinstall anything.Feedback very welcome:
@scope/pkg) as XML element names, same as<devDependencies>. Should I add adependencyOverridePropertiescounterpart todevDependencyPropertiesin this PR, or as a follow-up?