Skip to content

Commit

Permalink
Add MarkdownLint CLI checker
Browse files Browse the repository at this point in the history
Adds support for the MarkdownLint Command Line Interface based on the
Node.js markdownlint package.

 - https://github.com/igorshubovych/markdownlint-cli
  • Loading branch information
dholm committed Nov 26, 2017
1 parent d309432 commit f2451c5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ Vagrant.configure("2") do |config|
jshint \
eslint \
jscs \
markdownlint-cli \
standard \
semistandard \
jsonlint \
Expand Down
8 changes: 8 additions & 0 deletions doc/languages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,14 @@ to view the docstring of the syntax checker. Likewise, you may use

.. supported-language:: Markdown

.. syntax-checker:: markdown-markdownlint-cli

Check Markdown with `markdownlint <https://github.com/igorshubovych/markdownlint-cli>`_.

.. defcustom:: flycheck-markdown-markdownlint-cli-config

Path to configuration file.

.. syntax-checker:: markdown-mdl

Check Markdown with `markdownlint <https://github.com/mivok/markdownlint/>`_.
Expand Down
23 changes: 23 additions & 0 deletions flycheck.el
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ attention to case differences."
r-lintr
racket
rpm-rpmlint
markdown-markdownlint-cli
markdown-mdl
nix
rst-sphinx
Expand Down Expand Up @@ -8949,6 +8950,28 @@ See URL `https://sourceforge.net/projects/rpmlint/'."
;; In `sh-mode', we need the proper shell
(eq sh-shell 'rpm))))

(flycheck-def-config-file-var flycheck-markdown-markdownlint-cli-config
markdown-markdownlint-cli nil
:safe #'stringp
:package-version '(flycheck . "31"))

(flycheck-define-checker markdown-markdownlint-cli
"Markdown checker using markdownlint-cli.
See URL `https://github.com/igorshubovych/markdownlint-cli'."
:command ("markdownlint"
(config-file "--config" flycheck-markdown-markdownlint-cli-config)
source)
:error-patterns
((error line-start
(file-name) ": " line ": " (id (one-or-more (not (any space))))
" " (message) line-end))
:error-filter
(lambda (errors)
(flycheck-sanitize-errors
(flycheck-remove-error-file-names "(string)" errors)))
:modes (markdown-mode gfm-mode))

(flycheck-def-option-var flycheck-markdown-mdl-rules nil markdown-mdl
"Rules to enable for mdl.
Expand Down
8 changes: 8 additions & 0 deletions test/flycheck-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -3833,6 +3833,14 @@ Why not:
:checker rpm-rpmlint)
'(22 nil warning "macro-in-%changelog %{_bindir}" :checker rpm-rpmlint)))

(flycheck-ert-def-checker-test markdown-markdownlint-cli markdown nil
(flycheck-ert-should-syntax-check
"language/markdown.md" 'markdown-mode
'(1 nil error "First header should be a top level header [Expected: h1; Actual: h2]"
:id "MD002/first-header-h1" :checker markdown-markdownlint-cli)
'(1 nil error "First line in file should be a top level header [Context: "## Second Header First"]"
:id "MD041/first-line-h1" :checker markdown-markdownlint-cli)))

(flycheck-ert-def-checker-test markdown-mdl markdown nil
(flycheck-ert-should-syntax-check
"language/markdown.md" 'markdown-mode
Expand Down

0 comments on commit f2451c5

Please sign in to comment.