Skip to content

Commit 93b7a52

Browse files
committed
chore: move rules docs sources to plugins
1 parent 20ee895 commit 93b7a52

File tree

86 files changed

+37
-7
lines changed

Some content is hidden

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

86 files changed

+37
-7
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"build": "pnpm run update:version && nx run-many -t build --projects=\"packages/**\"",
3030
"build:all": "nx run-many -t build",
3131
"build:docs": "nx run-many -t build:docs --projects=\"packages/**\" && pnpm run update:readme",
32-
"build:website": "pnpm -F \"./website\" run build",
32+
"build:website": "pnpm run update:website && pnpm -F \"./website\" run build",
3333
"build:workspace": "pnpm -F \"./workspace/*\" run build",
3434
"format:check": "dprint check",
3535
"format:package-json": "pnpm --parallel -r exec fixpkg -q package.json && fixpkg && dprint fmt",
@@ -45,7 +45,7 @@
4545
"lint:ts": "eslint . --max-warnings 100",
4646
"lint:type": "pnpm -r run --parallel lint:type",
4747
"lint:website": "pnpm -F \"./website\" run lint",
48-
"prepare": "lefthook install && pnpm run build",
48+
"prepare": "lefthook install && pnpm run build && pnpm run update:website",
4949
"test": "vitest run --logHeapUsage",
5050
"update:all": "pnpm run update:version && pnpm run update:readme && pnpm run update:website",
5151
"update:readme": "tsx ./scripts/update-readme.ts",

pnpm-lock.yaml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/update-website.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
1-
import fs from "node:fs";
1+
import fs from "node:fs/promises";
2+
import path from "node:path";
23

3-
const changelog = fs.readFileSync("CHANGELOG.md", "utf-8");
4+
import { glob } from "./lib";
5+
6+
const docs = glob(["packages/plugins/eslint-plugin-react-*/src/rules/*.md"]);
7+
8+
const [
9+
files,
10+
// rules,
11+
] = Array.from(docs).reduce<readonly [[string, string][], [string, string][]]>(
12+
([files, rules], doc) => {
13+
const catename = /^packages\/plugins\/eslint-plugin-react-([^/]+)/u.exec(doc)?.[1] ?? "";
14+
const basename = path.parse(path.basename(doc)).name;
15+
const isPluginX = catename === "x";
16+
const name = isPluginX
17+
? basename
18+
: `${catename}-${basename}`;
19+
const title = isPluginX
20+
? basename
21+
: `${catename}/${basename}`;
22+
const dest = path.join("website", "content", "docs", "rules", `${name}.md`);
23+
return [[...files, [doc, dest]], [...rules, [name, title]]] as const;
24+
},
25+
[[], []],
26+
);
27+
28+
await Promise.all(files.map(async ([src, dest]) => fs.copyFile(src, dest)));
29+
30+
// fs.writeFileSync(path.join("website", "content", "docs", "rules", "data.json"), JSON.stringify(rules, null, 2));
31+
32+
const changelog = await fs.readFile("CHANGELOG.md", "utf-8");
433

534
const changelogWithFrontmatter = [
635
"---",
@@ -10,4 +39,4 @@ const changelogWithFrontmatter = [
1039
changelog,
1140
].join("\n");
1241

13-
fs.writeFileSync("website/content/docs/changelog.md", changelogWithFrontmatter);
42+
await fs.writeFile("website/content/docs/changelog.md", changelogWithFrontmatter);

website/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ yarn-error.log*
2525
# others
2626
.env*.local
2727
.vercel
28-
next-env.d.ts
28+
next-env.d.ts

website/content/docs/rules/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.md
2+
!overview.md

0 commit comments

Comments
 (0)