Skip to content

Commit

Permalink
style: use autocorrect-node for zh-CN (#14773)
Browse files Browse the repository at this point in the history
Improves "copywriting, correct spaces, words, and punctuations".
(Source: https://github.com/huacnlee/autocorrect)

Only enabled for zh-CN for now. Also runs before git commits.

Co-authored-by: A1lo <[email protected]>
  • Loading branch information
huacnlee and yin1999 committed Dec 21, 2023
1 parent fa94403 commit 3c87751
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .autocorrectignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/huacnlee/autocorrect
#
# Like `.gitignore`, this file to tell AutoCorrect which files need to check, some need to ignore.
files/
docs/
/*
!files/zh-cn/
!docs/zh-cn/
_wikihistory.json
44 changes: 0 additions & 44 deletions .github/workflows/autocorrect-lint.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/markdown-lint-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
run: |
yarn markdownlint-cli2 --fix "**/${{ matrix.lang }}/**/*.md"
node ./scripts/check-url-locale.js --fix "files/${{ matrix.lang }}"
ls -d 2>/dev/null "files/${{ matrix.lang }}" "docs/${{ matrix.lang }}" | xargs yarn autocorrect --fix
yarn prettier -w "**/${{ matrix.lang }}/**/*.md"
cd ${{ github.workspace }}/mdn/content && yarn fix:fm --config-file ${{ github.workspace }}/front-matter-config.json "${{ github.workspace }}/files/${{ matrix.lang }}"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pr-check-lint_content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ jobs:
echo "Running url locale checker"
node ./scripts/check-url-locale.js --fix ${files_to_lint}
echo "Running autocorrect"
yarn autocorrect --fix ${files_to_lint}
echo "Running Prettier"
yarn prettier -w ${files_to_lint}
Expand Down
1 change: 1 addition & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"*.md": [
"markdownlint-cli2 --fix",
"node ./scripts/check-url-locale.js --fix",
"autocorrect --fix",
"prettier --write"
]
}
2 changes: 1 addition & 1 deletion files/zh-cn/glossary/accent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ slug: Glossary/Accent

**强调色**(accent)通常为一种明亮的颜色,与颜色方案中更实用的背景和前景色形成对比。这些颜色存在于很多平台(但不是所有平台)的视觉样式中。

web 上,强调色有时用于 {{HTMLElement("input")}} 元素中控件的活跃部分,例如勾选的[复选框](/zh-CN/docs/Web/HTML/Element/input/checkbox)的背景。
Web 上,强调色有时用于 {{HTMLElement("input")}} 元素中控件的活跃部分,例如勾选的[复选框](/zh-CN/docs/Web/HTML/Element/input/checkbox)的背景。

## 参见

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
"type": "module",
"scripts": {
"fix:json": "prettier -w \"**/*.json(c)?\"",
"fix:md": "markdownlint-cli2 --fix \"**/*.md\" && node ./scripts/check-url-locale.js --fix files && prettier -w \"**/*.md\"",
"fix:md": "markdownlint-cli2 --fix \"**/*.md\" && node ./scripts/check-url-locale.js --fix files && yarn autocorrect --fix . && prettier -w \"**/*.md\"",
"fix:yml": "prettier -w \"**/*.yml\"",
"lint:json": "prettier -c \"**/*.json(c)?\"",
"lint:md": "markdownlint-cli2 \"**/*.md\" && node ./scripts/check-url-locale.js files && prettier -c \"**/*.md\"",
"lint:md": "markdownlint-cli2 \"**/*.md\" && node ./scripts/check-url-locale.js files && yarn autocorrect --lint . && prettier -c \"**/*.md\"",
"lint:yml": "prettier -c \"**/*.yml\"",
"prepare": "husky install"
},
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"autocorrect-node": "2.9.0",
"cld": "^2.9.1",
"fdir": "^6.1.1",
"front-matter": "^4.0.2",
Expand Down
36 changes: 36 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,42 @@ argparse@^2.0.1:
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==

[email protected]:
version "2.9.0"
resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-arm64/-/autocorrect-node-darwin-arm64-2.9.0.tgz#b1c058bfb226f6d25300f9fd3aca0020c8f62243"
integrity sha512-lNG5RvydyBWUToJ5dDgGCu1Mmi6uxJsErGNokyiLj0tP0HXsI7Ed+MPnVd2QLWDrSfTIaGr4JyJ0KjVe0TyznA==

[email protected]:
version "2.9.0"
resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-x64/-/autocorrect-node-darwin-x64-2.9.0.tgz#6399885701ec8ca7e22d7a06da4c33b0a7580334"
integrity sha512-giOy9nHnReU5pJH44jI1grPSdtyv0jhVt/UqKpnW3XaH8kss2CvF1BzW0/BAD6FbUOlh7S1JjrfTD4bWkqR1ZA==

[email protected]:
version "2.9.0"
resolved "https://registry.yarnpkg.com/autocorrect-node-linux-x64-gnu/-/autocorrect-node-linux-x64-gnu-2.9.0.tgz#55af46b851ba5f29e77796acc31ae88a74eaeac9"
integrity sha512-KMAwr4TM04HYQN0+fSVaxJ/+o+msrluSOKwI79wYnIukrSQSBLbVthVowsP6coUHi9A9Jq8fHhlAFdOQPVKGUA==

[email protected]:
version "2.9.0"
resolved "https://registry.yarnpkg.com/autocorrect-node-linux-x64-musl/-/autocorrect-node-linux-x64-musl-2.9.0.tgz#ffbea51cda8d3c3d49cfca41f8ce20eb2f78f9e6"
integrity sha512-Uly0OHk2ZSriClKNh6QEFI0CP9Uf8rUX0EFBNoPONwZtLWfvuthFZPb+9WJMW5H4+yRMU8T/p8yMM1iSnNgi9g==

[email protected]:
version "2.9.0"
resolved "https://registry.yarnpkg.com/autocorrect-node-win32-x64-msvc/-/autocorrect-node-win32-x64-msvc-2.9.0.tgz#081857f163f53ddbfff7ec9c5e14c59eef554f12"
integrity sha512-MKJxmoDMZzOq6OEvqcDV/2WnQ0KWBvqtWm7l0o0MBNG5PqTlV2wqHtmCk6gfLGLV0oNT9A30WsgYfGyEeNJ0wg==

[email protected]:
version "2.9.0"
resolved "https://registry.yarnpkg.com/autocorrect-node/-/autocorrect-node-2.9.0.tgz#4f89ff98bd5ad7cbcc4d2639ff73e9e3aeaa0d6b"
integrity sha512-a5/llf9KoBJg2H7dj1iCYbo/uYYiYm4Shr9zMMFrvsPS3LTMVDwfvUmpGhlod2F8AChaFpHS5OirFMd8Fxw+ag==
optionalDependencies:
autocorrect-node-darwin-arm64 "2.9.0"
autocorrect-node-darwin-x64 "2.9.0"
autocorrect-node-linux-x64-gnu "2.9.0"
autocorrect-node-linux-x64-musl "2.9.0"
autocorrect-node-win32-x64-msvc "2.9.0"

balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
Expand Down

0 comments on commit 3c87751

Please sign in to comment.