I'm facing a strange problem with ALE + eslint and I don't know what is wrong here.
Let's say I write this javascript code:
async function bootAppli+++cation() {
const element = document.getElementById('webui-react-root');
...
}
When I move the cursors to the line with the error, I can see this in the status line:
Parsing error: Unexpected token, expected "("^[[0m ^[[90m 7 | ^[[39m^[...| ^[[39m^[[0m^[[0m ^[[90m 12 | ^[[39m ...
And if I execute :AleDetail
I get a new buffer with
Parsing error: Unexpected token, expected "("
^[[0m ^[[90m 7 | ^[[39m^[[36mimport^[[39m {avusAPICommand} from ^[[32m'modules/api'^[[39m^[[33m;^[[39m^[[0m
^[[0m ^[[90m 8 | ^[[39m^[[0m
^[[0m^[[31m^[[1m>^[[22m^[[39m^[[90m 9 | ^[[39masync ^[[36mfunction^[[39m bootAppli^[[33m++^[[39m^[[33m+^[[39mcation() {^[[0m
^[[0m ^[[90m | ^[[39m ^[[31m^[[1m^^[[22m^[[39m^[[0m
^[[0m ^[[90m 10 | ^[[39m ^[[36mconst^[[39m element ^[[33m=^[[39m document^[[33m.^[[39mgetElementById(^[[32m'webui-react-root'^[[39m)^[[33m;^[[39m^[[0m
^[[0m ^[[90m 11 | ^[[39m^[[0m
^[[0m ^[[90m 12 | ^[[39m ^[[36mif^[[39m (element) {^[[0m
My vim config regarding ale is:
let g:ale_enabled = 0
let g:ale_fixers = {
\ 'typescript': [ 'eslint' ],
\ 'javascript': [ 'eslint' ],
\ 'typescriptreact': [ 'eslint' ],
\ 'html': [ 'prettier' ],
\}
let g:ale_javascript_eslint_executable = '/home/shaoran/local/nodejs/node-v10.16.0-linux-x64/bin/eslint_d'
let g:ale_javascript_flow_use_global = 1
let g:ale_javascript_prettier_executable = '/home/shaoran/local/nodejs/node-v10.16.0-linux-x64/bin/prettier'
let g:ale_statusline_format = ['%d errors', '%d warnings', 'no errors']
let g:ale_sign_error = 'X'
let g:ale_sign_warning = '!'
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'html': [ 'htmlhint' ],
\}
let g:ale_lint_delay=100
noremap <C-l>e :ALEEnable<CR>
noremap <C-l>t :ALEToggleBuffer<CR>
noremap <C-l>f :ALEFix<CR>
noremap <C-l>n :ALENextWrap<CR>
noremap <C-l>p :ALEPreviousWrap<CR>
and :ALEInfo
says:
ALEInfo
Current Filetype: javascript
Available Linters: ['eslint', 'fecs', 'flow', 'flow-language-server', 'jscs', 'jshint', 'standard', 'tsserver', 'xo']
Enabled Linters: ['eslint']
Ignored Linters: []
...
Command History:
(executable check - success) /home/shaoran/projects/avus/avus_webui/node_modules/.bin/eslint_d
(finished - exit code 0) ['/bin/bash', '-c', 'cd ''/home/shaoran/projects/avus/avus_webui'' && ''/home/shaoran/projects/avus/avus_webui/node_modules/.bin/esli
nt_d'' -f json --stdin --stdin-filename ''/home/shaoran/projects/avus/avus_webui/src/index.js'' < ''/tmp/v7VBp3D/2/index.js''']
<<<OUTPUT STARTS>>>
[{"filePath":"/home/shaoran/projects/avus/avus_webui/src/index.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0
}]
<<<OUTPUT ENDS>>>
(finished - exit code 1) ['/bin/bash', '-c', 'cd ''/home/shaoran/projects/avus/avus_webui'' && ''/home/shaoran/projects/avus/avus_webui/node_modules/.bin/esli
nt_d'' -f json --stdin --stdin-filename ''/home/shaoran/projects/avus/avus_webui/src/index.js'' < ''/tmp/v7VBp3D/3/index.js''']
<<<OUTPUT STARTS>>>
[{"filePath":"/home/shaoran/projects/avus/avus_webui/src/index.js","messages":[{"ruleId":null,"fatal":true,"severity":2,"message":"Parsing error: Unexpected t
oken, expected \"(\"\n\n\u001b[0m \u001b[90m 7 | \u001b[39m\u001b[36mimport\u001b[39m {avusAPICommand} from \u001b[32m'modules/api'\u001b[39m\u001b[33m;\u001
b[39m\u001b[0m\n\u001b[0m \u001b[90m 8 | \u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 9 | \u001b[39masync \u001b[36mfunc
tion\u001b[39m bootApplic\u001b[33m++\u001b[39m\u001b[33m++\u001b[39mation()...
and the .eslintrc
/* eslint-disable import/no-commonjs */
const resolve = require('./webpack.resolve.js');
module.exports = {
root: true,
parser: 'babel-eslint',
plugins: ['prettier'],
extends: ['standard', 'prettier', 'plugin:prettier/recommended', 'plugin:react/recommended'],
globals: {
it: 'readable',
expect: 'readable',
describe: 'readable',
__: 'readable',
},
rules: {
// turned off for now for compatibility, but should be enabled at some point
camelcase: 'off',
eqeqeq: 'off',
'no-inner-declarations': 'off',
'no-control-regex': 'off',
// detect unused injections -- unused function arguments are
// disallowed, unless they are marked with an underscore, e.g `function
// (foo, _bar, baz) { return foo + baz; }` is okay, but `function (foo,
// bar, baz) { return foo + baz; }` isn't.
'no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
},
],
// some more strict rules that often lead to errors
'prefer-rest-params': 'error',
'prefer-const': 'error',
'no-var': 'error',
'no-shadow': 'error',
// custom style
'dot-notation': 'error',
'no-return-await': 'off',
// prettier needs these
'prettier/prettier': 'error',
'standard/array-bracket-even-spacing': 'off',
'standard/computed-property-even-spacing': 'off',
'standard/object-curly-even-spacing': 'off',
'standard/no-callback-literal': 0,
// import stuff
'import/no-unresolved': [
'error',
{
amd: true,
commonjs: true,
},
],
'import/named': 'error',
'import/default': 'error',
'import/no-dynamic-require': 'error',
'import/no-amd': 'error',
'global-require': 'error',
'import/no-commonjs': 'error',
'import/no-useless-path-segments': 'error',
'import/export': 'error',
'import/no-named-as-default': 'error',
'import/no-extraneous-dependencies': 'error',
'import/first': 'error',
'import/no-duplicates': 'error',
'import/extensions': ['error', 'never'],
'import/order': [
'error',
{
groups: [
// treat node.js "builtin" modules just like externals
['builtin', 'external'],
// internal: "absolute" paths in the repository (e.g. 'modules/...')
'internal',
// parent: '../*'
'parent',
// sibling/index: './*'
['sibling', 'index'],
],
'newlines-between': 'always',
},
],
},
settings: {
'import/resolver': {
webpack: {
config: {
resolve,
},
},
},
},
};
How can I tell ALE to pass the --no-color
command line option? I'm unable to
find such an option.
ale/handlers/eslint.vim
and didn't find anything noteworthy. Might try bisecting your config and see if you have something set to force color. (I think ale probably assumes it doesn't output color when not running interactively, which might be true; for some reason, color is happening though.)eslint_d
. It also knows a--no-color
option but on some cases you still get colored output even if you call it with--no-color
. I'll create a bug report ineslint_d
.