Ale: StandardJS "fix" doesn't work.

Created on 6 Oct 2019  Â·  13Comments  Â·  Source: dense-analysis/ale

Debian 10, last vim from git(vim/src/ make, sudo make install). Another "fixers", for example: "prettier" - works fine.

.bashrc
NPM_PACKAGES="${HOME}/.local/.npm"
export PATH="$NPM_PACKAGES/bin:$PATH"
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

npm -g install standard
let g:ale_fixers = {'c': ['clang-format'], 'javascript': ['standard']}
I've tried ALEFix - no result.

Info:
Current Filetype: javascript
Available Linters: ['eslint', 'fecs', 'flow', 'flow-language-server', 'jscs', 'jshint', 'standard', 'tsserver', 'xo']
Enabled Linters: ['standard', 'tsserver']
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_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
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 = 1
let g:ale_fixers = {'c': ['clang-format'], 'javascript': ['standard']}
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 = 200
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 = {'javascript': ['standard', 'tsserver']}
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:

(executable check - success) standard
(finished - exit code 1) ['/bin/bash', '-c', '''standard'' --stdin ''/home/pavel/JS/main.js'' < ''/tmp/veY6zf4/1/main.js''']

<<>>
:1:10: 'range' is defined but never used.
:1:15: Missing space before function parentheses.
:2:7: 'array' is never reassigned. Use 'const' instead.
:2:17: Extra semicolon.
:4:53: Extra semicolon.
:6:59: Extra semicolon.
:8:15: Extra semicolon.
:11:10: 'sum' is defined but never used.
:11:13: Missing space before function parentheses.
:12:16: Extra semicolon.
:13:12: 'value' is never reassigned. Use 'const' instead.
:14:19: Extra semicolon.
:16:15: Extra semicolon.
:19:10: 'reverseArray' is defined but never used.
:19:22: Missing space before function parentheses.
:20:1: Expected indentation of 2 spaces but found 4.
:20:9: 'result' is never reassigned. Use 'const' instead.
:20:20: Extra semicolon.
:21:1: Expected indentation of 2 spaces but found 4.
:21:70: Extra semicolon.
:22:1: Expected indentation of 2 spaces but found 7.
:22:21: Extra semicolon.
:25:10: 'reverseArrayInPlace' is defined but never used.
:25:29: Missing space before function parentheses.
:27:9: 'old' is never reassigned. Use 'const' instead.
:27:23: Extra semicolon.
:28:43: Extra semicolon.
:29:38: Extra semicolon.
:31:15: Extra semicolon.
:34:10: 'arrayToList' is defined but never used.
:34:21: Missing space before function parentheses.
:35:18: Extra semicolon.
:37:43: Extra semicolon.
:39:14: Extra semicolon.
:42:10: 'listToArray' is defined but never used.
:42:21: Missing space before function parentheses.
:43:7: 'result' is never reassigned. Use 'const' instead.
:43:18: Extra semicolon.
:44:72: Extra semicolon.
:45:16: Extra semicolon.
:48:10: 'prepend' is defined but never used.
:48:17: Missing space before function parentheses.
:49:38: Extra semicolon.
:52:10: 'nth' is defined but never used.
:52:13: Missing space before function parentheses.
:53:30: Extra semicolon.
:54:14: Expected '===' and instead saw '=='.
:54:37: Extra semicolon.
:55:36: Extra semicolon.
:58:10: 'deepEqual' is defined but never used.
:58:19: Missing space before function parentheses.
:59:27: Extra semicolon.
:60:29: Expected '!==' and instead saw '!='.
:61:27: Expected '!==' and instead saw '!='.
:61:52: Extra semicolon.
:62:3: Split initialized 'let' declarations into multiple statements.
:62:7: 'keysA' is never reassigned. Use 'const' instead.
:62:31: 'keysB' is never reassigned. Use 'const' instead.
:62:53: Extra semicolon.
:63:50: Extra semicolon.
:64:12: 'key' is never reassigned. Use 'const' instead.
<<>>

(executable check - success) tsserver
(started) ['/bin/bash', '-c', '''tsserver''']

bug

Most helpful comment

I've merged #3046 now, which I hear fixes this.

I recommend everyone use ESLint instead of standard, which is what standard uses under the hood, is much more configurable, and tends to work a lot better.

All 13 comments

Anyone other information than, "doesn't work?"

Anyone other information than, "doesn't work?"

Yes, linter Standard for JS works fine, but ALEFix or fix on save - zero reaction. It's all. It is not just "plugin conflict" or something else, just no reaction. Another "fixers" works, for JS or whatever. Only standard with this behavior.

