Skillshub JavaScript Best Practices
Idiomatic JavaScript patterns and conventions for maintainable code.
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/best-practices" ~/.claude/skills/comeonoliver-skillshub-javascript-best-practices && rm -rf "$T"
manifest:
skills/HoangNguyen0403/agent-skills-standard/best-practices/SKILL.mdsource content
JavaScript Best Practices
Priority: P1 (OPERATIONAL)
Conventions and patterns for writing maintainable JavaScript.
Implementation Guidelines
- Naming:
(vars/funcs),camelCase
(classes),PascalCase
(constants).UPPER_SNAKE - Errors: Throw
objects only. Handle all async errors.Error - Comments: JSDoc for APIs. Explain "why" not "what".
- Files: One entity per file.
for exports.index.js - Modules: Named exports only. Order: Ext -> Int -> Rel.
Anti-Patterns
- No Globals: Encapsulate state.
- No Magic Numbers: Use
.const - No Nesting: Guard clauses/early returns.
- No Defaults: Use named exports.
- No Side Effects: Keep functions pure.
Code
// Constants const STATUS = { OK: 200, ERROR: 500 }; // Errors class APIError extends Error { constructor(msg, code) { super(msg); this.code = code; } } // Async + JDoc /** @throws {APIError} */ export async function getData(id) { if (!id) throw new APIError('Missing ID', 400); const res = await fetch(`/api/${id}`); if (!res.ok) throw new APIError('Failed', res.status); return res.json(); }
Reference & Examples
For module patterns and project structure: See references/REFERENCE.md.
Related Topics
language | tooling