plugins/languages/javascript/skills/core/SKILL.md
JavaScript/TypeScript 核心开发规范:ES2025-2026语法标准、ESM模块系统、const/let变量声明、命名约定、Vite 6构建工具、ESLint 9 flat config代码检查。编写JS/TS代码、创建项目、配置构建工具链时加载。
npx skillsauth add lazygophers/ccplugin plugins/languages/javascript/skills/coreInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| Agent | 说明 | | ----- | ---- | | dev | JavaScript 开发专家 | | debug | JavaScript 调试专家 | | test | JavaScript 测试专家 | | perf | JavaScript 性能优化专家 |
| 场景 | Skill | 说明 | |------|-------|------| | 异步编程 | Skills(javascript:async) | async/await、Promise、AbortController | | React 开发 | Skills(javascript:react) | React 19、Server Components、Next.js 15 | | Vue 开发 | Skills(javascript:vue) | Vue 3.5、Composition API、Nuxt 4 | | Web 安全 | Skills(javascript:security) | XSS 防护、CSP、Zod 验证 |
JavaScript 生态追求高性能、组件化、ESM 原生、运行时验证。
import/export,"type": "module"varrequire / module.exports)console.log(使用结构化日志)innerHTML 直接设置用户输入(XSS 漏洞).toSorted(), .toReversed())// Object.groupBy / Map.groupBy
const grouped = Object.groupBy(users, u => u.role);
// 非变异数组方法
const sorted = arr.toSorted((a, b) => a - b);
const reversed = arr.toReversed();
const updated = arr.with(0, 'new');
// Promise.withResolvers
const { promise, resolve, reject } = Promise.withResolvers();
// Array.fromAsync
const items = await Array.fromAsync(asyncIterable);
// Set 方法
const union = setA.union(setB);
const intersection = setA.intersection(setB);
const difference = setA.difference(setB);
// ES2026: 显式资源管理(using / await using)
{
using file = openFile("data.txt"); // 块结束时自动 dispose
// file[Symbol.dispose]() 自动调用
}
{
await using db = await connectDB(); // 异步资源自动清理
// db[Symbol.asyncDispose]() 自动调用
}
// camelCase: 变量、函数
const getUserData = async (userId) => { };
const isActive = true;
// UPPER_SNAKE_CASE: 模块级常量
const MAX_RETRIES = 3;
const API_TIMEOUT = 5000;
// PascalCase: 类、组件
class UserManager { }
function UserCard({ user }) { }
// kebab-case: 文件名
// user-service.js, api-client.js
// eslint.config.js
import js from '@eslint/js';
export default [
js.configs.recommended,
{
files: ['src/**/*.js', 'src/**/*.jsx'],
rules: {
'no-var': 'error',
'prefer-const': 'error',
'no-console': ['warn', { allow: ['warn', 'error'] }],
'prefer-arrow-callback': 'error',
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
}
}
];
src/
├── features/
│ ├── auth/
│ │ ├── hooks/
│ │ ├── services/
│ │ └── components/
│ └── shared/
├── config/
├── store/
└── main.js
| 现象 | 问题 | 严重程度 |
|------|------|---------|
| 使用 var | 作用域不清晰,禁止使用 | 高 |
| require() | 应使用 ESM import | 高 |
| arr.sort() | 变异原数组,应使用 .toSorted() | 中 |
| .eslintrc.js | 旧版配置,应迁移到 flat config | 中 |
| npm install | 应使用 pnpm | 中 |
| Jest 配置 | 应迁移到 Vitest 3.x | 中 |
| Webpack | 应迁移到 Vite 6 | 中 |
| moment.js | 应使用 date-fns 或 Temporal API | 低 |
"type": "module"development
Go 数据库规范——GORM Model 命名 ModelXxx、表名单数、枚举 uint8 + 常量、索引 idx_ 前缀 + deleted_at leading column、禁 time.Time 统一 int64 unix、禁指针/nullable 字段、TEXT/BLOB/JSON 禁 default、AutoMigrate 禁改主键。设计 DB model、写 GORM tag、建索引、做 migration 审查时触发。
development
Go HTTP API 规范——响应始终 200 + body code 字段、路由 /api/* 全 POST 单段 <Action><Model>、中间件逐路由注册禁 Group(prefix,mw...)、handler 仅返回 (rsp,error)、认证走 header。设计 HTTP API、写路由/handler/中间件时触发。
development
Go 项目结构规范——三层架构(API → Impl → State)、全局状态模式、internal/ 私有包、cmd/ 仅 main.go、go.work 多模块、禁止 Repository 接口和 DI 容器、struct 公共字段开头全 omitempty、handler var rsp 顶声明、禁 legacy migration。设计项目骨架、新建目录、组织包、做架构评审时触发。
development
Go 命名规范——Id/Uid 字段(非 ID)、IsActive/HasMFA 布尔前缀、CreatedAt 时间字段、接收者统一用 p、包名全小写无下划线、泛型类型参数描述性命名、集合字段 xxx_list 禁 xxxs 复数、Enum 0 值 XxxNil 禁 Unknown、禁 Status 统一 State、Set/Update 语义区分。定义结构体字段、函数、变量、包、接收者名、泛型、枚举时触发。