eslint-plugin-json-schema-validator
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -30,2 +30,21 @@ "use strict"; | ||
} | ||
if (jsonPath.startsWith("vscode://")) { | ||
let url = `https://raw.githubusercontent.com/ota-meshi/extract-vscode-schemas/main/resources/vscode/${jsonPath.slice(9)}`; | ||
if (!url.endsWith(".json")) { | ||
url = `${url}.json`; | ||
} | ||
return loadJsonFromURL(url, context, (orig) => { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; | ||
const result = (_a = edit === null || edit === void 0 ? void 0 : edit(orig)) !== null && _a !== void 0 ? _a : orig; | ||
if (jsonPath === "vscode://schemas/settings/machine") { | ||
const target = (_d = (_c = (_b = result === null || result === void 0 ? void 0 : result.properties) === null || _b === void 0 ? void 0 : _b["workbench.externalUriOpeners"]) === null || _c === void 0 ? void 0 : _c.additionalProperties) === null || _d === void 0 ? void 0 : _d.anyOf; | ||
removeEmptyEnum(target); | ||
} | ||
else if (jsonPath === "vscode://schemas/launch") { | ||
const target = (_k = (_j = (_h = (_g = (_f = (_e = result === null || result === void 0 ? void 0 : result.properties) === null || _e === void 0 ? void 0 : _e.compounds) === null || _f === void 0 ? void 0 : _f.items) === null || _g === void 0 ? void 0 : _g.properties) === null || _h === void 0 ? void 0 : _h.configurations) === null || _j === void 0 ? void 0 : _j.items) === null || _k === void 0 ? void 0 : _k.oneOf; | ||
removeEmptyEnum(target); | ||
} | ||
return result; | ||
}); | ||
} | ||
const json = fs_1.default.readFileSync(path_1.default.resolve(getCwd(context), jsonPath), "utf-8"); | ||
@@ -35,2 +54,23 @@ const data = JSON.parse(json); | ||
} | ||
function removeEmptyEnum(target) { | ||
if (!target) | ||
return; | ||
if (Array.isArray(target)) { | ||
for (const e of target) { | ||
removeEmptyEnum(e); | ||
} | ||
return; | ||
} | ||
if (Array.isArray(target.enum) && target.enum.length === 0) { | ||
delete target.enum; | ||
return; | ||
} | ||
if (target.type === "object" && | ||
target.properties && | ||
typeof target.properties === "object") { | ||
for (const key of Object.keys(target.properties)) { | ||
removeEmptyEnum(target.properties[key]); | ||
} | ||
} | ||
} | ||
function loadJsonFromURL(jsonPath, context, edit) { | ||
@@ -37,0 +77,0 @@ var _a, _b, _c; |
@@ -68,3 +68,4 @@ "use strict"; | ||
if (error.missingRef.startsWith("http://") || | ||
error.missingRef.startsWith("https://")) { | ||
error.missingRef.startsWith("https://") || | ||
error.missingRef.startsWith("vscode://")) { | ||
const uri = new url_1.URL(error.missingRef); | ||
@@ -71,0 +72,0 @@ uri.hash = ""; |
{ | ||
"name": "eslint-plugin-json-schema-validator", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "ESLint plugin that validates data using JSON Schema Validator.", | ||
@@ -87,3 +87,3 @@ "repository": "git+https://github.com/ota-meshi/eslint-plugin-json-schema-validator.git", | ||
"eslint-plugin-regexp": "^1.0.0", | ||
"eslint-plugin-toml": "^0.3.0", | ||
"eslint-plugin-toml": "^0.4.0", | ||
"eslint-plugin-vue": "^9.0.0", | ||
@@ -90,0 +90,0 @@ "eslint-plugin-yml": "^1.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101088
2342