Преглед изворни кода

Merge pull request #6343 from rahulpshah/feature/JP-6199--use-json5-instead-of-comment-json

Feature/jp 6199  use json5 instead of comment json
Jason Grout пре 6 година
родитељ
комит
b58e1ddce3

+ 2 - 2
dev_mode/package.json

@@ -100,8 +100,8 @@
     "@phosphor/widgets": "^1.6.0",
     "ajv": "^6.5.5",
     "codemirror": "~5.46.0",
-    "comment-json": "^1.1.3",
     "es6-promise": "~4.1.1",
+    "json5": "^2.1.0",
     "marked": "0.5.1",
     "moment": "~2.21.0",
     "path-posix": "~1.0.0",
@@ -223,7 +223,7 @@
       "@phosphor/widgets",
       "ajv",
       "codemirror",
-      "comment-json",
+      "json5",
       "es6-promise",
       "marked",
       "moment",

+ 2 - 2
jupyterlab/staging/package.json

@@ -99,8 +99,8 @@
     "@phosphor/widgets": "^1.6.0",
     "ajv": "^6.5.5",
     "codemirror": "~5.42.0",
-    "comment-json": "^1.1.3",
     "es6-promise": "~4.1.1",
+    "json5": "^2.1.0",
     "marked": "0.5.1",
     "moment": "~2.21.0",
     "path-posix": "~1.0.0",
@@ -222,7 +222,7 @@
       "@phosphor/widgets",
       "ajv",
       "codemirror",
-      "comment-json",
+      "json5",
       "es6-promise",
       "marked",
       "moment",

+ 2 - 2
packages/coreutils/package.json

@@ -35,14 +35,14 @@
     "@phosphor/disposable": "^1.1.2",
     "@phosphor/signaling": "^1.2.2",
     "ajv": "^6.5.5",
-    "comment-json": "^1.1.3",
+    "json5": "^2.1.0",
     "minimist": "~1.2.0",
     "moment": "~2.21.0",
     "path-posix": "~1.0.0",
     "url-parse": "~1.4.3"
   },
   "devDependencies": {
-    "@types/comment-json": "^1.1.0",
+    "@types/json5": "0.0.30",
     "@types/minimist": "~1.2.0",
     "rimraf": "~2.6.2",
     "typedoc": "^0.14.2",

+ 4 - 6
packages/coreutils/src/settingregistry.ts

@@ -3,7 +3,7 @@
 
 import Ajv from 'ajv';
 
-import * as json from 'comment-json';
+import * as json from 'json5';
 
 import {
   JSONExt,
@@ -458,9 +458,7 @@ export class DefaultSchemaValidator implements ISchemaValidator {
     // Parse the raw commented JSON into a user map.
     let user: JSONObject;
     try {
-      const strip = true;
-
-      user = json.parse(plugin.raw, null, strip) as JSONObject;
+      user = json.parse(plugin.raw, null) as JSONObject;
     } catch (error) {
       if (error instanceof SyntaxError) {
         return [
@@ -692,7 +690,7 @@ export class SettingRegistry {
       return;
     }
 
-    const raw = json.parse(plugins[plugin].raw, null, true);
+    const raw = json.parse(plugins[plugin].raw, null);
 
     // Delete both the value and any associated comment.
     delete raw[key];
@@ -725,7 +723,7 @@ export class SettingRegistry {
     }
 
     // Parse the raw JSON string removing all comments and return an object.
-    const raw = json.parse(plugins[plugin].raw, null, true);
+    const raw = json.parse(plugins[plugin].raw, null);
 
     plugins[plugin].raw = Private.annotatedPlugin(plugins[plugin], {
       ...raw,

+ 11 - 22
yarn.lock

@@ -1656,10 +1656,6 @@
   version "0.0.70"
   resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-0.0.70.tgz#2d9c850d6afbc93162c1434a827f86ad5ee90e35"
 
-"@types/comment-json@^1.1.0":
-  version "1.1.1"
-  resolved "https://registry.yarnpkg.com/@types/comment-json/-/comment-json-1.1.1.tgz#b4ae889912a93e64619f97989aecaff8ce889dca"
-
 "@types/dom4@^2.0.0":
   version "2.0.1"
   resolved "https://registry.yarnpkg.com/@types/dom4/-/dom4-2.0.1.tgz#506d5781b9bcab81bd9a878b198aec7dee2a6033"
@@ -1724,6 +1720,11 @@
   dependencies:
     "@types/jest-diff" "*"
 
+"@types/json5@0.0.30":
+  version "0.0.30"
+  resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.30.tgz#44cb52f32a809734ca562e685c6473b5754a7818"
+  integrity sha512-sqm9g7mHlPY/43fcSNrCYfOeX9zkTTK+euO5E6+CVijSMm5tTjkVdwdqRkY3ljjIAf8679vps5jKUoJBCLsMDA==
+
 "@types/lodash.escape@^4.0.4":
   version "4.0.4"
   resolved "https://registry.yarnpkg.com/@types/lodash.escape/-/lodash.escape-4.0.4.tgz#61312495e5ff48e142e176530903e3aac1146eb5"
@@ -3284,12 +3285,6 @@ commander@~2.18.0:
   version "2.18.0"
   resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970"
 
-comment-json@^1.1.3:
-  version "1.1.3"
-  resolved "https://registry.yarnpkg.com/comment-json/-/comment-json-1.1.3.tgz#6986c3330fee0c4c9e00c2398cd61afa5d8f239e"
-  dependencies:
-    json-parser "^1.0.0"
-
 commondir@^1.0.1:
   version "1.0.1"
   resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
@@ -4523,7 +4518,7 @@ esprima-fb@^15001.1.0-dev-harmony-fb:
   version "15001.1.0-dev-harmony-fb"
   resolved "https://registry.yarnpkg.com/esprima-fb/-/esprima-fb-15001.1.0-dev-harmony-fb.tgz#30a947303c6b8d5e955bee2b99b1d233206a6901"
 
-esprima@2.7.x, esprima@^2.7.0, esprima@^2.7.1:
+esprima@2.7.x, esprima@^2.7.1:
   version "2.7.3"
   resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581"
 
@@ -4829,8 +4824,8 @@ file-type@^10.10.0:
 file-uri-to-path@1:
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
-fileset@^2.0.2, fileset@^2.0.3:
 
+fileset@^2.0.2, fileset@^2.0.3:
   version "2.0.3"
   resolved "https://registry.yarnpkg.com/fileset/-/fileset-2.0.3.tgz#8e7548a96d3cc2327ee5e674168723a333bba2a0"
   dependencies:
@@ -6530,8 +6525,8 @@ jest-jasmine2@^24.7.1:
     jest-util "^24.7.1"
     pretty-format "^24.7.0"
     throat "^4.0.0"
-jest-junit@^6.3.0:
 
+jest-junit@^6.3.0:
   version "6.3.0"
   resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-6.3.0.tgz#99e64ebc54eddcb21238f0cc49f5820c89a8c785"
   integrity sha512-3PH9UkpaomX6CUzqjlnk0m4yBCW/eroxV6v61OM6LkCQFO848P3YUhfIzu8ypZSBKB3vvCbB4WaLTKT0BrIf8A==
@@ -6828,12 +6823,6 @@ json-parse-better-errors@^1.0.0, json-parse-better-errors@^1.0.1, json-parse-bet
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
 
-json-parser@^1.0.0:
-  version "1.1.5"
-  resolved "https://registry.yarnpkg.com/json-parser/-/json-parser-1.1.5.tgz#e62ec5261d1a6a5fc20e812a320740c6d9005677"
-  dependencies:
-    esprima "^2.7.0"
-
 json-schema-traverse@^0.3.0:
   version "0.3.1"
   resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340"
@@ -8833,8 +8822,8 @@ popper.js@^1.14.1:
 posix-character-classes@^0.1.0:
   version "0.1.1"
   resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
-postcss-modules-extract-imports@^2.0.0:
 
+postcss-modules-extract-imports@^2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-2.0.0.tgz#818719a1ae1da325f9832446b01136eeb493cd7e"
   integrity sha512-LaYLDNS4SG8Q5WAWqIJgdHPJrDDr/Lv775rMBFUbgjTz6j34lUznACHcdRWroPvXANP2Vj7yNK57vp9eFqzLWQ==
@@ -10712,8 +10701,8 @@ to-arraybuffer@^1.0.0:
 to-fast-properties@^1.0.3:
   version "1.0.3"
   resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47"
-to-fast-properties@^2.0.0:
 
+to-fast-properties@^2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
   integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=
@@ -10962,8 +10951,8 @@ typestyle@^2.0.1:
   dependencies:
     csstype "^2.4.0"
     free-style "2.5.1"
-ua-parser-js@^0.7.18, ua-parser-js@^0.7.9:
 
+ua-parser-js@^0.7.18, ua-parser-js@^0.7.9:
   version "0.7.19"
   resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.19.tgz#94151be4c0a7fb1d001af7022fdaca4642659e4b"