Skip to content

Commit 3f40cf1

Browse files
authored
Chore: use vitepress instead of vuepress as site builder (#485)
* Chore: use vitepress instead of vuepress as site builder * fix test * fix
1 parent e040e79 commit 3f40cf1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+13913
-33302
lines changed

.eslintignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/.nyc_output
22
/coverage
33
/dist
4-
/docs/.vuepress/dist
5-
/docs/.vuepress/components/demo/demo-code.js
4+
/docs/.vitepress/dist
5+
/docs/.vitepress/build-system/shim/eslint.mjs
66
/node_modules
77
/assets
8-
!/docs/.vuepress
8+
!/docs/.vitepress
99
!/.vscode
1010
!/.github
1111
/tests/fixtures/integrations/eslint-plugin/test.js

.eslintrc.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,34 @@ module.exports = {
8484
},
8585
{
8686
files: ["*.vue"],
87-
extends: ["plugin:@ota-meshi/+vue2", "plugin:@ota-meshi/+prettier"],
87+
extends: ["plugin:@ota-meshi/+vue3", "plugin:@ota-meshi/+prettier"],
8888
parserOptions: {
8989
sourceType: "module",
9090
},
9191
globals: {
9292
require: true,
9393
},
94+
rules: {
95+
"vue/multi-word-component-names": "off",
96+
"@typescript-eslint/no-explicit-any": "off",
97+
},
9498
},
9599
{
96-
files: ["docs/.vuepress/**"],
100+
files: ["docs/.vitepress/**"],
97101
parserOptions: {
98102
sourceType: "module",
99103
ecmaVersion: 2020,
100104
},
101105
globals: {
102106
window: true,
107+
require: true,
103108
},
104109
rules: {
105110
"require-jsdoc": "off",
111+
"node/file-extension-in-import": "off",
112+
"node/no-extraneous-import": "off",
113+
"node/no-unsupported-features/es-syntax": "off",
114+
"@typescript-eslint/no-explicit-any": "off",
106115
},
107116
},
108117
],

.github/workflows/GHPages.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ jobs:
3232
run: npm ci
3333
- name: Build docs
3434
run: |+
35-
export NODE_OPTIONS=--openssl-legacy-provider
3635
npm run docs:build
3736
- name: Setup Pages
3837
uses: actions/configure-pages@v2
3938
- name: Upload artifact
4039
uses: actions/upload-pages-artifact@v1
4140
with:
42-
path: ./docs/.vuepress/dist
41+
path: ./docs/.vitepress/dist/eslint-plugin-regexp
4342
- name: Deploy to GitHub Pages
4443
id: deployment
4544
uses: actions/deploy-pages@v1

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ dist
8888
# https://nextjs.org/blog/next-9-1#public-directory-support
8989
# public
9090

91-
# vuepress build output
92-
.vuepress/dist
91+
# vitepress build output
92+
.vitepress/dist
9393

9494
# Serverless directories
9595
.serverless/
@@ -102,3 +102,6 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
## Repo
107+
docs/.vitepress/build-system/shim/eslint.mjs

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The following steps will walk you through the process of creating a new rule.
6969

7070
The documentation should contain a description of the rule and the problem it detects/solves, examples, all features, all options, and any additional information relevant to the rule.
7171

72-
You can view the documentation live in your browser by running `npm run build && npm run docs:watch`. The live view will automatically update when you make changes to the documentation. However, you have to re-run the command to see changes to the rule implementation.
72+
You can view the documentation live in your browser by running `npm run docs:watch`. The live view will automatically update when you make changes to the documentation. However, you have to re-load the browser to see changes to the rule implementation.
7373

7474

7575
### Updating documentation
@@ -78,9 +78,9 @@ Almost all Markdown files of our website and the project `README.md` are partial
7878

7979
The following files are completely generated and must not be modified directly:
8080

81-
- `docs/README.md` - change this section of the project `README.md` instead.
82-
- `docs/rules/README.md`
83-
- `docs/user-guide/README.md` - change this section of the project `README.md` instead.
81+
- `docs/index.md` - change this section of the project `README.md` instead.
82+
- `docs/rules/index.md`
83+
- `docs/user-guide/index.md` - change this section of the project `README.md` instead.
8484

8585
The following files are partially generated:
8686

@@ -98,7 +98,7 @@ You can view changes to the website locally by running `npm run docs:watch`.
9898

9999
Aside from `npm test`, there are also a few other ways to manually test new features, changes, and new rules.
100100

