-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
维护:增加Prettier和Git Hooks #107
Conversation
✅ Deploy Preview for zotero-zh ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
[skip ci] [skip netlify]
不懂但是看起来挺高级的 |
笑死,lint-stage 都还是从你仓库抄的代码 |
这个hook不会用的话可能导致git出问题,会增加写文档的门槛,建议暂时别加 |
另一种方案就是在 lint-stage 里只对 markdown 运行 prettier,其他的都不执行,包括 markdownlint (prettier 的规则比 markdownlint 更宽松) Lines 30 to 35 in 3e7a3a8
因为 也可以看下是完全去掉 hook,还是用这种? |
我认为只要不破坏git流程,怎么搞都无所谓 |
* 添加prettier和git hook * Fix lint * Disable KaTeX * Fix typo * Add comment to markdownlint config [skip ci] [skip netlify] * 从lint-stage移除markdownlint * 修复大小写错误 * reorder settings * 仅在本仓库触发部署,fork仓库跳过
请大家看下是否可行,有无必要~
变更细节
增加
prettier
来格式化 Markdown,使用2.8.8
,该版本是最后一版支持在中英文之间加入空格的版本。配套的,禁用了
markdownlint
中与prettier
重叠的规则。在
.vscode/settings.json
中增加vscode-prettier
插件的推荐,并将其设置为 VS Code 的默认格式化器。这意味着,如果贡献者使用 VS Code 且正确安装了插件,则所有的格式都将被自动调整。
在
markdownlint
里启用专有名词大小写的修复,包括Zotero
,GitHub
等 —— 正常情况下,在保存时会自动修复。wiki/.markdownlint.json
Lines 2 to 17 in 46a90f8
增加了
lint-stage
到pre-commit
hook —— 也许不应该加?提交时,将自动修正暂存区的 md 文件,绝大部分的格式问题都应被自动修复;存在不能被自动修复的将中断提交 —— 这种错误通常也会导致构建失败?
—— 没有错误还好,如果有错误,会影响一小部分同学提交(如果这位同学处理不了)
或许也可以考虑取消这个 git hook?
维护者需要注意的
如果这个 PR 不合并,啥也不用动。
如果这个 PR 合并,维护者需要重新安装一次依赖项:
(或是
pnpm/yarn
)同时在 VS Code 里安装 Prettier 插件