All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: tunnckoCore (Charlike Mike Reagent) <mameto2011@gmail.com>,
2 " w0rp <devw0rp@gmail.com>, morhetz (Pavel Pertsev) <morhetz@gmail.com>
3 " Description: Integration between Prettier and ESLint.
5 call ale#Set('javascript_prettier_eslint_executable', 'prettier-eslint')
6 call ale#Set('javascript_prettier_eslint_use_global', get(g:, 'ale_use_global_executables', 0))
7 call ale#Set('javascript_prettier_eslint_options', '')
9 function! ale#fixers#prettier_eslint#GetExecutable(buffer) abort
10 return ale#path#FindExecutable(a:buffer, 'javascript_prettier_eslint', [
11 \ 'node_modules/prettier-eslint-cli/dist/index.js',
12 \ 'node_modules/.bin/prettier-eslint',
16 function! ale#fixers#prettier_eslint#Fix(buffer) abort
17 return ale#semver#RunWithVersionCheck(
19 \ ale#fixers#prettier_eslint#GetExecutable(a:buffer),
21 \ function('ale#fixers#prettier_eslint#ApplyFixForVersion'),
25 function! ale#fixers#prettier_eslint#ApplyFixForVersion(buffer, version) abort
26 let l:options = ale#Var(a:buffer, 'javascript_prettier_eslint_options')
27 let l:executable = ale#fixers#prettier_eslint#GetExecutable(a:buffer)
29 " 4.2.0 is the first version with --eslint-config-path
30 let l:config = ale#semver#GTE(a:version, [4, 2, 0])
31 \ ? ale#handlers#eslint#FindConfig(a:buffer)
33 let l:eslint_config_option = !empty(l:config)
34 \ ? ' --eslint-config-path ' . ale#Escape(l:config)
37 " 4.4.0 is the first version with --stdin-filepath
38 if ale#semver#GTE(a:version, [4, 4, 0])
41 \ 'command': ale#Escape(l:executable)
42 \ . l:eslint_config_option
43 \ . (!empty(l:options) ? ' ' . l:options : '')
44 \ . ' --stdin-filepath %s --stdin',
49 \ 'command': ale#Escape(l:executable)
51 \ . l:eslint_config_option
52 \ . (!empty(l:options) ? ' ' . l:options : '')
54 \ 'read_temporary_file': 1,