From 6398adc85333d27758d316716845c332f4a4dc77 Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Thu, 5 Feb 2026 12:48:19 +0000 Subject: [PATCH] docs: strengthen JavaScript style conventions in CLAUDE.md Expand the one-line JS style guideline into explicit rules with examples, covering arrow functions, const/let, template literals, and the inline onclick handler pattern. Prevents future code from being written with function declarations or var. --- CLAUDE.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index dc42010..ac9d94c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -737,7 +737,27 @@ let tasting_notes = decode_json_vec(self.tasting_notes_json, "timeline tasting n 6. **Commit authorship**: Never add "Co-Authored-By" trailers to commit messages 7. **Commit signing**: Never use `--no-gpg-sign` when committing — always allow the default GPG signing 8. **Committing**: Do not commit unless explicitly asked to — provide a draft commit message instead -9. **JavaScript style**: Use ES6+ syntax — `const`/`let`, arrow functions, template literals. Prefer `if`/`else` and `switch` over ternary operators; use ternaries only sparingly for simple, single-level expressions — never nest them +9. **JavaScript style**: + - **Never use `var`** — always `const` (default) or `let` (only when reassignment is needed) + - **Never use `function` declarations** — always arrow functions assigned to `const`: + ```js + // Good + const showForm = () => { ... }; + const handleClick = (evt) => { ... }; + + // Bad + function showForm() { ... } + ``` + - **Always use template literals** for string interpolation — never `+` concatenation: + ```js + // Good + `Failed (HTTP ${response.status}).` + + // Bad + 'Failed (HTTP ' + response.status + ').' + ``` + - Prefer `if`/`else` and `switch` over ternary operators; use ternaries only sparingly for simple, single-level expressions — never nest them + - **Inline `onclick` handlers + global arrow functions** — pages with imperative JS (e.g. account, checkin) define `const` arrow functions at `