From 47ba6eede5d9217d80772737c241217baa212fbe Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 11 Aug 2023 13:30:38 -0500 Subject: [PATCH 1/2] feat(linter): shellcheck --- lua/guard/tools/linter/shellcheck.lua | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lua/guard/tools/linter/shellcheck.lua diff --git a/lua/guard/tools/linter/shellcheck.lua b/lua/guard/tools/linter/shellcheck.lua new file mode 100644 index 00000000..a93cdee0 --- /dev/null +++ b/lua/guard/tools/linter/shellcheck.lua @@ -0,0 +1,37 @@ +local diag_fmt = require('guard.lint').diag_fmt +return { + cmd = 'shellcheck', + args = { '--format', 'json1', '--external-sources' }, + stdin = true, + output_fmt = function(result, buf) + local comments = vim.json.decode(result).comments + + if #comments < 1 then + return {} + end + + -- https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md + -- "Valid values in order of severity are error, warning, info and style." + local severities = { + error = 1, + warning = 2, + info = 3, + style = 4 + } + + local diags = {} + + vim.tbl_map(function(mes) + diags[#diags + 1] = diag_fmt( + buf, + tonumber(mes.line) - 1, + tonumber(mes.column) - 1, + mes.message .. ' [' .. mes.code .. ']', + severities[mes.level] or 4, + 'shellcheck' + ) + end, comments) + + return diags + end +} From b34fb5457022536f30dac37183b07ea13bbfb02d Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 11 Aug 2023 13:34:55 -0500 Subject: [PATCH 2/2] fix: add shellcheck to readme and cite sources --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fb5bdcbb..cbeadb76 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,10 @@ Table format for custom tool: #### Linter -- `clang-tidy` -- `Pylint` -- `rubocop` +- [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) +- [pylint](https://github.com/PyCQA/pylint) +- [rubocop](https://github.com/rubocop/rubocop) +- [shellcheck](https://github.com/koalaman/shellcheck) ## Troubleshooting