You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flag JSX return statements >50 lines or those with multiple conditional branches (3+ `{condition && <...>}` or ternary operators). Simple single-element returns or small layout wrappers are exempt.
125
+
Flag JSX return statements >25 lines or those with multiple conditional branches (3+ `{condition && <...>}` or ternary operators). Simple single-element returns or small layout wrappers are exempt.
2.**Repeated patterns:** Similar button/input groups with duplicated props (e.g., `role="tab"`, `aria-selected`, `onClick`) → extract into component.
226
237
3.**Multiple state sections:** Component with separate state for tabs/panels (e.g., `const [tab, setTab]` and `const [panel, setPanel]`) often signals multiple concerns.
2. If missing, flag if component has: hooks, event handlers, or conditional logic.
296
307
3. If tests exist, verify they assert on behavior (not just render existence).
297
308
298
-
## Large JSX/TSX blocks should be extracted into separate components
299
-
300
-
**Urgency:** suggestion
301
-
302
-
### Category
303
-
304
-
Maintainability
305
-
306
-
### Confidence Threshold
307
-
308
-
Flag JSX return statements >25 lines or those with multiple conditional branches (3+ `{condition && <...>}` or ternary operators). Simple single-element returns or small layout wrappers are exempt.
309
-
310
-
### Exceptions / False Positives
311
-
312
-
- Do not flag simple, single-element returns or small layout wrappers.
313
-
- Do not flag when extraction would require excessive prop-drilling that makes code less readable.
314
-
315
-
### Description
316
-
317
-
Large JSX blocks reduce readability, increase cognitive load, and make testing harder. Red flags: multiple conditional rendering branches, repeated patterns (like tab buttons with similar structure), deeply nested element hierarchies, and components managing multiple independent concerns.
318
-
319
-
### Anti-patterns to Flag
320
-
321
-
```tsx
322
-
// ❌ Return block with multiple conditional branches and repeated patterns
2.**Repeated patterns:** Similar button/input groups with duplicated props (e.g., `role="tab"`, `aria-selected`, `onClick`) → extract into component.
420
-
3.**Multiple state sections:** Component with separate state for tabs/panels (e.g., `const [tab, setTab]` and `const [panel, setPanel]`) often signals multiple concerns.
0 commit comments