-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: use vitepress * fix * fix
- Loading branch information
Showing
46 changed files
with
559 additions
and
538 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,3 +109,5 @@ dist | |
# docs | ||
/docs/assets | ||
/docs/**/*.html | ||
/docs/.vitepress/cache | ||
/docs/.vitepress/build-system/shim |
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,67 @@ | ||
/** | ||
* 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( | ||
// @ts-expect-error -- Cannot change `module` option | ||
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,3 @@ | ||
import all from "vue-eslint-parser"; | ||
export default all; | ||
export const parseForESLint = all.parseForESLint; |
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,144 @@ | ||
import type { DefaultTheme, UserConfig } from "vitepress"; | ||
import { defineConfig } from "vitepress"; | ||
import { BUNDLED_LANGUAGES } from "shiki"; | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
import eslint4b from "vite-plugin-eslint4b"; | ||
import type { RuleModule } from "../../src/types.js"; | ||
import { viteCommonjs } from "./vite-plugin.mjs"; | ||
|
||
import "./build-system/build.js"; | ||
const dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
// Include `json5` as alias for jsonc | ||
const jsonc = BUNDLED_LANGUAGES.find((lang) => lang.id === "jsonc"); | ||
if (jsonc) jsonc.aliases = [...(jsonc?.aliases ?? []), "json5"]; | ||
|
||
function ruleToSidebarItem({ | ||
meta: { | ||
docs: { ruleId, ruleName }, | ||
}, | ||
}: RuleModule): DefaultTheme.SidebarItem { | ||
return { | ||
text: ruleId, | ||
link: `/rules/${ruleName}`, | ||
}; | ||
} | ||
|
||
export default async (): Promise<UserConfig<DefaultTheme.Config>> => { | ||
const a = "../../lib/utils/rules.js"; | ||
const { rules } = (await import(a)) as { rules: RuleModule[] }; | ||
return defineConfig({ | ||
base: "/eslint-plugin-toml/", | ||
title: "eslint-plugin-toml", | ||
outDir: path.join(dirname, "./dist/eslint-plugin-toml"), | ||
description: "ESLint plugin provides linting rules for TOML", | ||
head: [ | ||
[ | ||
"link", | ||
{ | ||
rel: "icon", | ||
href: "/eslint-plugin-toml/logo.svg", | ||
type: "image/svg+xml", | ||
}, | ||
], | ||
], | ||
|
||
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"), | ||
events: path.join(dirname, "./build-system/shim/events.mjs"), | ||
}, | ||
}, | ||
define: { | ||
"process.env.NODE_DEBUG": "false", | ||
}, | ||
optimizeDeps: { | ||
// exclude: ["vue-eslint-parser"], | ||
}, | ||
}, | ||
|
||
lastUpdated: true, | ||
themeConfig: { | ||
logo: "/logo.svg", | ||
search: { | ||
provider: "local", | ||
options: { | ||
detailedView: true, | ||
}, | ||
}, | ||
editLink: { | ||
pattern: | ||
"https://github.com/ota-meshi/eslint-plugin-toml/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-toml", | ||
}, | ||
], | ||
sidebar: { | ||
"/rules/": [ | ||
{ | ||
text: "Rules", | ||
items: [{ text: "Available Rules", link: "/rules/" }], | ||
}, | ||
{ | ||
text: "YAML Rules", | ||
collapsed: false, | ||
items: rules | ||
.filter( | ||
(rule) => | ||
!rule.meta.docs.extensionRule && !rule.meta.deprecated, | ||
) | ||
.map(ruleToSidebarItem), | ||
}, | ||
{ | ||
text: "Extension Rules", | ||
collapsed: false, | ||
items: rules | ||
.filter( | ||
(rule) => rule.meta.docs.extensionRule && !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,6 @@ | ||
export function createRequire() { | ||
// noop | ||
} | ||
export default { | ||
createRequire, | ||
}; |
5 changes: 4 additions & 1 deletion
5
docs/.vuepress/styles/stylelint.config.js → docs/.vitepress/stylelint.config.js
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
module.exports = { | ||
extends: ["stylelint-config-standard", "stylelint-stylus/standard"], | ||
extends: ["stylelint-config-standard-vue"], | ||
rules: { | ||
"no-descending-specificity": null, | ||
"selector-class-pattern": null, | ||
"value-keyword-case": null, | ||
|
||
// Conflict with Prettier | ||
indentation: null, | ||
}, | ||
}; |
Oops, something went wrong.