Skip to content

Commit 958d869

Browse files
authored
feat(tsconfig): enable trailing comma support for JSONC (#479)
1 parent 03120de commit 958d869

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/util/fs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async function readJson(fileSystem, jsonFilePath, options = {}) {
4444
const jsonText = /** @type {string} */ (buf.toString());
4545
// Strip comments to support JSONC (e.g., tsconfig.json with comments)
4646
const jsonWithoutComments = stripComments
47-
? stripJsonComments(jsonText)
47+
? stripJsonComments(jsonText, { trailingCommas: true, whitespace: true })
4848
: jsonText;
4949
return JSON.parse(jsonWithoutComments);
5050
}

test/fixtures/tsconfig-paths/jsonc-comments/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@components/*": ["${configDir}/src/components/*"],
99
"foo": ["${configDir}/src/mapped/foo"],
1010
/* Block comment in paths */
11-
"bar/*": ["${configDir}/src/mapped/bar/*"]
11+
"bar/*": ["${configDir}/src/mapped/bar/*"],
1212
}
1313
}
1414
}

0 commit comments

Comments
 (0)