Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Since comments were added to `tsconfig.json` and `tsconfig.build.json` files, the `create-package` tool no longer works. This commit fixes the tool by using the `comment-json` package to parse JSONC files while retaining comments. Note that I needed to reformat `tsconfig.json` and `tsconfig.build.json` in this PR due to the way that I need to use `comment-json`. If we don't do this, then the next time someone runs `create-package` then the diffs for these files will be large.
126a0cd to
6296348
Compare
NicolasMassart
approved these changes
Jan 14, 2026
Mrtenz
reviewed
Jan 14, 2026
| await writeJsonFile( | ||
| REPO_TS_CONFIG_BUILD, | ||
| JSON.stringify(monorepoFileData.tsConfigBuild), | ||
| commentJson.stringify(monorepoFileData.tsConfigBuild, null, 2), |
There was a problem hiding this comment.
Prettier JSON parser incompatible with JSONC comments
Medium Severity
The writeJsonFile function uses parser: 'json' with prettier, but commentJson.stringify outputs JSONC content with comments when the input object has comment symbols (parsed from real tsconfig files). Prettier's json parser doesn't support comments and would throw a parse error. The test doesn't catch this because mock data lacks comment symbols. Using parser: 'json5' instead would handle comments correctly.
Contributor
Author
There was a problem hiding this comment.
Hmm I didn't know about this. Well, if this is a problem we can try this out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Since comments were added to
tsconfig.jsonandtsconfig.build.jsonfiles, thecreate-packagetool no longer works.This commit fixes the tool by using the
comment-jsonpackage to parse JSONC files while retaining comments. Note that I needed to reformattsconfig.jsonandtsconfig.build.jsonin this PR due to the way that I need to usecomment-json. If we don't do this, then the next time someone runscreate-packagethen the diffs for these files will be large.Manual testing steps
Run
yarn create-package --name foo-controller --description "This is the FooController". It should work.References
Checklist
Note
Fix create-package to support JSONC
comment-jsoninscripts/create-package/utils.tsto parse and stringifytsconfig.jsonandtsconfig.build.jsonwhile preserving commentsfinalizeAndWriteDatato write JSON with consistent indentation; adjust tests inutils.test.tsto expect pretty-printed outputtsconfig.jsonandtsconfig.build.jsonto expanded, consistently formatted referencescomment-jsontodevDependenciesand updateyarn.lockWritten by Cursor Bugbot for commit 6296348. This will update automatically on new commits. Configure here.