-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add markdown linting with markdownlint-cli2 #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Markdown Lint | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "**/*.md" | ||
| - "**/*.mdx" | ||
|
|
||
| jobs: | ||
| markdownlint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: 🧩 Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup/node | ||
| with: | ||
| node-version: "22" | ||
| - run: pnpm install | ||
| - run: npx markdownlint-cli2 "**/*.md" "**/*.mdx" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,6 @@ | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "default": true, | ||||||||||||||||||||||||||||
| "MD013": false, | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| "MD013": false, | |
| "MD013": false, | |
| // MD033 (no-inline-html) is disabled to allow inline HTML in markdown files as required by our documentation style. |
Copilot
AI
Aug 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MD041 rule (first-line-heading/first-line-h1) is disabled but not mentioned in the PR description. Consider documenting why this rule is disabled for better maintainability.
| "MD033": false, | |
| "MD033": false, | |
| // MD041 (first-line-heading/first-line-h1) is disabled to allow Markdown files without a top-level heading, as per project documentation conventions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Fix rules to match PR intent (no-bare-urls + asterisk emphasis) and avoid over-disabling.
Current config disables MD033 (no-inline-html) and MD041 (first heading) but PR objectives call for disabling MD034 (no-bare-urls) and setting emphasis style to asterisk. Recommend correcting the rules and adding MD049 configuration.
Apply this diff:
{
"default": true,
"MD013": false,
- "MD033": false,
- "MD041": false
+ "MD034": false,
+ "MD049": { "style": "asterisk" }
}If disabling MD041 was intentional for your docs, keep it alongside the above as needed.
🏁 Script executed:
#!/bin/bash
# Display the current markdownlint config to verify disabled rules
cat .markdownlint.jsoncLength of output: 97
Align markdownlint rules with PR objectives
The current config disables MD033 (inline HTML) and MD041 (first-heading), but the PR intends to disable MD034 (no-bare-urls) and enforce asterisk-based emphasis. Update the config accordingly:
- Remove
"MD033": false - Add
"MD034": false - Add
"MD049": { "style": "asterisk" } - Retain
"MD041": falseif you still want to disable the first-heading rule
{
"default": true,
"MD013": false,
- "MD033": false,
+ "MD034": false,
+ "MD049": { "style": "asterisk" },
"MD041": false
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| { | |
| "default": true, | |
| "MD013": false, | |
| "MD033": false, | |
| "MD041": false | |
| } | |
| { | |
| "default": true, | |
| "MD013": false, | |
| "MD034": false, | |
| "MD049": { "style": "asterisk" }, | |
| "MD041": false | |
| } |
🤖 Prompt for AI Agents
.markdownlint.jsonc around lines 1 to 6: the current config disables MD033 and
MD041 but the PR intends to disable MD034 and enforce asterisk emphasis; remove
the "MD033": false entry, add "MD034": false, add "MD049": { "style": "asterisk"
}, and keep "MD041": false if you still want to disable the first-heading rule
so the file reflects the PR objectives.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,11 @@ | |||||||
| # @ref https://evilmartians.github.io/lefthook/ | ||||||||
|
|
||||||||
| pre-commit: | ||||||||
| parallel: true | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid running pre-commit commands in parallel due to race conditions with file-modifying hooks. With parallel: true, commands like ruler:apply and git update-index can race with others, leading to nondeterministic results and staged content drift. Order also cannot be guaranteed in parallel mode (contradicts “placed before” intent). Apply this diff to run hooks sequentially: pre-commit:
- parallel: true
+ parallel: false📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| commands: | ||||||||
| markdownlint: | ||||||||
| glob: "**/*.{md,mdx}" | ||||||||
| run: npx markdownlint-cli2 {staged_files} | ||||||||
|
Comment on lines
+7
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainUse pnpm exec (or npx --no-install) for deterministic local tool usage. npx without --no-install may fetch arbitrary remote versions. Prefer pnpm exec to use the repo-pinned version. Also keeps behavior consistent with other hooks (e.g., commitlint uses --no-install). Apply this diff: markdownlint:
glob: "**/*.{md,mdx}"
- run: npx markdownlint-cli2 {staged_files}
+ run: pnpm exec markdownlint-cli2 {staged_files}Note: {staged_files} expands to a space-separated list; filenames with spaces could be problematic. If your repo allows such filenames, consider a wrapper script to safely handle arguments or lint via globs and restrict to staged via lefthook’s file list piping. 🏁 Script executed: #!/bin/bash
# Verify that pnpm is the package manager (pnpm-lock.yaml exists)
echo "=== Checking for pnpm-lock.yaml ==="
fd pnpm-lock.yaml || echo "pnpm-lock.yaml not found"
echo ""
# Show lefthook.yml entries for markdownlint and commitlint
echo "=== Extracting markdownlint and commitlint hooks from lefthook.yml ==="
rg -n 'markdownlint:|commitlint:' -C3 -t yml lefthook.yml || echo "No matches found"Length of output: 408 🏁 Script executed: #!/bin/bash
# Extract markdownlint and commitlint sections from lefthook.yml
echo "=== Lefthook: markdownlint hook ==="
rg -n 'markdownlint:' -C5 lefthook.yml || echo "✗ markdownlint section not found"
echo ""
echo "=== Lefthook: commitlint hook ==="
rg -n 'commitlint:' -C5 lefthook.yml || echo "✗ commitlint section not found"
echo ""
# Check for any filenames with spaces in the repo
echo "=== Checking for files with spaces in their names ==="
find . -not -path "./.git/*" -type f -name "* *" | head -n 5 || echo "✓ No files with spaces found (up to 5 shown)"Length of output: 830 Use
Apply this change in lefthook.yml: markdownlint:
glob: "**/*.{md,mdx}"
- run: npx markdownlint-cli2 {staged_files}
+ run: pnpm exec markdownlint-cli2 {staged_files}🤖 Prompt for AI Agents |
||||||||
| generate_structure_docs: | ||||||||
| run: ./scripts/generate-structure-docs.sh | ||||||||
| biome: | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ | |
| "test:ui": "pnpm --recursive run test:ui", | ||
| "test:coverage": "pnpm --recursive run test:coverage", | ||
| "lint": "pnpm --recursive --parallel run lint", | ||
| "lint:md": "markdownlint-cli2 \"**/*.md\" \"**/*.mdx\"", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Deduplicate command definitions across CI and hooks by reusing the script. Both the workflow and pre-commit hook shell out to markdownlint-cli2 with the same globs. Prefer a single source of truth to avoid drift.
I can push a patch across files if you prefer. 🤖 Prompt for AI Agents |
||
| "lint:strict": "pnpm --recursive --parallel run lint:strict", | ||
| "check": "pnpm run -r check && biome check . --write", | ||
| "clean": "pnpm --recursive run clean", | ||
|
|
@@ -70,10 +71,17 @@ | |
| "@commitlint/cli": "^19.8.1", | ||
| "@commitlint/config-conventional": "^19.8.1", | ||
| "lefthook": "^1.12.2", | ||
| "markdownlint-cli2": "^0.18.1", | ||
| "npm-run-all2": "^8.0.4", | ||
| "rimraf": "^6.0.1", | ||
| "tree-extended": "^4.6.0", | ||
| "vite": "^7.0.6", | ||
| "vitest": "^3.2.4" | ||
| "vitest": "^3.2.4", | ||
| "@types/node": "22.17.2" | ||
| }, | ||
| "pnpm": { | ||
| "overrides": { | ||
| "@types/node": "22.17.2" | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Use the package script or pnpm exec for consistency and version pinning.
Avoid npx fetching a different version at runtime. Reuse the script or invoke via pnpm exec.
Apply one of:
or
Also, confirm the local action ./.github/actions/setup/node supports Node 22 and sets up pnpm caching; if not, consider using actions/setup-node with pnpm/action-setup and a cache key on pnpm-store.
🏁 Script executed:
Length of output: 1414
🏁 Script executed:
Length of output: 2470
🏁 Script executed:
Length of output: 582
Update Markdown workflow to use frozen lockfile and existing lint script
For reproducible installs and pinned linting, replace the install and npx steps with your package script:
• File:
.github/workflows/markdownlint.ymlReplace lines 18–19:
The local
.github/actions/setup/nodeaction already pins Node 22 and configures pnpm caching, so no changes are needed there.📝 Committable suggestion
🤖 Prompt for AI Agents