`
call plug#begin()
Plug 'dense-analysis/ale'
nmap e[ (ale_previous_wrap)
nmap e] (ale_next_wrap)
let g:ale_sign_error = '✘'
let g:ale_sign_warning = 'âš '
let g:ale_sign_column_always = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_set_loclist = 0

let b:ale_linters = {
\ 'javascript': ['standard'],
\ 'php': ['phpcs']
\ }
let g:ale_php_phpcs_standard = "psr2"

Plug 'neomake/neomake'
let g:neomake_javascript_enabled_makers = ['standard']
let g:neomake_javascript_standard_maker = {
\ 'exe': 'standard',
\ 'args': ['--fix'],
\ }

let g:neomake_php_enabled_makers = ['prettier', 'phpcsfixer']
let g:neomake_php_prettier_maker = {
\ 'exe': 'prettier',
\ 'args': ['--write'],
\ }
let g:neomake_php_phpcsfixer_maker = {
\ 'exe': 'php-cs-fixer',
\ 'args': ['fix', '--rules=@PSR2'],
\ }

autocmd! BufWritePost * Neomake
augroup my_neomake_hooks
au!
autocmd User NeomakeJobFinished :checktime
augroup END

call plugin#end()

function! MyOnBattery()
if has('macunix')
return match(system('pmset -g batt'), "Now drawing from 'Battery Power'") != -1
elsif has('unix')
return readfile('/sys/class/power_supply/AC/online') == ['0']
endif
return 0
endfunction

if MyOnBattery()
call neomake#configure#automake('w')
else
call neomake#configure#automake('nw', 50)
endif

`

Thanks! But if ale has "fix", why need other dependencies. I'll just will use integrate fix from vim-lsp language server.

I have a same problem. It worked perfectly when I used the standard version 12.0.1. Then it doesn't work when using 13.1.0 and 14.3.1.

Same here. Fix does nothing. It seems the temp file folder isn't created.

Probabily i have the same problem. I noticed stardard fixer works fine only if you open vim instance in /tmp folder.. maybe some path problem?

Same as @nack43 for me. Using 14.3.1 fails, but 12.0.1 works fine.

I'm having this problem, but I don't think it's ale related.

So when I look at :ALEInfo, I see:

(finished - exit code 1) ['/bin/bash', '-c', '''standard'' --fix ''/tmp/vrSbwAp/8/handler.js''']

Which suggests to me that ale has copied my file to a temporary folder before running standard on it. So I did the same thing:

cp /home/kit/work/mylambda/handler.js /tmp/foobar
standard --fix /tmp/foobar/handler.js

/usr/local/lib/node_modules/standard/node_modules/deglob/node_modules/ignore/index.js:337
  throw new Ctor(message)
  ^

RangeError: path should be a `path.relative()`d string, but got "../../../../../tmp/foobar/handler.js"
    at throwError (/usr/local/lib/node_modules/standard/node_modules/deglob/node_modules/ignore/index.js:337:9)
    at checkPath (/usr/local/lib/node_modules/standard/node_modules/deglob/node_modules/ignore/index.js:356:12)
    at Ignore._test (/usr/local/lib/node_modules/standard/node_modules/deglob/node_modules/ignore/index.js:473:5)
    at Ignore.ignores (/usr/local/lib/node_modules/standard/node_modules/deglob/node_modules/ignore/index.js:512:17)
    at path (/usr/local/lib/node_modules/standard/node_modules/deglob/node_modules/ignore/index.js:516:26)
    at Array.filter (<anonymous>)
    at Ignore.filter (/usr/local/lib/node_modules/standard/node_modules/deglob/node_modules/ignore/index.js:520:29)
    at /usr/local/lib/node_modules/standard/node_modules/deglob/index.js:46:31
    at end (/usr/local/lib/node_modules/standard/node_modules/run-parallel/index.js:18:15)
    at done (/usr/local/lib/node_modules/standard/node_modules/run-parallel/index.js:22:10)

So maybe it's something with standard. Like @imtyM , I'm also using 14.3.1

ETA: I think it's related to this issue: https://github.com/standard/standard/issues/1384

FWIW a workaround is to downgrade to standard@12 which doesn't exhibit this problem.

@theimpostor thanks, works with standard 12.0

Having the same issue with 14.3.1 but... I need 14.3.1 :s

Any solution or workaround beside downgrading ?

Same for me

| Software | Version |
|---|---|
| Standard | 14.3.4 |
| node | 14 |
| node | 12 |
| nvim | 0.4.3 |
| Kubuntu | 20.04 |

Thanks :heart:

Edit

It seems that PR #2816 fixes this. I hope @w0rp is doing fine and he can review the PR soon.

I've merged #3046 now, which I hear fixes this.

I recommend everyone use ESLint instead of standard, which is what standard uses under the hood, is much more configurable, and tends to work a lot better.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amerov picture amerov  Â·  4Comments

aressler38 picture aressler38  Â·  3Comments

lervag picture lervag  Â·  3Comments

trevordmiller picture trevordmiller  Â·  4Comments

ianchanning picture ianchanning  Â·  3Comments