From fb720251bf38139c1811665852e1bc2f73d0393f Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 15 Apr 2018 12:25:15 +0100 Subject: [PATCH] Close #1504 - Add an option for removing --respect-pragma for flow --- ale_linters/javascript/flow.vim | 5 +++-- doc/ale-javascript.txt | 11 +++++++++++ test/test_flow_command.vader | 13 +++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim index d2b362b5..d555184e 100755 --- a/ale_linters/javascript/flow.vim +++ b/ale_linters/javascript/flow.vim @@ -5,6 +5,7 @@ call ale#Set('javascript_flow_executable', 'flow') call ale#Set('javascript_flow_use_home_config', 0) call ale#Set('javascript_flow_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_flow_use_respect_pragma', 1) function! ale_linters#javascript#flow#GetExecutable(buffer) abort let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig') @@ -47,8 +48,8 @@ function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort " If we can parse the version number, then only use --respect-pragma " if the version is >= 0.36.0, which added the argument. - let l:use_respect_pragma = empty(l:version) - \ || ale#semver#GTE(l:version, [0, 36]) + let l:use_respect_pragma = ale#Var(a:buffer, 'javascript_flow_use_respect_pragma') + \ && (empty(l:version) || ale#semver#GTE(l:version, [0, 36])) return ale#Escape(l:executable) \ . ' check-contents' diff --git a/doc/ale-javascript.txt b/doc/ale-javascript.txt index 80f41016..53a70fd7 100644 --- a/doc/ale-javascript.txt +++ b/doc/ale-javascript.txt @@ -103,6 +103,17 @@ g:ale_javascript_flow_use_global *g:ale_javascript_flow_use_global* See |ale-integrations-local-executables| +g:ale_javascript_flow_use_respect_pragma + *g:ale_javascript_flow_use_respect_pragma* + *b:ale_javascript_flow_use_respect_pragma* + Type: |Number| + Default: `1` + + By default, ALE will use the `--respect-pragma` option for `flow`, so only + files with the `@flow` pragma are checked by ALE. This option can be set to + `0` to disable that behaviour, so all files can be checked by `flow`. + + =============================================================================== importjs *ale-javascript-importjs* diff --git a/test/test_flow_command.vader b/test/test_flow_command.vader index 49546e94..c673ce0a 100644 --- a/test/test_flow_command.vader +++ b/test/test_flow_command.vader @@ -1,8 +1,11 @@ Before: runtime ale_linters/javascript/flow.vim + call ale#test#SetDirectory('/testplugin/test') After: + unlet! b:ale_javascript_flow_use_respect_pragma + call ale#test#RestoreDirectory() call ale#linter#Reset() call ale#semver#ResetVersionCache() @@ -15,6 +18,16 @@ Execute(flow should return a command to run if a .flowconfig file exists): \ . ' check-contents --respect-pragma --json --from ale %s', \ ale_linters#javascript#flow#GetCommand(bufnr('%'), []) +Execute(flow should not use the respect pragma argument if the option is off): + call ale#test#SetFilename('flow/a/sub/dummy') + + let b:ale_javascript_flow_use_respect_pragma = 0 + + AssertEqual + \ ale#Escape('flow') + \ . ' check-contents --json --from ale %s', + \ ale_linters#javascript#flow#GetCommand(bufnr('%'), []) + Execute(flow should should not use --respect-pragma for old versions): call ale#test#SetFilename('flow/a/sub/dummy')