CUS Developer 共享配置文件包。
用于团队或个人在多个项目中统一和复用开发相关配置文件(如 ESLint、Prettier、EditorConfig、VSCode、Cursor、Git、npm、Commitlint、TypeScript 等)。
npm install --save-dev @cus-developer/config
#或者
pnpm install -D github:dayney/cus-config#v0.0.7
在项目根目录下packjson.json 的scripts
中添加:
"postinstall": "node node_modules/@cus-developer/config/scripts/setup.cjs"
然后使用npm install
安装完了项目所有的依赖之后,会自动运行 npm run postinstall
命令即可一键同步配置到项目。
该命令会自动将本库中的所有配置文件和目录(如 .editorconfig、.prettierrc.yaml、.prettierignore、.gitignore、eslint.config.js、eslint.config.mjs、commitlint.config.js、.npmrc、.cursor、.vscode、cursor-rules.json、tsconfig.json 等)复制到你的项目根目录。
本项目支持开发、测试和生产三个环境的配置。
每个环境都有对应的环境变量配置文件:
.env.development
- 开发环境配置.env.test
- 测试环境配置.env.production
- 生产环境配置
针对不同环境的 TypeScript 配置:
tsconfig.json
- 基础配置tsconfig.test.json
- 测试环境配置tsconfig.prod.json
- 生产环境配置
ESLint 配置会根据当前环境自动切换规则:
- 开发环境:允许使用
console
,关闭debugger
检查 - 测试环境:允许使用
console
,关闭未使用变量检查 - 生产环境:禁止使用
console
,启用所有严格检查
# 开发环境
npm run dev
# 测试环境构建
npm run build:test
# 生产环境构建
npm run build:prod
# 预览构建结果
npm run preview
# 运行 ESLint 检查并自动修复
npm run lint
# 使用 Prettier 格式化代码
npm run format
- ESLint:
eslint.config.js
、eslint.config.mjs
- Prettier:
.prettierrc.yaml
、.prettierignore
- EditorConfig:
.editorconfig
- VS Code:
.vscode/
目录下所有配置 - Cursor:
.cursor/
目录下所有配置 - Commitlint:
commitlint.config.js
- Git:
.gitignore
- npm:
.npmrc
- TypeScript:
tsconfig.json
- 自定义规则:
cursor-rules.json
当本库有新版本时,在你的项目中运行:
npm update @cus-developer/config
npm run postinstall
即可同步最新的配置。
- Fork 本仓库
- 创建特性分支
- 提交更改
- 推送到分支
- 创建 Pull Request
MIT
这是一个可复用的项目配置模板,包含了常用的开发工具配置。
-
编辑器配置
- Cursor 编辑器配置
- VSCode 配置
- EditorConfig 配置
-
代码质量工具
- ESLint 配置
- Prettier 配置
- CommitLint 配置
-
其他配置
- NPM 配置
- Git 配置
- 克隆此仓库
- 运行安装脚本:
node scripts/setup.js
autocomplete-rules.json
: 自动完成规则component-rules.md
: 组件开发规范custom-prompts.json
: 自定义提示project-description.md
: 项目描述settings.json
: 编辑器设置snippets.json
: 代码片段
cursor.json
: Cursor 集成配置extensions.json
: 推荐扩展launch.json
: 调试配置settings.json
: 编辑器设置
eslint.config.mjs
: ESLint 规则配置
prettierrc.yaml
: 格式化规则prettierignore
: 忽略文件
.editorconfig
: 编辑器通用配置.npmrc
: NPM 配置.gitignore
: Git 忽略文件commitlint.config.js
: 提交信息规范