101-
1. `npm run build && npm run docs:watch`:
101+
1. `npm run docs:watch`:
102102

103103
The documentation page of each rule includes interactive examples. You can also use your local version of [the playground](https://ota-meshi.github.io/eslint-plugin-regexp/playground/) to for testing.
104104

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[eslint-plugin-regexp](https://www.npmjs.com/package/eslint-plugin-regexp) is ESLint plugin for finding RegExp mistakes and RegExp style guide violations.
44

5+
<!--PACKAGE_STATUS_START-->
6+
57
[![NPM license](https://img.shields.io/npm/l/eslint-plugin-regexp.svg)](https://www.npmjs.com/package/eslint-plugin-regexp)
68
[![NPM version](https://img.shields.io/npm/v/eslint-plugin-regexp.svg)](https://www.npmjs.com/package/eslint-plugin-regexp)
79
[![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/eslint-plugin-regexp&maxAge=3600)](http://www.npmtrends.com/eslint-plugin-regexp)
@@ -12,6 +14,8 @@
1214
[![Build Status](https://github.com/ota-meshi/eslint-plugin-regexp/workflows/CI/badge.svg?branch=master)](https://github.com/ota-meshi/eslint-plugin-regexp/actions?query=workflow%3ACI)
1315
[![Coverage Status](https://coveralls.io/repos/github/ota-meshi/eslint-plugin-regexp/badge.svg?branch=master)](https://coveralls.io/github/ota-meshi/eslint-plugin-regexp?branch=master)
1416

17+
<!--PACKAGE_STATUS_END-->
18+
1519
## :name_badge: Features
1620

1721
This ESLint plugin provides linting rules relate to better ways to help you avoid problems when using RegExp.

docs/.vitepress/build-system/build.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Pre-build cjs packages that cannot be bundled well.
3+
*/
4+
5+
import esbuild from "esbuild"
6+
import path from "path"
7+
import fs from "fs"
8+
import { fileURLToPath } from "url"
9+
10+
const dirname = path.dirname(
11+
fileURLToPath(
12+
// @ts-expect-error -- Cannot change `module` option
13+
import.meta.url,
14+
),
15+
)
16+
17+
build(
18+
path.join(dirname, "./src/eslint.mjs"),
19+
path.join(dirname, "./shim/eslint.mjs"),
20+
["path", "assert", "util"],
21+
)
22+
23+
/** build */
24+
function build(input: string, out: string, injects: string[] = []) {
25+
// eslint-disable-next-line no-console -- ignore
26+
console.log(`build@ ${input}`)
27+
let code = bundle(input, injects)
28+
code = transform(code, injects)
29+
fs.mkdirSync(path.dirname(out), { recursive: true })
30+
fs.writeFileSync(out, code, "utf8")
31+
}
32+
33+
/** bundle */
34+
function bundle(entryPoint: string, externals: string[]) {
35+
const result = esbuild.buildSync({
36+
entryPoints: [entryPoint],
37+
format: "esm",
38+
bundle: true,
39+
external: externals,
40+
write: false,
41+
inject: [path.join(dirname, "./src/process-shim.mjs")],
42+
})
43+
44+
return `${result.outputFiles[0].text}`
45+
}
46+
47+
/** transform code */
48+
function transform(code: string, injects: string[]) {
49+
const newCode = code.replace(/"[a-z]+" = "[a-z]+";/u, "")
50+
return `
51+
${injects
52+
.map(
53+
(inject) =>
54+
`import $inject_${inject.replace(/-/gu, "_")}$ from '${inject}';`,
55+
)
56+
.join("\n")}
57+
const $_injects_$ = {${injects
58+
.map((inject) => `${inject.replace(/-/gu, "_")}:$inject_${inject}$`)
59+
.join(",\n")}};
60+
function require(module, ...args) {
61+
return $_injects_$[module] || {}
62+
}
63+
${newCode}
64+
`
65+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const sep = "/"
2+
const posix = {
3+
sep,
4+
}
5+
posix.posix = posix
6+
export default posix
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import * as all from "../../../../node_modules/eslint/lib/linter/linter.js"
2+
const Linter = all.Linter
3+
export { Linter }
4+
export default { Linter }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export let process = {
2+
env: {},
3+
cwd: () => "",
4+
stdout: {},
5+
}
6+
if (typeof window !== "undefined") {
7+
window.process = process
8+
}

0 commit comments

Comments
 (0)