From bcd1a79e28c8ce42526b9e8f6e61902c519cf5af Mon Sep 17 00:00:00 2001 From: Allo Date: Wed, 27 Sep 2023 13:44:49 +0800 Subject: [PATCH] feat(ci): add url locale checker --- .github/workflows/markdown-lint-fix.yml | 1 + .github/workflows/pr-check-lint_content.yml | 3 +++ .lintstagedrc.json | 6 +++++- package.json | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/markdown-lint-fix.yml b/.github/workflows/markdown-lint-fix.yml index a4c61716934478..a5a0457b732e16 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" yarn prettier -w "**/${{ matrix.lang }}/**/*.md" + node ./scripts/check-url-locale.js --fix "files/${{ matrix.lang }}" cd ${{ github.workspace }}/mdn/content && yarn fix:fm --config-file ${{ github.workspace }}/front-matter-config.json "${{ github.workspace }}/files/${{ matrix.lang }}" - name: Create PR with only fixable issues diff --git a/.github/workflows/pr-check-lint_content.yml b/.github/workflows/pr-check-lint_content.yml index 58efde6c04bc8e..4af5e3e8ee347f 100644 --- a/.github/workflows/pr-check-lint_content.yml +++ b/.github/workflows/pr-check-lint_content.yml @@ -117,6 +117,9 @@ jobs: echo "Running Prettier" yarn prettier -w ${files_to_lint} + echo "Running url locale checker" + node ./scripts/check-url-locale.js --fix ${files_to_lint} + if [[ -n $(git diff) ]]; then echo "FILES_MODIFIED=true" >> $GITHUB_ENV fi diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 5b4d530600839f..9ab66a80d45e26 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,4 +1,8 @@ { "!*.md": "prettier --ignore-unknown --write", - "*.md": ["markdownlint-cli2 --fix", "prettier --write"] + "*.md": [ + "markdownlint-cli2 --fix", + "prettier --write", + "node ./scripts/check-url-locale.js --fix" + ] } diff --git a/package.json b/package.json index b9da0c4b53b266..9880a42a1605ba 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\" && prettier -w \"**/*.md\"", + "fix:md": "markdownlint-cli2 --fix \"**/*.md\" && prettier -w \"**/*.md\" && node ./scripts/check-url-locale.js --fix files", "fix:yml": "prettier -w \"**/*.yml\"", "lint:json": "prettier -c \"**/*.json(c)?\"", - "lint:md": "markdownlint-cli2 \"**/*.md\" && prettier -c \"**/*.md\"", + "lint:md": "markdownlint-cli2 \"**/*.md\" && prettier -c \"**/*.md\" && node ./scripts/check-url-locale.js files", "lint:yml": "prettier -c \"**/*.yml\"", "prepare": "husky install" },