简体   繁体   English

如何在emacs Web模式下运行jshint?

[英]How to run jshint in emacs web-mode?

As stated on the web-mode.org page, since May 2014 web-mode supports jshint. 如web-mode.org页面上所述,自2014年5月起, web-mode支持jshint。

I've been using jshint in js-mode , for which purpose I installed flycheck and added the following setting to the .emacs file: 我一直在js-mode使用jshint ,为此目的,我安装了flycheck并将以下设置添加到.emacs文件中:

(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. 我也想使jshint在web-mode ,但是没有这样做。 Here's what I tried: 这是我尝试过的:

open .js file 打开.js文件

Mx web-mode

Mx web-mode-jshint

Mx flycheck

But no luck. 但是没有运气。 Could you please suggest how to make jshint work in emacs's web-mode ? 您能否建议如何使jshint在emacs的web-mode

UPDATE: fxbois pointed out below that the only command that needs to be executed is Mx web-mode-jshint . 更新: fxbois在下面指出,唯一需要执行的命令是Mx 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 ). 这适用于常规.js文件,但不适用于.js.erb文件(常规web-mode可以识别)。 So the next part of my question is, does anybody know how to make web-mode-jshint work with .js.erb files? 因此,我的问题的下一部分是,有人知道如何使web-mode-jshint.js.erb文件web-mode-jshint工作吗?

You should only have to execute Mx web-mode-jshint 您只需要执行Mx web-mode-jshint

(of course, jshint should be installed) (当然,应该安装jshint

I just ran into this in the past 20 minutes and found that web-mode-jshint does not run automatically, use Cc Cj to evaluate the buffer manually. 我只是在过去20分钟内遇到此问题,发现web-mode-jshint不会自动运行,请使用Cc Cj手动评估缓冲区。 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, eg flycheck, but implements its own highlighting. (IMO)不幸的是, web-mode-jshint没有集成现有的jshint解决方案,例如flycheck,但是实现了自己的突出显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM