Skip to content

Commit

Permalink
Update js-yaml
Browse files Browse the repository at this point in the history
The new version of `js-yaml` doesn’t depend on `esprima`, which is a big unused
dependency.

Also `@types/js-yaml` was added for better type safety.
  • Loading branch information
remcohaszing committed Apr 30, 2021
1 parent 3992663 commit 7cd5ff8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"prettier": "2.0.5"
},
"dependencies": {
"js-yaml": "^3.13.1",
"js-yaml": "^4.1.0",
"jsonc-parser": "^2.2.1",
"request-light": "^0.2.4",
"vscode-json-languageservice": "^4.1.0",
Expand All @@ -49,6 +49,7 @@
},
"devDependencies": {
"@types/chai": "^4.2.12",
"@types/js-yaml": "^4.0.1",
"@types/mocha": "2.2.48",
"@types/node": "^12.11.7",
"@types/prettier": "2.0.2",
Expand Down
4 changes: 2 additions & 2 deletions src/languageservice/services/yamlSchemaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as nls from 'vscode-nls';
import { convertSimple2RegExpPattern } from '../utils/strings';
import { SingleYAMLDocument } from '../parser/yamlParser07';
import { JSONDocument } from '../parser/jsonParser07';
import * as yaml from 'js-yaml';
import { load } from 'js-yaml';

const localize = nls.loadMessageBundle();

Expand Down Expand Up @@ -587,7 +587,7 @@ export class YAMLSchemaService extends JSONSchemaService {
}

try {
const schemaContent: JSONSchema = yaml.safeLoad(content);
const schemaContent = load(content) as JSONSchema;
return new UnresolvedSchema(schemaContent, []);
} catch (yamlError) {
const errorMessage = localize(
Expand Down
17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==

"@types/js-yaml@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.1.tgz#5544730b65a480b18ace6b6ce914e519cec2d43b"
integrity sha512-xdOvNmXmrZqqPy3kuCQ+fz6wA0xU5pji9cd1nDrflWaAWtYLLGk5ykW0H6yg5TVyehHP1pfmuuSaZkhP+kspVA==

"@types/json-schema@^7.0.3":
version "7.0.5"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.5.tgz#dcce4430e64b443ba8945f0290fb564ad5bac6dd"
Expand Down Expand Up @@ -361,6 +366,11 @@ argparse@^1.0.7:
dependencies:
sprintf-js "~1.0.2"

argparse@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==

array-union@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
Expand Down Expand Up @@ -1379,6 +1389,13 @@ js-yaml@^3.13.1:
argparse "^1.0.7"
esprima "^4.0.0"

js-yaml@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
dependencies:
argparse "^2.0.1"

jsbn@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
Expand Down

0 comments on commit 7cd5ff8

Please sign in to comment.