-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: sync Markdownlint setup from mdn/content (#8181)
- Loading branch information
Showing
11 changed files
with
955 additions
and
111 deletions.
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Create Markdownlint auto-fix PR | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
fix: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
lang: | ||
- es | ||
- fr | ||
- ja | ||
- ko | ||
- pt-br | ||
- ru | ||
- zh-cn | ||
- zh-tw | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16" | ||
cache: yarn | ||
|
||
- name: Install all yarn packages | ||
env: | ||
HUSKY: 0 | ||
run: | | ||
yarn --frozen-lockfile | ||
- name: Lint markdown files | ||
run: | | ||
yarn markdownlint-cli2-fix "**/${{ matrix.lang }}/**/*.md" | ||
- name: Create PR with only fixable issues | ||
if: success() | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
commit-message: "${{ matrix.lang }}: auto-fix Markdownlint issues" | ||
branch: markdownlint-auto-cleanup-${{ matrix.lang }} | ||
title: "Markdownlint auto-cleanup for ${{ matrix.lang }}" | ||
author: mdn-bot <[email protected]> | ||
body: | | ||
All issues auto-fixed | ||
- name: Create PR with notice on unfixed issues | ||
if: failure() | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
commit-message: "${{ matrix.lang }}: auto-fix Markdownlint issues" | ||
branch: markdownlint-auto-cleanup-${{ matrix.lang }} | ||
title: "Markdownlint auto-cleanup for ${{ matrix.lang }}" | ||
author: mdn-bot <[email protected]> | ||
body: | | ||
Auto-fix was run, but additional issues found. | ||
Please review the run log: https://github.com/mdn/translated-content/actions/runs/${{ github.run_id }} |
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
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,18 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "markdownlint", | ||
"severity": "warning", | ||
"pattern": [ | ||
{ | ||
"regexp": "^([^:]*):(\\d+):?(\\d+)?\\s([\\w-\\/]*)\\s(.*)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"code": 4, | ||
"message": 5 | ||
} | ||
] | ||
} | ||
] | ||
} |
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,38 @@ | ||
name: Markdownlint (PR files) | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- "**/*.md" | ||
|
||
jobs: | ||
docs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v34 | ||
with: | ||
files: | | ||
**/*.md | ||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16" | ||
cache: yarn | ||
|
||
- name: Install all yarn packages | ||
run: | | ||
yarn --frozen-lockfile | ||
- name: Lint markdown files | ||
run: | | ||
echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json" | ||
files_to_lint="${{ steps.changed-files.outputs.all_changed_files }}" | ||
yarn markdownlint-cli2 ${files_to_lint} |
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
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
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,3 @@ | ||
{ | ||
"*.md": "markdownlint-cli2-fix" | ||
} |
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,134 @@ | ||
{ | ||
"config": { | ||
"default": true, | ||
// MD001 - Heading levels should only increment by one level at a time. | ||
// -> Disabled, as some callouts include headings. | ||
"MD001": false, | ||
"MD004": { | ||
"style": "dash" | ||
}, | ||
"MD007": { | ||
"indent": 2 | ||
}, | ||
"MD010": { | ||
"spaces_per_tab": 2 | ||
}, | ||
"MD013": false, | ||
// Fixed upstream, needs PRs in this repo | ||
"MD023": false, | ||
// Fixed upstream with "allow_different_nesting": true | ||
"MD024": false, | ||
"MD025": { | ||
"front_matter_title": "^\\s*title\\s*[:=]" | ||
}, | ||
"MD026": false, | ||
// Consecutive Notes/Callouts currently don't conform with this rule | ||
"MD028": false, | ||
// Force ordered numbering to catch accidental list ending from indenting | ||
"MD029": { | ||
"style": "ordered" | ||
}, | ||
"MD033": { | ||
"allowed_elements": [ | ||
"a", | ||
"abbr", | ||
"annotation", | ||
"base", | ||
"br", | ||
"caption", | ||
"code", | ||
"col", | ||
"colgroup", | ||
"dd", | ||
"details", | ||
"dfn", | ||
"div", | ||
"dl", | ||
"dt", | ||
"em", | ||
"h4", | ||
"h5", | ||
"img", | ||
"kbd", | ||
"li", | ||
"math", | ||
"menclose", | ||
"mfenced", | ||
"mfrac", | ||
"mfrac", | ||
"mi", | ||
"mmultiscripts", | ||
"mn", | ||
"mo", | ||
"mover", | ||
"mphantom", | ||
"mprescripts", | ||
"mroot", | ||
"mrow", | ||
"ms", | ||
"mspace", | ||
"mspace", | ||
"msqrt", | ||
"mstyle", | ||
"msub", | ||
"msubsup", | ||
"msup", | ||
"mtable", | ||
"mtd", | ||
"mtext", | ||
"mtr", | ||
"munder", | ||
"munderover", | ||
"none", | ||
"ol", | ||
"p", | ||
"pre", | ||
"section", | ||
"semantics", | ||
"strong", | ||
"sub", | ||
"summary", | ||
"sup", | ||
"table", | ||
"tbody", | ||
"td", | ||
"tfoot", | ||
"th", | ||
"thead", | ||
"tr", | ||
"ul", | ||
"var", | ||
"ruby", //Used in some Korean documents | ||
"rp", //Used in some Korean documents | ||
"rt", //Used in some Korean documents | ||
"i", // French translations use this for English literal text | ||
"q", // French translations use this for English literal text | ||
"h2", // Not always converted currently because of live samples using English IDs | ||
"h3", // Not always converted currently because of live samples using English IDs | ||
"h6" // Not always converted currently because of live samples using English IDs | ||
] | ||
}, | ||
// Fixed upstream, needs PRs in this repo | ||
"MD036": false, | ||
// Upstream fixing in https://github.com/mdn/content/pull/20115 | ||
"MD037": false, | ||
"MD040": false, | ||
// See https://github.com/mdn/content/pull/20026, as macros currently break this | ||
"MD042": false, | ||
// Tracked upstream as part of https://github.com/mdn/content/pull/19334 | ||
"MD045": false, | ||
"MD046": { | ||
"style": "fenced" | ||
}, | ||
// MD049 is set to underscore upstream, not yet fixed here | ||
"MD049": false, | ||
// MD050 is set to asterisk upstream, not yet fixed here | ||
"MD050": false, | ||
// MD051 - Link fragments should be valid. | ||
// -> Disabled, as yari generates link fragments by replacing spaces with underscores, not dashes. | ||
"MD051": false, | ||
// Incompatible with brackets in macros like MD042 | ||
"MD052": false | ||
}, | ||
"ignores": ["node_modules", "**/conflicting/**", "**/orphaned/**", ".github/", "files/**/web/api/window/frames/index.md"] | ||
} |
Oops, something went wrong.