summaryrefslogtreecommitdiff
path: root/ale_linters/handlebars
diff options
context:
space:
mode:
authorCyrille David <dcyriller@users.noreply.github.com>2020-08-31 10:26:33 +0200
committerGitHub <noreply@github.com>2020-08-31 09:26:33 +0100
commitd4a14746cdcda99ec70915c5540962c85e33f661 (patch)
treec577008a678dc29cf3df950a569889ef730ddf5f /ale_linters/handlebars
parentac2100d410378906d7d277561f50ae3305b6429e (diff)
downloadale-d4a14746cdcda99ec70915c5540962c85e33f661.zip
feat(template-lint): Read from stdin (#2622)
* ember-template-lint: Lint from stdin * This feature has recently been implemented in ember-template-lint. * Refactor ember-template-lint executable * Fallback on a temporary file for old template-lint Co-authored-by: w0rp <w0rp@users.noreply.github.com>
Diffstat (limited to 'ale_linters/handlebars')
-rw-r--r--ale_linters/handlebars/embertemplatelint.vim28
1 files changed, 24 insertions, 4 deletions
diff --git a/ale_linters/handlebars/embertemplatelint.vim b/ale_linters/handlebars/embertemplatelint.vim
index 74bd6a99..31d65b70 100644
--- a/ale_linters/handlebars/embertemplatelint.vim
+++ b/ale_linters/handlebars/embertemplatelint.vim
@@ -4,6 +4,28 @@
call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint')
call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0))
+function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [
+ \ 'node_modules/.bin/ember-template-lint',
+ \])
+endfunction
+
+function! ale_linters#handlebars#embertemplatelint#GetCommand(buffer, version) abort
+ " Reading from stdin was introduced in ember-template-lint@1.6.0
+ return ale#semver#GTE(a:version, [1, 6, 0])
+ \ ? '%e --json --filename %s'
+ \ : '%e --json %t'
+endfunction
+
+function! ale_linters#handlebars#embertemplatelint#GetCommandWithVersionCheck(buffer) abort
+ return ale#semver#RunWithVersionCheck(
+ \ a:buffer,
+ \ ale_linters#handlebars#embertemplatelint#GetExecutable(a:buffer),
+ \ '%e --version',
+ \ function('ale_linters#handlebars#embertemplatelint#GetCommand'),
+ \ )
+endfunction
+
function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort
let l:output = []
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
@@ -31,9 +53,7 @@ endfunction
call ale#linter#Define('handlebars', {
\ 'name': 'ember-template-lint',
-\ 'executable': {b -> ale#node#FindExecutable(b, 'handlebars_embertemplatelint', [
-\ 'node_modules/.bin/ember-template-lint',
-\ ])},
-\ 'command': '%e --json %t',
+\ 'executable': function('ale_linters#handlebars#embertemplatelint#GetExecutable'),
+\ 'command': function('ale_linters#handlebars#embertemplatelint#GetCommandWithVersionCheck'),
\ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle',
\})