Skip to content

Commit

Permalink
Add eslint, eslint_d linters (#7)
Browse files Browse the repository at this point in the history
* Add eslint_d linter

* Use eslint_d for source

* Add to readme

* Use GitHub URL for readme link.

Co-authored-by: HyBer <[email protected]>

* Add find to eslint_d

* Add eslint_d to linter init

* Add eslint

* Add eslint to readme

---------

Co-authored-by: HyBer <[email protected]>
  • Loading branch information
sirreal and BBboy01 authored Sep 19, 2023
1 parent 3996861 commit 8e80408
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

- [x] [clang-tidy](https://clang.llvm.org/extra/clang-tidy/)
- [ ] [codespell](https://github.com/codespell-project/codespell)
- [ ] [eslint](https://eslint.org/)
- [ ] [eslint_d](https://github.com/mantoni/eslint_d.js)
- [x] [flake8](https://github.com/PyCQA/flake8)
- [x] [hadolint](https://github.com/hadolint/hadolint)
- [x] [luacheck](https://github.com/lunarmodules/luacheck)
Expand Down
33 changes: 33 additions & 0 deletions lua/guard-collection/linter/eslint.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
local lint = require('guard.lint')

return {
cmd = 'eslint',
args = { '--format', 'json', '--stdin', '--stdin-filename' },
stdin = true,
fname = true,
find = {
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.json',
},
parse = lint.from_json({
get_diagnostics = function(...)
return vim.json.decode(...)[1].messages
end,
attributes = {
lnum = 'line',
end_lnum = 'endLine',
col = 'column',
end_col = 'endColumn',
message = 'message',
code = 'ruleId',
},
severities = {
lint.severities.warning,
lint.severities.error,
},
source = 'eslint',
}),
}
33 changes: 33 additions & 0 deletions lua/guard-collection/linter/eslint_d.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
local lint = require('guard.lint')

return {
cmd = 'eslint_d',
args = { '--format', 'json', '--stdin', '--stdin-filename' },
stdin = true,
fname = true,
find = {
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.json',
},
parse = lint.from_json({
get_diagnostics = function(...)
return vim.json.decode(...)[1].messages
end,
attributes = {
lnum = 'line',
end_lnum = 'endLine',
col = 'column',
end_col = 'endColumn',
message = 'message',
code = 'ruleId',
},
severities = {
lint.severities.warning,
lint.severities.error,
},
source = 'eslint_d',
}),
}
2 changes: 2 additions & 0 deletions lua/guard-collection/linter/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
return {
['clang-tidy'] = require('guard-collection.linter.clang-tidy'),
codespell = require('guard-collection.linter.codespell'),
eslint = require('guard-collection.linter.eslint'),
eslint_d = require('guard-collection.linter.eslint_d'),
flake8 = require('guard-collection.linter.flake8'),
hadolint = require('guard-collection.linter.hadolint'),
luacheck = require('guard-collection.linter.luacheck'),
Expand Down

0 comments on commit 8e80408

Please sign in to comment.