Skip to content

Commit 2ff2ffb

Browse files
authored
Fix naming-convention/use-state and website build script, closes #1352, #1353 (#1354)
1 parent 284da57 commit 2ff2ffb

File tree

9 files changed

+75
-359
lines changed

9 files changed

+75
-359
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ pnpm run format:write
5757
# Run all checks
5858
pnpm run lint
5959

60-
# Verify rules overview table
61-
pnpm run verify:rules
62-
```
63-
6460
## Development Workflow
6561

6662
### Testing
@@ -87,3 +83,4 @@ pnpm run verify:rules
8783
## Reference
8884
8985
- [Monorepo Structure](https://eslint-react.xyz/docs/contributing#monorepo-structure)
86+
```

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"author": "Rel1cx<[email protected]>",
2727
"type": "module",
2828
"scripts": {
29-
"build": "pnpm run update:version && pnpm run build:pkgs && pnpm run build:packages && pnpm run build:docs",
29+
"build": "pnpm run update:all && pnpm run build:pkgs && pnpm run build:packages && pnpm run build:docs",
3030
"build:docs": "pnpm -r --stream --filter \"./packages/**\" run build:docs",
3131
"build:packages": "pnpm -r --stream --filter \"./packages/**\" run build",
3232
"build:pkgs": "pnpm -r --stream --filter \"./.pkgs/*\" run build",
@@ -47,14 +47,12 @@
4747
"update:all": "pnpm run update:version && pnpm run update:readme && pnpm run update:website",
4848
"update:readme": "tsx ./scripts/update-readme.ts",
4949
"update:version": "tsx ./scripts/update-version.ts",
50-
"update:website": "tsx ./scripts/update-website.ts",
51-
"verify:rules": "tsx ./scripts/verify-rules-overview.ts"
50+
"update:website": "tsx ./scripts/update-website.ts"
5251
},
5352
"devDependencies": {
5453
"@effect/language-service": "^0.62.5",
5554
"@effect/platform": "^0.94.0",
5655
"@effect/platform-node": "^0.104.0",
57-
"@eslint-react/eslint-plugin": "workspace:*",
5856
"@eslint/compat": "^2.0.0",
5957
"@local/configs": "workspace:*",
6058
"@local/function-rules": "workspace:*",

packages/plugins/eslint-plugin-react-naming-convention/src/rules/use-state.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ ruleTester.run(RULE_NAME, rule, {
135135
136136
const [value] = useState(() => expensiveSetup());
137137
`,
138+
tsx`
139+
const [memoisedValue] = React.useState(() => calculateValue());
140+
`,
138141
tsx`
139142
import { useState } from "react";
140143

packages/plugins/eslint-plugin-react-naming-convention/src/rules/use-state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export function create(context: RuleContext<MessageID, Options>): RuleListener {
106106
});
107107
return;
108108
}
109+
// https://github.com/Rel1cx/eslint-react/issues/1352
109110
if (setter == null || !enforceSetterName) {
110111
return;
111112
}

packages/plugins/eslint-plugin/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ This project is and will continue to maintain that 90% of the code is written by
191191

192192
Contributions are welcome!
193193

194-
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/main/.github/CONTRIBUTING.md).
194+
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/fix-website-build-script/.github/CONTRIBUTING.md).
195195

196196
## License
197197

198-
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/main/LICENSE) file for details.
198+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/fix-website-build-script/LICENSE) file for details.

pnpm-lock.yaml

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

scripts/README.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,3 @@ pnpm run update:website
3131
### `verify-lockfile.ts`
3232

3333
Verifies the integrity of the pnpm lockfile.
34-
35-
### `verify-rules-overview.ts`
36-
37-
Verifies that the rules tables in `apps/website/content/docs/rules/overview.mdx` are accurate and up-to-date.
38-
39-
This script:
40-
41-
1. Checks that all rules from each plugin are present in the overview table
42-
2. Verifies that rule metadata (fixable, codemod, experimental, etc.) matches between the rule implementation and the overview table
43-
3. Reports any discrepancies found
44-
45-
```bash
46-
pnpm run verify:rules
47-
```
48-
49-
Run this script:
50-
51-
- After adding a new rule to ensure it's included in the overview
52-
- After modifying rule metadata to ensure the overview is updated
53-
- As part of the CI/CD pipeline to catch inconsistencies
54-
55-
The script will exit with code 0 if all checks pass, or code 1 if any issues are found.

