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

Open
#2,534 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, javascript, sql

Research direction

Locate PrettierFormatterStep and the code that currently populates devDependencies in the generated package.json. Read how formatter configuration is assembled, then verify that dependencyOverrides is emitted as npm overrides while existing devDependencies behavior remains unchanged.

Written by the indexing model from the issue text.

Description

enhancement

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.

Dominant language
Java
Stars
5.7k
Forks
560
Avg merge
1d 13h
Merged PRs (30d)
43

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diffplug/spotless

All issues in diffplug/spotless

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.