JavaScript Pro
Core Workflow
- Analyze requirements - Review package.json, module system, Node version
- Design architecture - Plan modules, async flows, error handling
- Implement - Write ES2023+ code with proper patterns
- Validate - Run linter, check for memory leaks
- Test - Write comprehensive tests with 85%+ coverage
Key Patterns
Async/Await Error Handling
async function fetchUser(id) {
try {
const response = await fetch(`/api/users/${id}`);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return await response.json();
} catch (err) {
console.error("fetchUser failed:", err);
return null;
}
}
Optional Chaining & Nullish Coalescing
const city = user?.address?.city ?? "Unknown";
ESM Module Structure
// utils/math.mjs
export const add = (a, b) => a + b;
export const multiply = (a, b) => a * b;
// consumer.mjs
import { add } from "./utils/math.mjs";
Constraints
MUST DO
- Use ES2023+ features exclusively
- Use optional chaining (
?.) and nullish coalescing (??)
- Use async/await for all asynchronous operations
- Use ESM (
import/export) for new projects
- Implement proper error handling with try/catch
MUST NOT DO
- Use
var (always use const or let)
- Use callback-based patterns (prefer Promises)
- Mix CommonJS and ESM in the same module
- Skip error handling in async functions
- Use synchronous I/O in Node.js
Knowledge Reference
ES2023+, async/await, Promises, ESM/CJS, Web Workers, Fetch API, Node.js streams, Event Loop, memory management
1---2name: javascript-pro3description: Writes, debugs, and refactors JavaScript code using modern ES2023+ features, async/await patterns, ESM module systems, and Node.js APIs.4license: MIT5compatibility: opencode6metadata:7 source: https://skillmd.com/skills/belentani7/javascript-pro8 author: open-source9 version: "1.1.0"10 domain: language11 triggers: JavaScript, ES2023, async await, Node.js, vanilla JavaScript, Web Workers, Fetch API, browser API, module system12 role: specialist13 scope: implementation14 output-format: code15 related-skills: typescript-pro, fullstack-guardian16---1718# JavaScript Pro1920## Core Workflow21221. **Analyze requirements** - Review package.json, module system, Node version232. **Design architecture** - Plan modules, async flows, error handling243. **Implement** - Write ES2023+ code with proper patterns254. **Validate** - Run linter, check for memory leaks265. **Test** - Write comprehensive tests with 85%+ coverage2728## Key Patterns2930### Async/Await Error Handling31```js32async function fetchUser(id) {33 try {34 const response = await fetch(`/api/users/${id}`);35 if (!response.ok) throw new Error(`HTTP ${response.status}`);36 return await response.json();37 } catch (err) {38 console.error("fetchUser failed:", err);39 return null;40 }41}42```4344### Optional Chaining & Nullish Coalescing45```js46const city = user?.address?.city ?? "Unknown";47```4849### ESM Module Structure50```js51// utils/math.mjs52export const add = (a, b) => a + b;53export const multiply = (a, b) => a * b;5455// consumer.mjs56import { add } from "./utils/math.mjs";57```5859## Constraints6061### MUST DO62- Use ES2023+ features exclusively63- Use optional chaining (`?.`) and nullish coalescing (`??`)64- Use async/await for all asynchronous operations65- Use ESM (`import`/`export`) for new projects66- Implement proper error handling with try/catch6768### MUST NOT DO69- Use `var` (always use `const` or `let`)70- Use callback-based patterns (prefer Promises)71- Mix CommonJS and ESM in the same module72- Skip error handling in async functions73- Use synchronous I/O in Node.js7475## Knowledge Reference7677ES2023+, async/await, Promises, ESM/CJS, Web Workers, Fetch API, Node.js streams, Event Loop, memory management