flymake-eslint icon indicating copy to clipboard operation
flymake-eslint copied to clipboard

Allow running ESLint using npx

Open denisw opened this issue 1 year ago • 4 comments

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.

denisw avatar Nov 12 '22 22:11 denisw

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.

orzechowskid avatar Nov 27 '22 03:11 orzechowskid

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

denisw avatar Dec 01 '22 06:12 denisw

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

kazmuroi avatar Dec 21 '22 07:12 kazmuroi

found this code snippet:

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

yassernasc avatar May 09 '23 18:05 yassernasc