diff options
author | w0rp <devw0rp@gmail.com> | 2017-11-21 14:37:01 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-11-21 14:37:01 +0000 |
commit | 3ef98f42bdb0d692346d4aab29bd0809a6d5bdd4 (patch) | |
tree | be31144555116acf716734d4469a075ebe3c1b68 /ale_linters/javascript/flow.vim | |
parent | ac7f69063db30edfad14fac19b9d06be487885b1 (diff) | |
download | ale-3ef98f42bdb0d692346d4aab29bd0809a6d5bdd4.zip |
Fix #783 - Do not run Flow with home directory configuration files by default
Diffstat (limited to 'ale_linters/javascript/flow.vim')
-rwxr-xr-x | ale_linters/javascript/flow.vim | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim index 8dc930cd..643ea190 100755 --- a/ale_linters/javascript/flow.vim +++ b/ale_linters/javascript/flow.vim @@ -1,32 +1,48 @@ " Author: Zach Perrault -- @zperrault -" Description: FlowType checking for JavaScript files - -" Flow extra errors " Author: Florian Beeres <yuuki@protonmail.com> +" Description: FlowType checking for JavaScript files call ale#Set('javascript_flow_executable', 'flow') +call ale#Set('javascript_flow_use_home_config', 0) call ale#Set('javascript_flow_use_global', 0) function! ale_linters#javascript#flow#GetExecutable(buffer) abort + let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig') + + if empty(l:flow_config) + " Don't run Flow if we can't find a .flowconfig file. + return '' + endif + + " Don't run Flow with a configuration file from the home directory by + " default, which can eat all of your RAM. + if fnamemodify(l:flow_config, ':h') is? $HOME + \&& !ale#Var(a:buffer, 'javascript_flow_use_home_config') + return '' + endif + return ale#node#FindExecutable(a:buffer, 'javascript_flow', [ \ 'node_modules/.bin/flow', \]) endfunction function! ale_linters#javascript#flow#VersionCheck(buffer) abort - return ale#Escape(ale_linters#javascript#flow#GetExecutable(a:buffer)) - \ . ' --version' + let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer) + + if empty(l:executable) + return '' + endif + + return ale#Escape(l:executable) . ' --version' endfunction function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort - let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig') + let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer) - if empty(l:flow_config) - " Don't run Flow if we can't find a .flowconfig file. + if empty(l:executable) return '' endif - let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer) let l:version = ale#semver#GetVersion(l:executable, a:version_lines) " If we can parse the version number, then only use --respect-pragma |