mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
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>
99 lines
2.4 KiB
Plaintext
99 lines
2.4 KiB
Plaintext
Before:
|
|
call ale#assert#SetUpFixerTest('html', 'djlint', 'djlint')
|
|
|
|
After:
|
|
Restore
|
|
|
|
call ale#assert#TearDownFixerTest()
|
|
|
|
Execute(The djlint callback should return the correct default command):
|
|
AssertEqual
|
|
\ {'command': ale#Escape('djlint') . ' --reformat -'},
|
|
\ ale#fixers#djlint#Fix(bufnr(''))
|
|
|
|
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'
|
|
|
|
AssertFixer
|
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
|
\ . ' --reformat'
|
|
\ . ' --profile jinja'
|
|
\ . ' -',
|
|
\ }
|
|
|
|
|
|
Execute(Should set --profile for experimental language, Handlebars):
|
|
call ale#test#SetFilename('../test-files/djlint/testfile.hbs')
|
|
|
|
set filetype=handlebars
|
|
|
|
AssertFixer
|
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
|
\ . ' --reformat'
|
|
\ . ' --profile handlebars'
|
|
\ . ' -',
|
|
\ }
|
|
|
|
Execute(Should set --profile for htmldjango, Django templates):
|
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
|
|
|
set filetype=htmldjango
|
|
|
|
AssertFixer
|
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
|
\ . ' --reformat'
|
|
\ . ' --profile django'
|
|
\ . ' -',
|
|
\ }
|
|
|
|
Execute(Should set --profile for htmlangular):
|
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
|
|
|
set filetype=htmlangular
|
|
|
|
AssertFixer
|
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
|
\ . ' --reformat'
|
|
\ . ' --profile angular'
|
|
\ . ' -',
|
|
\ }
|
|
|
|
Execute(Should set --profile for jinja):
|
|
call ale#test#SetFilename('../test-files/djlint/testfile.jinja2')
|
|
|
|
set filetype=jinja
|
|
|
|
AssertFixer
|
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
|
\ . ' --reformat'
|
|
\ . ' --profile jinja'
|
|
\ . ' -',
|
|
\ }
|
|
|
|
Execute(Should set --profile for nunjucks):
|
|
call ale#test#SetFilename('../test-files/djlint/testfile.njk')
|
|
|
|
set filetype=nunjucks
|
|
|
|
AssertFixer
|
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
|
\ . ' --reformat'
|
|
\ . ' --profile nunjucks'
|
|
\ . ' -',
|
|
\ }
|
|
|
|
Execute(Should set --profile for Go HTML templates):
|
|
call ale#test#SetFilename('../test-files/djlint/testfile.html')
|
|
|
|
set filetype=gohtmltmpl
|
|
|
|
AssertFixer
|
|
\ { 'command': ale#Escape(g:ale_html_djlint_executable)
|
|
\ . ' --reformat'
|
|
\ . ' --profile golang'
|
|
\ . ' -',
|
|
\ }
|