I was trying to get emacs to point to a version of eslint that isn't installed globally (but located in the node_modules of the directory one level up), so I followed this: Flycheck with file relative eslint executable, but flycheck is still only finding the global version (at "/usr/local/bin/eslint"). Below are the lines I added to my init.el related to flycheck.
;; configure flycheck for linting, make sure it starts globally
(add-hook 'after-init-hook #'global-flycheck-mode)
;; the following didn't work
;; I had to install eslint globally to get it to work and it wasnt ideal :(
(defun my/use-eslint-from-node-modules ()
(let* ((root (locate-dominating-file
(or (buffer-file-name) default-directory)
"node_modules"))
(eslint (and root
(expand-file-name "node_modules/eslint/bin/eslint.js"
root))))
(when (and eslint (file-executable-p eslint))
(setq-local flycheck-javascript-eslint-executable eslint))))
(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
I am using Mac OSX Mojave with Emacs 26.1.1