From 395d9fa2aa7f8c29a1c9810bbf5a439f0ce47bc3 Mon Sep 17 00:00:00 2001 From: yoan667 <125768742+yoan667@users.noreply.github.com> Date: Sat, 22 Nov 2025 13:15:28 +0100 Subject: [PATCH] Add SuperHTML linter for HTML (#5055) --- ale_linters/html/superhtml.vim | 34 +++++++++++++++++++++++ doc/ale-html.txt | 18 ++++++++++++ doc/ale-supported-languages-and-tools.txt | 1 + doc/ale.txt | 1 + supported-tools.md | 1 + test/linter/test_superhtml.vader | 29 +++++++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 ale_linters/html/superhtml.vim create mode 100644 test/linter/test_superhtml.vader diff --git a/ale_linters/html/superhtml.vim b/ale_linters/html/superhtml.vim new file mode 100644 index 00000000..61dbb3ce --- /dev/null +++ b/ale_linters/html/superhtml.vim @@ -0,0 +1,34 @@ +call ale#Set('html_superhtml_executable', 'superhtml') +call ale#Set('html_superhtml_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#html#superhtml#GetCommand(buffer) abort + return '%e check --stdin' +endfunction + +function! ale_linters#html#superhtml#Handle(buffer, lines) abort + let l:output = [] + let l:pattern = '^\(.*\):\(\d\+\):\(\d\+\): \(.*\)$' + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if !empty(l:match) + call add(l:output, { + \ 'lnum': str2nr(l:match[2]), + \ 'col': str2nr(l:match[3]), + \ 'text': l:match[4], + \ 'type': 'E' + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('html', { +\ 'name': 'superhtml', +\ 'executable': {b -> ale#Var(b, 'html_superhtml_executable')}, +\ 'command': function('ale_linters#html#superhtml#GetCommand'), +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#html#superhtml#Handle', +\}) diff --git a/doc/ale-html.txt b/doc/ale-html.txt index a5b93d58..84babc30 100644 --- a/doc/ale-html.txt +++ b/doc/ale-html.txt @@ -206,6 +206,24 @@ g:ale_html_stylelint_use_global See |ale-integrations-local-executables| +=============================================================================== +superhtml *ale-html-superhtml* + +g:ale_html_superhtml_executable *g:ale_html_superhtml_executable* + *b:ale_html_superhtml_executable* + Type: |String| + Default: `'superhtml'` + + This variable can be changed to use a different executable for superhtml. + +g:ale_html_superhtml_use_global *g:ale_html_superhtml_use_global* + *b:ale_html_superhtml_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== tidy *ale-html-tidy* diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 56f0a211..43c7821a 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -289,6 +289,7 @@ Notes: * `prettier` * `proselint` * `rustywind` + * `superhtml` * `tidy` * `write-good` * HTML Angular diff --git a/doc/ale.txt b/doc/ale.txt index 07f56d28..5d0a6161 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -3586,6 +3586,7 @@ documented in additional help files. prettier..............................|ale-html-prettier| rustywind.............................|ale-html-rustywind| stylelint.............................|ale-html-stylelint| + superhtml.............................|ale-html-superhtml| tidy..................................|ale-html-tidy| vscodehtml............................|ale-html-vscode| write-good............................|ale-html-write-good| diff --git a/supported-tools.md b/supported-tools.md index fdd611ba..691c5e62 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -299,6 +299,7 @@ formatting. * [prettier](https://github.com/prettier/prettier) * [proselint](http://proselint.com/) * [rustywind](https://github.com/avencera/rustywind) + * [superhtml](https://github.com/kristoff-it/superhtml) * [tidy](http://www.html-tidy.org/) * [write-good](https://github.com/btford/write-good) * HTML Angular diff --git a/test/linter/test_superhtml.vader b/test/linter/test_superhtml.vader new file mode 100644 index 00000000..15527c18 --- /dev/null +++ b/test/linter/test_superhtml.vader @@ -0,0 +1,29 @@ +Before: + call ale#assert#SetUpLinterTest('html', 'superhtml') + call ale#test#SetFilename('test.html') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'superhtml', + \ ale#Escape('superhtml') . ' check --stdin' + +Execute(The executable should be configurable): + let g:ale_html_superhtml_executable = '/usr/local/bin/superhtml' + + AssertLinter '/usr/local/bin/superhtml', + \ ale#Escape('/usr/local/bin/superhtml') . ' check --stdin' + +Execute(The options should be configurable): + let g:ale_html_superhtml_options = '--some-option' + + AssertLinter 'superhtml', + \ ale#Escape('superhtml') . ' check --stdin' + +Execute(The use_global option should be respected): + let g:ale_html_superhtml_executable = 'custom_superhtml' + let g:ale_html_superhtml_use_global = 1 + + AssertLinter 'custom_superhtml', + \ ale#Escape('custom_superhtml') . ' check --stdin'