Skip to content

Commit e3a1bb0

Browse files
committed
Use jQuery project standards for JSHint options.
1 parent 5aa8b12 commit e3a1bb0

File tree

7 files changed

+102
-75
lines changed

7 files changed

+102
-75
lines changed

.jshintrc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
2+
"boss": true,
23
"curly": true,
34
"eqeqeq": true,
45
"eqnull": true,
56
"expr": true,
6-
"latedef": true,
7+
"immed": true,
78
"noarg": true,
8-
"node": true,
9+
"onevar": true,
910
"quotmark": "double",
1011
"smarttabs": true,
1112
"trailing": true,
1213
"undef": true,
13-
"unused": true
14-
}
14+
"unused": true,
15+
16+
"node": true
17+
}

Gruntfile.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ module.exports = function(grunt) {
33

44
"use strict";
55

6+
// The concatenated file won't pass onevar but our modules can
7+
var readOptionalJSON = function( filepath ) {
8+
var data = {};
9+
try {
10+
data = grunt.file.readJSON( filepath );
11+
} catch(e) {}
12+
return data;
13+
},
14+
srcHintOptions = readOptionalJSON("src/.jshintrc");
15+
delete srcHintOptions.onevar;
16+
617
// Project configuration.
718
grunt.initConfig({
819
pkg: grunt.file.readJSON("package.json"),
@@ -50,9 +61,7 @@ module.exports = function(grunt) {
5061
jshint: {
5162
dist: {
5263
src: [ "dist/jquery-migrate.js" ],
53-
options: {
54-
jshintrc: "src/.jshintrc"
55-
}
64+
options: srcHintOptions
5665
},
5766
tests: {
5867
src: [ "test/*.js" ],

src/.jshintrc

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
{
2-
"bitwise": true,
3-
"browser": true,
2+
"boss": true,
43
"curly": true,
54
"eqeqeq": true,
65
"eqnull": true,
7-
"evil": true,
86
"expr": true,
9-
"maxerr": 100,
10-
"newcap": false,
7+
"immed": true,
8+
"noarg": true,
9+
"onevar": true,
1110
"quotmark": "double",
12-
"sub": true,
11+
"smarttabs": true,
1312
"trailing": true,
1413
"undef": true,
1514
"unused": true,
16-
"wsh": true,
15+
16+
"sub": true,
17+
18+
"browser": true,
19+
"es5": true,
20+
1721
"globals": {
18-
"define": true,
19-
"DOMParser": true,
2022
"jQuery": true,
21-
"global": true,
22-
"module": true,
23-
"exports": true,
24-
"require": true,
25-
"file": true,
26-
"log": true,
27-
"console": true
23+
"define": true,
24+
"module": true
2825
}
2926
}

src/migrate.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ jQuery.migrateWarnings = [];
88
// jQuery.migrateMute = false;
99

1010
// Show a message on the console so devs know we're active
11-
if ( !jQuery.migrateMute && window.console && console.log ) {
12-
console.log("JQMIGRATE: Logging is active");
11+
if ( !jQuery.migrateMute && window.console && window.console.log ) {
12+
window.console.log("JQMIGRATE: Logging is active");
1313
}
1414

1515
// Set to false to disable traces that appear with warnings
@@ -24,10 +24,11 @@ jQuery.migrateReset = function() {
2424
};
2525

2626
function migrateWarn( msg) {
27+
var console = window.console;
2728
if ( !warnedAbout[ msg ] ) {
2829
warnedAbout[ msg ] = true;
2930
jQuery.migrateWarnings.push( msg );
30-
if ( window.console && console.warn && !jQuery.migrateMute ) {
31+
if ( console && console.warn && !jQuery.migrateMute ) {
3132
console.warn( "JQMIGRATE: " + msg );
3233
if ( jQuery.migrateTrace && console.trace ) {
3334
console.trace();

test/.jshintrc

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
{
2-
"browser": true,
2+
"boss": true,
33
"curly": true,
4-
"devel": true,
4+
"eqeqeq": true,
55
"eqnull": true,
6-
"evil": true,
76
"expr": true,
8-
"maxerr": 100,
7+
"immed": true,
8+
"noarg": true,
9+
"onevar": true,
910
"quotmark": "double",
1011
"smarttabs": true,
11-
"sub": true,
1212
"trailing": true,
1313
"undef": true,
14+
15+
"evil": true,
16+
"sub": true,
17+
18+
"browser": true,
19+
"devel": true,
1420
"wsh": true,
21+
1522
"globals": {
16-
"jQuery": true,
17-
"TestManager": true,
18-
"expectNoWarning": true,
1923
"expectWarning": true,
24+
"expectNoWarning": true,
25+
"TestManager": true,
26+
27+
"jQuery": true,
2028
"QUnit": true,
21-
"deepEqual": true,
22-
"equal": true,
23-
"expect": true,
2429
"module": true,
25-
"notEqual": true,
2630
"ok": true,
27-
"start": true,
31+
"equal": true,
32+
"test": true,
33+
"asyncTest": true,
34+
"notEqual": true,
35+
"deepEqual": true,
2836
"strictEqual": true,
37+
"notStrictEqual": true,
38+
"start": true,
2939
"stop": true,
30-
"test": true
40+
"expect": true
3141
}
3242
}

test/core.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ test( "jQuery.browser", function() {
104104
test( "jQuery.sub() - Static Methods", function(){
105105
expect( 19 );
106106

107-
var Subclass;
107+
var Subclass, SubSubclass;
108108

109109
// Other warnings may be fired when props are copied
110110
expectWarning( "jQuery.sub", function() {
@@ -125,16 +125,16 @@ test( "jQuery.sub() - Static Methods", function(){
125125

126126
//Test Simple Subclass
127127
ok(Subclass["topLevelMethod"]() === false, "Subclass.topLevelMethod thought debug was true");
128-
ok(Subclass["config"]["locale"] == "en_US", Subclass["config"]["locale"] + " is wrong!");
128+
ok(Subclass["config"]["locale"] === "en_US", Subclass["config"]["locale"] + " is wrong!");
129129
deepEqual(Subclass["config"]["test"], undefined, "Subclass.config.test is set incorrectly");
130130
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
131131

132132
//Create a SubSubclass
133-
var SubSubclass = Subclass.sub();
133+
SubSubclass = Subclass.sub();
134134

135135
//Make Sure the SubSubclass inherited properly
136136
ok(SubSubclass["topLevelMethod"]() === false, "SubSubclass.topLevelMethod thought debug was true");
137-
ok(SubSubclass["config"]["locale"] == "en_US", SubSubclass["config"]["locale"] + " is wrong!");
137+
ok(SubSubclass["config"]["locale"] === "en_US", SubSubclass["config"]["locale"] + " is wrong!");
138138
deepEqual(SubSubclass["config"]["test"], undefined, "SubSubclass.config.test is set incorrectly");
139139
equal(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
140140

@@ -145,13 +145,13 @@ test( "jQuery.sub() - Static Methods", function(){
145145
SubSubclass.ajax = function() {return false;};
146146
ok(SubSubclass["topLevelMethod"](), "SubSubclass.topLevelMethod thought debug was false");
147147
deepEqual(SubSubclass(document)["subClassMethod"], Subclass.fn["subClassMethod"], "Methods Differ!");
148-
ok(SubSubclass["config"]["locale"] == "es_MX", SubSubclass["config"]["locale"] + " is wrong!");
149-
ok(SubSubclass["config"]["test"] == "worked", "SubSubclass.config.test is set incorrectly");
148+
ok(SubSubclass["config"]["locale"] === "es_MX", SubSubclass["config"]["locale"] + " is wrong!");
149+
ok(SubSubclass["config"]["test"] === "worked", "SubSubclass.config.test is set incorrectly");
150150
notEqual(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
151151

152152
//This shows that the modifications to the SubSubClass did not bubble back up to it's superclass
153153
ok(Subclass["topLevelMethod"]() === false, "Subclass.topLevelMethod thought debug was true");
154-
ok(Subclass["config"]["locale"] == "en_US", Subclass["config"]["locale"] + " is wrong!");
154+
ok(Subclass["config"]["locale"] === "en_US", Subclass["config"]["locale"] + " is wrong!");
155155
deepEqual(Subclass["config"]["test"], undefined, "Subclass.config.test is set incorrectly");
156156
deepEqual(Subclass(document)["subSubClassMethod"], undefined, "subSubClassMethod set incorrectly");
157157
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
@@ -163,7 +163,7 @@ test( "jQuery.sub() - .fn Methods", function(){
163163
var Subclass = jQuery.sub(),
164164
SubclassSubclass = Subclass.sub(),
165165
jQueryDocument = jQuery(document),
166-
selectors, contexts, methods, method, arg, description;
166+
selectors, contexts, method, arg, description;
167167

168168
jQueryDocument.toString = function(){ return "jQueryDocument"; };
169169

0 commit comments

Comments
 (0)