Skip to content

Commit d41c5d5

Browse files
authored
Merge 07de5c4 into f5bab9d
2 parents f5bab9d + 07de5c4 commit d41c5d5

File tree

3 files changed

+79
-5
lines changed

3 files changed

+79
-5
lines changed

.github/workflows/lint.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Linting
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
lint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
22+
# This identifies which files changed in the specific commit or PR
23+
- uses: tj-actions/changed-files@v47
24+
id: changed-files
25+
with:
26+
files: '**/*.md'
27+
separator: ","
28+
29+
# This runs the linter ONLY on the files identified above
30+
- uses: DavidAnson/markdownlint-cli2-action@v22
31+
if: steps.changed-files.outputs.any_changed == 'true'
32+
with:
33+
globs: ${{ steps.changed-files.outputs.all_changed_files }}
34+
separator: ","
35+
fix: true
36+
37+
# Check if anything was fixed, then Commit & Push
38+
- name: Commit and push fixes
39+
if: always() && steps.changed-files.outputs.any_changed == 'true'
40+
run: |
41+
# Configure the bot's identity
42+
git config --global user.name "github-actions[bot]"
43+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
44+
45+
# Check if the linter modified any files
46+
if [[ -n $(git status -s) ]]; then
47+
git add .
48+
git commit -m "style: auto-fix markdown formatting"
49+
git push origin HEAD:${{ github.head_ref }}
50+
fi

CONTRIBUTING.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ chore: update mkdocs dependencies
177177

178178
### Linting
179179

180-
The project uses [markdownlint](https://github.com/DavidAnson/markdownlint) with configuration in `.markdownlint.json`. Key settings:
180+
The project uses [markdownlint](https://github.com/DavidAnson/markdownlint) with configuration in `.markdownlint.json`.
181+
182+
**Automated Checks:**
183+
We have a GitHub Action that checks for formatting errors on Pull Requests. To avoid flagging legacy issues, **it only checks files that you have modified.**
184+
185+
**Key Rules:**
181186

182187
- 4-space indentation for lists (`MD007`).
183188
- No hard tab restrictions disabled.
@@ -186,13 +191,19 @@ The project uses [markdownlint](https://github.com/DavidAnson/markdownlint) with
186191
- Allowed code blocks without language specification (`MD040`).
187192
- Allow fenced code blocks, as this commonly errors when indented (see [discussion](https://github.com/DavidAnson/markdownlint/issues/327)).
188193

189-
For faster PR review, you may want to run linting locally; we do have a PR Action in place as well. First install markdownlint, then run
194+
**Local Testing**
195+
For faster PR review, you may want to run linting locally. We recommend installing `markdownlint-cli2` or the VS Code extension.
190196

191-
```console
192-
markdownlint -c .markdownlint.json -f docs/wiki-guide/
197+
```bash
198+
# Install
199+
npm install markdownlint-cli2 --global
200+
# Run on the specific file you are editing
201+
markdownlint-cli2 "docs/path/to/your/file.md"
202+
# Fix simple errors automatically
203+
markdownlint-cli2 --fix "docs/path/to/your/file.md"
193204
```
194205

195-
The `-f` resolves simple formatting issues, and alerts will be raised for more complicated linter style rules (e.g., referencing a link as `[here](URL)` will produce the line: `<filename>.md:191:2 MD059/descriptive-link-text Link text should be descriptive [Context: "[here]"]`).
206+
The `--fix` resolves simple formatting issues, and alerts will be raised for more complicated linter style rules (e.g., referencing a link as `[here](URL)` will produce the line: `<filename>.md:191:2 MD059/descriptive-link-text Link text should be descriptive [Context: "[here]"]`).
196207

197208
### Content Review
198209

lint-fail-test.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#Auto-Fixable Header (No space after hash)
2+
3+
This paragraph has trailing spaces at the end.
4+
5+
# Duplicate Header
6+
Content A
7+
8+
# Duplicate Header
9+
Content B (Linter won't be able to fix the duplicate header but should point it out)
10+
11+
<div class="error">
12+
Inline HTML is also not auto-fixable
13+
</div>

0 commit comments

Comments
 (0)