@agjs/tsforge 0.1.17 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -139,6 +139,21 @@ const RULE_DOCS: Record<string, IRuleDoc> = {
|
|
|
139
139
|
bad: "items.map((it, i) => <li key={i}>{it.text}</li>)",
|
|
140
140
|
good: "items.map((it) => <li key={it.id}>{it.text}</li>)",
|
|
141
141
|
},
|
|
142
|
+
"tsforge/no-jsx-computation": {
|
|
143
|
+
what: "No `.map()`/`.filter()`/arithmetic/chained logic inside JSX `{…}` — extract to a hook or pre-prep variable first.",
|
|
144
|
+
bad: "<ul>{items.filter((i) => i.visible).map((i) => <li key={i.id}>{i.label}</li>)}</ul>",
|
|
145
|
+
good: "const rows = useMemo(() => items.filter(...).map(...), [items]); return <ul>{rows}</ul>;",
|
|
146
|
+
},
|
|
147
|
+
"tsforge/no-state-in-component-body": {
|
|
148
|
+
what: "State hooks (`useState`, `useEffect`, `useMemo`, …) belong in `Component.hooks.ts`, not in the `.tsx` component body.",
|
|
149
|
+
bad: "export function Button() { const [open, setOpen] = useState(false); return <button />; }",
|
|
150
|
+
good: "export function useButton() { const [open, setOpen] = useState(false); return { open }; }",
|
|
151
|
+
},
|
|
152
|
+
"tsforge/no-inline-jsx-functions": {
|
|
153
|
+
what: "No inline arrow/function expressions in JSX attributes — bind handlers in the hook and pass a reference.",
|
|
154
|
+
bad: "<button onClick={() => doThing(id)} />",
|
|
155
|
+
good: "const onClickRow = useCallback(() => doThing(id), [id]); <button onClick={onClickRow} />",
|
|
156
|
+
},
|
|
142
157
|
};
|
|
143
158
|
|
|
144
159
|
/**
|