aboutsummaryrefslogtreecommitdiffstats
path: root/build/jshint-check.js
blob: 2594539318b887112f9358ecfbe60067d54a3330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var jshint = require("./lib/jshint").JSHINT,
		src = require("fs").readFileSync("dist/jquery.js", "utf8"),
		config = {
			evil: true,
			browser: true,
			wsh: true,
			eqnull: true,
			expr: true,
			curly: true,
			trailing: true,
			undef: true,
			smarttabs: true,
			predef: [
				"define",
				"DOMParser"
			],
			maxerr: 100
		};

if ( jshint( src, config ) ) {
	console.log("JSHint check passed.");
} else {

	console.log( "JSHint found errors." );

	jshint.errors.forEach(function( e ) {
		if ( !e ) { return; }

		var str = e.evidence ? e.evidence : "",
		character = e.character === true ? "EOL" : "C" + e.character;

		if ( str ) {
			str = str.replace( /\t/g, " " ).trim();
			console.log( " [L" + e.line + ":" + character + "] " + e.reason + "\n  " + str + "\n");
		}
	});
}