scripts/update-website.ts

Lines changed: 66 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as NodeContext from "@effect/platform-node/NodeContext";
22
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
33
import * as FileSystem from "@effect/platform/FileSystem";
44
import * as Path from "@effect/platform/Path";
5-
import pluginMod from "@eslint-react/eslint-plugin";
65
import ansis from "ansis";
76
import { identity } from "effect";
87
import * as Effect from "effect/Effect";
@@ -103,72 +102,73 @@ function generateRuleMetaJson(metas: RuleMeta[]) {
103102
});
104103
}
105104

105+
// TODO: Not implemented yet
106106
// Process the rules overview file
107-
const processRulesOverview = Effect.gen(function*() {
108-
const fs = yield* FileSystem.FileSystem;
109-
const path = yield* Path.Path;
110-
const targetPath = path.join("apps", "website", "content", "docs", "rules", "overview.mdx");
111-
const markdownTables = [[""], [""], [""], [""], [""], [""]];
112-
for (const doc of glob(DOCS_GLOB)) {
113-
const catename = /^packages\/plugins\/eslint-plugin-react-([^/]+)/u.exec(doc)?.[1] ?? "";
114-
const basename = path.parse(path.basename(doc)).name;
115-
const filename = path.resolve(doc).replace(/\.mdx$/u, ".ts");
116-
const rulename = `${catename}/${basename}`;
117-
const tableIndex = orderedCategories.findIndex((c) => c.key === catename);
118-
const tableLines = markdownTables[tableIndex] ?? [];
119-
const { default: ruleModule, RULE_FEATURES, RULE_NAME } = yield* Effect.tryPromise(() => import(filename));
120-
const description = match(ruleModule)
121-
.with({ meta: { docs: { description: P.select(P.string) } } }, identity)
122-
.otherwise(() => "No description available.");
123-
const isPluginX = catename === "x";
124-
const entryInRecommended = pluginMod
125-
.configs
126-
.recommended
127-
.rules
128-
?.[isPluginX ? `@eslint-react/${RULE_NAME}` : `@eslint-react/${catename}/${RULE_NAME}`];
129-
const entryInStrict = pluginMod
130-
.configs
131-
.strict
132-
.rules
133-
?.[isPluginX ? `@eslint-react/${RULE_NAME}` : `@eslint-react/${catename}/${RULE_NAME}`];
134-
const getSeverity = (entry: unknown): number =>
135-
match(entry)
136-
.with("off", () => 0)
137-
.with("warn", () => 1)
138-
.with("error", () => 2)
139-
.with(P.number, (n) => n)
140-
.with(P.array(), ([s]) => getSeverity(s))
141-
.otherwise(() => 0);
142-
const getSeverityIcon = (severity: number) => {
143-
return match(severity)
144-
.with(0, () => "0️⃣")
145-
.with(1, () => "1️⃣")
146-
.with(2, () => "2️⃣")
147-
.otherwise(() => "0️⃣");
148-
};
149-
const getFeatureIcon = (feature: unknown) => {
150-
return match(feature)
151-
.with("CFG", () => "⚙️")
152-
.with("DBG", () => "🐞")
153-
.with("FIX", () => "🔧")
154-
.with("MOD", () => "🔄")
155-
.with("TSC", () => "💭")
156-
.with("EXP", () => "🧪")
157-
.otherwise(() => "");
158-
};
159-
const severityInRecommended = getSeverity(entryInRecommended);
160-
const severityInStrict = getSeverity(entryInStrict);
161-
tableLines.push(
162-
[
163-
`[${basename}](${catename === "x" ? "" : catename + "-"}${basename})`,
164-
`${getSeverity(entryInRecommended)} ${getSeverity(entryInStrict)}`,
165-
`${RULE_FEATURES.map((f: string) => "`" + getFeatureIcon(f) + "`").join(" ")}`,
166-
].join(" | "),
167-
);
168-
// yield* Effect.log(markdownTables);
169-
// TODO: Not implemented yet.
170-
}
171-
});
107+
// const processRulesOverview = Effect.gen(function*() {
108+
// const fs = yield* FileSystem.FileSystem;
109+
// const path = yield* Path.Path;
110+
// const targetPath = path.join("apps", "website", "content", "docs", "rules", "overview.mdx");
111+
// const markdownTables = [[""], [""], [""], [""], [""], [""]];
112+
// for (const doc of glob(DOCS_GLOB)) {
113+
// const catename = /^packages\/plugins\/eslint-plugin-react-([^/]+)/u.exec(doc)?.[1] ?? "";
114+
// const basename = path.parse(path.basename(doc)).name;
115+
// const filename = path.resolve(doc).replace(/\.mdx$/u, ".ts");
116+
// const rulename = `${catename}/${basename}`;
117+
// const tableIndex = orderedCategories.findIndex((c) => c.key === catename);
118+
// const tableLines = markdownTables[tableIndex] ?? [];
119+
// // TODO: Read rule module directly from pluginMod instead of dynamic import
120+
// const { default: ruleModule, RULE_FEATURES, RULE_NAME } = yield* Effect.tryPromise(() => import(filename));
121+
// const description = match(ruleModule)
122+
// .with({ meta: { docs: { description: P.select(P.string) } } }, identity)
123+
// .otherwise(() => "No description available.");
124+
// const isPluginX = catename === "x";
125+
// const entryInRecommended = pluginMod
126+
// .configs
127+
// .recommended
128+
// .rules
129+
// ?.[isPluginX ? `@eslint-react/${RULE_NAME}` : `@eslint-react/${catename}/${RULE_NAME}`];
130+
// const entryInStrict = pluginMod
131+
// .configs
132+
// .strict
133+
// .rules
134+
// ?.[isPluginX ? `@eslint-react/${RULE_NAME}` : `@eslint-react/${catename}/${RULE_NAME}`];
135+
// const getSeverity = (entry: unknown): number =>
136+
// match(entry)
137+
// .with("off", () => 0)
138+
// .with("warn", () => 1)
139+
// .with("error", () => 2)
140+
// .with(P.number, (n) => n)
141+
// .with(P.array(), ([s]) => getSeverity(s))
142+
// .otherwise(() => 0);
143+
// const getSeverityIcon = (severity: number) => {
144+
// return match(severity)
145+
// .with(0, () => "0️⃣")
146+
// .with(1, () => "1️⃣")
147+
// .with(2, () => "2️⃣")
148+
// .otherwise(() => "0️⃣");
149+
// };
150+
// const getFeatureIcon = (feature: unknown) => {
151+
// return match(feature)
152+
// .with("CFG", () => "⚙️")
153+
// .with("DBG", () => "🐞")
154+
// .with("FIX", () => "🔧")
155+
// .with("MOD", () => "🔄")
156+
// .with("TSC", () => "💭")
157+
// .with("EXP", () => "🧪")
158+
// .otherwise(() => "");
159+
// };
160+
// const severityInRecommended = getSeverity(entryInRecommended);
161+
// const severityInStrict = getSeverity(entryInStrict);
162+
// tableLines.push(
163+
// [
164+
// `[${basename}](${catename === "x" ? "" : catename + "-"}${basename})`,
165+
// `${getSeverity(entryInRecommended)} ${getSeverity(entryInStrict)}`,
166+
// `${RULE_FEATURES.map((f: string) => "`" + getFeatureIcon(f) + "`").join(" ")}`,
167+
// ].join(" | "),
168+
// );
169+
// // yield* Effect.log(markdownTables);
170+
// }
171+
// });
172172

173173
const processChangelog = Effect.gen(function*() {
174174
const fs = yield* FileSystem.FileSystem;
@@ -206,8 +206,6 @@ const program = Effect.gen(function*() {
206206

207207
yield* generateRuleMetaJson(metas);
208208

209-
yield* processRulesOverview;
210-
211209
yield* processChangelog;
212210

213211
yield* Effect.log(ansis.bold.green("Documentation processing completed."));

0 commit comments

Comments
 (0)