From 8a1099bb59696185a77422ae12e3e384b0eeb81b Mon Sep 17 00:00:00 2001 From: Ben Falconer Date: Fri, 11 May 2018 10:45:41 +0100 Subject: [PATCH] Run sass-lint from the target's directory --- ale_linters/sass/sasslint.vim | 14 ++++++++++++-- ale_linters/scss/sasslint.vim | 14 ++++++++++++-- .../test_sasslint_command_callback.vader | 17 +++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 test/command_callback/test_sasslint_command_callback.vader diff --git a/ale_linters/sass/sasslint.vim b/ale_linters/sass/sasslint.vim index bbe71255..aaaa3d2d 100644 --- a/ale_linters/sass/sasslint.vim +++ b/ale_linters/sass/sasslint.vim @@ -1,8 +1,18 @@ -" Author: KabbAmine - https://github.com/KabbAmine +" Author: KabbAmine - https://github.com/KabbAmine, Ben Falconer +" + +function! ale_linters#sass#sasslint#GetCommand(buffer) abort + return ale#path#BufferCdString(a:buffer) + \ . ale#Escape('sass-lint') + \ . ' -v' + \ . ' -q' + \ . ' -f compact' + \ . ' %t' +endfunction call ale#linter#Define('sass', { \ 'name': 'sasslint', \ 'executable': 'sass-lint', -\ 'command': 'sass-lint -v -q -f compact %t', +\ 'command_callback': 'ale_linters#sass#sasslint#GetCommand', \ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \}) diff --git a/ale_linters/scss/sasslint.vim b/ale_linters/scss/sasslint.vim index bd016465..f6075001 100644 --- a/ale_linters/scss/sasslint.vim +++ b/ale_linters/scss/sasslint.vim @@ -1,8 +1,18 @@ -" Author: KabbAmine - https://github.com/KabbAmine +" Author: KabbAmine - https://github.com/KabbAmine, Ben Falconer +" + +function! ale_linters#scss#sasslint#GetCommand(buffer) abort + return ale#path#BufferCdString(a:buffer) + \ . ale#Escape('sass-lint') + \ . ' -v' + \ . ' -q' + \ . ' -f compact' + \ . ' %t' +endfunction call ale#linter#Define('scss', { \ 'name': 'sasslint', \ 'executable': 'sass-lint', -\ 'command': 'sass-lint -v -q -f compact %t', +\ 'command_callback': 'ale_linters#scss#sasslint#GetCommand', \ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \}) diff --git a/test/command_callback/test_sasslint_command_callback.vader b/test/command_callback/test_sasslint_command_callback.vader new file mode 100644 index 00000000..81ce893b --- /dev/null +++ b/test/command_callback/test_sasslint_command_callback.vader @@ -0,0 +1,17 @@ +Before: + runtime ale_linters/sass/sasslint.vim + + call ale#test#SetDirectory('/testplugin/test/command_callback') + call ale#test#SetFilename('test.sass') + +After: + Restore + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(The default sasslint command should be correct): + AssertEqual + \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ . ale#Escape('sass-lint') . ' -v -q -f compact %t', + \ ale_linters#sass#sasslint#GetCommand(bufnr(''))