Repository: typescript-eslint/tslint-to-eslint-config (ts)

Issue:
Allow JSON5 features such as trailing commas in editor configs
<!--
👋 Hi, thanks for filing an issue on tslint-to-eslint-config! 💖
Please fill out all fields below to ensure your issue is addressed.

If your issue doesn't provide enough info to fully explain or reproduce your bug, it will be closed. 😦
-->

This issue is related to https://github.com/typescript-eslint/tslint-to-eslint-config/issues/407

### 🐛 Bug Report

-   `tslint-to-eslint-config` version: 1.5.0
-   ESLint version: ^7.10.0
-   Node version: 12.18.3

#### Actual Behavior
`tslint-to-eslint-config` overwrite's entire `.vscode/settings.json` with an empty config if there is a trailing comma

##### With trailing comma
```diff
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 44f8082..ca2996c 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,14 @@
-{
-    "editor.formatOnSave": true,
-}
+/*
+👋 Hi! This file was autogenerated by tslint-to-eslint-config.
+https://github.com/typescript-eslint/tslint-to-eslint-config
+
+It represents the closest reasonable ESLint configuration to this
+project's original TSLint configuration.
+
+We recommend eventually switching this configuration to extend from
+the recommended rulesets in typescript-eslint. 
+https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
+
+Happy linting! 💖
+*/
+{}
```

##### Without trailing comma
```diff
diff --git a/.vscode/settings.json b/.vscode/settings.json
index f89ed5f..1eadf3f 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,16 @@
+/*
+👋 Hi! This file was autogenerated by tslint-to-eslint-config.
+https://github.com/typescript-eslint/tslint-to-eslint-config
+
+It represents the closest reasonable ESLint configuration to this
+project's original TSLint configuration.
+
+We recommend eventually switching this configuration to extend from
+the recommended rulesets in typescript-eslint. 
+https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
+
+Happy linting! 💖
+*/
 {
     "editor.formatOnSave": true
 }
```

#### Expected Behavior

<!-- What are the specific changes you'd like to see? -->

##### 1. The actual bug represented in this issue
It should accept trailing commas as they are valid in vscode configs.

##### 2. The bigger, not exactly this bug, but related problem:
It should not overwrite any settings in .vscode/* folder without an explicit option.

From the readme:
> The tslint-to-eslint-config command reads in any existing linter, TypeScript, and package configuration files, then creates an .eslintrc.js result based on them.

This does not indicate it's going to modify my editor files at all, only that it will create a new file, `.eslintrc.js`. **Please require an option/flag for any changes to editor configs!**

#### Reproduction

<!--
Please paste a link to a repository, Gist, or other means of reproducing your error here.
Note that `tslint-to-eslint-config` includes information from `package.json`, `tsconfig.json`, and other files, so just your ESLint configuration may not be enough.
-->
Add a trailing comma to your last item in your `.vscode/settings.json`, and run `tslint-to-eslint-config`, you'll see that it outputs an empty object.

Pull request:
Used JSON5 for config file parsing
## PR Checklist

-   [x] Addresses an existing issue: fixes #742
-   [x] That issue was marked as [`status: accepting prs`](https://github.com/typescript-eslint/tslint-to-eslint-config/labels/status%3A%20accepting%20prs)

## Overview

Quick replacement: instead of just `strip-json-comments`, uses the full JSON5 library to support fancy ECMAScript 5.1 features such as trailing commas.

Patch:
diff --git a/package-lock.json b/package-lock.json
index adce709..9393148 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2861,6 +2861,12 @@
             "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==",
             "dev": true
         },
+        "@types/json5": {
+            "version": "0.0.30",
+            "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.30.tgz",
+            "integrity": "sha512-sqm9g7mHlPY/43fcSNrCYfOeX9zkTTK+euO5E6+CVijSMm5tTjkVdwdqRkY3ljjIAf8679vps5jKUoJBCLsMDA==",
+            "dev": true
+        },
         "@types/lodash": {
             "version": "4.14.162",
             "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.162.tgz",
@@ -6679,7 +6685,6 @@
             "version": "2.1.3",
             "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz",
             "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==",
-            "dev": true,
             "requires": {
                 "minimist": "^1.2.5"
             }
@@ -8584,7 +8589,8 @@
         "strip-json-comments": {
             "version": "3.1.1",
             "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
-            "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig=="
+            "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
+            "dev": true
         },
         "supports-color": {
             "version": "7.1.0",
diff --git a/package.json b/package.json
index 840defc..9a90fdf 100644
--- a/package.json
+++ b/package.json
@@ -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"
     },
@@ -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",
diff --git a/src/utils.ts b/src/utils.ts
index 798c4c0..391af14 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -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;
 
@@ -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);


Test patch:
diff --git a/src/input/importer.test.ts b/src/input/importer.test.ts
index 861bc37..0237797 100644
--- a/src/input/importer.test.ts
+++ b/src/input/importer.test.ts
@@ -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",
             }),
         );
     });