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 sphinx-lint support #696

Merged
merged 1 commit into from
Nov 18, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Other dedicated linters that are built-in are:
| [snyk][snyk] | `snyk_iac` |
| [Solhint][solhint] | `solhint` |
| [Spectral][spectral] | `spectral` |
| [sphinx-lint][sphinx-lint] | `sphinx-lint` |
| [sqlfluff][sqlfluff] | `sqlfluff` |
| [standardjs][standardjs] | `standardjs` |
| [StandardRB][27] | `standardrb` |
Expand Down Expand Up @@ -551,6 +552,7 @@ busted tests/
[snakemake]: https://snakemake.github.io
[snyk]: https://github.com/snyk/cli
[spectral]: https://github.com/stoplightio/spectral
[sphinx-lint]: https://github.com/sphinx-contrib/sphinx-lint
[gitlint]: https://github.com/jorisroovers/gitlint
[pflake8]: https://github.com/csachs/pyproject-flake8
[fish]: https://github.com/fish-shell/fish-shell
Expand Down
12 changes: 12 additions & 0 deletions lua/lint/linters/sphinx-lint.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local efm = '%f:%l: %m'

return {
cmd = 'sphinx-lint',

stream = 'stderr',
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat(efm, {
source = 'sphinx-lint',
severity = vim.diagnostic.severity.WARN,
}),
}
35 changes: 35 additions & 0 deletions spec/sphinx-lint_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
describe('linter.sphinx-lint', function()
it('can parse the output', function()
local parser = require('lint.linters.sphinx-lint').parser
local bufnr = vim.uri_to_bufnr('file:///foo.rst')
local result = parser([[
/foo.rst:42: trailing whitespace (trailing-whitespace)
/foo.rst:420: missing space before default role: beep boop (missing-space-before-default-role)
]], bufnr)

assert.are.same(2, #result)

local expected_error = {
source = 'sphinx-lint',
message = 'trailing whitespace (trailing-whitespace)',
lnum = 41,
col = 0,
end_lnum = 41,
end_col = 0,
severity = vim.diagnostic.severity.WARN,
}
assert.are.same(expected_error, result[1])

expected_error = {
source = 'sphinx-lint',
message = 'missing space before default role: beep boop (missing-space-before-default-role)',
lnum = 419,
col = 0,
end_lnum = 419,
end_col = 0,
severity = vim.diagnostic.severity.WARN,
}
assert.are.same(expected_error, result[2])

end)
end)
Loading