This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/test/fixers/test_prettier_eslint_fixer.callback.vader
w0rp 9fe7b1fe6a
Close #2281 - Separate cwd commands from commands
Working directories are now set seperately from the commands so they
can later be swapped out when running linters over projects is
supported, and also better support filename mapping for running linters
on other machines in future.
2021-03-01 20:11:10 +00:00

97 lines
2.4 KiB
Text

Before:
call ale#assert#SetUpFixerTest('javascript', 'prettier_eslint')
Save g:ale_command_wrapper
let g:ale_command_wrapper = ''
After:
call ale#assert#TearDownFixerTest()
Execute(The default command should be correct):
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --write'
\ }
Execute(Additional options should be used when set):
let b:ale_javascript_prettier_eslint_options = '--foobar'
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --foobar --write'
\ }
Execute(--eslint-config-path should be set for 4.2.0 and up):
call ale#test#SetFilename('eslint-test-files/react-app/foo/bar.js')
GivenCommandOutput ['4.2.0']
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --eslint-config-path ' . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/.eslintrc.js'))
\ . ' --write'
\ }
Execute(--eslint-config-path shouldn't be used for older versions):
call ale#test#SetFilename('eslint-test-files/react-app/foo/bar.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --write'
\ }
Execute(The version check should be correct):
AssertFixer [
\ ale#Escape('prettier-eslint') . ' --version',
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --write'
\ }
\]
Execute(The new --stdin-filepath option should be used when the version is new enough):
call ale#test#SetFilename('eslint-test-files/react-app/foo/bar.js')
GivenCommandOutput ['4.4.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape('prettier-eslint')
\ . ' --eslint-config-path ' . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/.eslintrc.js'))
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(The version number should be cached):
GivenCommandOutput ['4.4.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape('prettier-eslint')
\ . ' --stdin-filepath %s --stdin',
\ }
GivenCommandOutput []
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape('prettier-eslint')
\ . ' --stdin-filepath %s --stdin',
\ }