name: format-js description: Format JavaScript/TypeScript code with Prettier
JavaScript/TypeScript Format Skill
๐ Overview
Use Prettier to automatically format JavaScript and TypeScript code:
- ๐จ Consistent style: Unified formatting across multiple file types
- โก Fast execution: Millisecond-level formatting speed
- ๐ง Out of the box: Reasonable default configuration
- ๐ Wide support: JS, TS, JSX, TSX, JSON, CSS, etc.
๐ง Prerequisites
| Tool | Min Version | Check Command | Installation |
|---|---|---|---|
| Node.js | 16+ | node --version |
nodejs.org |
| Prettier | 2.8+ | prettier --version |
npm install -g prettier |
๐ Usage
Method 1: AI Assistant
"Use format-js to format my JavaScript code"
Method 2: Run Script Directly
# Windows
.\.agent\skills\format-js\scripts\format.ps1
# Linux/Mac
./.agent/skills/format-js/scripts/format.sh
Method 3: With Parameters
# Check without modifying
.\.agent\skills\format-js\scripts\format.ps1 -Check
# Format specific file types
.\.agent\skills\format-js\scripts\format.ps1 -Extensions "js,ts,jsx,tsx"
๐ฏ What It Formats
- โ Indentation and spacing
- โ Quote unification (single/double)
- โ Line length limits
- โ Semicolon add/remove
- โ Bracket and comma normalization
- โ Arrow function formatting
โ๏ธ Configuration
// .prettierrc
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 80,
"arrowParens": "avoid"
}