Hi, first of all, great plugin!
My issue is that ALE doesn't seem to pick up eslintrc environment settings. For instance, I'll set es6 as my environment, I still get warnings for use of const. This does not happen if I run eslint manually from the command line.
Eslint version: v4.3.0
OS version: macOS 10.12.6
Neovim version: v0.2.0
Here's my JS:
'use strict';
const fs = require('fs');
function avg(nums) {
let total = 0;
nums.foreach(num => total += num);
return total / nums.length;
}
function avgperf(data) {
for (let key in data) {
if (data.hasownproperty(key)) {
console.log(`${key} -> ${avg(data[key])}`);
}
}
}
And here's my eslintrc (example is YAML, but I also tried JSON):
---
env:
node: true
browser: true
es6: true
And here's the output from ALEInfoToClipboard:
Current Filetype: javascript
Available Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']
Enabled Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']
Linter Variables:
let g:ale_javascript_eslint_executable = 'eslint'
let g:ale_javascript_eslint_options = ''
let g:ale_javascript_eslint_use_global = 0
let g:ale_javascript_flow_executable = 'flow'
let g:ale_javascript_flow_use_global = 0
let g:ale_javascript_jscs_executable = 'jscs'
let g:ale_javascript_jscs_use_global = 0
let g:ale_javascript_jshint_executable = 'jshint'
let g:ale_javascript_jshint_use_global = 0
let g:ale_javascript_standard_executable = 'standard'
let g:ale_javascript_standard_options = ''
let g:ale_javascript_standard_use_global = 0
let g:ale_javascript_xo_executable = 'xo'
let g:ale_javascript_xo_options = ''
let g:ale_javascript_xo_use_global = 0
Global Variables:
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%s'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_open_list = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_offset = 1000000
let g:ale_sign_warning = '--'
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(finished - exit code 1) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1472/avgPerf.js''']
<<<OUTPUT STARTS>>>
/Users/delucac/Downloads/avgPerf.js:5:1: Parsing error: Unexpected token function [Error]
1 problem
<<<OUTPUT ENDS>>>
(finished - exit code 2) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1473/avgPerf.js''']
<<<OUTPUT STARTS>>>
stdin:1:1: Use the function form of "use strict".
stdin:3:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:7: const 'fs' is initialized to 'undefined'.
stdin:3:9: Missing semicolon.
stdin:6:3: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:7:20: 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
stdin:12:8: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:19: 'template literal syntax' is only available in ES6 (use 'esversion: 6').
stdin:23:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:32:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:7: 'console' is not defined.
stdin:43:1: 'console' is not defined.
12 errors
<<<OUTPUT ENDS>>>
(started) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1474/avgPerf.js''']
(started) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1475/avgPerf.js''']
(finished - exit code 0) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1476/avgPerf.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 2) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1477/avgPerf.js''']
<<<OUTPUT STARTS>>>
stdin:1:1: Use the function form of "use strict".
stdin:3:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:6:3: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:7:20: 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
stdin:9:2: Missing semicolon.
stdin:12:8: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:19: 'template literal syntax' is only available in ES6 (use 'esversion: 6').
stdin:23:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:32:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:7: 'console' is not defined.
stdin:43:1: 'console' is not defined.
stdin:14:32: 'avg' is not defined.
12 errors
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1478/avgPerf.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 2) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1479/avgPerf.js''']
<<<OUTPUT STARTS>>>
stdin:1:1: Use the function form of "use strict".
stdin:3:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:13: Missing semicolon.
stdin:6:3: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:7:20: 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
stdin:12:8: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:19: 'template literal syntax' is only available in ES6 (use 'esversion: 6').
stdin:23:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:32:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:12: 'r' is not defined.
stdin:14:7: 'console' is not defined.
stdin:43:1: 'console' is not defined.
12 errors
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1480/avgPerf.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 2) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1481/avgPerf.js''']
<<<OUTPUT STARTS>>>
stdin:1:1: Use the function form of "use strict".
stdin:3:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:15: Missing semicolon.
stdin:6:3: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:7:20: 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
stdin:12:8: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:19: 'template literal syntax' is only available in ES6 (use 'esversion: 6').
stdin:23:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:32:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:12: 'req' is not defined.
stdin:14:7: 'console' is not defined.
stdin:43:1: 'console' is not defined.
12 errors
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1482/avgPerf.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 2) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1483/avgPerf.js''']
<<<OUTPUT STARTS>>>
stdin:1:1: Use the function form of "use strict".
stdin:3:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:21: Missing semicolon.
stdin:6:3: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:7:20: 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
stdin:12:8: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:19: 'template literal syntax' is only available in ES6 (use 'esversion: 6').
stdin:23:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:32:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:12: 'require' is not defined.
stdin:14:7: 'console' is not defined.
stdin:43:1: 'console' is not defined.
12 errors
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1484/avgPerf.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 2) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1485/avgPerf.js''']
<<<OUTPUT STARTS>>>
stdin:1:1: Use the function form of "use strict".
stdin:3:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:23: Missing semicolon.
stdin:6:3: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:7:20: 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
stdin:12:8: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:19: 'template literal syntax' is only available in ES6 (use 'esversion: 6').
stdin:23:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:32:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:12: 'require' is not defined.
stdin:14:7: 'console' is not defined.
stdin:43:1: 'console' is not defined.
12 errors
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1486/avgPerf.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 2) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1487/avgPerf.js''']
<<<OUTPUT STARTS>>>
stdin:1:1: Use the function form of "use strict".
stdin:3:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:25: Missing semicolon.
stdin:6:3: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:7:20: 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
stdin:12:8: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:19: 'template literal syntax' is only available in ES6 (use 'esversion: 6').
stdin:23:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:32:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:12: 'require' is not defined.
stdin:14:7: 'console' is not defined.
stdin:43:1: 'console' is not defined.
12 errors
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1488/avgPerf.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 2) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1489/avgPerf.js''']
<<<OUTPUT STARTS>>>
stdin:1:1: Use the function form of "use strict".
stdin:3:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:6:3: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:7:20: 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
stdin:12:8: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:19: 'template literal syntax' is only available in ES6 (use 'esversion: 6').
stdin:23:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:32:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:12: 'require' is not defined.
stdin:14:7: 'console' is not defined.
stdin:43:1: 'console' is not defined.
11 errors
<<<OUTPUT ENDS>>>
(finished - exit code 0) ['/usr/local/bin/bash', '-c', '''eslint'' -f unix --stdin --stdin-filename ''/Users/delucac/Downloads/avgPerf.js'' < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1490/avgPerf.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 2) ['/usr/local/bin/bash', '-c', '''jshint'' --reporter unix --extract auto - < ''/var/folders/6f/bvrhxwl52y36t5q1h10pzkx80000gn/T/nvimN4SOH1/1491/avgPerf.js''']
<<<OUTPUT STARTS>>>
stdin:1:1: Use the function form of "use strict".
stdin:3:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:6:3: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:7:20: 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
stdin:12:8: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:14:19: 'template literal syntax' is only available in ES6 (use 'esversion: 6').
stdin:23:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:32:1: 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
stdin:3:12: 'require' is not defined.
stdin:14:7: 'console' is not defined.
stdin:43:1: 'console' is not defined.
11 errors
<<<OUTPUT ENDS>>>
What is your configuration file named, and is the version of eslint being run from Vim the same version as you are running in the command line? Try checking this with :!eslint --version.
Which command do you use to run eslint on a file from the command line? Do you have any other configuration files in any directories above your configuration file?
Thanks for the quick reply!
The eslint version inside neovim is the same as the version on the command line, aka 4.3.0.
I run plain eslint from the command line, e.g. eslint myfile.js. The eslintrc is in the same directory as the test file. There are no other eslintrc file above it.
That's weird. eslint --stdin --stdiln-filename /abs/path/to/whatever.js < /tmp/whatever.js should be enough to find any configuration files in or above the directory with the file being checked, and that has been working for months now.
Could you create an example project which repeats this bug?
Sure thing, @w0rp. Here's a demo project I whipped up: https://github.com/bronzehedwick/ale-eslint-demo
I only just noticed, but if you look at the output above, it's JSHint returning those errors, not eslint. You should disable JSHint.
Oh wow, thank you! I feel silly.
Yep! I ran into this as well, not sure where jshint was coming from. But this fixed it.
let g:ale_linters = {'javascript': ['eslint']}
Thanks @jeromecovington worked for me as well
Most helpful comment
Yep! I ran into this as well, not sure where jshint was coming from. But this fixed it.