Permalink
Browse files

Use jQuery project standards for JSHint options.

1 parent 5aa8b12 commit e3a1bb03284cb06d929b8e98435fe1d0b79224a1 @dmethvin dmethvin committed May 1, 2013
Showing with 102 additions and 75 deletions.
  1. +7 −4 .jshintrc
  2. +12 −3 Gruntfile.js
  3. +13 −16 src/.jshintrc
  4. +4 −3 src/migrate.js
  5. +24 −14 test/.jshintrc
  6. +8 −8 test/core.js
  7. +34 −27 test/event.js
View
@@ -1,14 +1,17 @@
{
+ "boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
- "latedef": true,
+ "immed": true,
"noarg": true,
- "node": true,
+ "onevar": true,
"quotmark": "double",
"smarttabs": true,
"trailing": true,
"undef": true,
- "unused": true
-}
+ "unused": true,
+
+ "node": true
+}
View
@@ -3,6 +3,17 @@ module.exports = function(grunt) {
"use strict";
+ // The concatenated file won't pass onevar but our modules can
+ var readOptionalJSON = function( filepath ) {
+ var data = {};
+ try {
+ data = grunt.file.readJSON( filepath );
+ } catch(e) {}
+ return data;
+ },
+ srcHintOptions = readOptionalJSON("src/.jshintrc");
+ delete srcHintOptions.onevar;
+
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
@@ -50,9 +61,7 @@ module.exports = function(grunt) {
jshint: {
dist: {
src: [ "dist/jquery-migrate.js" ],
- options: {
- jshintrc: "src/.jshintrc"
- }
+ options: srcHintOptions
},
tests: {
src: [ "test/*.js" ],
View
@@ -1,29 +1,26 @@
{
- "bitwise": true,
- "browser": true,
+ "boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
- "evil": true,
"expr": true,
- "maxerr": 100,
- "newcap": false,
+ "immed": true,
+ "noarg": true,
+ "onevar": true,
"quotmark": "double",
- "sub": true,
+ "smarttabs": true,
"trailing": true,
"undef": true,
"unused": true,
- "wsh": true,
+
+ "sub": true,
+
+ "browser": true,
+ "es5": true,
+
"globals": {
- "define": true,
- "DOMParser": true,
"jQuery": true,
- "global": true,
- "module": true,
- "exports": true,
- "require": true,
- "file": true,
- "log": true,
- "console": true
+ "define": true,
+ "module": true
}
}
View
@@ -8,8 +8,8 @@ jQuery.migrateWarnings = [];
// jQuery.migrateMute = false;
// Show a message on the console so devs know we're active
-if ( !jQuery.migrateMute && window.console && console.log ) {
- console.log("JQMIGRATE: Logging is active");
+if ( !jQuery.migrateMute && window.console && window.console.log ) {
+ window.console.log("JQMIGRATE: Logging is active");
}
// Set to false to disable traces that appear with warnings
@@ -24,10 +24,11 @@ jQuery.migrateReset = function() {
};
function migrateWarn( msg) {
+ var console = window.console;
if ( !warnedAbout[ msg ] ) {
warnedAbout[ msg ] = true;
jQuery.migrateWarnings.push( msg );
- if ( window.console && console.warn && !jQuery.migrateMute ) {
+ if ( console && console.warn && !jQuery.migrateMute ) {
console.warn( "JQMIGRATE: " + msg );
if ( jQuery.migrateTrace && console.trace ) {
console.trace();
View
@@ -1,32 +1,42 @@
{
- "browser": true,
+ "boss": true,
"curly": true,
- "devel": true,
+ "eqeqeq": true,
"eqnull": true,
- "evil": true,
"expr": true,
- "maxerr": 100,
+ "immed": true,
+ "noarg": true,
+ "onevar": true,
"quotmark": "double",
"smarttabs": true,
- "sub": true,
"trailing": true,
"undef": true,
+
+ "evil": true,
+ "sub": true,
+
+ "browser": true,
+ "devel": true,
"wsh": true,
+
"globals": {
- "jQuery": true,
- "TestManager": true,
- "expectNoWarning": true,
"expectWarning": true,
+ "expectNoWarning": true,
+ "TestManager": true,
+
+ "jQuery": true,
"QUnit": true,
- "deepEqual": true,
- "equal": true,
- "expect": true,
"module": true,
- "notEqual": true,
"ok": true,
- "start": true,
+ "equal": true,
+ "test": true,
+ "asyncTest": true,
+ "notEqual": true,
+ "deepEqual": true,
"strictEqual": true,
+ "notStrictEqual": true,
+ "start": true,
"stop": true,
- "test": true
+ "expect": true
}
}
View
@@ -104,7 +104,7 @@ test( "jQuery.browser", function() {
test( "jQuery.sub() - Static Methods", function(){
expect( 19 );
- var Subclass;
+ var Subclass, SubSubclass;
// Other warnings may be fired when props are copied
expectWarning( "jQuery.sub", function() {
@@ -125,16 +125,16 @@ test( "jQuery.sub() - Static Methods", function(){
//Test Simple Subclass
ok(Subclass["topLevelMethod"]() === false, "Subclass.topLevelMethod thought debug was true");
- ok(Subclass["config"]["locale"] == "en_US", Subclass["config"]["locale"] + " is wrong!");
+ ok(Subclass["config"]["locale"] === "en_US", Subclass["config"]["locale"] + " is wrong!");
deepEqual(Subclass["config"]["test"], undefined, "Subclass.config.test is set incorrectly");
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
//Create a SubSubclass
- var SubSubclass = Subclass.sub();
+ SubSubclass = Subclass.sub();
//Make Sure the SubSubclass inherited properly
ok(SubSubclass["topLevelMethod"]() === false, "SubSubclass.topLevelMethod thought debug was true");
- ok(SubSubclass["config"]["locale"] == "en_US", SubSubclass["config"]["locale"] + " is wrong!");
+ ok(SubSubclass["config"]["locale"] === "en_US", SubSubclass["config"]["locale"] + " is wrong!");
deepEqual(SubSubclass["config"]["test"], undefined, "SubSubclass.config.test is set incorrectly");
equal(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
@@ -145,13 +145,13 @@ test( "jQuery.sub() - Static Methods", function(){
SubSubclass.ajax = function() {return false;};
ok(SubSubclass["topLevelMethod"](), "SubSubclass.topLevelMethod thought debug was false");
deepEqual(SubSubclass(document)["subClassMethod"], Subclass.fn["subClassMethod"], "Methods Differ!");
- ok(SubSubclass["config"]["locale"] == "es_MX", SubSubclass["config"]["locale"] + " is wrong!");
- ok(SubSubclass["config"]["test"] == "worked", "SubSubclass.config.test is set incorrectly");
+ ok(SubSubclass["config"]["locale"] === "es_MX", SubSubclass["config"]["locale"] + " is wrong!");
+ ok(SubSubclass["config"]["test"] === "worked", "SubSubclass.config.test is set incorrectly");
notEqual(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
//This shows that the modifications to the SubSubClass did not bubble back up to it's superclass
ok(Subclass["topLevelMethod"]() === false, "Subclass.topLevelMethod thought debug was true");
- ok(Subclass["config"]["locale"] == "en_US", Subclass["config"]["locale"] + " is wrong!");
+ ok(Subclass["config"]["locale"] === "en_US", Subclass["config"]["locale"] + " is wrong!");
deepEqual(Subclass["config"]["test"], undefined, "Subclass.config.test is set incorrectly");
deepEqual(Subclass(document)["subSubClassMethod"], undefined, "subSubClassMethod set incorrectly");
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
@@ -163,7 +163,7 @@ test( "jQuery.sub() - .fn Methods", function(){
var Subclass = jQuery.sub(),
SubclassSubclass = Subclass.sub(),
jQueryDocument = jQuery(document),
- selectors, contexts, methods, method, arg, description;
+ selectors, contexts, method, arg, description;
jQueryDocument.toString = function(){ return "jQueryDocument"; };
Oops, something went wrong. Retry.

0 comments on commit e3a1bb0

Please sign in to comment.