syncpack icon indicating copy to clipboard operation
syncpack copied to clipboard

feat(fix): preserve original formatting

Open nlwillia opened this issue 1 year ago • 1 comments

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.

nlwillia avatar Jan 23 '24 20:01 nlwillia

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

JamieMason avatar Jan 23 '24 20:01 JamieMason