Skip to content

Commit 3136114

Browse files
committed
chore: integrate prettier and enhance code quality checks
adds prettier configuration and integrates it into the linting workflow to enforce consistent code style across the project. also updates eslint configuration to include prettier rules and adds format commands to package.json. adds prettier 配置并将其集成到 linting 工作流程中,以在整个项目中强制执行一致的代码样式。还更新了 eslint 配置以包含 prettier 规则,并在 package.json 中添加了格式化命令。 Change-Id: I077c5695ff26d06b27fd983fbfaa212370180329 Signed-off-by: OhYee <oyohyee@oyohyee.com>
1 parent 61cb26b commit 3136114

149 files changed

Lines changed: 2700 additions & 3584 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
22
"root": true,
33
"parser": "@typescript-eslint/parser",
4-
"plugins": ["@typescript-eslint"],
5-
"extends": [
6-
"eslint:recommended",
7-
"plugin:@typescript-eslint/recommended"
8-
],
4+
"plugins": ["@typescript-eslint", "prettier"],
5+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
96
"env": {
107
"node": true,
118
"es2022": true
@@ -18,8 +15,8 @@
1815
"@typescript-eslint/no-explicit-any": "warn",
1916
"@typescript-eslint/explicit-function-return-type": "off",
2017
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
21-
"no-constant-condition": ["error", { "checkLoops": false }]
18+
"no-constant-condition": ["error", { "checkLoops": false }],
19+
"prettier/prettier": "error"
2220
},
2321
"ignorePatterns": ["dist", "node_modules", "*.js"]
2422
}
25-

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ about: Create a report to help us improve
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
2424
If applicable, add screenshots to help explain your problem.
2525

2626
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
27+
28+
- OS: [e.g. iOS]
29+
- Browser [e.g. chrome, safari]
30+
- Version [e.g. 22]
3031

3132
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
33+
34+
- Device: [e.g. iPhone6]
35+
- OS: [e.g. iOS8.1]
36+
- Browser [e.g. stock browser, safari]
37+
- Version [e.g. 22]
3638

3739
**Additional context**
3840
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

109
**Is your feature request related to a problem? Please describe.**

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v4
4646
with:
47-
fetch-depth: 0 # 获取完整历史用于增量覆盖率检查
47+
fetch-depth: 0 # 获取完整历史用于增量覆盖率检查
4848

4949
- name: Use Node.js 18.x
5050
uses: actions/setup-node@v4

.github/workflows/publish.yaml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
branches:
77
- '**'
88
tags-ignore:
9-
- '**' # 忽略 tag push,避免与 release 事件重复触发
9+
- '**' # 忽略 tag push,避免与 release 事件重复触发
1010

1111
# GitHub Release 触发正式发布
1212
release:
@@ -21,8 +21,8 @@ on:
2121
default: 'test'
2222
type: choice
2323
options:
24-
- official # 正式发布
25-
- test # 测试发布
24+
- official # 正式发布
25+
- test # 测试发布
2626
version:
2727
description: '版本号(留空则自动递增)/ Version (leave empty for auto-increment)'
2828
required: false
@@ -33,9 +33,9 @@ on:
3333
default: 'patch'
3434
type: choice
3535
options:
36-
- patch # 0.0.1 -> 0.0.2
37-
- minor # 0.0.1 -> 0.1.0
38-
- major # 0.0.1 -> 1.0.0
36+
- patch # 0.0.1 -> 0.0.2
37+
- minor # 0.0.1 -> 0.1.0
38+
- major # 0.0.1 -> 1.0.0
3939

