← スキル一覧に戻る

javascript-best-practices
by HoangNguyen0403
javascript-best-practicesは、other分野における実用的なスキルです。複雑な課題への対応力を強化し、業務効率と成果の質を改善します。
⭐ 111🍴 40📅 2026年1月23日
SKILL.md
name: JavaScript Best Practices description: Idiomatic JavaScript patterns and conventions for maintainable code. metadata: labels: [javascript, best-practices, conventions, code-quality] triggers: files: ['/*.js', '/*.mjs'] keywords: [module, import, export, error, validation]
JavaScript Best Practices
Priority: P1 (OPERATIONAL)
Conventions and patterns for writing maintainable JavaScript.
Implementation Guidelines
- Naming:
camelCase(vars/funcs),PascalCase(classes),UPPER_SNAKE(constants). - Errors: Throw
Errorobjects only. Handle all async errors. - Comments: JSDoc for APIs. Explain "why" not "what".
- Files: One entity per file.
index.jsfor exports. - 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
スコア
総合スコア
85/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
✓説明文
100文字以上の説明がある
+10
✓人気
GitHub Stars 100以上
+5
✓最近の活動
1ヶ月以内に更新
+10
✓フォーク
10回以上フォークされている
+5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
レビュー
💬
レビュー機能は近日公開予定です

