summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/css/stylelint.vim21
-rw-r--r--ale_linters/handlebars/embertemplatelint.vim17
-rw-r--r--ale_linters/html/htmlhint.vim17
-rw-r--r--ale_linters/javascript/flow.vim17
-rw-r--r--ale_linters/javascript/jshint.vim17
-rw-r--r--ale_linters/javascript/standard.vim21
-rw-r--r--ale_linters/javascript/xo.vim21
-rw-r--r--ale_linters/sass/stylelint.vim17
-rw-r--r--ale_linters/scss/stylelint.vim17
-rw-r--r--ale_linters/typescript/tslint.vim21
-rw-r--r--autoload/ale/handlers/eslint.vim18
-rw-r--r--autoload/ale/node.vim22
12 files changed, 69 insertions, 157 deletions
diff --git a/ale_linters/css/stylelint.vim b/ale_linters/css/stylelint.vim
index 5cb67a81..9f683190 100644
--- a/ale_linters/css/stylelint.vim
+++ b/ale_linters/css/stylelint.vim
@@ -1,24 +1,13 @@
" Author: diartyz <diartyz@gmail.com>
-let g:ale_css_stylelint_executable =
-\ get(g:, 'ale_css_stylelint_executable', 'stylelint')
-
-let g:ale_css_stylelint_options =
-\ get(g:, 'ale_css_stylelint_options', '')
-
-let g:ale_css_stylelint_use_global =
-\ get(g:, 'ale_css_stylelint_use_global', 0)
+call ale#Set('css_stylelint_executable', 'stylelint')
+call ale#Set('css_stylelint_options', '')
+call ale#Set('css_stylelint_use_global', 0)
function! ale_linters#css#stylelint#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'css_stylelint_use_global')
- return ale#Var(a:buffer, 'css_stylelint_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'css_stylelint', [
\ 'node_modules/.bin/stylelint',
- \ ale#Var(a:buffer, 'css_stylelint_executable')
- \)
+ \])
endfunction
function! ale_linters#css#stylelint#GetCommand(buffer) abort
diff --git a/ale_linters/handlebars/embertemplatelint.vim b/ale_linters/handlebars/embertemplatelint.vim
index 91dda70a..bbf7dd90 100644
--- a/ale_linters/handlebars/embertemplatelint.vim
+++ b/ale_linters/handlebars/embertemplatelint.vim
@@ -1,22 +1,13 @@
" Author: Adrian Zalewski <aazalewski@hotmail.com>
" Description: Ember-template-lint for checking Handlebars files
-let g:ale_handlebars_embertemplatelint_executable =
-\ get(g:, 'ale_handlebars_embertemplatelint_executable', 'ember-template-lint')
-
-let g:ale_handlebars_embertemplatelint_use_global =
-\ get(g:, 'ale_handlebars_embertemplatelint_use_global', 0)
+call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint')
+call ale#Set('handlebars_embertemplatelint_use_global', 0)
function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'handlebars_embertemplatelint_use_global')
- return ale#Var(a:buffer, 'handlebars_embertemplatelint_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [
\ 'node_modules/.bin/ember-template-lint',
- \ ale#Var(a:buffer, 'handlebars_embertemplatelint_executable')
- \)
+ \])
endfunction
function! ale_linters#handlebars#embertemplatelint#GetCommand(buffer) abort
diff --git a/ale_linters/html/htmlhint.vim b/ale_linters/html/htmlhint.vim
index ab1c6e02..e142d22a 100644
--- a/ale_linters/html/htmlhint.vim
+++ b/ale_linters/html/htmlhint.vim
@@ -1,21 +1,14 @@
" Author: KabbAmine <amine.kabb@gmail.com>, deathmaz <00maz1987@gmail.com>, diartyz <diartyz@gmail.com>
" Description: HTMLHint for checking html files
-" CLI options
-let g:ale_html_htmlhint_options = get(g:, 'ale_html_htmlhint_options', '--format=unix')
-let g:ale_html_htmlhint_executable = get(g:, 'ale_html_htmlhint_executable', 'htmlhint')
-let g:ale_html_htmlhint_use_global = get(g:, 'ale_html_htmlhint_use_global', 0)
+call ale#Set('html_htmlhint_options', '--format=unix')
+call ale#Set('html_htmlhint_executable', 'htmlhint')
+call ale#Set('html_htmlhint_use_global', 0)
function! ale_linters#html#htmlhint#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'html_htmlhint_use_global')
- return ale#Var(a:buffer, 'html_htmlhint_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'html_htmlhint', [
\ 'node_modules/.bin/htmlhint',
- \ ale#Var(a:buffer, 'html_htmlhint_executable')
- \)
+ \])
endfunction
function! ale_linters#html#htmlhint#GetCommand(buffer) abort
diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim
index 461dd867..4e1494e2 100644
--- a/ale_linters/javascript/flow.vim
+++ b/ale_linters/javascript/flow.vim
@@ -1,22 +1,13 @@
" Author: Zach Perrault -- @zperrault
" Description: FlowType checking for JavaScript files
-let g:ale_javascript_flow_executable =
-\ get(g:, 'ale_javascript_flow_executable', 'flow')
-
-let g:ale_javascript_flow_use_global =
-\ get(g:, 'ale_javascript_flow_use_global', 0)
+call ale#Set('javascript_flow_executable', 'flow')
+call ale#Set('javascript_flow_use_global', 0)
function! ale_linters#javascript#flow#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'javascript_flow_use_global')
- return ale#Var(a:buffer, 'javascript_flow_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'javascript_flow', [
\ 'node_modules/.bin/flow',
- \ ale#Var(a:buffer, 'javascript_flow_executable')
- \)
+ \])
endfunction
function! ale_linters#javascript#flow#GetCommand(buffer) abort
diff --git a/ale_linters/javascript/jshint.vim b/ale_linters/javascript/jshint.vim
index 757d2096..93b16a8f 100644
--- a/ale_linters/javascript/jshint.vim
+++ b/ale_linters/javascript/jshint.vim
@@ -1,22 +1,13 @@
" Author: Chris Kyrouac - https://github.com/fijshion
" Description: JSHint for Javascript files
-let g:ale_javascript_jshint_executable =
-\ get(g:, 'ale_javascript_jshint_executable', 'jshint')
-
-let g:ale_javascript_jshint_use_global =
-\ get(g:, 'ale_javascript_jshint_use_global', 0)
+call ale#Set('javascript_jshint_executable', 'jshint')
+call ale#Set('javascript_jshint_use_global', 0)
function! ale_linters#javascript#jshint#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'javascript_jshint_use_global')
- return ale#Var(a:buffer, 'javascript_jshint_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'javascript_jshint', [
\ 'node_modules/.bin/jshint',
- \ ale#Var(a:buffer, 'javascript_jshint_executable')
- \)
+ \])
endfunction
function! ale_linters#javascript#jshint#GetCommand(buffer) abort
diff --git a/ale_linters/javascript/standard.vim b/ale_linters/javascript/standard.vim
index befb85f3..ab5ef5a7 100644
--- a/ale_linters/javascript/standard.vim
+++ b/ale_linters/javascript/standard.vim
@@ -1,25 +1,14 @@
" Author: Ahmed El Gabri <@ahmedelgabri>
" Description: standardjs for JavaScript files
-let g:ale_javascript_standard_executable =
-\ get(g:, 'ale_javascript_standard_executable', 'standard')
-
-let g:ale_javascript_standard_options =
-\ get(g:, 'ale_javascript_standard_options', '')
-
-let g:ale_javascript_standard_use_global =
-\ get(g:, 'ale_javascript_standard_use_global', 0)
+call ale#Set('javascript_standard_executable', 'standard')
+call ale#Set('javascript_standard_use_global', 0)
+call ale#Set('javascript_standard_options', '')
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'javascript_standard_use_global')
- return ale#Var(a:buffer, 'javascript_standard_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
\ 'node_modules/.bin/standard',
- \ ale#Var(a:buffer, 'javascript_standard_executable')
- \)
+ \])
endfunction
function! ale_linters#javascript#standard#GetCommand(buffer) abort
diff --git a/ale_linters/javascript/xo.vim b/ale_linters/javascript/xo.vim
index 0c6d91a1..648e0d14 100644
--- a/ale_linters/javascript/xo.vim
+++ b/ale_linters/javascript/xo.vim
@@ -1,25 +1,14 @@
" Author: Daniel Lupu <lupu.daniel.f@gmail.com>
" 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)
+call ale#Set('javascript_xo_executable', 'xo')
+call ale#Set('javascript_xo_use_global', 0)
+call ale#Set('javascript_xo_options', '')
function! ale_linters#javascript#xo#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'javascript_xo_use_global')
- return ale#Var(a:buffer, 'javascript_xo_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'javascript_xo', [
\ 'node_modules/.bin/xo',
- \ ale#Var(a:buffer, 'javascript_xo_executable')
- \)
+ \])
endfunction
function! ale_linters#javascript#xo#GetCommand(buffer) abort
diff --git a/ale_linters/sass/stylelint.vim b/ale_linters/sass/stylelint.vim
index 14d5467e..98c37257 100644
--- a/ale_linters/sass/stylelint.vim
+++ b/ale_linters/sass/stylelint.vim
@@ -1,21 +1,12 @@
" Author: diartyz <diartyz@gmail.com>
-let g:ale_sass_stylelint_executable =
-\ get(g:, 'ale_sass_stylelint_executable', 'stylelint')
-
-let g:ale_sass_stylelint_use_global =
-\ get(g:, 'ale_sass_stylelint_use_global', 0)
+call ale#Set('sass_stylelint_executable', 'stylelint')
+call ale#Set('sass_stylelint_use_global', 0)
function! ale_linters#sass#stylelint#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'sass_stylelint_use_global')
- return ale#Var(a:buffer, 'sass_stylelint_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'sass_stylelint', [
\ 'node_modules/.bin/stylelint',
- \ ale#Var(a:buffer, 'sass_stylelint_executable')
- \)
+ \])
endfunction
function! ale_linters#sass#stylelint#GetCommand(buffer) abort
diff --git a/ale_linters/scss/stylelint.vim b/ale_linters/scss/stylelint.vim
index af462686..00189a8b 100644
--- a/ale_linters/scss/stylelint.vim
+++ b/ale_linters/scss/stylelint.vim
@@ -1,21 +1,12 @@
" Author: diartyz <diartyz@gmail.com>
-let g:ale_scss_stylelint_executable =
-\ get(g:, 'ale_scss_stylelint_executable', 'stylelint')
-
-let g:ale_scss_stylelint_use_global =
-\ get(g:, 'ale_scss_stylelint_use_global', 0)
+call ale#Set('scss_stylelint_executable', 'stylelint')
+call ale#Set('scss_stylelint_use_global', 0)
function! ale_linters#scss#stylelint#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'scss_stylelint_use_global')
- return ale#Var(a:buffer, 'scss_stylelint_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'scss_stylelint', [
\ 'node_modules/.bin/stylelint',
- \ ale#Var(a:buffer, 'scss_stylelint_executable')
- \)
+ \])
endfunction
function! ale_linters#scss#stylelint#GetCommand(buffer) abort
diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim
index c382ed21..44784455 100644
--- a/ale_linters/typescript/tslint.vim
+++ b/ale_linters/typescript/tslint.vim
@@ -1,25 +1,14 @@
" Author: Prashanth Chandra https://github.com/prashcr
" Description: tslint for TypeScript files
-let g:ale_typescript_tslint_executable =
-\ get(g:, 'ale_typescript_tslint_executable', 'tslint')
-
-let g:ale_typescript_tslint_config_path =
-\ get(g:, 'ale_typescript_tslint_config_path', '')
-
-let g:ale_typescript_tslint_use_global =
-\ get(g:, 'ale_typescript_tslint_use_global', 0)
+call ale#Set('typescript_tslint_executable', 'tslint')
+call ale#Set('typescript_tslint_config_path', '')
+call ale#Set('typescript_tslint_use_global', 0)
function! ale_linters#typescript#tslint#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'typescript_tslint_use_global')
- return ale#Var(a:buffer, 'typescript_tslint_executable')
- endif
-
- return ale#path#ResolveLocalPath(
- \ a:buffer,
+ return ale#node#FindExecutable(a:buffer, 'typescript_tslint', [
\ 'node_modules/.bin/tslint',
- \ ale#Var(a:buffer, 'typescript_tslint_executable')
- \)
+ \])
endfunction
function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
diff --git a/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim
index 17852119..080005a6 100644
--- a/autoload/ale/handlers/eslint.vim
+++ b/autoload/ale/handlers/eslint.vim
@@ -5,25 +5,11 @@ call ale#Set('javascript_eslint_executable', 'eslint')
call ale#Set('javascript_eslint_use_global', 0)
function! ale#handlers#eslint#GetExecutable(buffer) abort
- if ale#Var(a:buffer, 'javascript_eslint_use_global')
- return ale#Var(a:buffer, 'javascript_eslint_executable')
- endif
-
- " Look for eslint_d first, then the path React uses, then the basic
- " eslint path.
- for l:path in [
+ return ale#node#FindExecutable(a:buffer, 'javascript_eslint', [
\ 'node_modules/.bin/eslint_d',
\ 'node_modules/eslint/bin/eslint.js',
\ 'node_modules/.bin/eslint',
- \]
- let l:executable = ale#path#FindNearestFile(a:buffer, l:path)
-
- if !empty(l:executable)
- return l:executable
- endif
- endfor
-
- return ale#Var(a:buffer, 'javascript_eslint_executable')
+ \])
endfunction
function! s:FindConfig(buffer) abort
diff --git a/autoload/ale/node.vim b/autoload/ale/node.vim
new file mode 100644
index 00000000..54b53fb9
--- /dev/null
+++ b/autoload/ale/node.vim
@@ -0,0 +1,22 @@
+" Author: w0rp <devw0rp@gmail.com>
+" Description: Functions for working with Node executables.
+
+" Given a buffer number, a base variable name, and a list of paths to search
+" for in ancestor directories, detect the executable path for a Node program.
+"
+" The use_global and executable options for the relevant program will be used.
+function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort
+ if ale#Var(a:buffer, a:base_var_name . '_use_global')
+ return ale#Var(a:buffer, a:base_var_name . '_executable')
+ endif
+
+ for l:path in a:path_list
+ let l:executable = ale#path#FindNearestFile(a:buffer, l:path)
+
+ if !empty(l:executable)
+ return l:executable
+ endif
+ endfor
+
+ return ale#Var(a:buffer, a:base_var_name . '_executable')
+endfunction