branch: elpa/flycheck
commit 5840540ea8d7dd051ca65921b859cdb6c4404f2f
Author: Bozhidar Batsov <bozhi...@batsov.dev>
Commit: Bozhidar Batsov <bozhi...@batsov.dev>

    Add markdownlint-cli2 checker
---
 CHANGES.rst       |  1 +
 doc/languages.rst |  8 ++++++++
 flycheck.el       | 29 +++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/CHANGES.rst b/CHANGES.rst
index 324a8269ec..f64acefd32 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -18,6 +18,7 @@ New Features
   customize how error messages are to be cleared.
 - [#2075]: Add the ``flycheck-chktex-extra-flags`` option to the 
``tex-chktex`` checker.
 - [#2107]: Add ``-Xcompiler`` option for ``cuda-nvcc``.
+- Add support for ``markdownlint-cli2`` checker.
 
 -----------
 Bugs fixed
diff --git a/doc/languages.rst b/doc/languages.rst
index dd7bec1b8f..46c9031342 100644
--- a/doc/languages.rst
+++ b/doc/languages.rst
@@ -853,6 +853,14 @@ to view the docstring of the syntax checker.  Likewise, 
you may use
 
          A list of enabled rules.
 
+   .. syntax-checker:: markdown-markdownlint-cli2
+
+      Check Markdown with markdownlint-cli2_.
+
+      .. _markdownlint-cli2: https://github.com/DavidAnson/markdownlint-cli2
+
+      .. syntax-checker-config-file:: 
flycheck-markdown-markdownlint-cli2-config
+
    .. syntax-checker:: markdown-mdl
 
       Check Markdown with markdownlint_ (a.k.a. ``mdl``).
diff --git a/flycheck.el b/flycheck.el
index 98abb04f57..333d63acf7 100644
--- a/flycheck.el
+++ b/flycheck.el
@@ -11300,6 +11300,35 @@ See URL 
`https://github.com/igorshubovych/markdownlint-cli'."
           (url 
"https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#%s";))
       (and error-code `(url . ,(format url error-code))))))
 
+(flycheck-def-config-file-var flycheck-markdown-markdownlint-cli2-config
+    markdown-markdownlint-cli2
+    '(".markdownlint-cli2.json" ".markdownlint-cli2.jsonc" 
".markdownlint-cli2.yaml")
+  :package-version '(flycheck . "35"))
+
+(flycheck-define-checker markdown-markdownlint-cli2
+  "Markdown checker using markdownlint-cli2.
+
+See URL `https://github.com/DavidAnson/markdownlint-cli2'."
+  :command ("markdownlint-cli2"
+            (config-file "--config" flycheck-markdown-markdownlint-cli2-config)
+            "--"
+            source)
+  :error-patterns
+  ((error line-start
+          (file-name) ":" line
+          (? ":" column) " " (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)
+  :error-explainer
+  (lambda (err)
+    (let ((error-code (substring (flycheck-error-id err) 0 5))
+          (url 
"https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#%s";))
+      (and error-code `(url . ,(format url error-code))))))
+
 (flycheck-def-option-var flycheck-markdown-mdl-rules nil markdown-mdl
   "Rules to enable for mdl.
 

Reply via email to