diff --git a/packages/cspell-lib/package-lock.json b/packages/cspell-lib/package-lock.json index 4cd59337c1c..4573cbf475b 100644 --- a/packages/cspell-lib/package-lock.json +++ b/packages/cspell-lib/package-lock.json @@ -12,7 +12,7 @@ "@cspell/cspell-bundled-dicts": "^5.18.2", "@cspell/cspell-types": "^5.18.2", "clear-module": "^4.1.2", - "comment-json": "^4.1.1", + "comment-json": "^4.2.2", "configstore": "^5.0.1", "cosmiconfig": "^7.0.1", "cspell-glob": "^5.18.2", @@ -1835,12 +1835,12 @@ "dev": true }, "node_modules/comment-json": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.1.1.tgz", - "integrity": "sha512-v8gmtPvxhBlhdRBLwdHSjGy9BgA23t9H1FctdQKyUrErPjSrJcdDMqBq9B4Irtm7w3TNYLQJNH6ARKnpyag1sA==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.2.tgz", + "integrity": "sha512-H8T+kl3nZesZu41zO2oNXIJWojNeK3mHxCLrsBNu6feksBXsgb+PtYz5daP5P86A0F3sz3840KVYehr04enISQ==", "dependencies": { "array-timsort": "^1.0.3", - "core-util-is": "^1.0.2", + "core-util-is": "^1.0.3", "esprima": "^4.0.1", "has-own-prop": "^2.0.0", "repeat-string": "^1.6.1" @@ -6362,12 +6362,12 @@ "dev": true }, "comment-json": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.1.1.tgz", - "integrity": "sha512-v8gmtPvxhBlhdRBLwdHSjGy9BgA23t9H1FctdQKyUrErPjSrJcdDMqBq9B4Irtm7w3TNYLQJNH6ARKnpyag1sA==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.2.tgz", + "integrity": "sha512-H8T+kl3nZesZu41zO2oNXIJWojNeK3mHxCLrsBNu6feksBXsgb+PtYz5daP5P86A0F3sz3840KVYehr04enISQ==", "requires": { "array-timsort": "^1.0.3", - "core-util-is": "^1.0.2", + "core-util-is": "^1.0.3", "esprima": "^4.0.1", "has-own-prop": "^2.0.0", "repeat-string": "^1.6.1" diff --git a/packages/cspell-lib/package.json b/packages/cspell-lib/package.json index 14a8a0f7a67..2000dd8a639 100644 --- a/packages/cspell-lib/package.json +++ b/packages/cspell-lib/package.json @@ -51,7 +51,7 @@ "@cspell/cspell-bundled-dicts": "^5.18.2", "@cspell/cspell-types": "^5.18.2", "clear-module": "^4.1.2", - "comment-json": "^4.1.1", + "comment-json": "^4.2.2", "configstore": "^5.0.1", "cosmiconfig": "^7.0.1", "cspell-glob": "^5.18.2", diff --git a/packages/cspell-lib/src/util/resolveFile.test.ts b/packages/cspell-lib/src/util/resolveFile.test.ts index 30a680017b3..7bf09dbd4cc 100644 --- a/packages/cspell-lib/src/util/resolveFile.test.ts +++ b/packages/cspell-lib/src/util/resolveFile.test.ts @@ -13,7 +13,7 @@ interface Config { const defaultConfigFile = require.resolve('@cspell/cspell-bundled-dicts/cspell-default.json'); const defaultConfigLocation = path.dirname(defaultConfigFile); -const config: Config = parse(fs.readFileSync(defaultConfigFile, 'utf-8')); +const config = readConfig(defaultConfigFile); const ext = path.extname(__filename); const notFound = '1fgh0dld6y56cr1wls.r9bp0ckc00ds0gna.json'; @@ -59,3 +59,9 @@ describe('Validate resolveFile', () => { expect(r.found).toBe(found); }); }); + +function readConfig(filename: string): Config { + const parsed = parse(fs.readFileSync(filename, 'utf-8')); + if (!parsed || typeof parsed !== 'object') throw new Error(`Unable to parse "${filename}"`); + return parsed as unknown as Config; +} diff --git a/packages/cspell/package-lock.json b/packages/cspell/package-lock.json index 936f833e2a6..525723ddee1 100644 --- a/packages/cspell/package-lock.json +++ b/packages/cspell/package-lock.json @@ -12,7 +12,7 @@ "@cspell/cspell-pipe": "^5.18.2", "chalk": "^4.1.2", "commander": "^9.0.0", - "comment-json": "^4.1.1", + "comment-json": "^4.2.2", "cspell-gitignore": "^5.18.2", "cspell-glob": "^5.18.2", "cspell-lib": "^5.18.2", @@ -1856,12 +1856,12 @@ } }, "node_modules/comment-json": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.1.1.tgz", - "integrity": "sha512-v8gmtPvxhBlhdRBLwdHSjGy9BgA23t9H1FctdQKyUrErPjSrJcdDMqBq9B4Irtm7w3TNYLQJNH6ARKnpyag1sA==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.2.tgz", + "integrity": "sha512-H8T+kl3nZesZu41zO2oNXIJWojNeK3mHxCLrsBNu6feksBXsgb+PtYz5daP5P86A0F3sz3840KVYehr04enISQ==", "dependencies": { "array-timsort": "^1.0.3", - "core-util-is": "^1.0.2", + "core-util-is": "^1.0.3", "esprima": "^4.0.1", "has-own-prop": "^2.0.0", "repeat-string": "^1.6.1" @@ -6374,12 +6374,12 @@ "integrity": "sha512-JJfP2saEKbQqvW+FI93OYUB4ByV5cizMpFMiiJI8xDbBvQvSkIk0VvQdn1CZ8mqAO8Loq2h0gYTYtDFUZUeERw==" }, "comment-json": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.1.1.tgz", - "integrity": "sha512-v8gmtPvxhBlhdRBLwdHSjGy9BgA23t9H1FctdQKyUrErPjSrJcdDMqBq9B4Irtm7w3TNYLQJNH6ARKnpyag1sA==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.2.tgz", + "integrity": "sha512-H8T+kl3nZesZu41zO2oNXIJWojNeK3mHxCLrsBNu6feksBXsgb+PtYz5daP5P86A0F3sz3840KVYehr04enISQ==", "requires": { "array-timsort": "^1.0.3", - "core-util-is": "^1.0.2", + "core-util-is": "^1.0.3", "esprima": "^4.0.1", "has-own-prop": "^2.0.0", "repeat-string": "^1.6.1" diff --git a/packages/cspell/package.json b/packages/cspell/package.json index 0fca61198fe..4d1812dc41c 100644 --- a/packages/cspell/package.json +++ b/packages/cspell/package.json @@ -73,7 +73,7 @@ "@cspell/cspell-pipe": "^5.18.2", "chalk": "^4.1.2", "commander": "^9.0.0", - "comment-json": "^4.1.1", + "comment-json": "^4.2.2", "cspell-gitignore": "^5.18.2", "cspell-glob": "^5.18.2", "cspell-lib": "^5.18.2",