1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
Save g:ale_javascript_prettier_executable
Save g:ale_javascript_prettier_options
" Use an invalid global executable, so we don't match it.
let g:ale_javascript_prettier_executable = 'xxxinvalid'
let g:ale_javascript_prettier_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
silent cd command_callback
let g:dir = getcwd()
After:
let g:ale_has_override = {}
call ale#test#RestoreDirectory()
Execute(The prettier callback should return the correct default values):
call ale#test#SetFilename('../prettier-test-files/testfile.js')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --parser babylon'
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
Execute(The prettier callback should include configuration files when the option is set):
let g:ale_javascript_prettier_use_local_config = 1
call ale#test#SetFilename('../prettier-test-files/with_config/testfile.js')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --parser babylon'
\ . ' --config ' . ale#Escape(simplify(g:dir . '/../prettier-test-files/with_config/.prettierrc'))
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
Execute(The prettier callback should include custom prettier options):
let g:ale_javascript_prettier_options = '--no-semi'
call ale#test#SetFilename('../prettier-test-files/with_config/testfile.js')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --no-semi --parser babylon'
\ . ' --config ' . ale#Escape(simplify(g:dir . '/../prettier-test-files/with_config/.prettierrc'))
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
Execute(Append '--parser typescript' for filetype=typescript):
set filetype=typescript
call ale#test#SetFilename('../prettier-test-files/testfile.ts')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --parser typescript'
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
Execute(Append '--parser json' for filetype=json):
set filetype=json
call ale#test#SetFilename('../prettier-test-files/testfile.json')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --parser json'
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
Execute(Append '--parser postcss' for filetype=scss):
set filetype=scss
call ale#test#SetFilename('../prettier-test-files/testfile.scss')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --parser postcss'
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
Execute(Append '--parser postcss' for filetype=css):
set filetype=css
call ale#test#SetFilename('../prettier-test-files/testfile.css')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --parser postcss'
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
|