mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-26 01:36:03 +03:00
[GH-ISSUE #197] Enable linting code blocks in Markdown content with external tools like eslint and flake8 #2017
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2017
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @proofit404 on GitHub (Jun 12, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/197
Hi, thanks for an awesome package!
I wonder if there is any possibility to integrate somehow
markdownlintwith external tools likeeslint,flake8orrubocopto lint code examples written in the markdown document?No pressure at all, I'm just asking if there is an internal API available I can use to write such plugins myself.
Best regards, Artem.
@DavidAnson commented on GitHub (Jun 12, 2019):
Yes, that should be possible!
There are examples of calling the
markdownlintAPI directly, as well as from Grunt and Gulp in the README: https://github.com/DavidAnson/markdownlint/blob/master/README.md#usageIf you can get the other tool(s) to flag chunks of Markdown content they encounter, you can lint that as
stringsinput like in the examples above.@DavidAnson commented on GitHub (Jun 12, 2019):
Oh, wait, you are asking about the reverse! That would take a bit of work on my part. I’ll look into this for a future release. Thanks!
@proofit404 commented on GitHub (Jun 12, 2019):
Cool! Thanks!
@DavidAnson commented on GitHub (Jul 31, 2019):
I realized the best way to do this was with a custom rule (vs. modifying the library as I'd first considered). So I wrote a custom rule example that runs ESLint against any JavaScript code fences in Markdown. There's a lot more this rule could do (and I may expand upon it in the future), but it shows how to accomplish the task in a reasonable manner and you should be able to translate it to other tools pretty easily. Hope it helps!
@DavidAnson commented on GitHub (Jul 31, 2019):
Direct link from the commit above:
github.com/DavidAnson/markdownlint@4d11e60cfe/test/rules/lint-javascript.js