Reviewer · Code Style
Readable, positive code structure
Write code that is easy to scan and reason about by favoring clarity over cleverness or terseness: - **Prefer positive conditions over negative ones.** Instead of filtering out what you don't want, filter for what you do want, e.g. use `engine.mountType.includes('auth')` rather than `engine.mountType !== 'secret'`.
Write code that is easy to scan and reason about by favoring clarity over cleverness or terseness:
- Prefer positive conditions over negative ones. Instead of filtering out what you don’t want, filter for what you do want, e.g. use
engine.mountType.includes('auth')rather thanengine.mountType !== 'secret'. - Use explicit, self-documenting parameters. When a function has defaults, name them in the call so intent is clear to the reader, e.g.
filterEnginesByMountType({ mountType = 'auth', includeEnterprise = false })instead of a positionalfilterEnginesByMountType('auth'). - Avoid superfluous code that frameworks/tools already provide by convention. Don’t add boilerplate (like an explicit index route) just to “show” something exists if the underlying tool already documents and handles it implicitly—this only adds noise and makes files harder to parse.
- Keep control flow simple and consistent with existing patterns. When extending conditionals, prefer a plain
if/elseover stackingelse ifbranches when the branches are mutually exclusive, and stay conservative/consistent with the original logic structure already established in the codebase unless there’s a clear reason to diverge. - Organize code in a logical, discoverable order. Group related routes/config/options together and order them to mirror how they’re navigated or used elsewhere (e.g., matching sidebar nav order), making it easier for future readers to locate related logic.
Example:
// Prefer
ALL_ENGINES.filter((engine) => engine.mountType.includes('auth') && !engine.requiresEnterprise);
// Over
ALL_ENGINES.filter((engine) => engine.mountType !== 'secret' && !engine.requiresEnterprise);