mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-25 04:16:50 +08:00
add rego support (#4199)
* add opa fmt fixer for rego files * add opa linter * add basic tests for linter and fixer * add cspell to the docs
This commit is contained in:
committed by
GitHub
parent
5479b58660
commit
75d2413425
33
test/fixers/test_opa_fmt_fixer_callback.vader
Normal file
33
test/fixers/test_opa_fmt_fixer_callback.vader
Normal file
@@ -0,0 +1,33 @@
|
||||
Before:
|
||||
Save g:ale_opa_fmt_executable
|
||||
Save g:ale_opa_fmt_options
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_opa_fmt_executable = 'xxxinvalid'
|
||||
let g:ale_opa_fmt_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The opa fmt callback should return the correct default values):
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('xxxinvalid') . ' fmt',
|
||||
\ },
|
||||
\ ale#fixers#opafmt#Fix(bufnr(''))
|
||||
|
||||
Execute(The opa fmt callback should include custom options):
|
||||
let g:ale_opa_fmt_options = "--list"
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' fmt'
|
||||
\ . ' ' . g:ale_opa_fmt_options
|
||||
\ },
|
||||
\ ale#fixers#opafmt#Fix(bufnr(''))
|
||||
16
test/linter/test_rego_opacheck.vader
Normal file
16
test/linter/test_rego_opacheck.vader
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
" Based upon :help ale-development
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('rego', 'opacheck')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default command should be correct):
|
||||
AssertLinter 'opa',
|
||||
\ ale#Escape('opa') . ' check %s --format json '
|
||||
|
||||
Execute(The default command should be overriden):
|
||||
let b:ale_rego_opacheck_executable = '/bin/other/opa'
|
||||
AssertLinter '/bin/other/opa',
|
||||
\ ale#Escape('/bin/other/opa') . ' check %s --format json '
|
||||
Reference in New Issue
Block a user