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
2 changes: 1 addition & 1 deletion .github/workflows/GHPages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:

# Allow one concurrent deployment
concurrency:
group: pages
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/NodeCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
pull_request:
branches: [main]

# Allow one concurrent deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -14,10 +19,19 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: actions/cache/restore@v4
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('package.json') }}-${{ github.ref }}
- name: Install Packages
run: yarn
- name: Lint
run: yarn lint
- uses: actions/cache/save@v4
if: always()
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('package.json') }}-${{ github.ref }}
test:
strategy:
matrix:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
branches:
- main

# Allow one concurrent deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release:
name: Release
Expand All @@ -16,10 +21,10 @@ jobs:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 16
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: "lts/*"

- name: Install Dependencies
run: yarn --ignore-engines
Expand All @@ -38,4 +43,3 @@ jobs:
title: "chore: release eslint-plugin-json-schema-validator"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: 👔 Format
on:
workflow_dispatch: null

# Allow one concurrent deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
format:
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ permissions:
issues: write
pull-requests: write

# Allow one concurrent deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
stale:
if: github.repository == 'ota-meshi/eslint-plugin-json-schema-validator'
Expand Down
8 changes: 4 additions & 4 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ export default async (): Promise<UserConfig<DefaultTheme.Config>> => {

// Generate a schema store cache and include it in the bundle.
schema.loadJson(
"https://json.schemastore.org/api/json/catalog.json",
"https://www.schemastore.org/api/json/catalog.json",
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- ignore
{} as any,
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- ignore
schema.loadSchema("https://json.schemastore.org/eslintrc.json", {} as any);
schema.loadSchema("https://www.schemastore.org/eslintrc.json", {} as any);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- ignore
schema.loadSchema("https://json.schemastore.org/prettierrc.json", {} as any);
schema.loadSchema("https://www.schemastore.org/prettierrc.json", {} as any);
schema.loadSchema(
"https://json.schemastore.org/partial-eslint-plugins.json",
"https://www.schemastore.org/partial-eslint-plugins.json",
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- ignore
{} as any,
);
Expand Down
16 changes: 8 additions & 8 deletions docs/.vitepress/shim/require-from-cache.mjs
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import catalog from "../../../.cached_schemastore/json.schemastore.org/api/json/catalog.json";
import eslintrc from "../../../.cached_schemastore/json.schemastore.org/eslintrc.json";
import partialEslintPlugins from "../../../.cached_schemastore/json.schemastore.org/partial-eslint-plugins.json";
import prettierrc from "../../../.cached_schemastore/json.schemastore.org/prettierrc.json";
import catalog from "../../../.cached_schemastore/www.schemastore.org/api/json/catalog.json";
import eslintrc from "../../../.cached_schemastore/www.schemastore.org/eslintrc.json";
import partialEslintPlugins from "../../../.cached_schemastore/www.schemastore.org/partial-eslint-plugins.json";
import prettierrc from "../../../.cached_schemastore/www.schemastore.org/prettierrc.json";

/**
* @param {string} p
*/
export default function fakeRequire(p) {
if (
p.endsWith(".cached_schemastore/json.schemastore.org/api/json/catalog.json")
p.endsWith(".cached_schemastore/www.schemastore.org/api/json/catalog.json")
) {
return { ...catalog, timestamp: Infinity };
}
if (p.endsWith(".cached_schemastore/json.schemastore.org/eslintrc.json")) {
if (p.endsWith(".cached_schemastore/www.schemastore.org/eslintrc.json")) {
return { ...eslintrc, timestamp: Infinity };
}
if (
p.endsWith(
".cached_schemastore/json.schemastore.org/partial-eslint-plugins.json",
".cached_schemastore/www.schemastore.org/partial-eslint-plugins.json",
)
) {
return { ...partialEslintPlugins, timestamp: Infinity };
}
if (p.endsWith(".cached_schemastore/json.schemastore.org/prettierrc.json")) {
if (p.endsWith(".cached_schemastore/www.schemastore.org/prettierrc.json")) {
return { ...prettierrc, timestamp: Infinity };
}
console.log(`unknown:${p}`);
Expand Down
8 changes: 4 additions & 4 deletions docs/.vitepress/theme/components/playground-block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const DEFAULT_CODE = `{

const JS_CODE = `/* eslint json-schema-validator/no-invalid: [
"error",
"https://json.schemastore.org/eslintrc"
"https://www.schemastore.org/eslintrc"
]
-- About options: https://ota-meshi.github.io/eslint-plugin-json-schema-validator/rules/no-invalid.html#options
*/
Expand All @@ -85,7 +85,7 @@ module.exports = {
`;
const JSON_CODE = `/* eslint json-schema-validator/no-invalid: [
"error",
"https://json.schemastore.org/eslintrc"
"https://www.schemastore.org/eslintrc"
]
-- About options: https://ota-meshi.github.io/eslint-plugin-json-schema-validator/rules/no-invalid.html#options
*/
Expand All @@ -100,7 +100,7 @@ const JSON_CODE = `/* eslint json-schema-validator/no-invalid: [
}
}
`;
const YAML_CODE = `# eslint json-schema-validator/no-invalid: [error, "https://json.schemastore.org/eslintrc"]
const YAML_CODE = `# eslint json-schema-validator/no-invalid: [error, "https://www.schemastore.org/eslintrc"]
# -- About options: https://ota-meshi.github.io/eslint-plugin-json-schema-validator/rules/no-invalid.html#options
extends:
- 42
Expand All @@ -110,7 +110,7 @@ rules:
"eqeqeq": "warn"
"strict": "off"
`;
const TOML_CODE = `# eslint json-schema-validator/no-invalid: [error, "https://json.schemastore.org/prettierrc"]
const TOML_CODE = `# eslint json-schema-validator/no-invalid: [error, "https://www.schemastore.org/prettierrc"]
# -- About options: https://ota-meshi.github.io/eslint-plugin-json-schema-validator/rules/no-invalid.html#options
trailingComma = "es3"
tabWidth = 4
Expand Down
84 changes: 43 additions & 41 deletions docs/rules/no-invalid.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ This rule validates the file with JSON Schema and reports errors.
// File name is ".eslintrc.json"
/* eslint json-schema-validator/no-invalid: 'error' */
{
"overrides": [
{
"files": ["good"],
/* ✓ GOOD */
"extends": ["foo"]
},
{
"files": ["bad"],
/* ✗ BAD */
"extends": [42]
}
]
overrides: [
{
files: ["good"],
/* ✓ GOOD */
extends: ["foo"],
},
{
files: ["bad"],
/* ✗ BAD */
extends: [42],
},
],
}
```

Expand All @@ -45,19 +45,21 @@ This rule validates the file with JSON Schema and reports errors.

```json5
{
"json-schema-validator/no-invalid": [
"error",
"json-schema-validator/no-invalid": [
"error",
{
schemas: [
{
"schemas": [
{
"fileMatch": [".eslintrc.json"],
"schema": {/* JSON Schema Definition */} // or string
}
],
"useSchemastoreCatalog": true,
"mergeSchemas": true // or ["$schema", "options", "catalog"]
}
]
fileMatch: [".eslintrc.json"],
schema: {
/* JSON Schema Definition */
}, // or string
},
],
useSchemastoreCatalog: true,
mergeSchemas: true, // or ["$schema", "options", "catalog"]
},
],
}
```

Expand All @@ -76,24 +78,24 @@ This option can also be given a JSON schema file or URL. This is useful for conf
```js
/* eslint json-schema-validator/no-invalid: [
"error",
"https://json.schemastore.org/eslintrc"
"https://www.schemastore.org/eslintrc"
]
*/

module.exports = {
overrides: [
{
files: ["good"],
/* ✓ GOOD */
extends: ["foo"]
},
{
files: ["bad"],
/* ✗ BAD */
extends: [42]
}
]
}
overrides: [
{
files: ["good"],
/* ✓ GOOD */
extends: ["foo"],
},
{
files: ["bad"],
/* ✗ BAD */
extends: [42],
},
],
};
```

</eslint-code-block>
Expand All @@ -120,9 +122,9 @@ To match a custom block, use a glob like this:

```json5
{
// If you want to match the <i18n> block.
"fileMatch": ["**/*blockType=i18n*"],
"schema": { "type": "object" /* JSON Schema Definition */ }
// If you want to match the <i18n> block.
fileMatch: ["**/*blockType=i18n*"],
schema: { type: "object" /* JSON Schema Definition */ },
}
```

Expand Down
5 changes: 4 additions & 1 deletion src/utils/ast/js/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ function findVariable(
context: RuleContext,
node: AST.ESLintIdentifier,
): Variable | null {
return eslintUtils.findVariable(getScope(context, node), node);
return eslintUtils.findVariable(
getScope(context, node),
node,
) as Variable | null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { SchemaObject } from "./types";

const debug = debugBuilder("eslint-plugin-json-schema-validator:utils-schema");

const TTL = 1000 * 60 * 60 * 24;
const TTL = 1000 * 60 * 60 * 24; // 1 day
const RELOADING = new Set<string>();

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"$schema": "http://www.schemastore.org/tsconfig",
"compilerOptions": 42
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"$schema" = "http://json.schemastore.org/tsconfig"
"$schema" = "http://www.schemastore.org/tsconfig"
compilerOptions = 42
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
$schema: "http://json.schemastore.org/tsconfig"
$schema: "http://www.schemastore.org/tsconfig"
compilerOptions: 42
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"options": ["https://json.schemastore.org/eslintrc"]
"options": ["https://www.schemastore.org/eslintrc"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"eslintrc-escape-input.json",
"eslintrc-js-input.js"
],
"schema": "https://json.schemastore.org/eslintrc"
"schema": "https://www.schemastore.org/eslintrc"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"schemas": [
{
"fileMatch": ["**/*.json"],
"schema": "https://yarnpkg.com/configuration/yarnrc.json"
"schema": "https://docs.renovatebot.com/renovate-schema.json"
}
]
}
Expand Down
Loading
Loading