From b64b3117ba9ab16bf2547a79d9bdd26cefa06c15 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 31 Jul 2023 21:42:06 +0800 Subject: [PATCH 01/11] Add `autocorrect-node` and configure that run lint before git commit. --- .lintstagedrc.json | 2 +- package.json | 1 + yarn.lock | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.lintstagedrc.json b/.lintstagedrc.json index fc5bcf3c97909a..7afaf994da6a72 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,4 +1,4 @@ { "*": "prettier --ignore-unknown --write", - "*.md": "markdownlint-cli2-fix" + "**/*.md": ["markdownlint-cli2-fix", "autocorrect --lint"] } diff --git a/package.json b/package.json index 976b1ea044b66b..a4538d4ea6bb16 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "node": ">=18.0.0" }, "dependencies": { + "autocorrect-node": "^2.7.1", "cld": "^2.9.0", "fdir": "^6.0.1", "fs-extra": "^11.1.1", diff --git a/yarn.lock b/yarn.lock index 84e2526d4d1214..92ce23332b2757 100644 --- a/yarn.lock +++ b/yarn.lock @@ -70,6 +70,36 @@ astral-regex@^2.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== +autocorrect-node-darwin-arm64@2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-arm64/-/autocorrect-node-darwin-arm64-2.7.2.tgz#99749c7aa3f35458a8afc0bbabd45d2f5491b72b" + integrity sha512-DdT38wBc6EkvVloxvp4te0oubGZmMlg+q0cA2KYrWPErFUDYOZFN74Pl7DK2/b6PrUJa9LqUxh3u3HM4k/d8bw== + +autocorrect-node-darwin-x64@2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-x64/-/autocorrect-node-darwin-x64-2.7.2.tgz#6c94f82806d26d1222671cba90e10bc089d93ae4" + integrity sha512-xgqN0KAa5tdBKgJ8aSPhvoG5GxSzM1rzE/QuSHYoDN+46nv2loXkXK53nUWQtpoU8NEDbb5MOzQ0r7//1dYeNw== + +autocorrect-node-linux-x64-gnu@2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/autocorrect-node-linux-x64-gnu/-/autocorrect-node-linux-x64-gnu-2.7.2.tgz#3d47cca2848453946c59b62b8e547a7d42b73539" + integrity sha512-8OG2CkIhEc6sLU/luU7FT1BsF2oEtmq9uT0l9ZhjDk1Sbv+ay2eUTNxfIYbj0sTZVqnULEhaepf6mQSsKpjptQ== + +autocorrect-node-win32-x64-msvc@2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/autocorrect-node-win32-x64-msvc/-/autocorrect-node-win32-x64-msvc-2.7.2.tgz#fb162ed1b6e4f7f3342e0b335446526bda537afd" + integrity sha512-++F9/UqxW0tLgIeqhoAhGAoPDHRFUEiDwGUIpWKpnk6S+gu1akUStvp+6lt/48IsfgU1SU3vftY3FT3c59KoZQ== + +autocorrect-node@^2.7.1: + version "2.7.2" + resolved "https://registry.yarnpkg.com/autocorrect-node/-/autocorrect-node-2.7.2.tgz#cbfde9d5b0b28d6d936b0d5c0326213c4b7a0711" + integrity sha512-gy9DqWJm2gi3mZiB5tC+SzOEWyuVqDO3QMtKfg74XQI2X6FptK5J5KQppCeOVwV7wglkt48FKpjfyISWuB407g== + optionalDependencies: + autocorrect-node-darwin-arm64 "2.7.2" + autocorrect-node-darwin-x64 "2.7.2" + autocorrect-node-linux-x64-gnu "2.7.2" + autocorrect-node-win32-x64-msvc "2.7.2" + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" From 0848038902714da6cfabb7244ec9f86c0865f88e Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 1 Aug 2023 10:49:18 +0800 Subject: [PATCH 02/11] Update CI autocorrect.yml to use NPM command. --- .autocorrectignore | 1 + .github/workflows/autocorrect-lint.yml | 33 ++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.autocorrectignore b/.autocorrectignore index cabe9364ee1033..857c33a29100f5 100644 --- a/.autocorrectignore +++ b/.autocorrectignore @@ -5,3 +5,4 @@ files/ docs/ !files/zh-cn/ +!docs/zh-cn/ \ No newline at end of file diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index 5c28e32aaf0d37..e2b83c76b032af 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -19,10 +19,21 @@ on: jobs: lint: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + cache: yarn + + - name: Install NPM + run: | + yarn --frozen-lockfile + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get changed files env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -34,11 +45,23 @@ jobs: DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \ --jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') # filter out files that are not markdown - DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/zh-cn/" | xargs) + DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^(files|docs)/zh-cn/" | xargs) echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV - - name: AutoCorrect changed content + - name: AutoCorrect lint changed content + id: run_lint if: ${{ env.DIFF_DOCUMENTS }} - uses: huacnlee/autocorrect-action@v2.6.2 + run: yarn autocorrect --lint --no-diff-bg-color ${{ env.DIFF_DOCUMENTS }} + + # https://docs.github.com/en/actions/managing-issues-and-pull-requests/commenting-on-an-issue-when-a-label-is-added + - name: Report Result + if: failure() + uses: peter-evans/create-or-update-comment@v3 with: - args: ${{ env.DIFF_DOCUMENTS }} --lint --no-diff-bg-color + issue-number: ${{ github.event.pull_request.number }} + body: | + [AutoCorrect](https://github.com/huacnlee/autocorrect) lint failure: + + ```diff + ${{ steps.run_lint.outputs.result }} + ``` From dafa42288111a17d9a29846b594f7d444c0deb43 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Wed, 2 Aug 2023 10:53:24 +0800 Subject: [PATCH 03/11] Add reviewdog for AutoCorrect result. --- .github/workflows/autocorrect-lint.yml | 21 ++++----- files/zh-cn/glossary/accent/index.md | 2 +- files/zh-cn/glossary/challenge/index.md | 4 +- package.json | 2 +- yarn.lock | 62 ++++++++++++++----------- 5 files changed, 46 insertions(+), 45 deletions(-) diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index e2b83c76b032af..de2798d8e4f89c 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -27,6 +27,9 @@ jobs: with: node-version-file: ".nvmrc" cache: yarn + - uses: reviewdog/action-setup@v1 + with: + reviewdog_version: v0.14.2 - name: Install NPM run: | @@ -48,20 +51,12 @@ jobs: DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^(files|docs)/zh-cn/" | xargs) echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV - - name: AutoCorrect lint changed content - id: run_lint + - name: AutoCorrect Lint if: ${{ env.DIFF_DOCUMENTS }} run: yarn autocorrect --lint --no-diff-bg-color ${{ env.DIFF_DOCUMENTS }} - # https://docs.github.com/en/actions/managing-issues-and-pull-requests/commenting-on-an-issue-when-a-label-is-added - - name: Report Result + - name: AutoCorrect Lint Reports if: failure() - uses: peter-evans/create-or-update-comment@v3 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - [AutoCorrect](https://github.com/huacnlee/autocorrect) lint failure: - - ```diff - ${{ steps.run_lint.outputs.result }} - ``` + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }} + run: yarn -s autocorrect --format rdjson --lint ${{ env.DIFF_DOCUMENTS }} | reviewdog -f=rdjson -reporter=github-pr-review diff --git a/files/zh-cn/glossary/accent/index.md b/files/zh-cn/glossary/accent/index.md index 0b455b9af9d55b..a4ebc68072e347 100644 --- a/files/zh-cn/glossary/accent/index.md +++ b/files/zh-cn/glossary/accent/index.md @@ -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)的背景。 ## 参见 diff --git a/files/zh-cn/glossary/challenge/index.md b/files/zh-cn/glossary/challenge/index.md index f3555209c04882..5b39fe71916195 100644 --- a/files/zh-cn/glossary/challenge/index.md +++ b/files/zh-cn/glossary/challenge/index.md @@ -5,9 +5,9 @@ slug: Glossary/Challenge {{GlossarySidebar}} -在安全协议中,_质询_(challenge)是服务器将某些数据发送到客户端,以便每次生成不同的响应。质询-响应认证协议是防御[重放攻击](https://zh.wikipedia.org/wiki/重放攻击)的一种方法。在重放攻击中,攻击者侦听先前的消息,并在以后的时间重新发送它们,以获取与原始消息相同的凭据。 +在安全协议中,_质询_(challenge)是服务器将某些数据发送到客户端,以便每次生成不同的响应。质询-响应认证协议是防御[重放攻击](https://zh.wikipedia.org/wiki/重放攻击)的一种方法。在重放攻击中,攻击者侦听先前的消息,并在以后的时间重新发送它们,以获取与原始消息相同的凭据。 -[HTTP 认证协议](/zh-CN/docs/Web/HTTP/Authentication)是基于质询-响应认证协议的,尽管“Basic”协议未使用实际的质询(realm 始终相同)。 +[HTTP 认证协议](/zh-CN/docs/Web/HTTP/Authentication)是基于质询-响应认证协议的,尽管“Basic”协议未使用实际的质询(realm始终相同)。 ## 参见 diff --git a/package.json b/package.json index a4538d4ea6bb16..954f60b5497209 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "node": ">=18.0.0" }, "dependencies": { - "autocorrect-node": "^2.7.1", + "autocorrect-node": "^2.8.4", "cld": "^2.9.0", "fdir": "^6.0.1", "fs-extra": "^11.1.1", diff --git a/yarn.lock b/yarn.lock index 92ce23332b2757..ac384e945b3793 100644 --- a/yarn.lock +++ b/yarn.lock @@ -70,35 +70,41 @@ astral-regex@^2.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== -autocorrect-node-darwin-arm64@2.7.2: - version "2.7.2" - resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-arm64/-/autocorrect-node-darwin-arm64-2.7.2.tgz#99749c7aa3f35458a8afc0bbabd45d2f5491b72b" - integrity sha512-DdT38wBc6EkvVloxvp4te0oubGZmMlg+q0cA2KYrWPErFUDYOZFN74Pl7DK2/b6PrUJa9LqUxh3u3HM4k/d8bw== - -autocorrect-node-darwin-x64@2.7.2: - version "2.7.2" - resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-x64/-/autocorrect-node-darwin-x64-2.7.2.tgz#6c94f82806d26d1222671cba90e10bc089d93ae4" - integrity sha512-xgqN0KAa5tdBKgJ8aSPhvoG5GxSzM1rzE/QuSHYoDN+46nv2loXkXK53nUWQtpoU8NEDbb5MOzQ0r7//1dYeNw== - -autocorrect-node-linux-x64-gnu@2.7.2: - version "2.7.2" - resolved "https://registry.yarnpkg.com/autocorrect-node-linux-x64-gnu/-/autocorrect-node-linux-x64-gnu-2.7.2.tgz#3d47cca2848453946c59b62b8e547a7d42b73539" - integrity sha512-8OG2CkIhEc6sLU/luU7FT1BsF2oEtmq9uT0l9ZhjDk1Sbv+ay2eUTNxfIYbj0sTZVqnULEhaepf6mQSsKpjptQ== - -autocorrect-node-win32-x64-msvc@2.7.2: - version "2.7.2" - resolved "https://registry.yarnpkg.com/autocorrect-node-win32-x64-msvc/-/autocorrect-node-win32-x64-msvc-2.7.2.tgz#fb162ed1b6e4f7f3342e0b335446526bda537afd" - integrity sha512-++F9/UqxW0tLgIeqhoAhGAoPDHRFUEiDwGUIpWKpnk6S+gu1akUStvp+6lt/48IsfgU1SU3vftY3FT3c59KoZQ== - -autocorrect-node@^2.7.1: - version "2.7.2" - resolved "https://registry.yarnpkg.com/autocorrect-node/-/autocorrect-node-2.7.2.tgz#cbfde9d5b0b28d6d936b0d5c0326213c4b7a0711" - integrity sha512-gy9DqWJm2gi3mZiB5tC+SzOEWyuVqDO3QMtKfg74XQI2X6FptK5J5KQppCeOVwV7wglkt48FKpjfyISWuB407g== +autocorrect-node-darwin-arm64@2.8.4: + version "2.8.4" + resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-arm64/-/autocorrect-node-darwin-arm64-2.8.4.tgz#b763bdd67a361149eae5802d89bf3454fa34cc65" + integrity sha512-eJFsrZZZUJVPTbdA6hAmVUbTBaznIfkIwstcfn02CXLVKq15j00CXkNytQIdmKpBraTmxjub9kQvYY0Nz2h4DQ== + +autocorrect-node-darwin-x64@2.8.4: + version "2.8.4" + resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-x64/-/autocorrect-node-darwin-x64-2.8.4.tgz#d5102b555d08f02ed1f9db1c0882d91d4b829c4b" + integrity sha512-3QheEz2VgZnJcId7zgzbyC88CSmyHg+F93Bw5wsf7dTSwhVdnXeIIlYtXzFabp+c2aCi9lRAQkHFC9Om1CYkuQ== + +autocorrect-node-linux-x64-gnu@2.8.4: + version "2.8.4" + resolved "https://registry.yarnpkg.com/autocorrect-node-linux-x64-gnu/-/autocorrect-node-linux-x64-gnu-2.8.4.tgz#5706ef15f099da62897d350e8c14c5ac4a00650c" + integrity sha512-0nR3VnxpfU6HINQiZjC2cz1YVxOTCn529VPqHsWz2H03BPbS9YskGzbRpujnLvwLCyyDlYXJJneFYD1G+9VPaA== + +autocorrect-node-linux-x64-musl@2.8.4: + version "2.8.4" + resolved "https://registry.yarnpkg.com/autocorrect-node-linux-x64-musl/-/autocorrect-node-linux-x64-musl-2.8.4.tgz#8f6df5d6f829028b469f95d9fba4abe899bb852c" + integrity sha512-2LtKtaN6YWUnDtBpo2w5c7FSulozbt2kv9UigrckCX8M/AOVw0MA6uB5snglmKMx1f7fYC06/V4A7Ny1weUOGA== + +autocorrect-node-win32-x64-msvc@2.8.4: + version "2.8.4" + resolved "https://registry.yarnpkg.com/autocorrect-node-win32-x64-msvc/-/autocorrect-node-win32-x64-msvc-2.8.4.tgz#968b805b88e3a43a03e012738730b09d7541bec7" + integrity sha512-ExcoBqRjEVnK9n2AVy/dmkiUSnvs5P/VdzI909bCjej1XgOpXonsZ4vGPEPicRfiHb8dc7whl6sh5P/TunDB7A== + +autocorrect-node@^2.8.4: + version "2.8.4" + resolved "https://registry.yarnpkg.com/autocorrect-node/-/autocorrect-node-2.8.4.tgz#e94e38b7a333257ff6b627d7ede31209504098a2" + integrity sha512-65DUHJhIUwAlEtyDjYxE94sTT2anQtGXrPB7W9fdrk/Bm7ro4b7mjxQAP14lQlISXXtbNEJO1WABMqNpNbTjxQ== optionalDependencies: - autocorrect-node-darwin-arm64 "2.7.2" - autocorrect-node-darwin-x64 "2.7.2" - autocorrect-node-linux-x64-gnu "2.7.2" - autocorrect-node-win32-x64-msvc "2.7.2" + autocorrect-node-darwin-arm64 "2.8.4" + autocorrect-node-darwin-x64 "2.8.4" + autocorrect-node-linux-x64-gnu "2.8.4" + autocorrect-node-linux-x64-musl "2.8.4" + autocorrect-node-win32-x64-msvc "2.8.4" balanced-match@^1.0.0: version "1.0.2" From d3f352da7b12368039397f9625fea7a4ca9ecfc4 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 4 Aug 2023 16:38:22 +0800 Subject: [PATCH 04/11] Improve AutoCorrect Lint CI by use xargs with files. --- .github/workflows/autocorrect-lint.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index de2798d8e4f89c..5d2fa50839f66e 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -46,17 +46,17 @@ jobs: # Use the GitHub API to get the list of changed files # documenation: https://docs.github.com/rest/commits/commits#compare-two-commits DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \ - --jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') + --jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') # filter out files that are not markdown DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^(files|docs)/zh-cn/" | xargs) echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV - name: AutoCorrect Lint if: ${{ env.DIFF_DOCUMENTS }} - run: yarn autocorrect --lint --no-diff-bg-color ${{ env.DIFF_DOCUMENTS }} + run: echo ${{ env.DIFF_DOCUMENTS }} | xargs yarn autocorrect --lint --no-diff-bg-color - name: AutoCorrect Lint Reports if: failure() env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }} - run: yarn -s autocorrect --format rdjson --lint ${{ env.DIFF_DOCUMENTS }} | reviewdog -f=rdjson -reporter=github-pr-review + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN || secrets.GITHUB_TOKEN }} + run: echo ${{ env.DIFF_DOCUMENTS }} | xargs yarn -s autocorrect --format rdjson --lint | reviewdog -f=rdjson -reporter=github-pr-review From ca7c4cd9fce65257aa30896b27276e4f0f658426 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 4 Sep 2023 10:05:33 +0800 Subject: [PATCH 05/11] Update index.md --- files/zh-cn/glossary/accent/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/zh-cn/glossary/accent/index.md b/files/zh-cn/glossary/accent/index.md index a4ebc68072e347..31b7bded8a2782 100644 --- a/files/zh-cn/glossary/accent/index.md +++ b/files/zh-cn/glossary/accent/index.md @@ -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)的背景。 ## 参见 From d0cea2e48e0e361db71faf2c0d7926cc1ec5ccb0 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 4 Sep 2023 10:06:09 +0800 Subject: [PATCH 06/11] Update index.md --- files/zh-cn/glossary/accent/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/zh-cn/glossary/accent/index.md b/files/zh-cn/glossary/accent/index.md index 31b7bded8a2782..60ec2907638a9b 100644 --- a/files/zh-cn/glossary/accent/index.md +++ b/files/zh-cn/glossary/accent/index.md @@ -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)的背景。 ## 参见 From 2f278c641215d4aa3e8f28a039e043bca69acdcc Mon Sep 17 00:00:00 2001 From: Allo Date: Fri, 13 Oct 2023 10:12:34 +0800 Subject: [PATCH 07/11] chore(pre-commit-hook): use `fix` instead --- .lintstagedrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 358bfe465b9b02..bb7aed780bfda6 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -3,7 +3,7 @@ "*.md": [ "markdownlint-cli2 --fix", "node ./scripts/check-url-locale.js --fix", - "autocorrect --lint", + "autocorrect --fix", "prettier --write" ] } From 2f5140ae21907126068e55d8a2baf5b2abfb13a6 Mon Sep 17 00:00:00 2001 From: Allo Date: Fri, 13 Oct 2023 10:30:02 +0800 Subject: [PATCH 08/11] chore(ci): merge autocorrect into existing lint/fix system --- .github/workflows/autocorrect-lint.yml | 62 --------------------- .github/workflows/markdown-lint-fix.yml | 1 + .github/workflows/pr-check-lint_content.yml | 3 + package.json | 4 +- 4 files changed, 6 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/autocorrect-lint.yml diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml deleted file mode 100644 index 62f6e9dacf7a78..00000000000000 --- a/.github/workflows/autocorrect-lint.yml +++ /dev/null @@ -1,62 +0,0 @@ -# This workflow to use AutoCorrect tool for checking the copywriting, correct spaces and punctuations for CJK contents. -# -# For example: -# -# - incorrect: "欢迎阅读MDN文档." -# - correct: "欢迎阅读 MDN 文档。" -# -# - incorrect: "Welcome,this is MDN Web Docs。" -# - correct: "Welcome, to read MDN Web Docs." -# -# More details: -# https://github.com/huacnlee/autocorrect -name: AutoCorrect Lint -on: - pull_request: - branches: - - main - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - cache: yarn - - uses: reviewdog/action-setup@v1 - with: - reviewdog_version: v0.14.2 - - - name: Install NPM - run: | - yarn --frozen-lockfile - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get changed files - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BASE_SHA: ${{ github.event.pull_request.base.sha }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }} - run: | - # Use the GitHub API to get the list of changed files - # documenation: https://docs.github.com/rest/commits/commits#compare-two-commits - DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \ - --jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') - # filter out files that are not markdown - DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^(files|docs)/zh-cn/" | xargs) - echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV - - - name: AutoCorrect Lint - if: ${{ env.DIFF_DOCUMENTS }} - run: echo ${{ env.DIFF_DOCUMENTS }} | xargs yarn autocorrect --lint --no-diff-bg-color - - - name: AutoCorrect Lint Reports - if: failure() - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN || secrets.GITHUB_TOKEN }} - run: echo ${{ env.DIFF_DOCUMENTS }} | xargs yarn -s autocorrect --format rdjson --lint | reviewdog -f=rdjson -reporter=github-pr-review diff --git a/.github/workflows/markdown-lint-fix.yml b/.github/workflows/markdown-lint-fix.yml index 61b8eb91770af8..8a6131671a1e22 100644 --- a/.github/workflows/markdown-lint-fix.yml +++ b/.github/workflows/markdown-lint-fix.yml @@ -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 }}" diff --git a/.github/workflows/pr-check-lint_content.yml b/.github/workflows/pr-check-lint_content.yml index 643cfd81a9afd6..5517538fab3494 100644 --- a/.github/workflows/pr-check-lint_content.yml +++ b/.github/workflows/pr-check-lint_content.yml @@ -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} diff --git a/package.json b/package.json index b224b682295d70..1fa4735572f219 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ "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 files docs && 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 files docs && prettier -c \"**/*.md\"", "lint:yml": "prettier -c \"**/*.yml\"", "prepare": "husky install" }, From 78936314f26f6ec18f424ffe8ccd2e689d13c919 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 13 Oct 2023 18:06:03 +0800 Subject: [PATCH 09/11] Update .autocorrectignore Co-authored-by: A1lo --- .autocorrectignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.autocorrectignore b/.autocorrectignore index e3b565edbd2f4b..e172afde0a7792 100644 --- a/.autocorrectignore +++ b/.autocorrectignore @@ -2,8 +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 From e16d71a38c7dbd955c720216fce2b682016abc79 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 13 Oct 2023 18:07:13 +0800 Subject: [PATCH 10/11] Update package.json Co-authored-by: A1lo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1fa4735572f219..6b6c5e4f102d72 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "fix:md": "markdownlint-cli2 --fix \"**/*.md\" && node ./scripts/check-url-locale.js --fix files && yarn autocorrect --fix files docs && 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 && yarn autocorrect --lint files docs && 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" }, From 8240e9f3a3b989cb72dd31926a59a4283f187e98 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 13 Oct 2023 18:07:21 +0800 Subject: [PATCH 11/11] Update package.json Co-authored-by: A1lo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b6c5e4f102d72..44ea6e564b5c1d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "type": "module", "scripts": { "fix:json": "prettier -w \"**/*.json(c)?\"", - "fix:md": "markdownlint-cli2 --fix \"**/*.md\" && node ./scripts/check-url-locale.js --fix files && yarn autocorrect --fix files docs && 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 && yarn autocorrect --lint . && prettier -c \"**/*.md\"",