Skip to content

Commit dce7f7a

Browse files
authored
维护:增加Prettier和Git Hooks (#107)
* 添加prettier和git hook * Fix lint * Disable KaTeX * Fix typo * Add comment to markdownlint config [skip ci] [skip netlify] * 从lint-stage移除markdownlint * 修复大小写错误 * reorder settings * 仅在本仓库触发部署,fork仓库跳过
1 parent 3d2afc3 commit dce7f7a

Some content is hidden

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

48 files changed

+866
-2799
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: ./.github/workflows/build.yml
2020

2121
deploy-gh-pages:
22-
if: github.ref_name == 'main' && github.event_name == 'push'
22+
if: github.ref_name == 'main' && github.event_name == 'push' && github.repository == 'zotero-chinese/wiki'
2323
needs:
2424
- lint
2525
- build

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ node_modules/
33
package-lock.json
44
# pnpm-lock.yaml
55

6-
src/.vuepress/.cache/
7-
src/.vuepress/.temp/
8-
src/.vuepress/dist/
6+
**/.vuepress/.cache/
7+
**/.vuepress/.temp/
8+
**/.vuepress/dist/
99
**/.obsidian

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.markdownlint.json

Lines changed: 0 additions & 59 deletions
This file was deleted.

.markdownlint.jsonc

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
// 定义文档中涉及的专有名词
3+
"MD044": {
4+
"code_blocks": false,
5+
"html_elements": false,
6+
"names": [
7+
"Zotero",
8+
"JavaScript",
9+
"GitHub",
10+
"WebDAV",
11+
"Android",
12+
"iOS",
13+
"macOS",
14+
"WPS",
15+
"Word",
16+
"ZotFile",
17+
"Zotero Chinese"
18+
]
19+
},
20+
21+
// 兼容 Prettier
22+
// @see https://github.com/DavidAnson/markdownlint/blob/main/doc/Prettier.md
23+
"blanks-around-fences": false,
24+
"blanks-around-headings": false,
25+
"blanks-around-lists": false,
26+
"code-fence-style": false,
27+
"emphasis-style": false,
28+
"heading-start-left": false,
29+
"hr-style": false,
30+
"line-length": false,
31+
"list-indent": false,
32+
"list-marker-space": false,
33+
"no-blanks-blockquote": false,
34+
"no-hard-tabs": false,
35+
"no-missing-space-atx": false,
36+
"no-missing-space-closed-atx": false,
37+
"no-multiple-blanks": false,
38+
"no-multiple-space-atx": false,
39+
"no-multiple-space-blockquote": false,
40+
"no-multiple-space-closed-atx": false,
41+
"no-trailing-spaces": false,
42+
"ol-prefix": false,
43+
"strong-style": false,
44+
"ul-indent": false,
45+
46+
// 其他规则配置
47+
// @see https://github.com/vuepress-theme-hope/vuepress-theme-hope/blob/main/.markdownlint.json
48+
"default": true,
49+
"MD003": {
50+
"style": "atx"
51+
},
52+
"MD004": {
53+
"style": "dash"
54+
},
55+
"MD013": false,
56+
"MD024": {
57+
"allow_different_nesting": true
58+
},
59+
"MD025": {
60+
"front_matter_title": ""
61+
},
62+
"MD033": {
63+
"allowed_elements": [
64+
"br",
65+
"template",
66+
"script",
67+
"style",
68+
"ArtPlayer",
69+
"AudioPlayer",
70+
"AutoCatalog",
71+
"Badge",
72+
"BiliBili",
73+
"Catalog",
74+
"CodePen",
75+
"DemoProject",
76+
"FontIcon",
77+
"ProjectLink",
78+
"PDF",
79+
"Replit",
80+
"Share",
81+
"SiteInfo",
82+
"StackBlitz",
83+
"XiGua",
84+
"VideoPlayer",
85+
"YouTube",
86+
"AppearanceSwitch",
87+
"HopeIcon",
88+
"FlowChartPlayground",
89+
"IconDisplay",
90+
"KatexPlayground",
91+
"NetlifyBadge",
92+
"PrintButton",
93+
"ThemeColorPicker",
94+
"ToggleFullScreenButton",
95+
"ToggleRTLButton"
96+
]
97+
},
98+
// 兼容 Prettier 禁用
99+
// "MD035": {
100+
// "style": "---"
101+
// },
102+
"MD036": false,
103+
"MD040": false,
104+
"MD046": false,
105+
"MD049": false
106+
}

.prettierignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Vuepress Cache
2+
**/.vuepress/.cache/**
3+
# Vuepress Temp
4+
**/.vuepress/.temp/**
5+
# Vuepress Output
6+
**/.vuepress/dist/**
7+
# Lib files
8+
**/.vuepress/public/assets/
9+
10+
# Node modules
11+
node_modules/
12+
13+
# Obsidian files
14+
**/.obsidian/**
15+
16+
# NPM lock file
17+
pnpm-lock.yaml
18+
package-lock.json
19+
yarn.lock
20+
21+
.husky/

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"recommendations": [
3+
"esbenp.prettier-vscode",
34
"davidanson.vscode-markdownlint",
45
"yzhang.markdown-all-in-one"
56
]

.vscode/settings.json

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
{
2+
/** 编辑器相关 **/
3+
"editor.formatOnSave": true,
4+
"editor.formatOnType": false,
5+
"editor.defaultFormatter": "esbenp.prettier-vscode",
6+
"editor.codeActionsOnSave": {
7+
"source.fixAll.markdownlint": "always",
8+
"source.fixAll": "always"
9+
},
210
"[markdown]": {
311
"editor.fontFamily": "Sarasa Mono SC, Noto Sans Mono CJK SC, monospace",
4-
"editor.formatOnType": false,
5-
"editor.formatOnSave": true,
6-
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
12+
"editor.defaultFormatter": "esbenp.prettier-vscode"
713
},
14+
15+
/** Markdown 相关 **/
816
"markdown.validate.enabled": true,
917
"markdown.validate.fileLinks.enabled": "error",
18+
"markdown.validate.referenceLinks.enabled": "ignore",
1019
"markdown.copyFiles.destination": {
1120
"**/*": "${documentWorkspaceFolder}/src/assets/"
1221
},
1322
"markdown.updateLinksOnFileMove.enabled": "always",
14-
"editor.codeActionsOnSave": {
15-
"source.fixAll.markdownlint": true
16-
},
23+
"markdown.editor.pasteUrlAsFormattedLink.enabled": "smart",
24+
25+
/** 文件管理器相关 **/
1726
// "explorer.sortOrder": "mixed",
1827
"explorer.excludeGitIgnore": false,
1928
"files.exclude": {
@@ -23,19 +32,18 @@
2332
"**/CVS": true,
2433
"**/.DS_Store": true,
2534
"**/Thumbs.db": true
26-
// custom begin
35+
36+
/** custom begin **/
2737
// "node_modules": true,
38+
// "package.json": true,
39+
// "package-lock.json": true,
40+
// "pnpm-lock.yaml": true
2841
// "**/.*": true,
2942
// ".github": true,
3043
// ".gitignore": true,
31-
// "**/.vuepress": true,
3244
// ".vscode": true,
3345
// ".markdownlint.json": true,
34-
// // "package.json": true,
35-
// "package-lock.json": true,
36-
// "CODE_OF_CONDUCT.md": true,
46+
// "**/.vuepress": true,
3747
// "LICENSE": true
38-
},
39-
"markdown.editor.pasteUrlAsFormattedLink.enabled": "smart",
40-
"markdown.validate.referenceLinks.enabled": "ignore"
48+
}
4149
}

package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,28 @@
66
"type": "module",
77
"packageManager": "pnpm@8.11.0",
88
"scripts": {
9-
"docs:build": "vuepress build src",
10-
"docs:clean-dev": "vuepress dev src --clean-cache",
119
"docs:dev": "vuepress dev src",
10+
"docs:clean-dev": "vuepress dev src --clean-cache",
1211
"docs:dev-debug": "vuepress dev src --debug",
13-
"docs:update-package": "npx vp-update",
12+
"docs:build": "vuepress build src",
13+
"lint:prettier": "prettier --write .",
1414
"lint:md": "markdownlint-cli2-fix src/**/*.md",
15-
"lint-md": "lint-md src/**/*.md --fix"
15+
"docs:update-package": "npx vp-update",
16+
"prepare": "husky install"
1617
},
1718
"devDependencies": {
18-
"@lint-md/cli": "^2.0.0",
1919
"@vuepress/client": "2.0.0-rc.0",
20+
"husky": "^8.0.0",
21+
"lint-staged": "^15.1.0",
2022
"markdownlint-cli2": "^0.10.0",
2123
"mermaid": "^10.6.1",
24+
"prettier": "2.8.8",
2225
"vue": "^3.3.9",
2326
"vuepress": "2.0.0-rc.0",
2427
"vuepress-plugin-search-pro": "2.0.0-rc.0",
2528
"vuepress-theme-hope": "2.0.0-rc.0"
29+
},
30+
"lint-staged": {
31+
"*.md": "prettier --write"
2632
}
2733
}

0 commit comments

Comments
 (0)