JS: Tolerate trailing commas in JSON arrays#19267
Merged
asgerf merged 4 commits intogithub:mainfrom Apr 10, 2025
Merged
Conversation
Previously we'd fail to extract some tsconfig.json files because of this.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enables support for trailing commas in JSON arrays for tsconfig.json extraction.
- Added a changenote documenting the fix.
- Removed error-raising logic in JSONParser to allow trailing commas in array literals.
- Updated the extractor version to reflect the changes.
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| javascript/ql/src/change-notes/2025-04-10-json-array-trailing-comma.md | Added changenote explaining the fix for trailing commas in array literals in tsconfig.json. |
| javascript/extractor/src/com/semmle/js/parser/JSONParser.java | Removed the check that raised an error for omitted array elements, thereby allowing trailing commas. |
| javascript/extractor/src/com/semmle/js/extractor/Main.java | Updated the extractor version to indicate the new release date. |
Files not reviewed (2)
- javascript/extractor/tests/json/input/array-trailing-comma.json: Language not supported
- javascript/extractor/tests/json/output/trap/array-trailing-comma.json.trap: Language not supported
erik-krogh
approved these changes
Apr 10, 2025
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.
Standard JSON does not permit trailing commas, but
tsconfig.jsonfiles rely on an extension of JSON with trailing commas and comments.We already extract JSON using this extended format in general, but trailing commas in arrays were not supported, meaning
tsconfig.jsonfiles were rejected in some cases.