Skip to content

Commit

Permalink
Add ts-standard linter (#702)
Browse files Browse the repository at this point in the history
Co-authored-by: Mathias Fussenegger <[email protected]>
  • Loading branch information
AbelAnaya and mfussenegger authored Jan 18, 2025
1 parent 6742c6e commit 9195dd0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Other dedicated linters that are built-in are:
| [tfsec][tfsec] | `tfsec` |
| [tlint][tlint] | `tlint` |
| [trivy][trivy] | `trivy` |
| [ts-standard][ts-standard] | `ts-standard` |
| [typos][typos] | `typos` |
| [Vala][vala-lint] | `vala_lint` |
| [Vale][8] | `vale` |
Expand Down Expand Up @@ -590,3 +591,4 @@ busted tests/
[svlint]: https://github.com/dalance/svlint
[slang]: https://github.com/MikePopoloski/slang
[zizmor]: https://github.com/woodruffw/zizmor
[ts-standard]: https://github.com/standard/ts-standard
18 changes: 18 additions & 0 deletions lua/lint/linters/ts-standard.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local binary_name = "ts-standard"
local pattern = "[^:]+:(%d+):(%d+):([^%.]+%.?)%s%(([%a-]+)%)%s?%(?(%a*)%)?"
local groups = { "lnum", "col", "message", "code", "severity" }
local severities = {
[""] = vim.diagnostic.severity.ERROR,
["warning"] = vim.diagnostic.severity.WARN,
}

return {
cmd = function()
local local_binary = vim.fn.fnamemodify("./node_modules/.bin/" .. binary_name, ":p")
return vim.loop.fs_stat(local_binary) and local_binary or binary_name
end,
stdin = true,
args = { "--stdin" },
ignore_exitcode = true,
parser = require("lint.parser").from_pattern(pattern, groups, severities, { ["source"] = "ts-standard" }, {}),
}

0 comments on commit 9195dd0

Please sign in to comment.