-
-
Notifications
You must be signed in to change notification settings - Fork 0
add the hook and github action for markdownlint #157
Description
https://www.npmjs.com/package/markdownlint
We need to ensure that all Markdown files (.md, .mdx) in the project follow consistent formatting and style guidelines. This will improve documentation quality, readability, and maintainability.
The setup should include:
• A pre-commit hook via lefthook to run markdownlint locally before pushing.
• A GitHub Action to run markdownlint on pull requests, ensuring consistency across all contributions.
⸻
Technical Plan
- Install markdownlint
We will use markdownlint-cli2 because it is faster and supports glob patterns.
npm install --save-dev markdownlint-cli2
- Configuration file
Create a .markdownlint.jsonc config in the root of the repo:
{
"default": true,
"MD013": false, // Disable line length rule
"MD033": false, // Allow inline HTML
"MD041": false // Allow missing first header
}
- Lefthook pre-commit hook
Update lefthook.yml:
pre-commit:
parallel: true
commands:
markdownlint:
glob: "*.md"
run: npx markdownlint-cli2 {staged_files}
- GitHub Action workflow
Create .github/workflows/markdownlint.yml:
name: Markdown Lint
on:
pull_request:
paths:
- "/*.md"
- "/*.mdx"
jobs:
markdownlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm install
- run: npx markdownlint-cli2 "/*.md" "/*.mdx"
- Add npm script (optional)
In package.json:
{
"scripts": {
"lint:md": "markdownlint-cli2 "/*.md" "/*.mdx""
}
}
⸻
Acceptance Criteria
• markdownlint-cli2 installed as a dev dependency.
• .markdownlint.jsonc configuration file created with agreed rules.
• Lefthook pre-commit hook runs markdownlint on staged Markdown files.
• GitHub Action checks Markdown files on pull requests.
• Any lint violations cause pre-commit or CI to fail.