Reviewer · Code Style
Consistent code organization
Keep modules organized, non-repetitive, and consistent with existing conventions in the file. Specifically: 1. **Eliminate duplication** — if the same logic (e.g., building a lookup map) appears more than once, extract it into a small named helper function rather than copy-pasting it.
Keep modules organized, non-repetitive, and consistent with existing conventions in the file. Specifically:
-
Eliminate duplication — if the same logic (e.g., building a lookup map) appears more than once, extract it into a small named helper function rather than copy-pasting it.
-
Split unwieldy modules — when a single file or style/definition block grows too large (e.g., one giant CSS-in-JS object covering many unrelated UI parts), break it into smaller, purpose-specific files or modules. Group by logical concern (e.g., one module per component part: blocks, headings, lists, links, tables) so each file is easy to scan and reason about.
-
Prefer lookup tables over repetitive branching — when a switch/if-else has many cases that only differ by a static value, replace the repeated cases with a static lookup table (e.g.,
STATIC_HANDLES) and keep the switch/conditional only for the few cases that genuinely require computed logic. -
Follow established naming/typing patterns — if the file already defines named prop interfaces (e.g.,
FooProps) for components, don’t deviate by inlining prop types for new components. Match the convention:
// Instead of inline typing:
function ScenarioRow({ scenario }: { scenario: IdentityScenarioResult }) { ... }
// Match existing convention:
interface ScenarioRowProps {
scenario: IdentityScenarioResult;
}
function ScenarioRow({ scenario }: ScenarioRowProps) { ... }
Applying these practices keeps files readable, reduces maintenance overhead, and ensures the codebase feels uniform even as multiple contributors add new code.</description>