Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add DonggangChen/antigravity-agentic-skills --skill "code_formatter"
Install specific skill from multi-skill repository
# Description
Automated code formatting, Prettier/ESLint integration and code style consistency guide.
# SKILL.md
name: code_formatter
router_kit: FullStackKit
description: Automated code formatting, Prettier/ESLint integration and code style consistency guide.
metadata:
skillport:
category: development
tags: [big data, cleaning, code formatter, csv, data analysis, data engineering, data science, database, etl pipelines, export, import, json, machine learning basics, migration, nosql, numpy, pandas, python data stack, query optimization, reporting, schema design, sql, statistics, transformation, visualization] - code-style
π¨ Code Formatter
Automated code formatting and style consistency guide.
π Prettier Configuration
.prettierrc
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 80,
"bracketSpacing": true,
"arrowParens": "avoid",
"endOfLine": "lf"
}
Commands
# Format single file
npx prettier --write src/file.ts
# Format all files
npx prettier --write "src/**/*.{ts,tsx,js,jsx,json,css,md}"
# Check without writing
npx prettier --check "src/**/*"
π§ ESLint Integration
.eslintrc.js
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'prettier', // Disables Prettier conflicts
],
plugins: ['@typescript-eslint', 'react'],
rules: {
'no-console': 'warn',
'no-unused-vars': 'error',
},
};
Commands
# Lint
npx eslint src/
# Lint and fix
npx eslint src/ --fix
# Specific files
npx eslint "src/**/*.{ts,tsx}"
π Git Hooks (Husky + lint-staged)
package.json
{
"lint-staged": {
"*.{ts,tsx,js,jsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,css,md}": [
"prettier --write"
]
}
}
Setup
npx husky-init && npm install
npx husky add .husky/pre-commit "npx lint-staged"
π Ignore Files
.prettierignore
node_modules/
dist/
build/
.next/
coverage/
*.min.js
.eslintignore
node_modules/
dist/
build/
*.config.js
Code Formatter v1.1 - Enhanced
π Workflow
Source: Prettier Docs
Phase 1: Installation
- [ ] Packages: Install
prettier,eslintand relevant plugins. - [ ] Config: Add
.prettierrcand.eslintrcfiles to root directory. - [ ] Ignore: Add
build/,dist/to.prettierignorefile.
Phase 2: Automation
- [ ] Scripts: Add
formatandlintscripts topackage.json. - [ ] VS Code: Enable "Format on Save" in
.vscode/settings.json. - [ ] Hooks: Add pre-commit check with Husky and lint-staged.
Phase 3: CI Integration
- [ ] Pipeline: Add
npm run lintandprettier --checksteps to CI process.
Checkpoints
| Phase | Verification |
|---|---|
| 1 | Do files change when npm run format runs? |
| 2 | Does Husky prevent commit when there is incorrect code? |
| 3 | Does CI pipeline fail when there is a format error? |
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.