Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ba0b1e3

Browse files
authored
docs(website): use json5 library to parse config in playground (typescript-eslint#4341)
1 parent 135f30a commit ba0b1e3

File tree

3 files changed

+17
-345
lines changed

3 files changed

+17
-345
lines changed

packages/website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"react": "^17.0.2",
3030
"react-dom": "^17.0.2",
3131
"remark-docusaurus-tabs": "^0.2.0",
32+
"json5": "^2.2.0",
3233
"typescript": "*"
3334
},
3435
"devDependencies": {

packages/website/src/components/config/ConfigEditor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useCallback, useEffect, useReducer, useState } from 'react';
22
import clsx from 'clsx';
3+
import { parse } from 'json5';
34

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

@@ -79,7 +80,7 @@ function reducerObject(
7980
}
8081
case 'json': {
8182
try {
82-
const parsed: unknown = JSON.parse(action.code);
83+
const parsed: unknown = parse(action.code);
8384
if (isRecord(parsed)) {
8485
const item = parsed[action.field];
8586
if (item && isRecord(item)) {
@@ -93,8 +94,6 @@ function reducerObject(
9394
return state;
9495
}
9596
}
96-
// @ts-expect-error: Safeguard
97-
throw new Error();
9897
}
9998

10099
function filterConfig(

0 commit comments

Comments
 (0)