react: use node_modules version of eslint or global if not available
This commit is contained in:
parent
cf3068e4ef
commit
f88a7889a4
|
@ -38,6 +38,20 @@
|
||||||
(defun react/post-init-flycheck ()
|
(defun react/post-init-flycheck ()
|
||||||
(with-eval-after-load 'flycheck
|
(with-eval-after-load 'flycheck
|
||||||
(flycheck-add-mode 'javascript-eslint 'react-mode))
|
(flycheck-add-mode 'javascript-eslint 'react-mode))
|
||||||
|
(defun react/use-eslint-from-node-modules ()
|
||||||
|
(let* ((root (locate-dominating-file
|
||||||
|
(or (buffer-file-name) default-directory)
|
||||||
|
"node_modules"))
|
||||||
|
(global-eslint (executable-find "eslint"))
|
||||||
|
(local-eslint (expand-file-name "node_modules/.bin/eslint"
|
||||||
|
root))
|
||||||
|
(eslint (if (file-executable-p local-eslint)
|
||||||
|
local-eslint
|
||||||
|
global-eslint)))
|
||||||
|
(setq-local flycheck-javascript-eslint-executable eslint)))
|
||||||
|
|
||||||
|
(add-hook 'react-mode-hook #'react/use-eslint-from-node-modules)
|
||||||
|
|
||||||
(spacemacs/add-flycheck-hook 'react-mode))
|
(spacemacs/add-flycheck-hook 'react-mode))
|
||||||
|
|
||||||
(defun react/post-init-js-doc ()
|
(defun react/post-init-js-doc ()
|
||||||
|
|
Loading…
Reference in a new issue