Ale: ALE launched tsserver for a JavaScript file

Created on 2 Apr 2020  路  17Comments  路  Source: dense-analysis/ale

Information

VIM version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 13 2019 14:45:40)
Included patches: 1-503, 505-680, 682-1312

Operating System:
mac os x 10.15.3

What went wrong

Ale reports "property assignment expected" on spread operator

Reproducing the bug

Add Ale and eslint.
Configure with the following config to support latest JS everything with babel:

module.exports = {
    "env": {
        "browser": true,
        "node": true
    },
    "extends": "eslint:recommended",
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parser": "babel-eslint",
    "parserOptions": {
        "ecmaVersion": 2020,
        "sourceType": "module"
    },
    "rules": {
    }
};

open a file with a spread operator

const a = { a: 1 };
const b = { ...a };

You'll get an error property assignment expected

:ALEInfo

 Current Filetype: javascript.jsx
Available Linters: ['eslint', 'fecs', 'flow', 'flow-language-server', 'jscs', 'jshint', 'standard', 'tsserver', 'xo']
  Enabled Linters: ['eslint', 'fecs', 'flow', 'flow-language-server', 'jscs', 'jshint', 'standard', 'tsserver', 'xo']
 Suggested Fixers: 
  'eslint' - Apply eslint --fix to a file.
  'fecs' - Apply fecs format to a file.
  'importjs' - automatic imports for javascript
  'prettier' - Apply prettier to a file.
  'prettier_eslint', 'prettier-eslint' - Apply prettier-eslint to a file.
  'prettier_standard', 'prettier-standard' - Apply prettier-standard to a file.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'standard' - Fix JavaScript files using standard --fix
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
  'xo' - Fix JavaScript/TypeScript files using xo --fix.
 Linter Variables:

let g:ale_javascript_eslint_executable = 'eslint'
let g:ale_javascript_eslint_options = ''
let g:ale_javascript_eslint_suppress_eslintignore = 0
let g:ale_javascript_eslint_suppress_missing_config = 0
let g:ale_javascript_eslint_use_global = 0
let g:ale_javascript_fecs_executable = 'fecs'
let g:ale_javascript_fecs_use_global = 0
let g:ale_javascript_flow_executable = 'flow'
let g:ale_javascript_flow_ls_executable = 'flow'
let g:ale_javascript_flow_ls_use_global = 0
let g:ale_javascript_flow_use_global = 0
let g:ale_javascript_flow_use_home_config = 0
let g:ale_javascript_flow_use_respect_pragma = 1
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_tsserver_config_path = ''
let g:ale_javascript_tsserver_executable = 'tsserver'
let g:ale_javascript_tsserver_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_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
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 b:ale_fixers = {'javascript': ['eslint --ext .js,.jsx']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 500
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 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_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(started) ['/bin/bash', '-c', '''tsserver''']
(executable check - failure) xo
(finished - exit code 1) ['/bin/bash', '-c', 'cd ''/Users/funk/Development/Projects/platforming-magic-beatemup'' && ''/Users/funk/Development/Projects/platforming-magic-beatemup/node_modules/eslint/bin/eslint.js'' -f json --stdin --stdin-filename ''/Users/funk/Development/Projects/platforming-magic-beatemup/src/entities/index.js'' < ''/var/folders/q4/hll729yj637_2jt67llhr6640000gn/T/vlacawU/8/index.js''']

<<<OUTPUT STARTS>>>
[{"filePath":"/Users/funk/Development/Projects/platforming-magic-beatemup/src/entities/index.js","messages":[{"ruleId":"no-unused-vars","severity":2,"message":"'a' is assigned a value but never used.","line":5,"column":7,"nodeType":"Identifier","endLine":5,"endColumn":8},{"ruleId":"no-unused-vars","severity":2,"message":"'percent' is defined but never used.","line":22,"column":43,"nodeType":"Identifier","endLine":22,"endColumn":50},{"ruleId":"no-unused-vars","severity":2,"message":"'attack' is defined but never used.","line":22,"column":52,"nodeType":"Identifier","endLine":22,"endColumn":58},{"ruleId":"no-unused-vars","severity":2,"message":"'dt' is defined but never used.","line":22,"column":78,"nodeType":"Identifier","endLine":22,"endColumn":80},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":35,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":35,"endColumn":43},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":40,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":40,"endColumn":44},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":41,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":41,"endColumn":44},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":42,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":42,"endColumn":58},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":43,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":43,"endColumn":53},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":44,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":44,"endColumn":53}],"errorCount":10,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":"import { metaEntitiesSelector } from './metaEntitySelector';\n\nconst magnitude = (x, y) => Math.sqrt(x*x + y*y);\n\nconst a = {a :1};\n\nlet _id = 0;\nexport const createEntity = props => ({\n    type: 'CREATE_ENTITY',\n    entity: {\n        id: ++_id,\n        ...props\n    },\n    meta: metaEntitiesSelector\n});\n\nexport const removeEntity = entity => ({\n    type: 'REMOVE_ENTITY',\n    entity: entity()\n});\n\nexport default (state={}, { type, entity, percent, attack, distance, target, dt }) => {\n    switch(type) {\n        case 'CREATE_ENTITY':\n            return {\n                ...state,\n                [entity.id]: {\n                    x: 0,\n                    y: 0,\n                    ...entity\n                }\n            };\n\n        case 'REMOVE_ENTITY':\n            const newState = { ...state };\n            delete newState[entity.id];\n            return newState;\n\n        case 'SEEK_STEP':\n            const vx = target.x - entity.x;\n            const vy = target.y - entity.y;\n            const distanceFromTarget = magnitude(vx, vy);\n            const normalX = vx / distanceFromTarget;\n            const normalY = vy / distanceFromTarget;\n            //console.log('distance, normals: ', distance, normalX, normalY);\n\n            return {\n                ...state,\n                [entity.id]: {\n                    ...state[entity.id],\n                    x: state[entity.id].x + normalX * distance,\n                    y: state[entity.id].y + normalY * distance\n                }\n            };\n\n        default:\n            return state;\n    }\n};\n"}]
<<<OUTPUT ENDS>>>

(executable check - failure) fecs
(executable check - failure) jscs
(executable check - failure) jshint
(executable check - failure) standard
(executable check - failure) xo
(finished - exit code 1) ['/bin/bash', '-c', 'cd ''/Users/funk/Development/Projects/platforming-magic-beatemup'' && ''/Users/funk/Development/Projects/platforming-magic-beatemup/node_modules/eslint/bin/eslint.js'' -f json --stdin --stdin-filename ''/Users/funk/Development/Projects/platforming-magic-beatemup/src/entities/index.js'' < ''/var/folders/q4/hll729yj637_2jt67llhr6640000gn/T/vlacawU/9/index.js''']

<<<OUTPUT STARTS>>>
[{"filePath":"/Users/funk/Development/Projects/platforming-magic-beatemup/src/entities/index.js","messages":[{"ruleId":"no-unused-vars","severity":2,"message":"'b' is assigned a value but never used.","line":6,"column":7,"nodeType":"Identifier","endLine":6,"endColumn":8},{"ruleId":"no-unused-vars","severity":2,"message":"'percent' is defined but never used.","line":23,"column":43,"nodeType":"Identifier","endLine":23,"endColumn":50},{"ruleId":"no-unused-vars","severity":2,"message":"'attack' is defined but never used.","line":23,"column":52,"nodeType":"Identifier","endLine":23,"endColumn":58},{"ruleId":"no-unused-vars","severity":2,"message":"'dt' is defined but never used.","line":23,"column":78,"nodeType":"Identifier","endLine":23,"endColumn":80},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":36,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":36,"endColumn":43},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":41,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":41,"endColumn":44},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":42,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":42,"endColumn":44},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":43,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":43,"endColumn":58},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":44,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":44,"endColumn":53},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":45,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":45,"endColumn":53}],"errorCount":10,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":"import { metaEntitiesSelector } from './metaEntitySelector';\n\nconst magnitude = (x, y) => Math.sqrt(x*x + y*y);\n\nconst a = {a :1};\nconst b = { ...a };\n\nlet _id = 0;\nexport const createEntity = props => ({\n    type: 'CREATE_ENTITY',\n    entity: {\n        id: ++_id,\n        ...props\n    },\n    meta: metaEntitiesSelector\n});\n\nexport const removeEntity = entity => ({\n    type: 'REMOVE_ENTITY',\n    entity: entity()\n});\n\nexport default (state={}, { type, entity, percent, attack, distance, target, dt }) => {\n    switch(type) {\n        case 'CREATE_ENTITY':\n            return {\n                ...state,\n                [entity.id]: {\n                    x: 0,\n                    y: 0,\n                    ...entity\n                }\n            };\n\n        case 'REMOVE_ENTITY':\n            const newState = { ...state };\n            delete newState[entity.id];\n            return newState;\n\n        case 'SEEK_STEP':\n            const vx = target.x - entity.x;\n            const vy = target.y - entity.y;\n            const distanceFromTarget = magnitude(vx, vy);\n            const normalX = vx / distanceFromTarget;\n            const normalY = vy / distanceFromTarget;\n            //console.log('distance, normals: ', distance, normalX, normalY);\n\n            return {\n                ...state,\n                [entity.id]: {\n                    ...state[entity.id],\n                    x: state[entity.id].x + normalX * distance,\n                    y: state[entity.id].y + normalY * distance\n                }\n            };\n\n        default:\n            return state;\n    }\n};\n"}]
<<<OUTPUT ENDS>>>

(executable check - failure) fecs
(executable check - failure) jscs
(executable check - failure) jshint
(executable check - failure) standard
(executable check - failure) xo
(finished - exit code 1) ['/bin/bash', '-c', 'cd ''/Users/funk/Development/Projects/platforming-magic-beatemup'' && ''/Users/funk/Development/Projects/platforming-magic-beatemup/node_modules/eslint/bin/eslint.js'' -f json --stdin --stdin-filename ''/Users/funk/Development/Projects/platforming-magic-beatemup/src/entities/index.js'' < ''/var/folders/q4/hll729yj637_2jt67llhr6640000gn/T/vlacawU/10/index.js''']

<<<OUTPUT STARTS>>>
[{"filePath":"/Users/funk/Development/Projects/platforming-magic-beatemup/src/entities/index.js","messages":[{"ruleId":"no-unused-vars","severity":2,"message":"'percent' is defined but never used.","line":24,"column":43,"nodeType":"Identifier","endLine":24,"endColumn":50},{"ruleId":"no-unused-vars","severity":2,"message":"'attack' is defined but never used.","line":24,"column":52,"nodeType":"Identifier","endLine":24,"endColumn":58},{"ruleId":"no-unused-vars","severity":2,"message":"'dt' is defined but never used.","line":24,"column":78,"nodeType":"Identifier","endLine":24,"endColumn":80},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":37,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":37,"endColumn":43},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":42,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":42,"endColumn":44},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":43,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":43,"endColumn":44},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":44,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":44,"endColumn":58},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":45,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":45,"endColumn":53},{"ruleId":"no-case-declarations","severity":2,"message":"Unexpected lexical declaration in case block.","line":46,"column":13,"nodeType":"VariableDeclaration","messageId":"unexpected","endLine":46,"endColumn":53}],"errorCount":9,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":"import { metaEntitiesSelector } from './metaEntitySelector';\n\nconst magnitude = (x, y) => Math.sqrt(x*x + y*y);\n\nconst a = {a :1};\nconst b = { ...a };\nconsole.log(b);\n\nlet _id = 0;\nexport const createEntity = props => ({\n    type: 'CREATE_ENTITY',\n    entity: {\n        id: ++_id,\n        ...props\n    },\n    meta: metaEntitiesSelector\n});\n\nexport const removeEntity = entity => ({\n    type: 'REMOVE_ENTITY',\n    entity: entity()\n});\n\nexport default (state={}, { type, entity, percent, attack, distance, target, dt }) => {\n    switch(type) {\n        case 'CREATE_ENTITY':\n            return {\n                ...state,\n                [entity.id]: {\n                    x: 0,\n                    y: 0,\n                    ...entity\n                }\n            };\n\n        case 'REMOVE_ENTITY':\n            const newState = { ...state };\n            delete newState[entity.id];\n            return newState;\n\n        case 'SEEK_STEP':\n            const vx = target.x - entity.x;\n            const vy = target.y - entity.y;\n            const distanceFromTarget = magnitude(vx, vy);\n            const normalX = vx / distanceFromTarget;\n            const normalY = vy / distanceFromTarget;\n            //console.log('distance, normals: ', distance, normalX, normalY);\n\n            return {\n                ...state,\n                [entity.id]: {\n                    ...state[entity.id],\n                    x: state[entity.id].x + normalX * distance,\n                    y: state[entity.id].y + normalY * distance\n                }\n            };\n\n        default:\n            return state;\n    }\n};\n"}]
<<<OUTPUT ENDS>>>

(executable check - failure) fecs
(executable check - failure) jscs
(executable check - failure) jshint
(executable check - failure) standard
(executable check - failure) xo



bug

All 17 comments

I really wish ALE had any kind of debug information on the line in question. Just searching the number 6, I can't find any mention of an error on line 6, where i get the error "Property assignment expected"

FYI I've been bashing my head on the table for hours on this and it's causing me to rage pretty hard. A fresh setup and no debugging information simply means I'm screwed.

Can you try disabling the tsserver linter? This wouldn't be a permanent fix but I can't see any output from eslint which AFAICT is the only other linter, and this would slim down which one is giving us issues.

Actually, this is a JavaScript file, so tsserver shouldn't even be started for this. Meaning the only linter we should be running is eslint. Can you also manually try running eslint?

manually running eslint is fine ... ill add more info in a sec.

So, I tried defining ale_linters with eslint and that caused ONLY eslint to be run, which seems to do what i want :p.

I don't know what the other programs were doing, but they were erroronously reporting on js errors, inspite of my babel configuration.

Anyways im good now. I'm burnt out dealing with this problem, so I'll just settle with things working as they are.

The only one that looks like it ran was tsserver. Everything else had an "executable check" - they're not installed.

If you don't mind, I'd like to rename this issue to "tsserver started on JavaScript file". You can stop following this issue by clicking the "Unsubscribe" button in the notifications section, to the right of this comments feed.

Feel free. Let me know if you need any additional config files, and honestly, if you can't reproduce, feel free to close it.

Strangely, I didn't have this issue on a different laptop with the same vimrc, but I was programming in Typescript on that laptop and likely had a proper setup for TS, that would have told tsserver that the spread operator was valid. [that's my guess anyways, I don't know how tsserver works]

Good luck.

Ugh, if I use nerdtree and it opens a new buffer, then it uses tsserver inspite of me specifying eslint as the parser.

If i use the explicit setting, then it doesn't use ANY parser, even though I've specified eslint.

let b:ale_linters = ['eslint']

let g:ale_linters_explicit = 1

Yeah, you have b:ale_linters - that's a per-buffer option. You want g:ale_linters

b for buffer, g for global

Ah that helped.

and now I'm getting the error

Error detected while processing function ale#debugging#Info[4]..ale#linter#Get[6]..<SNR>106_GetLinterNames:                                                                                                                                                                     
line   19:                                                                                                                                                                                                                                                                      
E715: Dictionary required                                                                               

I think my laptop is on the fritz @.@

Sorry I shoulda seen that. You want let g:ale_linters = { "javascript.jsx": ["eslint"] }

You might also want to add in one for just JavaScript.

ok, everything is settled. Sorry, I'm very good at finding the thing that doesn't work @.@

Btw is this documentation up to date: https://github.com/dense-analysis/ale#5i-how-do-i-disable-particular-linters

It says let g:ale_linters = ['eslint'] is valid

" In ~/.vim/ftplugin/javascript.vim, or somewhere similar.

Did you take this into consideration?

The reason for this specific functionality is that if it's in a tfplugin it'll be run for every buffer. On a buffer level, ALE is more than happy to just take the array. On a global level, it wants the dictionary.

Cool, good to know.

let g:ale_linters = ['eslint'] is not valid, but let b:ale_linters = ['eslint'] is. ALE is behaving correctly. tsserver is enabled by default, including for JS files. If you don't like the error messages, disabling it is the correct thing to do.

Was this page helpful?
0 / 5 - 0 ratings