JamieMason / syncpack

Consistent dependency versions in large JavaScript Monorepos.
https://jamiemason.github.io/syncpack/
MIT License
1.41k stars 49 forks source link

feat(fix): preserve original formatting #195

Closed nlwillia closed 1 month ago

nlwillia commented 8 months ago

Description

Given:

{
  "name": "syncpack-format",
  "version": "1.0.0",
  "scripts": {
    "lint": "syncpack lint",
    "fix": "syncpack fix-mismatches"
  },
  "keywords": ["test"],
  "devDependencies": {
    "syncpack": "^12.3.0"
  },
  "syncpack": {
    "lintFormatting": false
  }
}

Running npm run fix will rewrite the keywords property with unnecessary newlines even with lintFormatting indicated as false.

  "keywords": [
    "test"
  ],

Suggested Solution

I imagine it's a headache to consider whitespace when reconstituting files, but it would be preferable for keys that aren't changed to be emitted the same as how they're read if formatting is turned off.

JamieMason commented 8 months ago

Thanks @nlwillia, yeah tricky one as this is being done basically by JSON.stringify.

JamieMason commented 1 month ago

Released in 13.0.0