Skip to content

Used JSON5 for config file parsing #755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"cson-parser": "4.0.5",
"eslint-config-prettier": "6.14.0",
"glob": "7.1.6",
"json5": "^2.1.3",
"lodash": "4.17.20",
"minimatch": "3.0.4",
"strip-json-comments": "3.1.1",
"tslint": "6.1.3",
"typescript": "4.0.3"
},
Expand All @@ -30,6 +30,7 @@
"@types/eslint-config-prettier": "6.11.0",
"@types/glob": "7.1.3",
"@types/jest": "26.0.15",
"@types/json5": "0.0.30",
"@types/lodash": "4.14.162",
"@types/minimatch": "3.0.3",
"@types/node": "12.12.21",
Expand Down
2 changes: 1 addition & 1 deletion src/input/importer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("importer", () => {
// Assert
expect(imported).toEqual(
expect.objectContaining({
message: "Unexpected token N in JSON at position 0",
message: "JSON5: invalid character 'O' at 1:2",
}),
);
});
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import stripJsonComments from "strip-json-comments";
import JSON5 from "json5";

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

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

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