7/28/2017 - 12:35 PM

Use ESLint from project folder

Use ESLint from project folder

(defun my/use-eslint-from-node-modules ()
  (let ((root (locate-dominating-file
               (or (buffer-file-name) default-directory)
               (lambda (dir)
                 (let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js" dir)))
                   (and eslint (file-executable-p eslint)))))))
    (when root
      (let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js" root)))
        (setq-local flycheck-javascript-eslint-executable eslint)))))

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."

  (when (and (memq window-system '(mac ns))
            (require 'exec-path-from-shell nil t))
  ;; (setq exec-path-from-shell-debug t)
  (exec-path-from-shell-copy-envs '("LANG" "LC_ALL"))
  (message "Initialized PATH and other variables from SHELL."))

  (add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
  (setq js2-mode-show-parse-errors nil)
  (setq js2-mode-show-strict-warnings nil)