生成符合项目规范的 React 组件。当用户要求创建组件、新建 React 组件或生成组件文件时使用
89%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
项目使用以下约定:
确认组件信息
创建文件结构
src/components/{ComponentName}/
├── index.tsx
├── {ComponentName}.module.css
└── {ComponentName}.test.tsx生成组件文件
index.tsx 模板:
import React from 'react';
import styles from './{ComponentName}.module.css';
interface {ComponentName}Props {
// 定义 props 类型
}
/**
* {组件描述}
* @param props - 组件属性
*/
export const {ComponentName}: React.FC<{ComponentName}Props> = (props) => {
return (
<div className={styles.container}>
{/* 组件内容 */}
</div>
);
};{ComponentName}.module.css 模板:
.container {
/* 组件样式 */
}{ComponentName}.test.tsx 模板:
import { render, screen } from '@testing-library/react';
import { {ComponentName} } from './index';
describe('{ComponentName}', () => {
it('renders correctly', () => {
render(<{ComponentName} />);
// 添加断言
});
});生成后自动运行:
npm run type-checknpm run lintnpm test -- {ComponentName}如有错误,显示错误信息并提供修复建议。
einverne/dotfiles
411968f
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.