Skip to content

Commit d368bfd

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular/cli): allow trailing commas in JSON files
Currently, both tsconfigs and workspace configuration files can contain trailing commas Closes #19576
1 parent 07e3766 commit d368bfd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/angular/cli/utilities/json-file.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class JSONFile {
3838
}
3939

4040
const errors: ParseError[] = [];
41-
this._jsonAst = parseTree(this.content, errors);
41+
this._jsonAst = parseTree(this.content, errors, { allowTrailingComma: true });
4242
if (errors.length) {
4343
formatError(this.path, errors);
4444
}
@@ -106,7 +106,7 @@ export class JSONFile {
106106
// tslint:disable-next-line: no-any
107107
export function readAndParseJson(path: string): any {
108108
const errors: ParseError[] = [];
109-
const content = parse(readFileSync(path, 'utf-8'), errors);
109+
const content = parse(readFileSync(path, 'utf-8'), errors, { allowTrailingComma: true });
110110
if (errors.length) {
111111
formatError(path, errors);
112112
}
@@ -121,5 +121,5 @@ function formatError(path: string, errors: ParseError[]): never {
121121

122122
// tslint:disable-next-line: no-any
123123
export function parseJson(content: string): any {
124-
return parse(content);
124+
return parse(content, undefined, { allowTrailingComma: true });
125125
}

0 commit comments

Comments
 (0)