Fix #260 automatically set .csslintrc files from ancestor directories
This commit is contained in:
parent
8e71f233da
commit
2a88b60ff1
5 changed files with 46 additions and 1 deletions
|
@ -1,9 +1,18 @@
|
|||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: This file adds support for checking CSS code with csslint.
|
||||
|
||||
function! ale_linters#css#csslint#GetCommand(buffer) abort
|
||||
let l:csslintrc = ale#util#FindNearestFile(a:buffer, '.csslintrc')
|
||||
let l:config_option = !empty(l:csslintrc)
|
||||
\ ? '--config=' . fnameescape(l:csslintrc)
|
||||
\ : ''
|
||||
|
||||
return 'csslint --format=compact ' . l:config_option . ' %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('css', {
|
||||
\ 'name': 'csslint',
|
||||
\ 'executable': 'csslint',
|
||||
\ 'command': 'csslint --format=compact %t',
|
||||
\ 'command_callback': 'ale_linters#css#csslint#GetCommand',
|
||||
\ 'callback': 'ale#handlers#HandleCSSLintFormat',
|
||||
\})
|
||||
|
|
0
test/csslint-test-files/other-app/testfile.css
Normal file
0
test/csslint-test-files/other-app/testfile.css
Normal file
0
test/csslint-test-files/some-app/.csslintrc
Normal file
0
test/csslint-test-files/some-app/.csslintrc
Normal file
0
test/csslint-test-files/some-app/subdir/testfile.css
Normal file
0
test/csslint-test-files/some-app/subdir/testfile.css
Normal file
36
test/test_csslint_config_detection.vader
Normal file
36
test/test_csslint_config_detection.vader
Normal file
|
@ -0,0 +1,36 @@
|
|||
Before:
|
||||
silent! cd /testplugin/test
|
||||
let g:dir = getcwd()
|
||||
|
||||
runtime ale_linters/css/csslint.vim
|
||||
|
||||
After:
|
||||
silent execute 'cd ' . g:dir
|
||||
unlet! g:dir
|
||||
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(--config should be set when the .csslintrc file is found):
|
||||
new csslint-test-files/some-app/subdir/testfile.js
|
||||
|
||||
AssertEqual
|
||||
\ (
|
||||
\ 'csslint --format=compact '
|
||||
\ . '--config=' . fnameescape(g:dir . '/csslint-test-files/some-app/.csslintrc')
|
||||
\ . ' %t'
|
||||
\ ),
|
||||
\ ale_linters#css#csslint#GetCommand(bufnr(''))
|
||||
|
||||
:q
|
||||
|
||||
Execute(--config should not be used when no .csslintrc file exists):
|
||||
new csslint-test-files/other-app/testfile.css
|
||||
|
||||
AssertEqual
|
||||
\ (
|
||||
\ 'csslint --format=compact '
|
||||
\ . ' %t'
|
||||
\ ),
|
||||
\ ale_linters#css#csslint#GetCommand(bufnr(''))
|
||||
|
||||
:q
|
Reference in a new issue