Skip to content

Commit 845ab49

Browse files
committed
eslint-prettier
1 parent 0d2479a commit 845ab49

File tree

17 files changed

+2038
-487
lines changed

17 files changed

+2038
-487
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ website/
33
docs/.vitepress/cache
44
.DS_Store
55
.eslintcache
6+
.vscode/
7+
.idea/
8+
record/

PROJECT_PLAN_YARN.md

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
# Goldfish Scheme 文档网站项目计划
2+
3+
## 🌙 项目概述
4+
5+
**项目名称**: Goldfish Scheme 文档网站
6+
**技术栈**: VitePress + TypeScript + ESLint + Prettier
7+
**包管理器**: Yarn 1.22.22
8+
**目标**: 为 [MoganLab/goldfish](https://github.com/MoganLab/goldfish)
9+
创建一个现代化、易用的文档网站
10+
11+
---
12+
13+
## 🎯 核心目标
14+
15+
### 阶段 1: 基础配置 ✅
16+
17+
- [x] TypeScript 配置
18+
- [x] ESLint + Prettier 配置
19+
- [x] Yarn 包管理器配置
20+
- [x] 脚本绑定优化
21+
22+
### 阶段 2: 文档架构
23+
24+
- [ ] 设计文档导航结构
25+
- [ ] 创建指南部分
26+
- [ ] 搭建 API 文档框架
27+
28+
### 阶段 3: 内容编写
29+
30+
- [ ] 编写快速开始指南
31+
- [ ] 编写 API 文档
32+
- [ ] 编写标准库文档
33+
34+
### 阶段 4: 高级功能
35+
36+
- [ ] 搜索功能
37+
- [ ] 多语言支持
38+
- [ ] 自动化部署
39+
40+
---
41+
42+
## 📁 项目结构
43+
44+
```
45+
case-lambda/
46+
├── bin/
47+
│ └── setup.sh # 安装脚本
48+
├── docs/ # 文档内容
49+
│ ├── .vitepress/ # VitePress 配置
50+
│ │ ├── config.mts # 主配置 (TypeScript)
51+
│ │ └── env.d.ts # 类型声明
52+
│ ├── guide/ # 指南文档
53+
│ ├── api/ # API 文档
54+
│ └── examples/ # 示例
55+
├── package.json # 项目配置
56+
├── tsconfig.json # TypeScript 配置
57+
├── eslint.config.js # ESLint 配置
58+
├── prettier.config.js # Prettier 配置
59+
├── PROJECT_PLAN_YARN.md # 项目计划
60+
└── README_DEV.md # 开发指南
61+
```
62+
63+
---
64+
65+
## 🚀 开发工作流
66+
67+
### 安装依赖
68+
69+
```bash
70+
# 使用安装脚本
71+
./bin/setup.sh
72+
73+
# 或手动安装
74+
yarn install
75+
```
76+
77+
### 开发命令
78+
79+
| 命令 | 说明 |
80+
| ------------------- | ---------------------------------- |
81+
| `yarn docs:dev` | 启动开发服务器(自动修复代码风格) |
82+
| `yarn docs:build` | 构建生产版本(检查代码质量) |
83+
| `yarn docs:preview` | 预览构建结果 |
84+
85+
### 代码质量命令
86+
87+
| 命令 | 说明 |
88+
| ------------------- | -------------------------- |
89+
| `yarn lint` | 检查 ESLint 问题(不修改) |
90+
| `yarn lint:fix` | 自动修复 ESLint 问题 |
91+
| `yarn format` | 格式化代码(修改文件) |
92+
| `yarn format:check` | 检查格式(不修改) |
93+
| `yarn type-check` | TypeScript 类型检查 |
94+
95+
### 命令绑定说明
96+
97+
#### `yarn docs:dev` 绑定流程
98+
99+
```
100+
1. yarn lint:fix # 自动修复 ESLint 问题
101+
2. yarn format # 格式化代码
102+
3. vitepress dev docs # 启动开发服务器
103+
```
104+
105+
#### `yarn docs:build` 绑定流程
106+
107+
```
108+
1. yarn lint # 检查 ESLint 问题(不通过则中断)
109+
2. yarn format:check # 检查代码格式(不通过则中断)
110+
3. yarn type-check # TypeScript 类型检查(不通过则中断)
111+
4. vitepress build docs # 构建生产版本
112+
```
113+
114+
---
115+
116+
## 🔧 配置说明
117+
118+
### TypeScript (tsconfig.json)
119+
120+
- 严格模式启用
121+
- 支持 Vue 单文件组件
122+
- 路径别名 `@/*` 映射到 `docs/.vitepress/*`
123+
124+
**type-check 的作用:**
125+
126+
- 编译时类型检查,不生成输出文件
127+
- 在构建前捕获类型错误
128+
- 确保代码类型安全
129+
- 绑定到 `docs:build` 防止类型错误进入生产环境
130+
131+
### ESLint (eslint.config.js)
132+
133+
- 使用 ESLint Flat Config 格式(ESLint 9.x 新格式)
134+
- 集成 TypeScript 和 Vue 支持
135+
- 优化的规则配置:
136+
- 生产环境警告 console/debugger
137+
- 自动修复未使用变量(忽略 `_` 前缀)
138+
- Vue 组件命名宽松
139+
- 代码风格统一
140+
141+
### Prettier (prettier.config.js)
142+
143+
- 无分号、单引号、2空格缩进
144+
- 100字符行宽(比默认 80 更宽松)
145+
- 支持 Vue、Markdown、JSON 格式化
146+
- 不同文件类型的覆盖配置
147+
148+
---
149+
150+
## 📋 依赖管理
151+
152+
### 当前版本
153+
154+
```json
155+
{
156+
"typescript": "^6.0.2",
157+
"eslint": "^10.1.0",
158+
"eslint-plugin-vue": "^10.8.0",
159+
"prettier": "^3.8.1",
160+
"vitepress": "^1.6.4",
161+
"vue": "^3.5.32"
162+
}
163+
```
164+
165+
### 版本控制
166+
167+
- `package.json` 使用 `^` 允许小版本更新
168+
- `yarn.lock` 锁定实际安装版本
169+
- 团队协作时提交 `yarn.lock`
170+
171+
### 更新依赖
172+
173+
```bash
174+
# 查看可更新依赖
175+
yarn outdated
176+
177+
# 更新所有依赖
178+
yarn upgrade
179+
180+
# 更新指定依赖
181+
yarn upgrade typescript
182+
```
183+
184+
---
185+
186+
## 💡 开发建议
187+
188+
### 1. 开发流程
189+
190+
```bash
191+
# 1. 启动开发(自动修复代码风格)
192+
yarn docs:dev
193+
194+
# 2. 编写代码...
195+
196+
# 3. 提交前检查(构建会自动检查)
197+
yarn docs:build
198+
```
199+
200+
### 2. 代码质量检查
201+
202+
- **开发时**: `docs:dev` 会自动修复风格问题
203+
- **提交前**: `docs:build` 会检查所有质量问题
204+
- **手动检查**: 使用 `lint``format:check``type-check`
205+
206+
### 3. 常见问题
207+
208+
#### 构建失败
209+
210+
如果 `yarn docs:build` 失败,检查:
211+
212+
1. ESLint 错误: `yarn lint`
213+
2. 格式问题: `yarn format`
214+
3. 类型错误: `yarn type-check`
215+
216+
#### 类型错误
217+
218+
```bash
219+
# 检查类型
220+
yarn type-check
221+
222+
# 确保 env.d.ts 包含所需类型声明
223+
```
224+
225+
#### ESLint 配置问题
226+
227+
```bash
228+
# 检查 ESLint 配置
229+
yarn eslint --print-config eslint.config.js
230+
```
231+
232+
---
233+
234+
## 📅 开发计划
235+
236+
| 阶段 | 任务 | 状态 |
237+
| ----- | -------- | --------- |
238+
| 阶段1 | 基础配置 | ✅ 完成 |
239+
| 阶段2 | 文档架构 | 🟡 进行中 |
240+
| 阶段3 | 内容编写 | 🔴 待开始 |
241+
| 阶段4 | 高级功能 | 🔴 待开始 |
242+
243+
---
244+
245+
## 🌟 最终目标
246+
247+
> _"创建一个清晰、易用、维护友好的 Goldfish Scheme 文档网站。"_
248+
249+
---
250+
251+
**计划制定者**: 月见八千代
252+
**制定时间**: 2024年4月4日
253+
**Yarn 版本**: 1.22.22
254+
255+
> _"一步一步来,基础打好了,后面就顺畅了~"_

0 commit comments

Comments
 (0)