fixers/xo: support monorepos
This commit is contained in:
parent
8ffde14039
commit
f17beadb49
8 changed files with 16 additions and 16 deletions
|
@ -29,7 +29,7 @@ function! ale#handlers#xo#HandleJSON(buffer, lines) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#handlers#xo#GetProjectRoot(buffer) abort
|
function! ale#handlers#xo#GetProjectRoot(buffer) abort
|
||||||
let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json')
|
let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules')
|
||||||
|
|
||||||
return empty(l:package_path) ? '' : fnamemodify(l:package_path, ':p:h')
|
return empty(l:modules_dir) ? '' : fnamemodify(l:modules_dir, ':h:h')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -7,39 +7,39 @@ After:
|
||||||
call ale#assert#TearDownFixerTest()
|
call ale#assert#TearDownFixerTest()
|
||||||
|
|
||||||
Execute(The xo callback should return the correct default values):
|
Execute(The xo callback should return the correct default values):
|
||||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
|
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.js')
|
||||||
|
|
||||||
AssertFixer
|
AssertFixer
|
||||||
\ {
|
\ {
|
||||||
\ 'read_temporary_file': 1,
|
\ 'read_temporary_file': 1,
|
||||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js'))
|
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
|
||||||
\ . ' --fix %t',
|
\ . ' --fix %t',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
Execute(The xo callback should include custom xo options):
|
Execute(The xo callback should include custom xo options):
|
||||||
let g:ale_javascript_xo_options = '--space'
|
let g:ale_javascript_xo_options = '--space'
|
||||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
|
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.js')
|
||||||
|
|
||||||
AssertFixer
|
AssertFixer
|
||||||
\ {
|
\ {
|
||||||
\ 'read_temporary_file': 1,
|
\ 'read_temporary_file': 1,
|
||||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js'))
|
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
|
||||||
\ . ' --fix %t'
|
\ . ' --fix %t'
|
||||||
\ . ' --space',
|
\ . ' --space',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
Execute(--stdin should be used when xo is new enough):
|
Execute(--stdin should be used when xo is new enough):
|
||||||
let g:ale_javascript_xo_options = '--space'
|
let g:ale_javascript_xo_options = '--space'
|
||||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
|
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.js')
|
||||||
|
|
||||||
GivenCommandOutput ['0.30.0']
|
GivenCommandOutput ['0.30.0']
|
||||||
AssertFixer
|
AssertFixer
|
||||||
\ {
|
\ {
|
||||||
\ 'command': ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files'))
|
\ 'command': ale#path#CdString(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo'))
|
||||||
\ . (has('win32') ? 'node.exe ' : '')
|
\ . (has('win32') ? 'node.exe ' : '')
|
||||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js'))
|
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
|
||||||
\ . ' --stdin --stdin-filename %s'
|
\ . ' --stdin --stdin-filename %s'
|
||||||
\ . ' --fix'
|
\ . ' --fix'
|
||||||
\ . ' --space',
|
\ . ' --space',
|
||||||
|
|
|
@ -7,39 +7,39 @@ After:
|
||||||
call ale#assert#TearDownFixerTest()
|
call ale#assert#TearDownFixerTest()
|
||||||
|
|
||||||
Execute(The xo callback should return the correct default values):
|
Execute(The xo callback should return the correct default values):
|
||||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.ts')
|
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.ts')
|
||||||
|
|
||||||
AssertFixer
|
AssertFixer
|
||||||
\ {
|
\ {
|
||||||
\ 'read_temporary_file': 1,
|
\ 'read_temporary_file': 1,
|
||||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js'))
|
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
|
||||||
\ . ' --fix %t',
|
\ . ' --fix %t',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
Execute(The xo callback should include custom xo options):
|
Execute(The xo callback should include custom xo options):
|
||||||
let g:ale_typescript_xo_options = '--space'
|
let g:ale_typescript_xo_options = '--space'
|
||||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.ts')
|
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.ts')
|
||||||
|
|
||||||
AssertFixer
|
AssertFixer
|
||||||
\ {
|
\ {
|
||||||
\ 'read_temporary_file': 1,
|
\ 'read_temporary_file': 1,
|
||||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js'))
|
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
|
||||||
\ . ' --fix %t'
|
\ . ' --fix %t'
|
||||||
\ . ' --space',
|
\ . ' --space',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
Execute(--stdin should be used when xo is new enough):
|
Execute(--stdin should be used when xo is new enough):
|
||||||
let g:ale_typescript_xo_options = '--space'
|
let g:ale_typescript_xo_options = '--space'
|
||||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.ts')
|
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.ts')
|
||||||
|
|
||||||
GivenCommandOutput ['0.30.0']
|
GivenCommandOutput ['0.30.0']
|
||||||
AssertFixer
|
AssertFixer
|
||||||
\ {
|
\ {
|
||||||
\ 'command': ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files'))
|
\ 'command': ale#path#CdString(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo'))
|
||||||
\ . (has('win32') ? 'node.exe ' : '')
|
\ . (has('win32') ? 'node.exe ' : '')
|
||||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js'))
|
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
|
||||||
\ . ' --stdin --stdin-filename %s'
|
\ . ' --stdin --stdin-filename %s'
|
||||||
\ . ' --fix'
|
\ . ' --fix'
|
||||||
\ . ' --space',
|
\ . ' --space',
|
||||||
|
|
0
test/xo-test-files/monorepo/node_modules/xo/cli.js
generated
vendored
Normal file
0
test/xo-test-files/monorepo/node_modules/xo/cli.js
generated
vendored
Normal file
0
test/xo-test-files/monorepo/package.json
Normal file
0
test/xo-test-files/monorepo/package.json
Normal file
0
test/xo-test-files/monorepo/packages/a/index.js
Normal file
0
test/xo-test-files/monorepo/packages/a/index.js
Normal file
0
test/xo-test-files/monorepo/packages/a/index.ts
Normal file
0
test/xo-test-files/monorepo/packages/a/index.ts
Normal file
0
test/xo-test-files/monorepo/packages/a/package.json
Normal file
0
test/xo-test-files/monorepo/packages/a/package.json
Normal file
Reference in a new issue