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.
2 call ale#assert#SetUpFixerTest('javascript', 'prettier')
3 Save g:ale_command_wrapper
5 let g:ale_command_wrapper = ''
8 call ale#assert#TearDownFixerTest()
10 Execute(The prettier callback should return the correct default values):
11 call ale#test#SetFilename('../test-files/prettier/testfile.js')
15 \ 'read_temporary_file': 1,
16 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
21 Execute(The --config option should not be set automatically):
22 let g:ale_javascript_prettier_use_local_config = 1
23 call ale#test#SetFilename('../test-files/prettier/with_config/testfile.js')
27 \ 'read_temporary_file': 1,
28 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
33 Execute(The prettier callback should include custom prettier options):
34 let g:ale_javascript_prettier_options = '--no-semi'
35 call ale#test#SetFilename('../test-files/prettier/with_config/testfile.js')
39 \ 'read_temporary_file': 1,
40 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
46 Execute(The version check should be correct):
47 call ale#test#SetFilename('../test-files/prettier/testfile.js')
50 \ ale#Escape('prettier') . ' --version',
51 \ {'read_temporary_file': 1, 'command': ale#Escape('prettier') . ' %t --write'}
54 Execute(--stdin-filepath should be used when prettier is new enough):
55 let g:ale_javascript_prettier_options = '--no-semi'
56 call ale#test#SetFilename('../test-files/prettier/with_config/testfile.js')
58 GivenCommandOutput ['1.6.0']
62 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
64 \ . ' --stdin-filepath %s --stdin',
67 Execute(The version number should be cached):
68 call ale#test#SetFilename('../test-files/prettier/with_config/testfile.js')
70 GivenCommandOutput ['1.6.0']
74 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
75 \ . ' --stdin-filepath %s --stdin',
82 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
83 \ . ' --stdin-filepath %s --stdin',
86 Execute(Should set --parser to `babylon` by default, < 1.16.0):
87 call ale#test#SetFilename('../test-files/prettier/testfile')
89 set filetype=javascript
91 GivenCommandOutput ['1.6.0']
95 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
96 \ . ' --parser babylon'
97 \ . ' --stdin-filepath %s --stdin',
100 Execute(Should set --parser to `babel` by default, >= 1.16.0):
101 call ale#test#SetFilename('../test-files/prettier/testfile')
103 set filetype=javascript
105 GivenCommandOutput ['1.16.0']
109 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
110 \ . ' --parser babel'
111 \ . ' --stdin-filepath %s --stdin',
114 Execute(Should set --parser based on filetype, TypeScript):
115 call ale#test#SetFilename('../test-files/prettier/testfile')
117 set filetype=typescript
119 GivenCommandOutput ['1.6.0']
123 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
124 \ . ' --parser typescript'
125 \ . ' --stdin-filepath %s --stdin',
128 Execute(Should set --parser based on filetype, CSS):
129 call ale#test#SetFilename('../test-files/prettier/testfile')
133 GivenCommandOutput ['1.6.0']
137 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
139 \ . ' --stdin-filepath %s --stdin',
142 Execute(Should set --parser based on filetype, LESS):
143 call ale#test#SetFilename('../test-files/prettier/testfile')
147 GivenCommandOutput ['1.6.0']
151 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
153 \ . ' --stdin-filepath %s --stdin',
156 Execute(Should set --parser based on filetype, SCSS):
157 call ale#test#SetFilename('../test-files/prettier/testfile')
161 GivenCommandOutput ['1.6.0']
165 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
167 \ . ' --stdin-filepath %s --stdin',
170 Execute(Should set --parser based on filetype, JSON):
171 call ale#test#SetFilename('../test-files/prettier/testfile')
175 GivenCommandOutput ['1.6.0']
179 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
181 \ . ' --stdin-filepath %s --stdin',
184 Execute(Should set --parser based on filetype, JSON5):
185 call ale#test#SetFilename('../test-files/prettier/testfile')
189 GivenCommandOutput ['1.6.0']
193 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
194 \ . ' --parser json5'
195 \ . ' --stdin-filepath %s --stdin',
198 Execute(Should set --parser based on filetype, GraphQL):
199 call ale#test#SetFilename('../test-files/prettier/testfile')
203 GivenCommandOutput ['1.6.0']
207 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
208 \ . ' --parser graphql'
209 \ . ' --stdin-filepath %s --stdin',
212 Execute(Should set --parser based on filetype, Markdown):
213 call ale#test#SetFilename('../test-files/prettier/testfile')
215 set filetype=markdown
217 GivenCommandOutput ['1.6.0']
221 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
222 \ . ' --parser markdown'
223 \ . ' --stdin-filepath %s --stdin',
226 Execute(Should set --parser based on filetype, Vue):
227 call ale#test#SetFilename('../test-files/prettier/testfile')
231 GivenCommandOutput ['1.6.0']
235 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
237 \ . ' --stdin-filepath %s --stdin',
240 Execute(Should set --parser based on filetype, YAML):
241 call ale#test#SetFilename('../test-files/prettier/testfile')
245 GivenCommandOutput ['1.6.0']
249 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
251 \ . ' --stdin-filepath %s --stdin',
254 Execute(Should set --parser based on filetype, HTML):
255 call ale#test#SetFilename('../test-files/prettier/testfile')
259 GivenCommandOutput ['1.6.0']
263 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
265 \ . ' --stdin-filepath %s --stdin',
268 Execute(Should set --parser based on filetype, Ruby):
269 call ale#test#SetFilename('../test-files/prettier/testfile')
273 GivenCommandOutput ['1.6.0']
277 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
279 \ . ' --stdin-filepath %s --stdin',
282 Execute(Should set --parser based on first filetype of multiple filetypes):
283 call ale#test#SetFilename('../test-files/prettier/testfile')
285 set filetype=css.scss
287 GivenCommandOutput ['1.6.0']
291 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
293 \ . ' --stdin-filepath %s --stdin',
296 Execute(Should set --parser based on first filetype of multiple filetypes):
297 call ale#test#SetFilename('../test-files/prettier/testfile')
301 GivenCommandOutput ['1.6.0']
305 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
306 \ . ' --parser astro'
307 \ . ' --stdin-filepath %s --stdin',
310 Execute(Should set --parser for experimental language, Handlebars):
311 call ale#test#SetFilename('../test-files/prettier/testfile.hbs')
313 set filetype=html.handlebars
315 GivenCommandOutput ['1.6.0']
319 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
320 \ . ' --parser glimmer'
321 \ . ' --stdin-filepath %s --stdin',
324 Execute(Changes to directory where .prettierignore is found):
325 call ale#test#SetFilename('../test-files/prettier/with_prettierignore/src/testfile.js')
327 GivenCommandOutput ['1.6.0']
330 \ 'cwd': expand('%:p:h:h'),
331 \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
332 \ . ' --stdin-filepath %s --stdin',
335 Execute(The prettier_d post-processor should permit regular JavaScript content):
338 \ 'const x = ''Error: foo''',
341 \ ale#fixers#prettier#ProcessPrettierDOutput(bufnr(''), [
342 \ 'const x = ''Error: foo''',
346 Execute(The prettier_d post-processor should handle error messages correctly):
349 \ ale#fixers#prettier#ProcessPrettierDOutput(bufnr(''), [
350 \ 'SyntaxError: Unexpected token, expected "," (36:28)',