microsoft/rushstack

[@rushstack/node-core-library] use the JsonFile.save() update existing json5 syntax file error.

fansenze opened this issue · 0 comments

Summary

use the JsonFile.save(@rushstack/node-core-library) update existing json5 syntax file error.

Repro steps

  • open this link

  • execute node test.js in terminal

Actual result: it will cause error in terminal: SyntaxError: Trailing comma in object at 4:1

Expected result: save successfully.

Details

Currently:

  • JsonFile.load set json5 mode to jju by default, so that can load files both json / cjson / json5 syntax.
  • JsonFile.save not support json5 syntax string by default when set updateExistingFile as true.

Expected:
i think the default json syntax should remain consistent in JsonFile read/write functions.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
Package name: @rushstack/node-core-library
Package version? 3.62.0
Operating system? Mac
Would you consider contributing a PR? No
Node.js version (node -v)? 16.16.0 / 20.10.0