Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The plugin can't find eslint even though it is in PATH #233

Open
ghost opened this issue Mar 8, 2018 · 3 comments
Open

The plugin can't find eslint even though it is in PATH #233

ghost opened this issue Mar 8, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 8, 2018

I've downloaded and unpacked node.js into $HOME/node/, and have added $HOME/node/bin/ to PATH. Then I have installed eslint: npm -g install eslint. Even though I can now invoke eslint from the command line, vim-autoformat can't find it (it only looks in node_modules/.bin/, ~/.npm-global/bin/ and /usr/local/bin/).

It would be nice if vim-autoformat didn't just look for formatters in the hard-coded locations.

@chtenb
Copy link
Member

chtenb commented Mar 9, 2018

ESLint is a weird one. I did not implement support for it, and do not use it myself either.
Feel free to extend the support in defaults.vim to cover your case.

@keeferrourke
Copy link

Since this is related, I won't open a new issue. The automatter also can't find eslint on my system when it's installed globally.

sudo npm -g install eslint installed eslint to /usr/bin/eslint on my Fedora 27 machine with npm v5.6.0. A quick fix might be to just add this as another path to check, as seems to be the case in defaults.vim at the moment, but it would be better if vim-autoformat could just check the path if it fails to find eslint in the current directory's node_modules/ folder.

@opennota I may tackle this issue later if you don't get to it before me. For now I've just symlinked /usr/bin/eslint to /usr/local/bin/eslint

@keeferrourke
Copy link

keeferrourke commented May 20, 2018

I've submitted PR #243 which fixes this problem. It simplifies some of the logic and makes allows the formatter to run even if there is no eslintrc that can be found. Please check it out.

keeferrourke added a commit to keeferrourke/vim-autoformat that referenced this issue May 20, 2018
The old formatdef for eslint could not correctly locate the binary for
eslint installed via `sudo npm -g install eslint`. It would also not
work if a `eslintrc.*` file did not exist.

This simple patch makes the formatter fall back on using the $PATH to
locate `eslint` if it is not a locally installed node_module, allows the
formatter to run with the --no-eslintrc option if no config file can be
found, and simplifies some of the logic where the formatter attempts to
find the config files.

Patch tested with `vim` 8.0 compiled for Fedora 28 Workstation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants