dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.48k stars 1.43k forks source link

ALE working but standardjs linter not. #868

Closed german1608 closed 6 years ago

german1608 commented 7 years ago

I recently installed ALE via pathogen and I don't know why my standard linter doesn't work. I used the g:ale_linters option to specify standard as my linter for javacript. But It just doesn't work.

If I dont' set that variable, all linters are enabled but the only one that works is jshint. Here is the output of :ALEInfo

Current Filetype: javascript.jsx
Available Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']
  Enabled Linters: ['standard']
 Linter Variables:
let g:ale_javascript_standard_executable = 'standard'
let g:ale_javascript_standard_options = ''
let g:ale_javascript_standard_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 = {'javascript': ['standard']}
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:
w0rp commented 7 years ago

Where have you installed standard?

german1608 commented 7 years ago

in my node_modules/ directory of my project.

w0rp commented 7 years ago

Does the executable exist in node_modules/.bin/standard, or in another location?

german1608 commented 7 years ago

Yes. The executable is in the node_modules/.bin/ folder:

image

w0rp commented 7 years ago

Where is the file you are editing in the relation to your node_modules directory, and can you execute standard from node_modules?

german1608 commented 7 years ago

The main file and the directory where are more files are both siblings of node_modules.

ls
node_modules/   test/(here are more js files)  index.js   package.json ....

You mean by executing ./node_modules/.bin/standard? Yes

w0rp commented 7 years ago

After you pull from master, what do you get from :ALEInfo? Do you see any executable checks being done, or commands being run?

german1608 commented 7 years ago
Current Filetype: javascript.jsx
Available Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']
  Enabled Linters: ['standard']
 Linter Variables:
let g:ale_javascript_standard_executable = 'standard'
let g:ale_javascript_standard_options = ''
let g:ale_javascript_standard_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 = {'javascript': ['standard']}
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:
(executable check - failure) standard
(executable check - failure) standard
(executable check - failure) standard
(executable check - failure) standard
german1608 commented 7 years ago

I just installed it globally and now works! Thanks for your help anyway!

w0rp commented 7 years ago

I'll see if I can figure out what the problem is here later and fix it. You shouldn't have to install standard globally.

german1608 commented 7 years ago

