Skip to content

Commit

Permalink
docs(website): use json5 library to parse config in playground (#4341)
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Dec 23, 2021
1 parent 135f30a commit ba0b1e3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 345 deletions.
1 change: 1 addition & 0 deletions packages/website/package.json
Expand Up @@ -29,6 +29,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"remark-docusaurus-tabs": "^0.2.0",
"json5": "^2.2.0",
"typescript": "*"
},
"devDependencies": {
Expand Down
5 changes: 2 additions & 3 deletions packages/website/src/components/config/ConfigEditor.tsx
@@ -1,5 +1,6 @@
import React, { useCallback, useEffect, useReducer, useState } from 'react';
import clsx from 'clsx';
import { parse } from 'json5';

import styles from './ConfigEditor.module.css';

Expand Down Expand Up @@ -79,7 +80,7 @@ function reducerObject(
}
case 'json': {
try {
const parsed: unknown = JSON.parse(action.code);
const parsed: unknown = parse(action.code);
if (isRecord(parsed)) {
const item = parsed[action.field];
if (item && isRecord(item)) {
Expand All @@ -93,8 +94,6 @@ function reducerObject(
return state;
}
}
// @ts-expect-error: Safeguard
throw new Error();
}

function filterConfig(
Expand Down

0 comments on commit ba0b1e3

Please sign in to comment.