Add linting support for all formats supported by djlint (#4920)
Some checks are pending
CI / build_image (push) Waiting to run
CI / test_ale (--linters-only) (push) Blocked by required conditions
CI / test_ale (--neovim-07-only) (push) Blocked by required conditions
CI / test_ale (--neovim-08-only) (push) Blocked by required conditions
CI / test_ale (--vim-80-only) (push) Blocked by required conditions
CI / test_ale (--vim-90-only) (push) Blocked by required conditions

* Refactor djlint linter code

This patch moves the code to the `autoload` directory, so it's available
when it's needed by a specific linter. This avoids redundant code when
another format supported by djlint is added.

* Add linting support for all formats supported by djlint

So far, the `djlint` linter in ALE only supported `html`, which is only
one of several file types supported by `djlint`.

This patch adds support for the following file types:

* gohtmltmpl
* handlebars
* htmlangular
* htmldjango
* jinja
* nunjucks

* Add djlint fixer for various HTML template formats

* Supported formats:
    - html
    - htmlangular
    - htmldjango
    - jinja
    - handlebars
    - nunjucks
    - gohtmltmpl

* Add doc entries

* Add vader tests

---------

Co-authored-by: Adrian Vollmer <computerfluesterer@protonmail.com>
This commit is contained in:
Adrian Vollmer
2025-03-17 23:56:32 +01:00
committed by GitHub
parent fe6a91fb92
commit 47f1f49655
23 changed files with 448 additions and 38 deletions

View File

@@ -12,3 +12,58 @@ Execute(The executable should be configurable):
let g:ale_html_djlint_options = '--option'
AssertLinter 'foo bar', ale#Escape('foo bar') . ' --option %s'
Execute(The --profile option should not be overridden):
call ale#test#SetFilename('../test-files/djlint/testfile.html')
set filetype=htmldjango
let g:ale_html_djlint_options = '--profile jinja'
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
\ . ' --profile jinja'
\ . ' %s',
Execute(Should set --profile for htmlangular):
call ale#test#SetFilename('../test-files/djlint/testfile.html')
set filetype=htmlangular
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
\ . ' --profile angular'
\ . ' %s',
Execute(Should set --profile for jinja):
call ale#test#SetFilename('../test-files/djlint/testfile.html')
set filetype=jinja
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
\ . ' --profile jinja'
\ . ' %s',
Execute(Should set --profile for Handlebars):
call ale#test#SetFilename('../test-files/djlint/testfile.html')
set filetype=handlebars
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
\ . ' --profile handlebars'
\ . ' %s',
Execute(Should set --profile for nunjucks):
call ale#test#SetFilename('../test-files/djlint/testfile.html')
set filetype=nunjucks
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
\ . ' --profile nunjucks'
\ . ' %s',
Execute(Should set --profile for Go HTML Templates):
call ale#test#SetFilename('../test-files/djlint/testfile.html')
set filetype=gohtmltmpl
AssertLinter 'djlint', ale#Escape(g:ale_html_djlint_executable)
\ . ' --profile golang'
\ . ' %s',