htmlhint

https://github.com/yaniswang/HTMLHint

使用

var HTMLHint  = require("htmlhint").HTMLHint;
var messages = HTMLHint.verify(code, options);

选项

{
'tagname-lowercase': true,
'attr-lowercase': true,
'attr-value-double-quotes': true,
'doctype-first': true,
'tag-pair': true,
'spec-char-escape': true,
'id-unique': true
}

返回

[{
type: 'error',
message: 'Id redefinition of [ row ].',
raw: ' id="row"',
evidence: '<div id="row" class="clearfix">',
line: 114,
col: 5,
rule:
{
id: 'id-unique',
description: 'Id must be unique.',
link: 'https://github.com/yaniswang/HTMLHint/wiki/id-unique'
}
}]

csslint

https://github.com/stubbornella/csslint

使用

var csslint = require('csslint').CSSLint;
var result = csslint.verify(code, rules);

选项

...

返回

{
messages:
[{ type: 'warning',
line: 1,
col: 1,
message: 'The universal selector (*) is known to be slow.',
evidence: '*{}',
rule: [Object]
}],
stats: [ floats: 0, 'font-sizes': 0, important: 0, 'rule-count': 1 ],
ruleset: {}
}

jslint

https://github.com/reid/node-jslint

使用

var jslint = require('jslint');
var result = jslint(code);
var data = jslint.data();

选项

anon :true  //匿名函数声明中function关键字与()之间的空白可以被省略
bitwise : true //允许按位运算
browser : true //浏览器(标准)是预定义的全局
cap : true //允许大写的HTML
continue : true //容忍continuation语句
css : true //允许检查CSS
debug : true //允许debuger语句
devel : true //允许控制台语句console、alert语句
eqeq : true //允许==和!=运算符
es5 : true //允许ECMAScript 5 的语法
evil : true //允许使用eval
forin : true //for in声明的中的key不需要使用hasOwnProperty过滤
fragment : true //允许检查HTML片段
indent : 空白缩进的数量,默认建议4个空格
maxerr : 允许做大的错误数,默认是50
maxlen : 允许单行的最大长度
newcap : true //构造函数的首字母大小写可以被忽略
node : true //node.js是预定义的全局
nomen : true //允许标识符以_开头
on : true //允许在HTML使用类似onclick这样的事件处理
passfail : true //应该在扫描到第一个错误时停止
plusplus : true //允许++递增 或 --递减
properties : true //由于 JavaScript 是松散类型、动态对象的语言,在编译时不可能确定,如果希望检查属性名称拼写,所有内置的属性名称必须写在 /*properties*/中
regexp : true //允许正则表达式文本中含有.
rhino : true //假设是在rhino环境中
undef : true //变量的定义顺序可以是混乱的,比如var a = b.name, b = {name: "b"};
unparam : true //允许忽略未使用的参数
sloppy : true //'use strict'标注是可选的
sub : true //容忍所有的下标表示法,如果属性名是一个合法的标识符,建议用.表示法
vars : true //允许每个函数有多个var声明
white : true //容忍多余的空白
widget : true //假设是在Yahoo Widgets环境中
windows : true //MS Windows的特定全局应该是预定义的

返回

{
errors: [
{
{ id: '(error)',
raw: 'Unexpected dangling \'_\' in \'{a}\'.',
evidence: ' environment.bind("touchstart", _onTouchStart);
line: 25,
character: 36,
a: '_onTouchStart',
b: undefined,
c: undefined,
d: undefined,
reason: 'Unexpected dangling \'_\' in \'_onTouchStart\'.' },
}
]
}

jshint

使用

var JSHINT = require("jshint").JSHINT;
var result = jshint(js);

选项

