Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use vitepress v1 * fix
- Loading branch information
Showing
56 changed files
with
1,092 additions
and
878 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Pre-build cjs packages that cannot be bundled well. | ||
*/ | ||
import esbuild from "esbuild"; | ||
import path from "path"; | ||
import fs from "fs"; | ||
import { fileURLToPath } from "url"; | ||
|
||
const dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
build( | ||
path.join(dirname, "./src/vue-eslint-parser.mjs"), | ||
path.join(dirname, "./shim/vue-eslint-parser.mjs"), | ||
["eslint", "path", "module", "events"], | ||
); | ||
build( | ||
path.join(dirname, "./src/events.mjs"), | ||
path.join(dirname, "./shim/events.mjs"), | ||
[], | ||
); | ||
|
||
function build(input: string, out: string, injects: string[] = []) { | ||
// eslint-disable-next-line no-console -- ignore | ||
console.log(`build@ ${input}`); | ||
let code = bundle(input, injects); | ||
code = transform(code, injects); | ||
fs.mkdirSync(path.dirname(out), { recursive: true }); | ||
fs.writeFileSync(out, code, "utf8"); | ||
} | ||
|
||
function bundle(entryPoint: string, externals: string[]) { | ||
const result = esbuild.buildSync({ | ||
entryPoints: [entryPoint], | ||
format: "esm", | ||
bundle: true, | ||
external: externals, | ||
write: false, | ||
}); | ||
|
||
return `${result.outputFiles[0].text}`; | ||
} | ||
|
||
function transform(code: string, injects: string[]) { | ||
const newCode = code.replace(/"[a-z]+" = "[a-z]+";/u, ""); | ||
return ` | ||
${injects | ||
.map( | ||
(inject) => | ||
`import $inject_${inject.replace(/-/gu, "_")}$ from '${inject}';`, | ||
) | ||
.join("\n")} | ||
const $_injects_$ = {${injects | ||
.map((inject) => `${inject.replace(/-/gu, "_")}:$inject_${inject}$`) | ||
.join(",\n")}}; | ||
function require(module, ...args) { | ||
return $_injects_$[module] || {} | ||
} | ||
${newCode} | ||
if (typeof __require !== 'undefined') __require.cache = {}; | ||
`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import all from "events"; | ||
export default all; | ||
export const EventEmitter = all.EventEmitter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import all from "vue-eslint-parser"; | ||
export default all; | ||
export const parseForESLint = all.parseForESLint; | ||
export const AST = all.AST; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import type { DefaultTheme, UserConfig } from "vitepress"; | ||
import { defineConfig } from "vitepress"; | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
import eslint4b from "vite-plugin-eslint4b"; | ||
import { viteCommonjs } from "./vite-plugin.mjs"; | ||
|
||
import "./build-system/build.mts"; | ||
|
||
type RuleModule = { | ||
meta: { docs: { ruleId: string; ruleName: string }; deprecated?: boolean }; | ||
}; | ||
|
||
const dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
function ruleToSidebarItem({ | ||
meta: { | ||
docs: { ruleId, ruleName }, | ||
}, | ||
}: RuleModule): DefaultTheme.SidebarItem { | ||
return { | ||
text: ruleId, | ||
link: `/rules/${ruleName}`, | ||
}; | ||
} | ||
|
||
export default async (): Promise<UserConfig<DefaultTheme.Config>> => { | ||
const schemaPath = "../../lib/utils/schema.js"; | ||
const schema = (await import( | ||
schemaPath | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports -- ignore | ||
)) as typeof import("../../src/utils/schema.js"); | ||
|
||
// Generate a schema store cache and include it in the bundle. | ||
schema.loadJson( | ||
"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); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- ignore | ||
schema.loadSchema("https://json.schemastore.org/prettierrc.json", {} as any); | ||
schema.loadSchema( | ||
"https://json.schemastore.org/partial-eslint-plugins.json", | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- ignore | ||
{} as any, | ||
); | ||
const rulesPath = "../../lib/utils/rules.js"; | ||
const { rules } = (await import(rulesPath)) as { rules: RuleModule[] }; | ||
return defineConfig({ | ||
base: "/eslint-plugin-json-schema-validator/", | ||
title: "eslint-plugin-json-schema-validator", | ||
outDir: path.join(dirname, "./dist/eslint-plugin-json-schema-validator"), | ||
description: | ||
"ESLint plugin that validates data using JSON Schema Validator", | ||
head: [], | ||
|
||
vite: { | ||
plugins: [viteCommonjs(), eslint4b()], | ||
resolve: { | ||
alias: { | ||
"vue-eslint-parser": path.join( | ||
dirname, | ||
"./build-system/shim/vue-eslint-parser.mjs", | ||
), | ||
module: path.join(dirname, "./shim/module.mjs"), | ||
fs: path.join(dirname, "./shim/fs.mjs"), | ||
synckit: path.join(dirname, "./shim/synckit.mjs"), | ||
"tunnel-agent": path.join(dirname, "./shim/tunnel-agent.mjs"), | ||
events: path.join(dirname, "./build-system/shim/events.mjs"), | ||
}, | ||
}, | ||
define: { | ||
"process.env.NODE_DEBUG": "false", | ||
"process.platform": JSON.stringify(process.platform), | ||
"process.version": JSON.stringify(process.version), | ||
}, | ||
optimizeDeps: { | ||
// exclude: ["vue-eslint-parser"], | ||
}, | ||
}, | ||
|
||
lastUpdated: true, | ||
themeConfig: { | ||
search: { | ||
provider: "local", | ||
options: { | ||
detailedView: true, | ||
}, | ||
}, | ||
editLink: { | ||
pattern: | ||
"https://github.com/ota-meshi/eslint-plugin-json-schema-validator/edit/main/docs/:path", | ||
}, | ||
nav: [ | ||
{ text: "Introduction", link: "/" }, | ||
{ text: "User Guide", link: "/user-guide/" }, | ||
{ text: "Rules", link: "/rules/" }, | ||
{ text: "Playground", link: "/playground/" }, | ||
], | ||
socialLinks: [ | ||
{ | ||
icon: "github", | ||
link: "https://github.com/ota-meshi/eslint-plugin-json-schema-validator", | ||
}, | ||
], | ||
sidebar: { | ||
"/rules/": [ | ||
{ | ||
text: "Rules", | ||
items: [{ text: "Available Rules", link: "/rules/" }], | ||
}, | ||
{ | ||
text: "JSON Schema Validator Rules", | ||
collapsed: false, | ||
items: rules | ||
.filter((rule) => !rule.meta.deprecated) | ||
.map(ruleToSidebarItem), | ||
}, | ||
|
||
// Rules in no category. | ||
...(rules.some((rule) => rule.meta.deprecated) | ||
? [ | ||
{ | ||
text: "Deprecated", | ||
collapsed: false, | ||
items: rules | ||
.filter((rule) => rule.meta.deprecated) | ||
.map(ruleToSidebarItem), | ||
}, | ||
] | ||
: []), | ||
], | ||
"/": [ | ||
{ | ||
text: "Guide", | ||
items: [ | ||
{ text: "Introduction", link: "/" }, | ||
{ text: "User Guide", link: "/user-guide/" }, | ||
{ text: "Rules", link: "/rules/" }, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function existsSync(arg) { | ||
return arg === "/"; | ||
} | ||
export function mkdirSync() { | ||
// noop | ||
} | ||
export default { existsSync, mkdirSync }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function createRequire() { | ||
// noop | ||
} | ||
export default { | ||
createRequire, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import catalog from "../../../.cached_schemastore/www.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"; | ||
|
||
/** | ||
* @param {string} p | ||
*/ | ||
export default function fakeRequire(p) { | ||
if ( | ||
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")) { | ||
return { ...eslintrc, timestamp: Infinity }; | ||
} | ||
if ( | ||
p.endsWith( | ||
".cached_schemastore/json.schemastore.org/partial-eslint-plugins.json", | ||
) | ||
) { | ||
return { ...partialEslintPlugins, timestamp: Infinity }; | ||
} | ||
if (p.endsWith(".cached_schemastore/json.schemastore.org/prettierrc.json")) { | ||
return { ...prettierrc, timestamp: Infinity }; | ||
} | ||
console.log(`unknown:${p}`); | ||
return {}; | ||
} | ||
|
||
fakeRequire.resolve = () => ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function createSyncFn() { | ||
return function () { | ||
// noop | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {}; | ||
export default {}; |
Oops, something went wrong.