https://github.com/yaniswang/HTMLHintcss
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' } }]
https://github.com/stubbornella/csslinthtml
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: {} }
https://github.com/reid/node-jslintnode
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\'.' }, } ] }
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\'.' }, } ] }