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" },