Skip to content

Commit

Permalink
markdownlint: use stdin (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
xudyang1 authored Sep 22, 2024
1 parent 6487452 commit 968a35d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 37 deletions.
20 changes: 11 additions & 9 deletions lua/lint/linters/markdownlint.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
local efm = '%f:%l:%c %m,%f:%l %m'
local is_windows = vim.loop.os_uname().version:match('Windows')
local efm = "stdin:%l:%c %m,stdin:%l %m"
local is_windows = vim.loop.os_uname().version:match("Windows")
return {
cmd = is_windows and 'markdownlint.cmd' or 'markdownlint',
ignore_exitcode = true,
stream = 'stderr',
parser = require('lint.parser').from_errorformat(efm, {
source = 'markdownlint',
severity = vim.diagnostic.severity.WARN,
})
cmd = is_windows and "markdownlint.cmd" or "markdownlint",
stdin = true,
args = { "--stdin" },
ignore_exitcode = true,
stream = "stderr",
parser = require("lint.parser").from_errorformat(efm, {
source = "markdownlint",
severity = vim.diagnostic.severity.WARN,
}),
}
56 changes: 28 additions & 28 deletions tests/markdownlint_spec.lua
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
describe('linter.markdownlint', function()
it('can parse the output', function()
local parser = require('lint.linters.markdownlint').parser
describe("linter.markdownlint", function()
it("can parse the output", function()
local parser = require("lint.linters.markdownlint").parser
local result = parser([[
README.md:35 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## What's in this repo?"]
README.md:36 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- `dotfiles`"]
README.md:47:81 MD013/line-length Line length [Expected: 80; Actual: 114]
README.md:55:81 MD013/line-length Line length [Expected: 80; Actual: 244]
stdin:35 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## What's in this repo?"]
stdin:36 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- `dotfiles`"]
stdin:47:81 MD013/line-length Line length [Expected: 80; Actual: 114]
stdin:55:81 MD013/line-length Line length [Expected: 80; Actual: 244]
]])
assert.are.same(4, #result)
local expected = {
source = 'markdownlint',
message = 'MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## What\'s in this repo?"]',
lnum = 34,
col = 0,
end_lnum = 34,
end_col = 0,
severity = vim.diagnostic.severity.WARN,
}
assert.are.same(expected, result[1])
assert.are.same(4, #result)
local expected = {
source = "markdownlint",
message = 'MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## What\'s in this repo?"]',
lnum = 34,
col = 0,
end_lnum = 34,
end_col = 0,
severity = vim.diagnostic.severity.WARN,
}
assert.are.same(expected, result[1])

expected = {
source = 'markdownlint',
message = 'MD013/line-length Line length [Expected: 80; Actual: 114]',
lnum = 46,
col = 80,
end_lnum = 46,
end_col = 80,
severity = vim.diagnostic.severity.WARN,
}
assert.are.same(expected, result[3])
expected = {
source = "markdownlint",
message = "MD013/line-length Line length [Expected: 80; Actual: 114]",
lnum = 46,
col = 80,
end_lnum = 46,
end_col = 80,
severity = vim.diagnostic.severity.WARN,
}
assert.are.same(expected, result[3])
end)
end)

0 comments on commit 968a35d

Please sign in to comment.