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

Allow running ESLint using npx #26

Open
denisw opened this issue Nov 12, 2022 · 4 comments
Open

Allow running ESLint using npx #26

denisw opened this issue Nov 12, 2022 · 4 comments

Comments

@denisw
Copy link

denisw commented Nov 12, 2022

Currently, ESLint needs to be in executable-path, which means that ESLint must be installed globally or executable-path has to be configured per project. It would be nice if flymake-eslint would offer the possibility to run ESLint through NPM's npx command instead (npx eslint), which would automatically pick up the ESLint version installed in the project's node_modules, and only runs the globally installed version as a fallback.

@orzechowskid
Copy link
Owner

thanks for raising an issue. until I get some time to work on this again (and it needs a lot of work!), would updating the buffer-local value of exec-path be an acceptable solution? if so then you should be able to do something like this (untested) to put the closest node_modules/.bin at the front of your path:

(push
  (file-name-concat
    (locate-dominating-file
      (buffer-file-name)
      "package.json")
    "node_modules" ".bin")
  exec-path)
(flymake-eslint-enable)

that should first try node_modules/.bin/eslint then fall back to any globally-installed eslint.

@denisw
Copy link
Author

denisw commented Dec 1, 2022

Thanks for your reply! That sounds like a workable solution, thanks for the tip! 👍

@denisw denisw closed this as completed Dec 1, 2022
@denisw denisw reopened this Dec 1, 2022
@kazmuroi
Copy link

codesuki/add-node-modules-path might help.

@yassernasc
Copy link

found this code snippet:

(use-package flymake-eslint
  :custom
  (flymake-eslint-executable-name "npx"))

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

4 participants