From d8efd4fa73277908467ba59926428ca22703df27 Mon Sep 17 00:00:00 2001 From: Daniel Lupu Date: Thu, 9 Feb 2017 20:54:49 +0200 Subject: [PATCH] add xo support (#304) * add xo support * add documentation * Fix a screw up when fixing conflicts * Fix it harder --- ale_linters/javascript/xo.vim | 41 +++++++++++++++++++++++++++++++++++ doc/ale.txt | 38 +++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 ale_linters/javascript/xo.vim diff --git a/ale_linters/javascript/xo.vim b/ale_linters/javascript/xo.vim new file mode 100644 index 00000000..e27f6f33 --- /dev/null +++ b/ale_linters/javascript/xo.vim @@ -0,0 +1,41 @@ +" Author: Daniel Lupu +" Description: xo for JavaScript files + +let g:ale_javascript_xo_executable = +\ get(g:, 'ale_javascript_xo_executable', 'xo') + +let g:ale_javascript_xo_options = +\ get(g:, 'ale_javascript_xo_options', '') + +let g:ale_javascript_xo_use_global = +\ get(g:, 'ale_javascript_xo_use_global', 0) + +function! ale_linters#javascript#xo#GetExecutable(buffer) abort + if g:ale_javascript_xo_use_global + return g:ale_javascript_xo_executable + endif + + return ale#util#ResolveLocalPath( + \ a:buffer, + \ 'node_modules/.bin/xo', + \ g:ale_javascript_xo_executable + \) +endfunction + +function! ale_linters#javascript#xo#GetCommand(buffer) abort + return ale_linters#javascript#xo#GetExecutable(a:buffer) + \ . ' ' . g:ale_javascript_xo_options + \ . ' --reporter unix --stdin --stdin-filename %s' +endfunction + +function! ale_linters#javascript#xo#Handle(buffer, lines) abort + " xo uses eslint and the output format is the same + return ale_linters#javascript#eslint#Handle(a:buffer, a:lines) +endfunction + +call ale#linter#Define('javascript', { +\ 'name': 'xo', +\ 'executable_callback': 'ale_linters#javascript#xo#GetExecutable', +\ 'command_callback': 'ale_linters#javascript#xo#GetCommand', +\ 'callback': 'ale_linters#javascript#xo#Handle', +\}) diff --git a/doc/ale.txt b/doc/ale.txt index 187251f6..348be809 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -36,6 +36,7 @@ CONTENTS *ale-contents* 4.24. python-pylint...................|ale-linter-options-python-pylint| 4.25. erlang..........................|ale-linter-options-erlang| 4.26. phpmd...........................|ale-linter-options-phpmd| + 4.27. xo..............................|ale-linter-options-xo| 5. Linter Integration Notes.............|ale-linter-integration| 5.1. merlin..........................|ale-linter-integration-ocaml-merlin| 5.2. rust.............................|ale-integration-rust| @@ -86,7 +87,7 @@ The following languages and tools are supported. * Go: 'gofmt -e', 'go vet', 'golint', 'go build' * Haskell: 'ghc', 'hlint' * HTML: 'HTMLHint', 'tidy' -* JavaScript: 'eslint', 'jscs', 'jshint', 'flow' +* JavaScript: 'eslint', 'jscs', 'jshint', 'flow', 'xo' * JSON: 'jsonlint' * LaTeX: 'chktex', 'lacheck' * Lua: 'luacheck' @@ -892,6 +893,41 @@ g:ale_php_phpmd_ruleset *g:ale_php_phpmd_ruleset* This variable controls the ruleset used by phpmd. Default is to use all of the available phpmd rulesets +------------------------------------------------------------------------------ +4.27. xo *ale-linter-options-xo* + +g:ale_javascript_xo_executable *g:ale_javascript_xo_executable* + + Type: |String| + Default: `'xo'` + + ALE will first discover the xo path in an ancestor node_modules + directory. If no such path exists, this variable will be used instead. + + This variable can be set to change the path to xo. + + If you wish to use only a globally installed version of xo, set + |g:ale_javascript_xo_use_global| to `1`. + + +g:ale_javascript_xo_options *g:ale_javascript_xo_options* + + Type: |String| + Default: `''` + + This variable can be set to pass additional options to xo. + + +g:ale_javascript_xo_use_global *g:ale_javascript_xo_use_global* + + Type: |String| + Default: `0` + + This variable controls whether or not ALE will search for a local path for + xo first. If this variable is set to `1`, then ALE will always use the + global version of xo, in preference to locally installed versions of + xo in node_modules. + =============================================================================== 5. Linter Integration Notes *ale-linter-integration*