Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(claude): comment style rules
Elian Doran5a5fa9f7e2ba
diff --git a/CLAUDE.md b/CLAUDE.mdindex 6538e0e0b8..1dc44c4dad 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -344,6 +344,8 @@ Use `note.getOwnedAttribute()` for direct, `note.getAttribute()` for inherited.- Import sorting via `eslint-plugin-simple-import-sort`- **Never use the TypeScript non-null assertion operator (postfix `!`)** — including in tests. Narrow instead: optional chaining (`?.`), a `?? fallback`, an explicit null check before use, or an `*OrThrow` accessor (e.g. `becca.getNoteOrThrow(id)` rather than `becca.getNote(id)!`).- **Helper placement** — when extracting a standalone helper function from a component, widget, hook, or route, place it **below** the primary export it supports (or in a separate module), not wedged between the imports and the main definition. Keep the file's primary export near the top so the entry point reads first; supporting helpers follow it.+- **Comments** — Google developer documentation style: plain English, present tense, active voice, naming the real identifiers involved (`froca.getNote()`, not "the cache lookup"). Use *can* (ability), *might* (possibility) and *must* (requirement) precisely; never *may*, which is ambiguous between the two. Say what the code does or why it is shaped that way — not what it used to do or what changed.+- **CSS comments** — do not narrate the change in a comment (`/* moved from the toolbar */`, `/* was 8px, bumped for the new layout */`). That belongs in the commit message. A CSS comment earns its place only when the rule is non-obvious on its own — a workaround for a browser bug, a value that must match one defined elsewhere, a `z-index` in a stacking contract.- **No ~10-SLOC modules** — do not give a component, hook, or helper a file of its own when it amounts to about ten lines of substance. A file that exists to hold one small thing costs a module boundary, an import at every call site, and a second place to look, and buys nothing. Add it to an existing module instead — preferably one it is already built from, or that owns the same concept, so the group of related things stays discoverable from a single import. Example: `OverlayFullscreenButton` is a preset `OverlayControlButton`, so it lives in `apps/client/src/widgets/react/OverlayControlGroup.tsx` beside the group and button it composes, not in a file of its own — and its tests live in that module's spec for the same reason. Split a module out once it has grown enough substance to stand alone.## Testing