Yeah you're right. I'll tell you anything that happens. I'll maybe uninstall it (globally) and install it (locally like a dependency) of my project. But right now I'm happy with it. Thanks! (if you want don't close the issue till something happens again)

w0rp commented 7 years ago

I tried creating a new directory and installing standard with yarn add standard, and it worked. Are you working on a React app by chance? I know that there are some scripts which install some files to different locations for React. Maybe opening node_modules/.bin/standard will provide some clues.

german1608 commented 7 years ago

I'm not using React in that project. I installed standard via npm.

german1608 commented 7 years ago

I just uninstalled it globally and now doesn't work. I tried with another project that has standard installed but also doesn't works.

w0rp commented 7 years ago

Leave it installed globally so it works for you.

I recommend checking out the contents of node_modules/.bin/standard. That might give you some clues as to why the file isn't executable.

german1608 commented 7 years ago

image That file is a link and there are the content of that file

image These are the contents of option.js

And here is a pastebin of the source code of node_modules/standard-engine/bin/cmd.js (required at standard file)

I'll take a look by myself to those files. But here I left them to you if you see something first

w0rp commented 7 years ago

Pull ALE again. I just pushed a commit to prefer executing node_modules/standard/bin/cmd.js instead.

german1608 commented 7 years ago

Same. I uninstalled standard globally and same happens. I tried reinstall it locally but same

german1608 commented 7 years ago

THis is the output of :ALEInfo

Current Filetype: javascript.jsx
Available Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']
  Enabled Linters: ['standard']
 Linter Variables:
let g:ale_javascript_standard_executable = 'standard'
let g:ale_javascript_standard_options = ''
let g:ale_javascript_standard_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 = {'javascript': ['standard']}
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:
(executable check - failure) standard
(executable check - failure) standard
(executable check - failure) standard
(executable check - failure) standard
w0rp commented 7 years ago

Hmm, I'm not sure. The executable checks there are still there for just standard. Could you create a project which repeats the bug and put that on GitHub somewhere? A zip file would do fine as well, etc. Let me know what environment you're running Vim, such as your Linux distribution, or other OS version. I'll take a look at that later and see if I can see anything wrong.

german1608 commented 7 years ago

Ok. I'm using ubuntu 16.04. vim 8.0. I just create a new project and installed standard but nothing happens. It doesn't work. Here is a zip file of the project that I created (it includes node_modules/ dir). I pulled ALE before testing everything.

german1608 commented 7 years ago

What version of npm do you have? I'm using 3.10.1 . Maybe it's that idk

w0rp commented 7 years ago

I have 4.2.0, but I use yarn, and whatever the latest version of that is.

navxio commented 6 years ago

same issue here, for me it does not work when I've installed standard globally.

Installing it in the project does the trick though..

navxio commented 6 years ago

Tried adding this, but to no avail

let g:ale_javascript_standard_use_global = 1

Edit: figured it out

let g:ale_javascript_standard_executable='/path/to/global/standard'

juliandkatz commented 6 years ago

I'm also having trouble with standard, though not sure if this is the exact same problem...

My ALEInfo output:

 Current Filetype: javascript.jsx
Available Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']
  Enabled Linters: ['standard']
 Linter Variables:
let g:ale_javascript_standard_executable = 'standard'
let g:ale_javascript_standard_options = ''
let g:ale_javascript_standard_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 = '%code: %%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 = {'javascript': ['standard']}
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:
(executable check - success) /Users/A780976/personalDev/farm-web-app/node_modules/standard/bin/cmd.js
(started) ['/bin/zsh', '-c', '''/Users/A780976/personalDev/farm-web-app/node_modules/standard/bin/cmd.js'' --stdin ''/Users/A780976/personalDev/farm-web-app/src/App.js'' < ''/var/folders/qc/t8d0jpy13mq9j36cgl253vh80000gp/T/nvimukxGj8/3/App.js''']
(finished - exit code 127) ['/bin/zsh', '-c', '''/Users/A780976/personalDev/farm-web-app/node_modules/standard/bin/cmd.js'' --stdin ''/Users/A780976/personalDev/farm-web-app/src/App.js'' < ''/var/folders/qc/t8d0jpy13mq9j36cgl253vh80000gp/T/nvimukxGj8/4/App.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 127) ['/bin/zsh', '-c', '''/Users/A780976/personalDev/farm-web-app/node_modules/standard/bin/cmd.js'' --stdin ''/Users/A780976/personalDev/farm-web-app/src/App.js'' < ''/var/folders/qc/t8d0jpy13mq9j36cgl253vh80000gp/T/nvimukxGj8/5/App.js''']
<<<NO OUTPUT RETURNED>>>

The standard executable seems to be fine:

$ ls -al node_modules/.bin/standard
lrwxr-xr-x  1 A780976  staff    22B Nov 18 21:47 node_modules/.bin/standard -> ../standard/bin/cmd.js

For context, I also have standard installed globally:

$ which standard
/Users/A780976/.nvm/versions/node/v8.9.1/bin/standard

via nvm

I have tried adding the

let g:ale_javascript_standard_use_global = 1

variable in my ~/.config/nvim/init.vim, but it has had no effect.

Would appreciate any help!! This is the last big piece of my vim --> neovim migration :)

w0rp commented 6 years ago

Try and use the local version if you can, so it will be updated along with your other packages. What's the problem?

juliandkatz commented 6 years ago

@w0rp So there are 3 errors in the file:

$ standard src/App.js
standard: Use JavaScript Standard Style (https://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.
  /Users/A780976/personalDev/farm-web-app/src/App.js:4:19: Extra semicolon.
  /Users/A780976/personalDev/farm-web-app/src/App.js:9:22: Unexpected usage of doublequote.
  /Users/A780976/personalDev/farm-web-app/src/App.js:10:27: Unexpected usage of doublequote.

These never show up in ALE. Rather, the debug output seems to show NO OUTPUT RETURNED

My bet is on some sort of PATH problem related to nvm

juliandkatz commented 6 years ago

Problem solved!

Turns out it was a PATH problem after all. For zsh users, note that:

.zshrc is run after .zshenv

Run your nvm.sh setup script at the bottom of .zshrc.

Sorry for the problem! Clearly had nothing to do with ALE.

nightsdark commented 6 years ago

I had a simular problem to juliankatz1991

The debug output shows \<<NO OUTPUT RETURED>>

I solved this: by fixing a missing comma in package.json

The error was traced in my code from running

 standard src/app.js 
/home/chad/.nvm/versions/node/v8.9.1/lib/node_modules/standard/node_modules/pkg-conf/node_modules/parse-json/index.js:31
                throw jsonErr;
                ^
JSONError: Unexpected string in JSON at position 664 while parsing '{  "name": "application-name",  "versi' in package.json
    at module.exports (/home/chad/.nvm/versions/node/v8.9.1/lib/node_modules/standard/node_modules/pkg-conf/node_modules/parse-json/index.js:26:19)
    at parse (/home/chad/.nvm/versions/node/v8.9.1/lib/node_modules/standard/node_modules/pkg-conf/node_modules/load-json-file/index.js:8:29)
    at Function.module.exports.sync.fp [as sync] (/home/chad/.nvm/versions/node/v8.9.1/lib/node_modules/standard/node_modules/pkg-conf/node_modules/load-json-file/index.js:11:29)
    at Function.sync (/home/chad/.nvm/versions/node/v8.9.1/lib/node_modules/standard/node_modules/pkg-conf/index.js:52:27)
    at Linter.parseOpts (/home/chad/.nvm/versions/node/v8.9.1/lib/node_modules/standard/node_modules/standard-engine/index.js:140:15)
    at Linter.lintFiles (/home/chad/.nvm/versions/node/v8.9.1/lib/node_modules/standard/node_modules/standard-engine/index.js:94:15)
    at Object.Cli [as cli] (/home/chad/.nvm/versions/node/v8.9.1/lib/node_modules/standard/node_modules/standard-engine/bin/cmd.js:99:14)
    at Object.<anonymous> (/home/chad/.nvm/versions/node/v8.9.1/lib/node_modules/standard/bin/cmd.js:7:30)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)