ts-starter
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTypeScript Starter
TypeScript 项目初始化配置
Automatically configure linting, formatting, testing, and compiler defaults for TypeScript projects.
自动为TypeScript项目配置代码检查、格式化、测试及编译器默认设置。
Workflow
工作流程
-
Detect package manager
- Prefer when no lockfile exists.
pnpm - If lockfile exists, keep the existing manager.
- Detection order:
- ->
pnpm-lock.yamlpnpm - ->
package-lock.jsonnpm - ->
yarn.lockyarn - or
bun.lock->bun.lockbbun
- Ask the user only when detection is ambiguous.
- Prefer
-
Detect project kind
- Classify as ,
frontend, ornode-app.library - Use existing files (, framework deps, publish fields, entry points) for detection.
vite.config.* - Ask the user when the project kind is unclear.
- Classify as
-
Install baseline dependencies
- Install as dev dependencies: ,
typescript,@types/node,@biomejs/biome.vitest - Use package-manager-specific commands from references/environment-setup.md.
- Install as dev dependencies:
-
Apply TypeScript configuration
- Create or update with strict-and-safety defaults.
tsconfig.json - Keep ESM defaults.
- Preserve existing options whenever possible and patch only missing required fields.
- Reference: references/config-examples.md
- Template: assets/tsconfig.json.template
- Create or update
-
Apply Biome configuration
- Create or update .
biome.json - Add ,
lint, andlint:fixscripts informatif missing.package.json - Keep existing scripts and merge safely.
- Reference: references/config-examples.md
- Template: assets/biome.json.template
- Create or update
-
Apply Vitest configuration
- Create or update and test scripts.
vitest.config.ts - Use Vitest as the default runner for all project kinds in this skill version.
- Reference: references/config-examples.md
- Template: assets/vitest.config.ts.template
- Create or update
-
Optional VSCode settings
- Ask whether to add .
.vscode/settings.json - Reference: references/vscode-settings.md
- Template: assets/.vscode-settings.json.template
- Ask whether to add
-
Optional Git hooks
- Ask whether to set up Husky + lint-staged.
- Configure pre-commit for lint and typecheck (test optional).
- Reference: references/git-hooks-setup.md
- Template: assets/.husky-pre-commit.template
-
Update ignore rules
- Create or patch for common TypeScript/Node artifacts.
.gitignore - Template: assets/.gitignore.template
- Create or patch
-
Run smoke validation
- Run ,
typecheck, andlintonce after setup.test - Keep commands package-manager-specific.
-
检测包管理器
- 当不存在锁文件时,优先使用。
pnpm - 若存在锁文件,则保留现有管理器。
- 检测顺序:
- →
pnpm-lock.yamlpnpm - →
package-lock.jsonnpm - →
yarn.lockyarn - 或
bun.lock→bun.lockbbun
- 仅当检测结果不明确时,才询问用户。
- 当不存在锁文件时,优先使用
-
检测项目类型
- 分类为、
frontend或node-app。library - 利用现有文件(、框架依赖、发布字段、入口文件)进行检测。
vite.config.* - 当项目类型不明确时,询问用户。
- 分类为
-
安装基础依赖
- 安装开发依赖:、
typescript、@types/node、@biomejs/biome。vitest - 使用references/environment-setup.md中包管理器专属的命令。
- 安装开发依赖:
-
应用TypeScript配置
- 创建或更新,启用严格安全的默认设置。
tsconfig.json - 保留ESM默认配置。
- 尽可能保留现有配置项,仅补充缺失的必填字段。
- 参考文档:references/config-examples.md
- 模板:assets/tsconfig.json.template
- 创建或更新
-
应用Biome配置
- 创建或更新。
biome.json - 若中缺少
package.json、lint和lint:fix脚本,则添加这些脚本。format - 保留现有脚本并安全合并。
- 参考文档:references/config-examples.md
- 模板:assets/biome.json.template
- 创建或更新
-
应用Vitest配置
- 创建或更新及测试脚本。
vitest.config.ts - 在当前版本的工具中,所有类型的项目默认使用Vitest作为测试运行器。
- 参考文档:references/config-examples.md
- 模板:assets/vitest.config.ts.template
- 创建或更新
-
可选VSCode设置
- 询问是否添加。
.vscode/settings.json - 参考文档:references/vscode-settings.md
- 模板:assets/.vscode-settings.json.template
- 询问是否添加
-
可选Git钩子
- 询问是否设置Husky + lint-staged。
- 配置pre-commit钩子用于代码检查和类型校验(测试为可选)。
- 参考文档:references/git-hooks-setup.md
- 模板:assets/.husky-pre-commit.template
-
更新忽略规则
- 创建或修补,添加TypeScript/Node项目的常见产物忽略规则。
.gitignore - 模板:assets/.gitignore.template
- 创建或修补
-
运行冒烟验证
- 完成设置后,运行一次、
typecheck和lint命令。test - 使用与包管理器对应的命令。
- 完成设置后,运行一次
Principles
设计原则
- Config-only: Do not scaffold framework applications by default.
- Command-first: Prefer commands over manual editing when possible.
- Idempotent updates: Re-running setup must not duplicate scripts or corrupt config.
- Preserve existing intent: Merge with current project configuration and patch only required pieces.
- 仅配置不搭建:默认不搭建框架应用。
- 优先命令行:尽可能使用命令行而非手动编辑。
- 幂等更新:重复运行设置不会导致脚本重复或配置损坏。
- 保留现有配置意图:与当前项目配置合并,仅修补必填部分。
Internal Contracts
内部约定
- :
project_kindfrontend | node-app | library - :
package_managerpnpm | npm | yarn | bun
- :
project_kindfrontend | node-app | library - :
package_managerpnpm | npm | yarn | bun
References
参考文档
- Environment setup: references/environment-setup.md
- Configuration examples: references/config-examples.md
- Git hooks setup: references/git-hooks-setup.md
- VSCode settings: references/vscode-settings.md
- 环境设置:references/environment-setup.md
- 配置示例:references/config-examples.md
- Git钩子设置:references/git-hooks-setup.md
- VSCode设置:references/vscode-settings.md