azangru
azangru

Reputation: 2738

How to run jshint in emacs web-mode?

As stated on the web-mode.org page, since May 2014 web-mode supports jshint.

I've been using jshint in js-mode, for which purpose I installed flycheck and added the following setting to the .emacs file:

(require 'flycheck)
(add-hook 'js-mode-hook
          (lambda () (flycheck-mode t)))

I would also like to make jshint work in web-mode, but failed to do so. Here’s what I tried:

open .js file

M-x web-mode

M-x web-mode-jshint

M-x flycheck

But no luck. Could you please suggest how to make jshint work in emacs's web-mode?

UPDATE: fxbois pointed out below that the only command that needs to be executed is M-x web-mode-jshint. This works on regular .js files, but does not work on .js.erb files (which are recognized by the regular web-mode). So the next part of my question is, does anybody know how to make web-mode-jshint work with .js.erb files?

Upvotes: 0

Views: 675

Answers (2)

ahamlin
ahamlin

Reputation: 11

I just ran into this in the past 20 minutes and found that web-mode-jshint does not run automatically, use C-c C-j to evaluate the buffer manually. I am still searching for a way to run the evaluation automatically.

(IMO) It is unfortunate that web-mode-jshint does not integrate existing jshint solutions, e.g. flycheck, but implements its own highlighting.

Upvotes: 1

fxbois
fxbois

Reputation: 826

You should only have to execute M-x web-mode-jshint

(of course, jshint should be installed)

Upvotes: 1

Related Questions