Skip to content

Commit

Permalink
feat(gitlint): add gitlint linter
Browse files Browse the repository at this point in the history
  • Loading branch information
pbnj committed Oct 13, 2023
1 parent 0f54481 commit 664f353
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Other dedicated linters that are built-in are:
| [Flake8][13] | `flake8` |
| [flawfinder][35] | `flawfinder` |
| [gdlint (gdtoolkit)][gdlint] | `gdlint` |
| [gitlint][gitlint] | `gitlint` |
| [Golangci-lint][16] | `golangcilint` |
| [glslc][glslc] | `glslc` |
| [DirectX Shader Compiler][dxc] | `dxc` |
Expand Down Expand Up @@ -399,3 +400,4 @@ busted tests/
[deno]: https://github.com/denoland/deno
[standardjs]: https://standardjs.com/
[biomejs]: https://github.com/biomejs/biome
[gitlint]: https://github.com/jorisroovers/gitlint
9 changes: 9 additions & 0 deletions lua/lint/linters/gitlint.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
return {
cmd = "gitlint",
stdin = false,
args = { "--staged", "--msg-filename" },
append_fname = true,
stream = "stderr",
ignore_exitcode = true,
parser = require("lint.parser").from_pattern([[^(\d+): (\w+) (.*)$]], { "lnum", "code", "message" }, nil, nil, nil),
}
17 changes: 17 additions & 0 deletions tests/gitlint_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe("linter.gitlint", function()
it("can parse the output", function()
local parser = require("lint.linters.gitlint").parser
local result = parser([[3: B5 Body message is too short (11<20): "foo bar baz"]])
local expected = {
source = "gitlint",
message = "Body message is too short",
code = "B5",
lnum = 3,
col = 0,
end_lnum = 3,
end_col = 0,
severity = vim.diagnostic.severity.INFO,
}
assert.are.same(expected, result)
end)
end)

0 comments on commit 664f353

Please sign in to comment.