chore(prettier): add format script and explicit .prettierrc#95
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
PR1(#94)已用
tsc --noEmit + prettier --check替换 eslint,但格式标准仍隐式依赖 prettier 默认配置,且没有供贡献者一键格式化的入口。本 PR 是分阶段方案的第二阶段:保留 prettier,把格式配置显式化并补上format脚本。改动
.prettierrc:显式锁定 prettier 2 默认选项(printWidth 80 / tabWidth 2 / semi / singleQuote false / trailingComma es5 / arrowParens always / endOfLine lf),与 PR1 已归一的代码一致package.json新增 script:format=prettier --write "src/**/*.ts" "__tests__/**/*.ts"lint脚本不变(仍typecheck && prettier --check,CI 继续守护格式)prettier依赖保留(^2.7.1→ 2.8.8,不升 v3 以避免再次全量重格式化)验证
prettier --check(带新.prettierrc):All matched files use Prettier code style!npm run format:幂等,对受管文件无改动(git status 仅.prettierrc+package.json变化)npm run lint:通过(typecheck 0 错 + prettier --check 通过)npm test:11 suites / 106 tests 全过npm run build:成功说明
prettier、不升级到 v3(避免全量重格式化)glob弃用警告(测试链,非本次范围)