Skip to content

Commit

Permalink
Add stylelint linter (#8)
Browse files Browse the repository at this point in the history
* Add stylelint linter

* Add to linter init module

* Add stylelint find
  • Loading branch information
sirreal authored Sep 19, 2023
1 parent 8e80408 commit c0b5dbe
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
- [x] [pylint](https://github.com/PyCQA/pylint)
- [ ] [rubocop](https://github.com/rubocop/rubocop)
- [ ] [shellcheck](https://github.com/koalaman/shellcheck)
- [ ] [stylelint](https://stylelint.io/)

## License MIT
1 change: 1 addition & 0 deletions lua/guard-collection/linter/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ return {
rubocop = require('guard-collection.linter.rubocop'),
selene = require('guard-collection.linter.selene'),
shellcheck = require('guard-collection.linter.shellcheck'),
stylelint = require('guard-collection.linter.stylelint'),
}
37 changes: 37 additions & 0 deletions lua/guard-collection/linter/stylelint.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local lint = require('guard.lint')

return {
cmd = 'stylelint',
args = { '--formatter', 'json', '--stdin', '--stdin-filename' },
stdin = true,
fname = true,
fine = {
'.stylelintrc',
'.stylelintrc.cjs',
'.stylelintrc.js',
'.stylelintrc.json',
'.stylelintrc.yaml',
'.stylelintrc.yml',
'stylelint.config.cjs',
'stylelint.config.mjs',
'stylelint.config.js',
},
parse = lint.from_json({
get_diagnostics = function(...)
return vim.json.decode(...)[1].warnings
end,
attributes = {
lnum = 'line',
end_lnum = 'endLine',
col = 'column',
end_col = 'endColumn',
message = 'text',
code = 'rule',
},
severities = {
warning = lint.severities.warning,
error = lint.severities.error,
},
source = 'stylelint',
}),
}

0 comments on commit c0b5dbe

Please sign in to comment.