Skip to content

Commit 9b9285b

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

File tree

87 files changed

+129
-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.

87 files changed

+129
-7
lines changed

package.json

+2-2
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",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"pages": [
3+
"overview",
4+
"------",
5+
"ensure-forward-ref-using-ref",
6+
"no-access-state-in-setstate",
7+
"no-array-index-key",
8+
"no-children-count",
9+
"no-children-for-each",
10+
"no-children-map",
11+
"no-children-only",
12+
"no-children-prop",
13+
"no-children-to-array",
14+
"no-class-component",
15+
"no-clone-element",
16+
"no-comment-textnodes",
17+
"no-complex-conditional-rendering",
18+
"no-component-will-mount",
19+
"no-component-will-receive-props",
20+
"no-component-will-update",
21+
"no-context-provider",
22+
"no-create-ref",
23+
"no-default-props",
24+
"no-direct-mutation-state",
25+
"no-duplicate-jsx-props",
26+
"no-duplicate-key",
27+
"no-forward-ref",
28+
"no-implicit-key",
29+
"no-leaked-conditional-rendering",
30+
"no-missing-component-display-name",
31+
"no-missing-key",
32+
"no-nested-components",
33+
"no-prop-types",
34+
"no-redundant-should-component-update",
35+
"no-set-state-in-component-did-mount",
36+
"no-set-state-in-component-did-update",
37+
"no-set-state-in-component-will-update",
38+
"no-string-refs",
39+
"no-unsafe-component-will-mount",
40+
"no-unsafe-component-will-receive-props",
41+
"no-unsafe-component-will-update",
42+
"no-unstable-context-value",
43+
"no-unstable-default-props",
44+
"no-unused-class-component-members",
45+
"no-unused-state",
46+
"no-use-context",
47+
"no-useless-fragment",
48+
"prefer-destructuring-assignment",
49+
"prefer-react-namespace-import",
50+
"prefer-read-only-props",
51+
"prefer-shorthand-boolean",
52+
"prefer-shorthand-fragment",
53+
"avoid-shorthand-boolean",
54+
"avoid-shorthand-fragment",
55+
"use-jsx-vars",
56+
"---DOM Rules---",
57+
"dom-no-void-elements-with-children",
58+
"dom-no-dangerously-set-innerhtml",
59+
"dom-no-dangerously-set-innerhtml-with-children",
60+
"dom-no-find-dom-node",
61+
"dom-no-missing-button-type",
62+
"dom-no-missing-iframe-sandbox",
63+
"dom-no-namespace",
64+
"dom-no-render-return-value",
65+
"dom-no-script-url",
66+
"dom-no-unknown-property",
67+
"dom-no-unsafe-iframe-sandbox",
68+
"dom-no-unsafe-target-blank",
69+
"---Web API Rules---",
70+
"web-api-no-leaked-event-listener",
71+
"web-api-no-leaked-interval",
72+
"web-api-no-leaked-resize-observer",
73+
"web-api-no-leaked-timeout",
74+
"---Hooks Extra Rules---",
75+
"hooks-extra-no-unnecessary-use-callback",
76+
"hooks-extra-no-unnecessary-use-memo",
77+
"hooks-extra-no-useless-custom-hooks",
78+
"hooks-extra-no-direct-set-state-in-use-effect",
79+
"hooks-extra-no-direct-set-state-in-use-layout-effect",
80+
"hooks-extra-prefer-use-state-lazy-initialization",
81+
"---Naming Convention Rules---",
82+
"naming-convention-component-name",
83+
"naming-convention-filename",
84+
"naming-convention-filename-extension",
85+
"naming-convention-use-state",
86+
"---Debug Rules---",
87+
"debug-class-component",
88+
"debug-function-component",
89+
"debug-hook",
90+
"debug-is-from-react"
91+
]
92+
}

pnpm-lock.yaml

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/update-website.ts

+32-3
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

+1-1
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

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.md
2+
!overview.md

0 commit comments

Comments
 (0)