https://blog.oio.de/2012/03/26/jshint-eclipse-javascript-code-quality-plugin-for-eclipse/
 
Stuff for Java info junkies

jshint-eclipse: JavaScript Code Quality Plugin for Eclipse

JavaScript has a lot of pitfalls, so it is very important to have a code analysis tool that detects errors and bad programming style.

jshint-eclipse is an Eclipse plugin that uses the static code analysis tool JSHint to analyze your JavaScript sources.

JSHint is a community-driven tool to detect errors and potential problems in JavaScript code and to enforce your team’s coding conventions.
It is very flexible so you can easily adjust it to your particular
coding guidelines and the environment you expect your code to execute
in.

To install it, use the Eclipse update site: http://github.eclipsesource.com/jshint-eclipse/updates/

To activate JSHint for your project, open the project properties dialog, select JSHint and check “Enable JSHint for this project“.

From now on, all your .js files will be checked.
To exclude files or complete directory trees from the analysis, right
click on the file/folder to exclude in the Navigator. Select Properties -> JSHint and check “Exclude this folder from jshint validation“. You should exclude third party javascript libraries like jQuery.

Here is a screenshot that shows JSHint in action. You can see warning
icons next to lines that violate rules. The problem view shows all the
violations with a description of the problem.

The default configuration of JSHint is not that strict, so you probably want to provide your own configuration. The configuration page shows all possible settings. To adjust these settings in Eclipse, open the preferences page and navigate to JSHint -> Options.

Here is my personal config that is a lot stricter than the default configuration:

1
2
3
4
5
6
7
8
9
10
11
12
13
devel: true,
browser: true,
curly: true,
eqeqeq: true,
forin: true,
immed: true,
latedef: newcap,
noarg: true,
noempty: true,
undef: true,
strict: true,
trailing: true,
newcap: true

JSHint directly supports some famous JavaScript frameworks. If you are using jQuery, you should add this to your config:

1
jquery: true

Like this:

Related

JavaScript Lint - checks your JavaScript source code for common mistakes21. August 2011In "Java and Quality"

Dynamic Reloading of Vaadin Applications With Maven and Eclipse, Pt. I23. August 2012In "Build, config and deploy"

TypeScript Plug-in for Eclipse5. August 2013In "Eclipse Universe"

Short URL for this post: https://blog.oio.de/AhY3W

Leave a Reply

 

  • Subscribe to Blog via Email

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 59 other subscribers

    Email Address

jshint-eclipse: JavaScript Code Quality Plugin for Eclipse的更多相关文章

  1. eclipse启动报错 Problems occurred when invoking code from plug-in: "org.eclipse.jface"

    eclipse在使用中可能会发生错误: Problems occurred when invoking code from plug-in: "org.eclipse.jface" ...

  2. Problems occurred when invoking code from plug-in: "org.eclipse.jface".

    java.lang.NullPointerException at com.genuitec.eclipse.easie.core.AppServer.getServerLabel(Unknown S ...

  3. view class source code with JAD plugin in Eclipse

    The default class viewer doesn't decompile the class file so you cannot open and check the source co ...

  4. eclipse's code assist

    突然发现有个类没有code assist功能了,而别的类都还有,新建的类也有,可是当把代码拷贝到新建的类还是不行:尝试了各种办法,包括删除workspace/.metadata/.plugin/org ...

  5. Plug-in 'org.eclipse.cdt.ui' contributed an invalid Menu Extension

    终于在mac上配置了最新的eclipse和adt(Win和Mac oxs通用),然后就Error Log报这种错误,运行了hello word,没有影响,但是依旧有这种错误! 记录下错误: eclip ...

  6. tip use view.isineditmode() in your custom views to skip code when shown in eclipse

    tip use view.isineditmode() in your custom views to skip code when shown in eclipse

  7. Use View.isInEditMode() in your custom views to skip code when shown in Eclipse

    今天在做自定义ViewGroup中,出现了一下错误提示Use View.isInEditMode() in your custom views to skip code when shown in E ...

  8. (办公)plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.jdt.internal

    今天上午开发环境遇到这个问题,解决方案如下,(解决了之后,项目并没有丢失.) 因为Eclipse的这个plug-in org.eclipse.jdt.ui was unable to load cla ...

  9. eclipse中无法新建Android工程 出现问题:Plug-in org.eclipse.ajdt.ui was unable to load

    转自:http://www.bubuko.com/infodetail-757338.html eclipse中打开后新建Android项目区仍无法创建,出现下列提示对话框: Plug-in org. ...

随机推荐

  1. maven 配置jetty 插件

    <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin ...

  2. POJ3469Dual Core CPU

    题意:给你n个模块,每个模块在A核花费为ai,在B核跑花费为bi,然后由m个任务(ai,bi,wi),表示如果ai,bi不在同一个核上跑,额外的花费为wi,求最小的花费. 分析: 用最小的费用将对象划 ...

  3. Binutils工具集常用工具

    GNU为GCC编译器提供了配套的辅助工具集(Binutils)http://www.gnu.org/software/binutils/ 1. addr2line ①将指定地址转换为对应的文件名和行号 ...

  4. JavaScript trim 实现去除字符串首尾指定字符的简单方法

    String.prototype.trim = function (char, type) { if (char) { if (type == 'left') { return this.replac ...

  5. JavaScript中使用ActiveXObject操作本地文件夹的方法

    转载地址    http://www.jb51.net/article/48538.htm 在Windows平台上, js可以调用很多Windows提供的ActivexObject,本文就使用js来实 ...

  6. 使用vlookup函数下拉全部相同解决

    菜单“公式”-“计算选项”改为自动 ref: https://zhidao.baidu.com/question/561971299094821004.html

  7. spring espect XX but YY

    注入和查找问题 HSF Consumer bean, 注入的是beanName='实际接口名', type='HSFSpringConsumerBean',  造成Autowire时查询出来的类型不匹 ...

  8. WIN10安装SW2012完整破解文件和问题解决Crack

    Win10在安装solidword后,激活时有可能报错,本文介绍怎么解决问题 安装后激活报错信息: 一.按下面步骤进行安装 1.相关序列号,记住要断网进行安装 Install SolidWorks 2 ...

  9. jmeter使用总结

    1.1 什么是 JMeter Apache JMeter 是 Apache 组织开发的基于 Java 的压力测试工具.用于对软件做压力测试,它最初被设计用于 Web 应用测试,但后来扩展到其他测试领域 ...

  10. Mybatis学习笔记4 - 获取自增主键的值

    获取自增主键的值:mysql支持自增主键,自增主键值的获取,mybatis也是利用statement.getGenreatedKeys():useGeneratedKeys="true&qu ...