-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into frontmatter-linter
- Loading branch information
Showing
5,003 changed files
with
67,857 additions
and
76,967 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
files/ | ||
docs/ | ||
!files/zh-cn/ | ||
_wikihistory.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
textRules: | ||
一二三,四五六.七八九: 0 | ||
一二三,四五六,七八九,一二三,四五六,七八九: 0 | ||
# sorted by `LC_ALL=C sort` command | ||
9.9亿: 0 | ||
一二三,四五六,七八九,一二三,四五六,七八九: 0 | ||
一二三,四五六.七八九: 0 | ||
我,爱,巧克力,青蛙: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
name: Lint and review content files | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
- main | ||
paths: | ||
- "**/*.md" | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
lint-and-review-docs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout BASE | ||
uses: actions/checkout@v3 | ||
|
||
- name: Checkout HEAD | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
path: pr_head | ||
|
||
- name: Get changed content from HEAD | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "mdn-bot" | ||
rm -r files docs *.md | ||
mv pr_head/files pr_head/docs pr_head/*.md . | ||
rm -r pr_head | ||
# To avoid contents of PR getting into the diff that we are going to generate | ||
# after running the linters, here we make a dummy commit. | ||
# Note, this commit is not getting pushed. | ||
git add . | ||
git commit -m "Code from PR head" | ||
- 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 | ||
# documentation: 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 ".*\.md$" | xargs) | ||
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV | ||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: yarn | ||
|
||
- name: Install all yarn packages | ||
run: yarn --frozen-lockfile | ||
|
||
- name: Lint and format markdown files | ||
if: ${{ env.DIFF_DOCUMENTS }} | ||
run: | | ||
# Generate random delimiter | ||
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings | ||
EOF="$(openssl rand -hex 8)" | ||
files_to_lint="${{ env.DIFF_DOCUMENTS }}" | ||
echo "Running markdownlint --fix" | ||
MD_LINT_FAILED=false | ||
MD_LINT_LOG=$(yarn markdownlint-cli2 --fix ${files_to_lint} 2>&1) || MD_LINT_FAILED=true | ||
echo "MD_LINT_LOG<<${EOF}" >> $GITHUB_ENV | ||
echo "${MD_LINT_LOG}" >> $GITHUB_ENV | ||
echo "${EOF}" >> $GITHUB_ENV | ||
echo "MD_LINT_FAILED=${MD_LINT_FAILED}" >> $GITHUB_ENV | ||
echo "Running Prettier" | ||
yarn prettier -w ${files_to_lint} | ||
if [[ -n $(git diff) ]]; then | ||
echo "FILES_MODIFIED=true" >> $GITHUB_ENV | ||
fi | ||
# info for troubleshooting | ||
echo MD_LINT_FAILED=${MD_LINT_FAILED} | ||
git diff | ||
- name: Setup reviewdog | ||
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true' | ||
uses: reviewdog/action-setup@v1 | ||
with: | ||
reviewdog_version: latest | ||
|
||
- name: Suggest changes using diff | ||
if: env.FILES_MODIFIED == 'true' | ||
env: | ||
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
TMPFILE=$(mktemp) | ||
git diff >"${TMPFILE}" | ||
git stash -u && git stash drop | ||
reviewdog \ | ||
-name="mdn-linter" \ | ||
-f=diff \ | ||
-f.diff.strip=1 \ | ||
-reporter=github-pr-review < "${TMPFILE}" | ||
- name: Add reviews for markdownlint errors | ||
if: env.MD_LINT_FAILED == 'true' | ||
env: | ||
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "${{ env.MD_LINT_LOG }}" | \ | ||
reviewdog \ | ||
-efm="%f:%l:%c %m" \ | ||
-efm="%f:%l %m" \ | ||
-name="markdownlint" \ | ||
-diff="git diff" \ | ||
-reporter="github-pr-review" | ||
- name: Fail if any issues pending | ||
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true' | ||
run: | | ||
echo -e "\nLogs from markdownlint:" | ||
echo "${{ env.MD_LINT_LOG }}" | ||
echo -e "\nPlease fix all the linting issues mentioned in above logs and in the review comments." | ||
exit 1 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"*": "prettier --ignore-unknown --write", | ||
"*.md": "markdownlint-cli2-fix" | ||
"!*.md": "prettier --ignore-unknown --write", | ||
"*.md": ["markdownlint-cli2 --fix", "prettier --write"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.