emacsflymakejshint

Emacs - Can't get Flymake to work with JSHint


I'm trying to get JSHint to work with Flymake.

jshint is indeed installed in /opt/bin and works. /opt/bin is in Emacs' exec-path.

I've followed the directions on the EmacsWiki and have this in my init.el:

(defun flymake-jshint-init ()
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
                     'flymake-create-temp-inplace))
         (local-file (file-relative-name
                      temp-file
                      (file-name-directory buffer-file-name))))
    (list "jshint" (list local-file))))

(setq flymake-err-line-patterns
      (cons '("^  [[:digit:]]+ \\([[:digit:]]+\\),\\([[:digit:]]+\\): \\(.+\\)$"
              nil 1 2 3)
            flymake-err-line-patterns))

(add-to-list 'flymake-allowed-file-name-masks
             '("\\.js\\'" flymake-jshint-init))

When I open JavaScript files, my modeline appears as:

[(Javascript Flymake* AC)]

This is odd because the * usually doesn't appear when I'm using Flymake with C++ or Python. According to the Flymake docs, Flymake* means "Flymake is currently running." However, Flymake isn't showing any errors.

I've checked the *Messages* buffer but it only lists a few lines of Fontifying foo.js... (regexps...................). No errors.

Other suggestions?


Solution

  • I found a project called jshint-mode and tried that. It created a buffer called *jshint-mode* which revealed the error: JSHint couldn't find the formidable module.

    I ran M-x setenv in Emacs to set NODE_PATH so that jshint could find the formidable library. I also set NODE_PATH in /etc/profile.