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 MarkdownLint CLI checker #1366

Merged
merged 1 commit into from Feb 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -10,6 +10,7 @@
- Jsonnet with ``jsonnet`` [GH-1345]
- Tcl with ``nagelfar`` [GH-1365]
- CWL with ``schema-salad-tool`` [GH-1361]
- MarkdownLint CLI with ``markdownlint`` [GH-1366]

- New features:

Expand Down
1 change: 1 addition & 0 deletions Vagrantfile
Expand Up @@ -163,6 +163,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
Expand Up @@ -723,6 +723,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>`_.

.. syntax-checker-config-file:: 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
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 @@ -8940,6 +8941,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 . "32"))

(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
Expand Up @@ -3806,6 +3806,14 @@ Why not:
)
)

(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