asi         : true, // if automatic semicolon insertion should be tolerated
bitwise : true, // if bitwise operators should not be allowed
boss : true, // if advanced usage of assignments should be allowed
browser : true, // if the standard browser globals should be predefined
camelcase : true, // if identifiers should be required in camel case
couch : true, // if CouchDB globals should be predefined
curly : true, // if curly braces around all blocks should be required
debug : true, // if debugger statements should be allowed
devel : true, // if logging globals should be predefined (console, alert, etc.)
dojo : true, // if Dojo Toolkit globals should be predefined
eqeqeq : true, // if === should be required
eqnull : true, // if == null comparisons should be tolerated
es5 : true, // if ES5 syntax should be allowed
esnext : true, // if es.next specific syntax should be allowed
evil : true, // if eval should be allowed
expr : true, // if ExpressionStatement should be allowed as Programs
forin : true, // if for in statements must filter
funcscope : true, // if only function scope should be used for scope tests
gcl : true, // if JSHint should be compatible with Google Closure Linter
globalstrict: true, // if global "use strict"; should be allowed (also enables 'strict')
immed : true, // if immediate invocations must be wrapped in parens
iterator : true, // if the `__iterator__` property should be allowed
jquery : true, // if jQuery globals should be predefined
lastsemic : true, // if semicolons may be ommitted for the trailing
// statements inside of a one-line blocks.
latedef : true, // if the use before definition should not be tolerated
laxbreak : true, // if line breaks should not be checked
laxcomma : true, // if line breaks should not be checked around commas
loopfunc : true, // if functions should be allowed to be defined within
// loops
mootools : true, // if MooTools globals should be predefined
multistr : true, // allow multiline strings
newcap : true, // if constructor names must be capitalized
noarg : true, // if arguments.caller and arguments.callee should be
// disallowed
node : true, // if the Node.js environment globals should be
// predefined
noempty : true, // if empty blocks should be disallowed
nonew : true, // if using `new` for side-effects should be disallowed
nonstandard : true, // if non-standard (but widely adopted) globals should
// be predefined
nomen : true, // if names should be checked
onevar : true, // if only one var statement per function should be
// allowed
passfail : true, // if the scan should stop on first error
phantom : true, // if PhantomJS symbols should be allowed
plusplus : true, // if increment/decrement should not be allowed
proto : true, // if the `__proto__` property should be allowed
prototypejs : true, // if Prototype and Scriptaculous globals should be
// predefined
rhino : true, // if the Rhino environment globals should be predefined
undef : true, // if variables should be declared before used
scripturl : true, // if script-targeted URLs should be tolerated
shadow : true, // if variable shadowing should be tolerated
smarttabs : true, // if smarttabs should be tolerated
// (http://www.emacswiki.org/emacs/SmartTabs)
strict : true, // require the "use strict"; pragma
sub : true, // if all forms of subscript notation are tolerated
supernew : true, // if `new function () { ... };` and `new Object;`
// should be tolerated
trailing : true, // if trailing whitespace rules apply
validthis : true, // if 'this' inside a non-constructor function is valid.
// This is a function scoped option only.
withstmt : true, // if with statements should be allowed
white : true, // if strict whitespace rules apply
worker : true, // if Web Worker script symbols should be allowed
wsh : true, // if the Windows Scripting Host environment globals
// should be predefined
yui : true, // YUI variables should be predefined // Obsolete options
onecase : true, // if one case switch statements should be allowed
regexp : true, // if the . should not be allowed in regexp literals
regexdash : true // if unescaped first/last dash (-) inside brackets
// should be tolerated
// These are the JSHint options that can take any value
// (we use this object to detect invalid options)
maxlen : false,
indent : false,
maxerr : false,
predef : false,
quotmark : false, //'single'|'double'|true
scope : false,
maxstatements: false, // {int} max statements per function
maxdepth : false, // {int} max nested block depth per function
maxparams : false, // {int} max params per function
maxcomplexity: false, // {int} max cyclomatic complexity per function
unused : true // warn if variables are unused. Available options:
// false - don't check for unused variables
// true - "vars" + check last function param
// "vars" - skip checking unused function params
// "strict" - "vars" + check all function params

返回

{
errors: [
{
{ id: '(error)',
raw: 'Unexpected dangling \'_\' in \'{a}\'.',
evidence: ' environment.bind("touchstart", _onTouchStart);
line: 25,
character: 36,
a: '_onTouchStart',
b: undefined,
c: undefined,
d: undefined,
reason: 'Unexpected dangling \'_\' in \'_onTouchStart\'.' },
}
]
}

nodejs 前端工具总结的更多相关文章

  1. 【tool】部署前端工具

    一.部署前端工具如下: nodejsnpmwebpackvue 二.安装nodejs 1. 下载稳当版本nodejs 2. 配置环境变量 NODE_HOME=D:\soft\nodejs\ path= ...

  2. 简单实现nodejs爬虫工具

    约30行代码实现一个简单nodejs爬虫工具,定时抓取网页数据. 使用npm模块 request---简单http请求客户端.(轻量级) fs---nodejs文件模块.   index.js var ...

  3. 前端工具之-- Sublime

    开始学习前端知识,做一些笔记来记录下- 之前学习都是使用的dw 现在前端开发工具既轻便功能也够强大. 下面记录下常用的前端工具: Sublime3:需要安装第三方包,一般 Atom:继承度非常好 VS ...

  4. 覆盖率测试工具gcov的前端工具_LCOV

    http://my.oschina.net/alphajay/blog/33725 1.Gcov是进行代码运行的覆盖率统计的工具,它随着gcc的发布一起发布的,它的使用也很简单,需要在编译和链接的时候 ...

  5. NodeJS常用工具

    一.NodeJS版本管理器n或者nvm npm install -g n npm install n -g --registry=https://registry.npm.taobao.org --v ...

  6. 前端工具之WebPack解密--使用

    接上一篇的内容继续来说,背景篇的内容主要是介绍web前端工具的出现的原因和当前主要JavaScript模块化编程的几种规范!这篇内容主要介绍webpack的初级使用! 注意:目前webpack分为两个 ...

  7. 前端工具之WebPack解密之背景

    请注意,这是一篇站在完全新手的角度上来写的文章.可能你是一个后端人员想了解前端工具的使用和概念;也可能你是一个前端小菜(还在DIV+CSS的世界里挣扎着).本文比较适合那些以前完全没有接触过WebPa ...

  8. css3前端工具

    随着CSS3的出现,CSS3讨论的话题越来越多了,现在各种教程也是多如牛毛,不比一年前的时候,找个资料要捞遍整个互联网,而且还很难找到自己需要的参考资料.从侧面也说明,CSS3对于前端工程师来说,越来 ...

  9. VS2015前端工具:NPM和Web Essentials

    VS2015前端工具:NPM和Web Essentials 1.写作背景 想在5月份前换个工作环境了,“检讨”一下自己混饭的技术水平和处世的人脉关系,觉得很不给力!为人方面,人各有志也就不纠结了,但本 ...

随机推荐

  1. 设计模式之——浅谈strategy模式(策略模式)

    strategy模式,即策略模式.个人觉得吧,策略模式更多的是一种思维方式. 首先我们要知道,为什么需要策略模式.举个例子,比如用程序输出今天下午去玩什么. PlayGame 玩游戏 package ...

  2. flask的session用法2

    from flask import Flask, session, redirect, url_for, escape, request app = Flask(__name__) @app.rout ...

  3. Linux学习-->如何通过Shell脚本实现发送邮件通知功能?

    1.安装和配置sendmail 不需要注册公网域名和MX记录(不需要架设公网邮件服务器),通过Linux系统自带的mail命令即可对公网邮箱发送邮件.不过mail命令是依赖sendmail的,所以我们 ...

  4. (转)Terraform,自动化配置与编排必备利器

    本文来自作者 QingCloud实践课堂 在 GitChat 上分享 「Terraform,自动化配置与编排必备利器」 Terraform - Infrastructure as Code 什么是 T ...

  5. AngularJS SQL

    服务端代码 以下列出了列出了几种服务端代码类型: 使用 PHP 和 MySQL.返回 JSON. 使用 PHP 和 MS Access.返回 JSON. 使用 ASP.NET, VB, 及 MS Ac ...

  6. 前端基础(html)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. Smarty 模板布局继承

    Smarty 模板继承 在覆盖父模板的{block}块以外的地方, 子模板不能定义任何内容.任何在{block}以外的 内容都会被自动忽略. 在子模板和父模板中的{block}内容,可以通过 appe ...

  8. MOPSO 多目标粒子群优化算法

    近年来,基于启发式的多目标优化技术得到了很大的发展,研究表明该技术比经典方法更实用和高效.有代表性的多目标优化算法主要有NSGA.NSGA-II.SPEA.SPEA2.PAES和PESA等.粒子群优化 ...

  9. shell给tcp或udp服务发送16进制报文指令

    指令:(sleep 2;echo "000F737D61747573" | xxd -r -p ;sleep 1)|nc 192.168.137.1 15000|hexdump - ...

  10. Linux内核参数之arp_ignore和arp_announce

    一.arp_ignore和arp_announce介绍 arp_ignore和arp_announce参数都和ARP协议相关,主要用于控制系统返回arp响应和发送arp请求时的动作.这两个参数很重要, ...