Skip to content
Back to skills

Javascript Best Practices

ASecurity

Common anti-patterns to avoid in JavaScript include: - Throwing strings or arbitrary values. Throw an `Error` object, and make sure every async operation has deliberate rejection handling. - Defining mutable state on the global object. Keep state inside a module or function instead. - Scattering magic numbers through business logic. Give them descriptive names, such as `const REQUEST_TIMEOUT_MS = 5000`. - Deeply nested conditionals. Validate invalid input early and return or throw before the ...

  • 584 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 5, 2026
developmentjavascriptjavaapi

Works with

  • api

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill javascript-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Javascript Best Practices?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Javascript Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-javascript-best-practices-83724eb8/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-javascript-best-practices-83724eb8)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md

Common anti-patterns to avoid in JavaScript include:

- Throwing strings or arbitrary values. Throw an `Error` object, and make sure every async operation has deliberate rejection handling.
- Defining mutable state on the global object. Keep state inside a module or function instead.
- Scattering magic numbers through business logic. Give them descriptive names, such as `const REQUEST_TIMEOUT_MS = 5000`.
- Deeply nested conditionals. Validate invalid input early and return or throw before the main path.
- Default exports and files that mix unrelated responsibilities. Keep one entity per file and expose the public surface through named exports from `index.js`.
- Functions that mutate shared data or perform surprising I/O. Prefer pure functions and make side effects explicit at the boundary.

Also keep imports organized as external, internal, and relative dependencies. Use `camelCase` for variables/functions, `PascalCase` for classes, and `UPPER_SNAKE` for constants; document public APIs with JSDoc that explains why unusual choices exist.

Files in this skill

  • eval-1.baseline.md815 B
  • eval-1.with-skill.md1.3 KB
  • eval-2.baseline.md988 B
  • eval-2.with-skill.md1 KB
  • eval-3.baseline.md865 B
  • eval-3.with-skill.md1.1 KB
  • trigger-1.md149 B
  • trigger-2.md119 B
  • trigger-3.md111 B
  • trigger-4.md109 B
  • trigger-5.md99 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.