Skip to content
Permalink
Browse files
Adds .jshintrc files for: grunt (default set), src, tests; Adapts jQu…
…ery-UI loading method
  • Loading branch information
rwaldron committed Jun 25, 2012
1 parent c436ae0 commit 96246332f723b0f83e465d0f9f580741c8272f80
Showing 4 changed files with 114 additions and 60 deletions.
@@ -0,0 +1,11 @@
{
"curly": true,
"eqnull": true,
"eqeqeq": true,
"expr": true,
"latedef": true,
"noarg": true,
"smarttabs": true,
"trailing": true,
"undef": true
}
@@ -5,6 +5,7 @@
*
*/

/*jshint node: true */
/*global config:true, task:true, process:true*/
module.exports = function( grunt ) {

@@ -14,8 +15,8 @@ module.exports = function( grunt ) {
function readOptionalJSON( filepath ) {
var data = {};
try {
data = grunt.file.readJSON(filepath);
grunt.log.write( "Reading data from " + filepath + "..." ).ok();
data = grunt.file.readJSON( filepath );
grunt.verbose.write( "Reading " + filepath + "..." ).ok();
} catch(e) {}
return data;
}
@@ -81,73 +82,32 @@ module.exports = function( grunt ) {
min: {
"dist/jquery.min.js": [ "<banner>", "dist/jquery.js" ]
},

lint: {
files: [ "test/unit/**/*.js", "grunt.js", "dist/jquery.js" ]
dist: "dist/jquery.js",
grunt: "grunt.js",
tests: "tests/unit/**/*.js"
},

jshint: (function() {
function jshintrc( path ) {
return readOptionalJSON( (path || "") + ".jshintrc" ) || {};
}

return {
options: jshintrc(),
dist: jshintrc( "src/" ),
tests: jshintrc( "test/" )
};
})(),

qunit: {
files: "test/index.html"
},
watch: {
files: [ "<config:lint.files>", "src/**/*.js" ],
tasks: "dev"
},
jshint: {
options: {
evil: true,
browser: true,
wsh: true,
eqnull: true,
expr: true,
curly: true,
trailing: true,
undef: true,
smarttabs: true,
maxerr: 100
},
globals: {
define: true,
DOMParser: true,
__dirname: true,
jQuery: true,
global: true,
module: true,
exports: true,
require: true,
file: true,
log: true,
console: true,
QUnit: true,
ok: true,
equal: true,
test: true,
asyncTest: true,
notEqual: true,
deepEqual: true,
strictEqual: true,
notStrictEqual: true,
start: true,
stop: true,
expect: true,
raises: true,
testIframe: true,
testIframeWithCallback: true,
createDashboardXML: true,
moduleTeardown: true,
testFoo: true,
foobar: true,
url: true,
t: true,
q: true,
amdDefined: true,
fireNative: true,
hasPHP: true,
isLocal: true,
originaljQuery: true,
"$": true,
"original$": true

}
},
uglify: {}
});

@@ -0,0 +1,27 @@
{
"options": {
"evil": true,
"browser": true,
"wsh": true,
"eqnull": true,
"expr": true,
"curly": true,
"trailing": true,
"undef": true,
"smarttabs": true,
"maxerr": 100
},
"globals": {
"define": true,
"DOMParser": true,
"__dirname": true,
"jQuery": true,
"global": true,
"module": true,
"exports": true,
"require": true,
"file": true,
"log": true,
"console": true
}
}
@@ -0,0 +1,56 @@
{
"options": {
"evil": true,
"browser": true,
"wsh": true,
"eqnull": true,
"expr": true,
"curly": true,
"trailing": true,
"undef": true,
"smarttabs": true,
"maxerr": 100
},
"globals": {
"define": true,
"DOMParser": true,
"__dirname": true,
"jQuery": true,
"global": true,
"module": true,
"exports": true,
"require": true,
"file": true,
"log": true,
"console": true,
"QUnit": true,
"ok": true,
"equal": true,
"test": true,
"asyncTest": true,
"notEqual": true,
"deepEqual": true,
"strictEqual": true,
"notStrictEqual": true,
"start": true,
"stop": true,
"expect": true,
"raises": true,
"testIframe": true,
"testIframeWithCallback": true,
"createDashboardXML": true,
"moduleTeardown": true,
"testFoo": true,
"foobar": true,
"url": true,
"t": true,
"q": true,
"amdDefined": true,
"fireNative": true,
"hasPHP": true,
"isLocal": true,
"originaljQuery": true,
"$": true,
"original$": true
}
}

2 comments on commit 9624633

@mikesherov
Copy link
Member

@mikesherov mikesherov commented on 9624633 Jun 26, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. My only thought on top of this is to separate the options for linting grunt.js to be different from those for dist/jquery.js. Right now, unless I'm reading this wrong, a few unnecessary globals are allowed in the dist file, and you had to add /*jshint node: true */ to the grunt.js file. I'd think separate .jshintrc files would eliminate the need for that.

@scottgonzalez
Copy link
Member

@scottgonzalez scottgonzalez commented on 9624633 Jun 26, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For UI we keep the main jshintrc based on the actual code, then use that for grunt.js and add the node: true comment as the only additional setting.

Please sign in to comment.