Skip to content
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

Add pre-commit linking using markdownlint-cli2 #194

Open
ns-rse opened this issue Sep 5, 2024 · 0 comments · May be fixed by #195
Open

Add pre-commit linking using markdownlint-cli2 #194

ns-rse opened this issue Sep 5, 2024 · 0 comments · May be fixed by #195

Comments

@ns-rse
Copy link

ns-rse commented Sep 5, 2024

Further to #191 it might be useful to implement a pre-commit hook for markdownlint-cli2 and combine it with a pre-commit.ci.

This would...

  1. Lint markdown before commits are made.
  2. Automatically fix issues in markdown before commits/pull requests are made.
  3. Check Pull Requests to documentation files (*.md and doc/**/*.md) are correctly linted if contributors haven't used pre-commit hooks locally.

.pre-commit-config.yaml...

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: check-added-large-files

 - repo: https://github.com/DavidAnson/markdownlint-cli2
   rev: v0.13.0
   hooks:
     - id: markdownlint-cli2
       args: []

ci:
 autofix_prs: true
 autofix_commit_msg: '[pre-commit.ci] Fixing issues with pre-commit'
 autoupdate_schedule: weekly
 autoupdate_commit_msg: '[pre-commit.ci] pre-commit-autoupdate'
 skip: [] # Optionally list ids of hooks to skip on CI

.markdownlint-cli2.yaml

A basic configuration file is below, a full list of customisable linting rules can be found here

config:

# MD013 - line-length
  line_length:
    line_length: 80
    code_blocks: false
    tables: false
  html:
    allowed_elements:
      - div

globs:

- "docs/**/*.md"
- "*.md"

fix: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant