Skip to content

Commit 182265f

Browse files
Josh GoldbergKingDarBoja
Josh Goldberg
andauthored
Used JSON5 for config file parsing (#755)
* Used JSON5 for config file parsing * Corrected test * Oops, a console log Co-authored-by: Manuel Bojato <30560560+KingDarBoja@users.noreply.github.com>
1 parent 85ef854 commit 182265f

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

package-lock.json

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"cson-parser": "4.0.5",
1616
"eslint-config-prettier": "6.14.0",
1717
"glob": "7.1.6",
18+
"json5": "^2.1.3",
1819
"lodash": "4.17.20",
1920
"minimatch": "3.0.4",
20-
"strip-json-comments": "3.1.1",
2121
"tslint": "6.1.3",
2222
"typescript": "4.0.3"
2323
},
@@ -30,6 +30,7 @@
3030
"@types/eslint-config-prettier": "6.11.0",
3131
"@types/glob": "7.1.3",
3232
"@types/jest": "26.0.15",
33+
"@types/json5": "0.0.30",
3334
"@types/lodash": "4.14.162",
3435
"@types/minimatch": "3.0.3",
3536
"@types/node": "12.12.21",

src/input/importer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe("importer", () => {
122122
// Assert
123123
expect(imported).toEqual(
124124
expect.objectContaining({
125-
message: "Unexpected token N in JSON at position 0",
125+
message: "JSON5: invalid character 'O' at 1:2",
126126
}),
127127
);
128128
});

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import stripJsonComments from "strip-json-comments";
1+
import JSON5 from "json5";
22

33
export const isDefined = <Item>(item: Item | undefined): item is Item => item !== undefined;
44

@@ -55,4 +55,4 @@ export const uniqueFromSources = <T>(...sources: (T | T[] | undefined)[]) => {
5555
return Array.from(new Set(items));
5656
};
5757

58-
export const parseJson = (text: string) => JSON.parse(stripJsonComments(text));
58+
export const parseJson = (text: string) => JSON5.parse(text);

0 commit comments

Comments
 (0)