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', 'eslint')
3 Save g:ale_command_wrapper
5 runtime autoload/ale/handlers/eslint.vim
7 let g:ale_command_wrapper = ''
10 call ale#assert#TearDownFixerTest()
12 Execute(The executable path should be correct):
13 call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js')
15 " eslint_d output with an older eslint version is used here.
16 GivenCommandOutput ['v4.4.1 (eslint_d v5.1.0)']
19 \ 'read_temporary_file': 1,
20 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
21 \ 'command': (has('win32') ? 'node.exe ' : '')
22 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
23 \ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/.eslintrc.js'))
27 Execute(The ESLint fixer shouldn't run if no configuration file can be found):
28 call ale#test#SetFilename('../no-configuration')
29 AssertFixerNotExecuted
31 Execute(The ESLint fixer should use a config file option if set for old versions):
32 call ale#test#SetFilename('../no-configuration')
33 let b:ale_javascript_eslint_options = '-c /foo.cfg'
37 \ 'read_temporary_file': 1,
39 \ 'command': ale#Escape('eslint') . ' -c /foo.cfg --fix %t',
42 let b:ale_javascript_eslint_options = '--bar -c /foo.cfg'
46 \ 'read_temporary_file': 1,
48 \ 'command': ale#Escape('eslint') . ' --bar -c /foo.cfg --fix %t',
51 let b:ale_javascript_eslint_options = '--config /foo.cfg'
55 \ 'read_temporary_file': 1,
57 \ 'command': ale#Escape('eslint') . ' --config /foo.cfg --fix %t',
60 let b:ale_javascript_eslint_options = '--bar --config /foo.cfg'
64 \ 'read_temporary_file': 1,
66 \ 'command': ale#Escape('eslint') . ' --bar --config /foo.cfg --fix %t',
69 Execute(The ESLint fixer should use a -c file option if set for eslint_d):
70 let b:ale_javascript_eslint_executable = '/bin/eslint_d'
71 GivenCommandOutput ['v3.19.0 (eslint_d v4.2.0)']
72 call ale#test#SetFilename('../no-configuration')
73 let b:ale_javascript_eslint_options = '-c /foo.cfg'
77 \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
79 \ 'command': ale#Escape('/bin/eslint_d')
81 \ . ' --stdin-filename %s --stdin --fix-to-stdout'
84 let b:ale_javascript_eslint_options = '--bar -c /foo.cfg'
88 \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
90 \ 'command': ale#Escape('/bin/eslint_d')
91 \ . ' --bar -c /foo.cfg'
92 \ . ' --stdin-filename %s --stdin --fix-to-stdout'
95 let b:ale_javascript_eslint_options = '--config /foo.cfg'
99 \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
101 \ 'command': ale#Escape('/bin/eslint_d')
102 \ . ' --config /foo.cfg'
103 \ . ' --stdin-filename %s --stdin --fix-to-stdout'
106 let b:ale_javascript_eslint_options = '--bar --config /foo.cfg'
110 \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
112 \ 'command': ale#Escape('/bin/eslint_d')
113 \ . ' --bar --config /foo.cfg'
114 \ . ' --stdin-filename %s --stdin --fix-to-stdout'
117 Execute(The ESLint fixer should use a config file option if set for new versions):
118 GivenCommandOutput ['4.9.0']
119 call ale#test#SetFilename('../no-configuration')
120 let b:ale_javascript_eslint_options = '-c /foo.cfg'
124 \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
126 \ 'command': ale#Escape('eslint')
128 \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
131 let b:ale_javascript_eslint_options = '--bar -c /foo.cfg'
135 \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
137 \ 'command': ale#Escape('eslint')
138 \ . ' --bar -c /foo.cfg'
139 \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
142 let b:ale_javascript_eslint_options = '--config /foo.cfg'
146 \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
148 \ 'command': ale#Escape('eslint')
149 \ . ' --config /foo.cfg'
150 \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
153 let b:ale_javascript_eslint_options = '--bar --config /foo.cfg'
157 \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
159 \ 'command': ale#Escape('eslint')
160 \ . ' --bar --config /foo.cfg'
161 \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
164 Execute(The lower priority configuration file in a nested directory should be preferred):
165 call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-config/testfile.js')
169 \ 'read_temporary_file': 1,
170 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/subdir-with-config'),
171 \ 'command': (has('win32') ? 'node.exe ' : '')
172 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
173 \ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/subdir-with-config/.eslintrc'))
177 Execute(--config in options should override configuration file detection for old versions):
178 call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-config/testfile.js')
180 let b:ale_javascript_eslint_options = '--config /foo.cfg'
184 \ 'read_temporary_file': 1,
185 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/subdir-with-config'),
186 \ 'command': (has('win32') ? 'node.exe ' : '')
187 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
188 \ . ' --config /foo.cfg'
192 let b:ale_javascript_eslint_options = '-c /foo.cfg'
196 \ 'read_temporary_file': 1,
197 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/subdir-with-config'),
198 \ 'command': (has('win32') ? 'node.exe ' : '')
199 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
204 Execute(package.json should be used as a last resort):
205 call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-package-json/testfile.js')
209 \ 'read_temporary_file': 1,
210 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
211 \ 'command': (has('win32') ? 'node.exe ' : '')
212 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
213 \ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/.eslintrc.js'))
217 call ale#test#SetFilename('../test-files/eslint/package.json')
221 \ 'read_temporary_file': 1,
222 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint'),
223 \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/node_modules/.bin/eslint'))
224 \ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/package.json'))
228 Execute(The version check should be correct):
229 call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-config/testfile.js')
231 " We should run the command to get the version the first time.
232 GivenCommandOutput ['4.9.0']
234 \ (has('win32') ? 'node.exe ' : '')
235 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
238 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/subdir-with-config'),
239 \ 'command': (has('win32') ? 'node.exe ' : '')
240 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
241 \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
242 \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
248 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/subdir-with-config'),
249 \ 'command': (has('win32') ? 'node.exe ' : '')
250 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
251 \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
252 \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
256 Execute(--fix-dry-run should be used for 4.9.0 and up):
257 call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js')
259 GivenCommandOutput ['4.9.0']
262 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
263 \ 'command': (has('win32') ? 'node.exe ' : '')
264 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
265 \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
266 \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
269 Execute(The --fix-dry-run post-processor should handle JSON output correctly):
272 \ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), [])
275 \ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), [''])
278 \ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), ['[{}]'])
281 \ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), ['[{"output": "foo\nbar"}]'])
283 Execute(The eslint_d post-processor should permit regular JavaScript content):
286 \ 'const x = ''Error: foo''',
289 \ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
290 \ 'const x = ''Error: foo''',
294 Execute(The eslint_d post-processor should handle error messages correctly):
297 \ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
298 \ 'Error: No ESLint configuration found.',
301 Execute(The eslint_d post-processor should handle failing to connect properly):
304 \ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
305 \ 'Could not connect',
308 Execute(The executable path should be correct for astro app):
309 call ale#test#SetFilename('../test-files/eslint/astro-app/src/pages/index.astro')
311 " eslint_d output with an older eslint version is used here.
312 GivenCommandOutput ['v4.4.1 (eslint_d v5.1.0)']
315 \ 'read_temporary_file': 1,
316 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app'),
317 \ 'command': (has('win32') ? 'node.exe ' : '')
318 \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app/node_modules/eslint/bin/eslint.js'))
319 \ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app/.eslintrc.js'))