Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-timers-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-json-schema-validator": patch
---

fix: update schemastore catlog url
2 changes: 1 addition & 1 deletion src/rules/no-invalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import fs from "fs";
import { getCwd, getFilename, getSourceCode } from "../utils/compat";
import { toCompatCreate } from "eslint-json-compat-utils";

const CATALOG_URL = "https://www.schemastore.org/api/json/catalog.json";
const CATALOG_URL = "https://json.schemastore.org/api/json/catalog.json";

/**
* Checks if match file
Expand Down
28 changes: 17 additions & 11 deletions src/utils/ast/js/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -- ignore
/* eslint-disable @typescript-eslint/no-explicit-any -- ignore */
import type { AST } from "vue-eslint-parser";
import type { RuleContext } from "../../../types";
// @ts-expect-error -- no type def
import * as eslintUtils from "@eslint-community/eslint-utils";
import type { Variable } from "eslint-scope";
import type { AST } from "vue-eslint-parser";

import type { RuleContext } from "../../../types";
import { getSourceCode } from "../../compat";

/**
Expand Down Expand Up @@ -58,8 +56,8 @@ export function getStringLiteralValue(
): string | null {
if (node.type === "Literal") {
if (node.value == null) {
if ((node as any).bigint != null) {
return String((node as any).bigint);
if (node.bigint != null) {
return String(node.bigint);
}
}
return String(node.value);
Expand Down Expand Up @@ -88,8 +86,12 @@ function findVariable(
export function getStaticValue(
context: RuleContext,
node: AST.ESLintNode,
): { value: any } | null {
return eslintUtils.getStaticValue(node, getScope(context, node));
): { value?: unknown; optional?: boolean } | null {
return eslintUtils.getStaticValue(
// @ts-expect-error -- `eslintUtils` is typed now but incompatible with Vue AST typings
node,
getScope(context, node),
);
}

/**
Expand Down Expand Up @@ -140,9 +142,13 @@ function getScope(context: RuleContext, currentNode: AST.ESLintNode) {
const inner = currentNode.type !== "Program";
const scopeManager = getSourceCode(context).scopeManager;

let node: any = currentNode;
let node: AST.Node | null = currentNode;
for (; node; node = node.parent || null) {
const scope = scopeManager.acquire(node, inner);
const scope = scopeManager.acquire(
// @ts-expect-error -- incompatible with Vue AST typings
node,
inner,
);

if (scope) {
if (scope.type === "function-expression-name") {
Expand Down
Loading