eslint-plugin-json-schema-validator
Advanced tools
Comparing version 4.6.1 to 4.7.0
@@ -16,2 +16,3 @@ "use strict"; | ||
const fs_1 = __importDefault(require("fs")); | ||
const compat_1 = require("../utils/compat"); | ||
const CATALOG_URL = "https://www.schemastore.org/api/json/catalog.json"; | ||
@@ -33,3 +34,3 @@ function matchFile(filename, fileMatch) { | ||
} | ||
const schemaPath = getCwd(context); | ||
const schemaPath = (0, compat_1.getCwd)(context); | ||
return (0, validator_factory_1.compile)(schema, schemaPath, context); | ||
@@ -115,3 +116,4 @@ } | ||
create(context, { filename }) { | ||
const cwd = getCwd(context); | ||
const sourceCode = (0, compat_1.getSourceCode)(context); | ||
const cwd = (0, compat_1.getCwd)(context); | ||
const relativeFilename = filename.startsWith(cwd) | ||
@@ -125,3 +127,2 @@ ? path_1.default.relative(cwd, filename) | ||
let existsExports = false; | ||
const sourceCode = context.getSourceCode(); | ||
function validateData(data, resolveLoc) { | ||
@@ -184,3 +185,3 @@ const errors = validator(data); | ||
Program(node) { | ||
if (context.parserServices.isJSON) { | ||
if (sourceCode.parserServices.isJSON) { | ||
const program = node; | ||
@@ -191,3 +192,3 @@ validateData((0, jsonc_eslint_parser_1.getStaticJSONValue)(program), (error) => { | ||
} | ||
else if (context.parserServices.isYAML) { | ||
else if (sourceCode.parserServices.isYAML) { | ||
const program = node; | ||
@@ -198,3 +199,3 @@ validateData((0, yaml_eslint_parser_1.getStaticYAMLValue)(program), (error) => { | ||
} | ||
else if (context.parserServices.isTOML) { | ||
else if (sourceCode.parserServices.isTOML) { | ||
const program = node; | ||
@@ -274,11 +275,11 @@ validateData((0, toml_eslint_parser_1.getStaticTOMLValue)(program), (error) => { | ||
let $schema = null; | ||
if (context.parserServices.isJSON) { | ||
if (sourceCode.parserServices.isJSON) { | ||
const program = node; | ||
$schema = findSchemaPathFromJSON(program); | ||
} | ||
else if (context.parserServices.isYAML) { | ||
else if (sourceCode.parserServices.isYAML) { | ||
const program = node; | ||
$schema = findSchemaPathFromYAML(program); | ||
} | ||
else if (context.parserServices.isTOML) { | ||
else if (sourceCode.parserServices.isTOML) { | ||
const program = node; | ||
@@ -291,3 +292,3 @@ $schema = findSchemaPathFromTOML(program); | ||
? context.getPhysicalFilename() | ||
: getPhysicalFilename(context.getFilename())), $schema) | ||
: getPhysicalFilename((0, compat_1.getFilename)(context))), $schema) | ||
: $schema | ||
@@ -297,3 +298,3 @@ : null; | ||
function get$SchemaValidators(context) { | ||
const $schemaPath = findSchemaPath(context.getSourceCode().ast); | ||
const $schemaPath = findSchemaPath(sourceCode.ast); | ||
if (!$schemaPath) | ||
@@ -417,8 +418,2 @@ return null; | ||
}); | ||
function getCwd(context) { | ||
if (context.getCwd) { | ||
return context.getCwd(); | ||
} | ||
return path_1.default.resolve(""); | ||
} | ||
function getPhysicalFilename(filename, child) { | ||
@@ -425,0 +420,0 @@ try { |
@@ -6,3 +6,3 @@ import type { JSONSchema4 } from "json-schema"; | ||
import type { AST as TOML } from "toml-eslint-parser"; | ||
import type { AST as ES } from "eslint"; | ||
import type { AST as ES, Scope } from "eslint"; | ||
import type { Comment as ESTreeComment } from "estree"; | ||
@@ -105,2 +105,3 @@ import type { ESLintNode, VElement } from "vue-eslint-parser/ast"; | ||
}; | ||
scopeManager: Scope.ScopeManager; | ||
getText(node?: NodeOrToken, beforeCount?: number, afterCount?: number): string; | ||
@@ -107,0 +108,0 @@ getLines(): string[]; |
@@ -28,2 +28,3 @@ "use strict"; | ||
const eslintUtils = __importStar(require("@eslint-community/eslint-utils")); | ||
const compat_1 = require("../../compat"); | ||
function getStaticPropertyName(node, context) { | ||
@@ -123,3 +124,3 @@ let key; | ||
const inner = currentNode.type !== "Program"; | ||
const scopeManager = context.getSourceCode().scopeManager; | ||
const scopeManager = (0, compat_1.getSourceCode)(context).scopeManager; | ||
let node = currentNode; | ||
@@ -126,0 +127,0 @@ for (; node; node = node.parent || null) { |
@@ -34,2 +34,3 @@ "use strict"; | ||
const path_1 = __importDefault(require("path")); | ||
const compat_1 = require("./compat"); | ||
function createRule(ruleName, rule) { | ||
@@ -39,3 +40,4 @@ return { | ||
create(context) { | ||
const filename = context.getFilename(); | ||
const sourceCode = (0, compat_1.getSourceCode)(context); | ||
const filename = (0, compat_1.getFilename)(context); | ||
const visitor = rule.create(context, { | ||
@@ -45,6 +47,6 @@ customBlock: false, | ||
}); | ||
if (typeof context.parserServices.defineCustomBlocksVisitor === | ||
if (typeof sourceCode.parserServices.defineCustomBlocksVisitor === | ||
"function" && | ||
path_1.default.extname(filename) === ".vue") { | ||
const jsonVisitor = context.parserServices.defineCustomBlocksVisitor(context, jsoncESLintParser, { | ||
const jsonVisitor = sourceCode.parserServices.defineCustomBlocksVisitor(context, jsoncESLintParser, { | ||
target(lang, block) { | ||
@@ -63,3 +65,3 @@ if (lang) { | ||
}); | ||
const yamlVisitor = context.parserServices.defineCustomBlocksVisitor(context, yamlESLintParser, { | ||
const yamlVisitor = sourceCode.parserServices.defineCustomBlocksVisitor(context, yamlESLintParser, { | ||
target: ["yaml", "yml"], | ||
@@ -73,3 +75,3 @@ create(blockContext) { | ||
}); | ||
const tomlVisitor = context.parserServices.defineCustomBlocksVisitor(context, tomlESLintParser, { | ||
const tomlVisitor = sourceCode.parserServices.defineCustomBlocksVisitor(context, tomlESLintParser, { | ||
target: ["toml"], | ||
@@ -76,0 +78,0 @@ create(blockContext) { |
@@ -12,2 +12,3 @@ "use strict"; | ||
const json_schema_migrate_1 = require("json-schema-migrate"); | ||
const compat_1 = require("./compat"); | ||
const debug = (0, debug_1.default)("eslint-plugin-json-schema-validator:utils-schema"); | ||
@@ -50,3 +51,3 @@ const TTL = 1000 * 60 * 60 * 24; | ||
} | ||
const json = fs_1.default.readFileSync(path_1.default.resolve(getCwd(context), jsonPath), "utf-8"); | ||
const json = fs_1.default.readFileSync(path_1.default.resolve((0, compat_1.getCwd)(context), jsonPath), "utf-8"); | ||
const data = JSON.parse(json); | ||
@@ -159,11 +160,5 @@ return edit ? edit(data) : data; | ||
if (modulePath.startsWith(".")) { | ||
return path_1.default.join(getCwd(context), modulePath); | ||
return path_1.default.join((0, compat_1.getCwd)(context), modulePath); | ||
} | ||
return modulePath; | ||
} | ||
function getCwd(context) { | ||
if (context.getCwd) { | ||
return context.getCwd(); | ||
} | ||
return path_1.default.resolve(""); | ||
} |
{ | ||
"name": "eslint-plugin-json-schema-validator", | ||
"version": "4.6.1", | ||
"version": "4.7.0", | ||
"description": "ESLint plugin that validates data using JSON Schema Validator.", | ||
@@ -56,2 +56,3 @@ "repository": "git+https://github.com/ota-meshi/eslint-plugin-json-schema-validator.git", | ||
"debug": "^4.3.1", | ||
"eslint-compat-utils": "^0.1.2", | ||
"json-schema-migrate": "^2.0.0", | ||
@@ -87,3 +88,3 @@ "jsonc-eslint-parser": "^2.0.0", | ||
"eslint-plugin-eslint-plugin": "^5.0.0", | ||
"eslint-plugin-json-schema-validator": "^4.0.0", | ||
"eslint-plugin-json-schema-validator": "^4.6.1", | ||
"eslint-plugin-jsonc": "^2.0.0", | ||
@@ -95,3 +96,3 @@ "eslint-plugin-markdown": "^3.0.0", | ||
"eslint-plugin-regexp": "^1.0.0", | ||
"eslint-plugin-toml": "^0.5.0", | ||
"eslint-plugin-toml": "^0.6.0", | ||
"eslint-plugin-vue": "^9.0.0", | ||
@@ -98,0 +99,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
107861
55
2464
12
+ Addedeslint-compat-utils@^0.1.2
+ Addedeslint-compat-utils@0.1.2(transitive)