4040
jobs:
4141
# 等待 CI 测试通过(仅 push 触发时)
@@ -104,20 +104,20 @@ jobs:
104104
# 获取包名
105105
PACKAGE_NAME=$(node -p "require('./package.json').name")
106106
echo "PACKAGE_NAME=${PACKAGE_NAME}" >> $GITHUB_OUTPUT
107-
107+
108108
# 获取基础版本号
109109
BASE_VERSION=$(node -p "require('./package.json').version")
110-
110+
111111
# 生成唯一标识符:优先使用 run_id,否则使用时间戳
112112
if [ -n "${{ github.run_id }}" ]; then
113113
UNIQUE_ID="${{ github.run_id }}"
114114
else
115115
UNIQUE_ID=$(date +%Y%m%d%H%M%S)
116116
fi
117-
117+
118118
# 生成 prerelease 版本号
119119
VERSION="${BASE_VERSION}-test.${UNIQUE_ID}"
120-
120+
121121
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
122122
echo "Test version: ${VERSION}"
123123
@@ -148,12 +148,12 @@ jobs:
148148
PACKAGE_NAME="${{ steps.version.outputs.PACKAGE_NAME }}"
149149
VERSION="${{ steps.version.outputs.VERSION }}"
150150
echo "Publishing ${PACKAGE_NAME}@${VERSION} with tag=test"
151-
151+
152152
# Remove any .npmrc that might interfere with OIDC
153153
rm -f ~/.npmrc
154154
rm -f .npmrc
155155
rm -f /home/runner/work/_temp/.npmrc
156-
156+
157157
# Publish using Trusted Publishers (OIDC)
158158
npm publish --tag test --access public --provenance
159159
env:
@@ -211,7 +211,7 @@ jobs:
211211
run: |
212212
PACKAGE_NAME=$(node -p "require('./package.json').name")
213213
echo "PACKAGE_NAME=${PACKAGE_NAME}" >> $GITHUB_OUTPUT
214-
214+
215215
# 确定版本号
216216
if [ "${{ github.event_name }}" = "release" ]; then
217217
VERSION="${{ github.event.release.tag_name }}"
@@ -254,7 +254,7 @@ jobs:
254254
VERSION="${MAJOR}.${MINOR}.${PATCH}"
255255
fi
256256
fi
257-
257+
258258
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
259259
echo "Official version: ${VERSION}"
260260
@@ -297,12 +297,12 @@ jobs:
297297
PACKAGE_NAME="${{ steps.config.outputs.PACKAGE_NAME }}"
298298
VERSION="${{ steps.config.outputs.VERSION }}"
299299
echo "Publishing ${PACKAGE_NAME}@${VERSION} with tag=latest"
300-
300+
301301
# Remove any .npmrc that might interfere with OIDC
302302
rm -f ~/.npmrc
303303
rm -f .npmrc
304304
rm -f /home/runner/work/_temp/.npmrc
305-
305+
306306
# Publish using Trusted Publishers (OIDC)
307307
npm publish --tag latest --access public --provenance
308308
env:
@@ -357,7 +357,7 @@ jobs:
357357
run: |
358358
PACKAGE_NAME=$(node -p "require('./package.json').name")
359359
echo "PACKAGE_NAME=${PACKAGE_NAME}" >> $GITHUB_OUTPUT
360-
360+
361361
VERSION="${{ inputs.version }}"
362362
if [ -z "$VERSION" ]; then
363363
# 自动生成测试版本号
@@ -372,7 +372,7 @@ jobs:
372372
373373
VERSION="${BASE_VERSION}-test.${UNIQUE_ID}"
374374
fi
375-
375+
376376
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
377377
echo "Test version: ${VERSION}"
378378
@@ -401,12 +401,12 @@ jobs:
401401
PACKAGE_NAME="${{ steps.version.outputs.PACKAGE_NAME }}"
402402
VERSION="${{ steps.version.outputs.VERSION }}"
403403
echo "Publishing ${PACKAGE_NAME}@${VERSION} with tag=test"
404-
404+
405405
# Remove any .npmrc that might interfere with OIDC
406406
rm -f ~/.npmrc
407407
rm -f .npmrc
408408
rm -f /home/runner/work/_temp/.npmrc
409-
409+
410410
# Publish using Trusted Publishers (OIDC)
411411
npm publish --tag test --access public --provenance
412412
env:

.prettierignore

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Dependencies
2+
node_modules/
3+
bun.lock
4+
5+
# Build outputs
6+
dist/
7+
coverage/
8+
*.tsbuildinfo
9+
10+
# Logs
11+
*.log
12+
npm-debug.log*
13+
yarn-debug.log*
14+
yarn-error.log*
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage/
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Dependency directories
30+
node_modules/
31+
jspm_packages/
32+
33+
# Optional npm cache directory
34+
.npm
35+
36+
# Optional eslint cache
37+
.eslintcache
38+
39+
# Microbundle cache
40+
.rpt2_cache/
41+
.rts2_cache_cjs/
42+
.rts2_cache_es/
43+
.rts2_cache_umd/
44+
45+
# Optional REPL history
46+
.node_repl_history
47+
48+
# Output of 'npm pack'
49+
*.tgz
50+
51+
# Yarn Integrity file
52+
.yarn-integrity
53+
54+
# dotenv environment variables file
55+
.env
56+
.env.test
57+
58+
# parcel-bundler cache (https://parceljs.org/)
59+
.cache
60+
.parcel-cache
61+
62+
# Next.js build output
63+
.next
64+
65+
# Nuxt.js build / generate output
66+
.nuxt
67+
dist
68+
69+
# Gatsby files
70+
.cache/
71+
public
72+
73+
# Storybook build outputs
74+
.out
75+
.storybook-out
76+
77+
# Temporary folders
78+
tmp/
79+
temp/
80+
81+
# Editor directories and files
82+
.vscode/*
83+
!.vscode/extensions.json
84+
.idea
85+
.DS_Store
86+
*.suo
87+
*.ntvs*
88+
*.njsproj
89+
*.sln
90+
*.sw?
91+
92+
# OS generated files
93+
Thumbs.db
94+
ehthumbs.db
95+
Desktop.ini
96+
97+
# Jest coverage
98+
coverage/
99+
100+
# TypeScript
101+
*.tsbuildinfo
102+
103+
# Optional stylelint cache
104+
.stylelintcache
105+
106+
# VS Code
107+
.vscode/settings.json
108+
.vscode/launch.json
109+
110+
# Local development
111+
.env.local
112+
.env.development.local
113+
.env.test.local
114+
.env.production.local
115+
116+
# Testing
117+
.pytest_cache/
118+
__pycache__/
119+
*.pyc
120+
121+
# Build artifacts
122+
build/
123+
out/
124+
125+
# Lock files (keep package-lock.json)
126+
yarn.lock
127+
pnpm-lock.yaml
128+
129+
# Generated files
130+
codegen/
131+
scripts/inject-version-check.mjs

.prettierrc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"bracketSpacing": true,
9+
"bracketSameLine": false,
10+
"arrowParens": "avoid",
11+
"endOfLine": "lf",
12+
"quoteProps": "as-needed",
13+
"jsxSingleQuote": true,
14+
"overrides": [
15+
{
16+
"files": "*.json",
17+
"options": {
18+
"printWidth": 200
19+
}
20+
},
21+
{
22+
"files": "*.md",
23+
"options": {
24+
"printWidth": 80,
25+
"proseWrap": "preserve"
26+
}
27+
}
28+
]
29+
}

0 commit comments

Comments
 (0)