From: James Bunton Date: Thu, 21 Jul 2016 07:39:29 +0000 (+1000) Subject: use local eslint in flycheck X-Git-Url: https://code.delx.au/dotemacs/commitdiff_plain/c02c1880bcf576babdf75766ad9ad0cd76342bd4 use local eslint in flycheck --- diff --git a/lisp/my-defuns.el b/lisp/my-defuns.el index c74f804..db7c56f 100644 --- a/lisp/my-defuns.el +++ b/lisp/my-defuns.el @@ -95,3 +95,12 @@ (comment-or-uncomment-region (region-beginning) (region-end)) (comment-or-uncomment-region (line-beginning-position) (line-end-position))) (forward-line)) + +(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/.bin/eslint" root)))) + (when (and eslint (file-executable-p eslint)) + (setq-local flycheck-javascript-eslint-executable eslint)))) diff --git a/lisp/my-minor-modes.el b/lisp/my-minor-modes.el index d07db74..e4dbe1e 100644 --- a/lisp/my-minor-modes.el +++ b/lisp/my-minor-modes.el @@ -16,6 +16,7 @@ (global-flycheck-mode 1) (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) (setq flycheck-emacs-lisp-load-path 'inherit) +(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules) (require 'misc)