Skip to content

Commit c869a1e

Browse files
committed
Build: update grunt-jscs-checker and pass with the new rules
1 parent 8e3a0ce commit c869a1e

39 files changed

+352
-187
lines changed

Gruntfile.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = function( grunt ) {
1919
grunt.initConfig({
2020
pkg: grunt.file.readJSON( "package.json" ),
2121
dst: readOptionalJSON( "dist/.destination.json" ),
22-
compare_size: {
22+
"compare_size": {
2323
files: [ "dist/jquery.js", "dist/jquery.min.js" ],
2424
options: {
2525
compress: {
@@ -93,13 +93,31 @@ module.exports = function( grunt ) {
9393
src: "src/**/*.js",
9494
gruntfile: "Gruntfile.js",
9595

96-
// Right know, check only test helpers
97-
test: [ "test/data/testrunner.js", "test/data/testinit.js" ],
98-
release: "build/*.js",
96+
// Right now, check only test helpers
97+
test: [ "test/data/testrunner.js" ],
98+
release: [ "build/*.js", "!build/release-notes.js" ],
9999
tasks: "build/tasks/*.js"
100100
},
101101
testswarm: {
102-
tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing".split( " " )
102+
tests: [
103+
"ajax",
104+
"attributes",
105+
"callbacks",
106+
"core",
107+
"css",
108+
"data",
109+
"deferred",
110+
"dimensions",
111+
"effects",
112+
"event",
113+
"manipulation",
114+
"offset",
115+
"queue",
116+
"selector",
117+
"serialize",
118+
"support",
119+
"traversing"
120+
]
103121
},
104122
watch: {
105123
files: [ "<%= jshint.all.src %>" ],
@@ -116,13 +134,13 @@ module.exports = function( grunt ) {
116134
sourceMappingURL: "jquery.min.map",
117135
report: "min",
118136
beautify: {
119-
ascii_only: true
137+
"ascii_only": true
120138
},
121139
banner: "/*! jQuery v<%= pkg.version %> | " +
122140
"(c) 2005, <%= grunt.template.today('yyyy') %> jQuery Foundation, Inc. | " +
123141
"jquery.org/license */",
124142
compress: {
125-
hoist_funs: false,
143+
"hoist_funs": false,
126144
loops: false,
127145
unused: false
128146
}

build/release-notes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ http.request({
1616
host: "bugs.jquery.com",
1717
port: 80,
1818
method: "GET",
19-
path: "/query?status=closed&resolution=fixed&max=400&component=!web&order=component&milestone=" + version
19+
path: "/query?status=closed&resolution=fixed&max=400&" +
20+
"component=!web&order=component&milestone=" + version
2021
}, function( res ) {
2122
var data = [];
2223

build/release.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ module.exports = function( Release ) {
8989

9090
var archiver = require( "archiver" )( "zip" ),
9191
md5file = cdnFolder + "/" + cdn + "-md5.txt",
92-
output = fs.createWriteStream( cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip" );
92+
output = fs.createWriteStream(
93+
cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip"
94+
);
9395

9496
output.on( "error", function( err ) {
9597
throw err;

build/tasks/build.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* Special concat/build task to handle various jQuery build requirements
3-
* Concats AMD modules, removes their definitions, and includes/excludes specified modules
3+
* Concats AMD modules, removes their definitions,
4+
* and includes/excludes specified modules
45
*/
56

67
module.exports = function( grunt ) {
@@ -35,7 +36,8 @@ module.exports = function( grunt ) {
3536
/**
3637
* Strip all definitions generated by requirejs
3738
* Convert "var" modules to var declarations
38-
* "var module" means the module only contains a return statement that should be converted to a var declaration
39+
* "var module" means the module only contains a return
40+
* statement that should be converted to a var declaration
3941
* This is indicated by including the file in any "var" folder
4042
* @param {String} name
4143
* @param {String} path
@@ -98,7 +100,8 @@ module.exports = function( grunt ) {
98100

99101
grunt.registerMultiTask(
100102
"build",
101-
"Concatenate source, remove sub AMD definitions, (include/exclude modules with +/- flags), embed date/version",
103+
"Concatenate source, remove sub AMD definitions, " +
104+
"(include/exclude modules with +/- flags), embed date/version",
102105
function() {
103106
var flag, index,
104107
done = this.async(),
@@ -113,15 +116,18 @@ module.exports = function( grunt ) {
113116
/**
114117
* Recursively calls the excluder to remove on all modules in the list
115118
* @param {Array} list
116-
* @param {String} [prepend] Prepend this to the module name. Indicates we're walking a directory
119+
* @param {String} [prepend] Prepend this to the module name.
120+
* Indicates we're walking a directory
117121
*/
118122
excludeList = function( list, prepend ) {
119123
if ( list ) {
120124
prepend = prepend ? prepend + "/" : "";
121125
list.forEach(function( module ) {
122126
// Exclude var modules as well
123127
if ( module === "var" ) {
124-
excludeList( fs.readdirSync( srcFolder + prepend + module ), prepend + module );
128+
excludeList(
129+
fs.readdirSync( srcFolder + prepend + module ), prepend + module
130+
);
125131
return;
126132
}
127133
if ( prepend ) {
@@ -143,7 +149,9 @@ module.exports = function( grunt ) {
143149
},
144150
/**
145151
* Adds the specified module to the excluded or included list, depending on the flag
146-
* @param {String} flag A module path relative to the src directory starting with + or - to indicate whether it should included or excluded
152+
* @param {String} flag A module path relative to
153+
* the src directory starting with + or - to indicate
154+
* whether it should included or excluded
147155
*/
148156
excluder = function( flag ) {
149157
var m = /^(\+|\-|)([\w\/-]+)$/.exec( flag ),
@@ -162,7 +170,7 @@ module.exports = function( grunt ) {
162170
// It's fine if the directory is not there
163171
try {
164172
excludeList( fs.readdirSync( srcFolder + module ), module );
165-
} catch( e ) {
173+
} catch ( e ) {
166174
grunt.verbose.writeln( e );
167175
}
168176
}
@@ -171,7 +179,9 @@ module.exports = function( grunt ) {
171179
} else {
172180
grunt.log.error( "Module \"" + module + "\" is a mimimum requirement.");
173181
if ( module === "selector" ) {
174-
grunt.log.error( "If you meant to replace Sizzle, use -sizzle instead." );
182+
grunt.log.error(
183+
"If you meant to replace Sizzle, use -sizzle instead."
184+
);
175185
}
176186
}
177187
} else {
@@ -195,8 +205,10 @@ module.exports = function( grunt ) {
195205
// * none (implicit exclude)
196206
// *:* all (implicit include)
197207
// *:*:-css all except css and dependents (explicit > implicit)
198-
// *:*:-css:+effects same (excludes effects because explicit include is trumped by explicit exclude of dependency)
199-
// *:+effects none except effects and its dependencies (explicit include trumps implicit exclude of dependency)
208+
// *:*:-css:+effects same (excludes effects because explicit include is
209+
// trumped by explicit exclude of dependency)
210+
// *:+effects none except effects and its dependencies
211+
// (explicit include trumps implicit exclude of dependency)
200212
delete flags[ "*" ];
201213
for ( flag in flags ) {
202214
excluder( flag );
@@ -249,7 +261,9 @@ module.exports = function( grunt ) {
249261
// Turn off opt-in if necessary
250262
if ( !optIn ) {
251263
// Overwrite the default inclusions with the explicit ones provided
252-
config.rawText.jquery = "define([" + (included.length ? included.join(",") : "") + "]);";
264+
config.rawText.jquery = "define([" +
265+
(included.length ? included.join(",") : "") +
266+
"]);";
253267
}
254268

255269
// Trace dependencies and concatenate files

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"grunt-contrib-uglify": "0.5.0",
4040
"grunt-contrib-watch": "0.6.1",
4141
"grunt-git-authors": "1.2.0",
42-
"grunt-jscs-checker": "0.4.1",
42+
"grunt-jscs-checker": "0.6.1",
4343
"grunt-jsonlint": "1.0.4",
4444
"grunt-npmcopy": "0.1.0",
4545
"gzip-js": "0.3.2",

src/ajax.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
8989
inspected[ dataType ] = true;
9090
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
9191
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
92-
if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
92+
if ( typeof dataTypeOrTransport === "string" &&
93+
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
94+
9395
options.dataTypes.unshift( dataTypeOrTransport );
9496
inspect( dataTypeOrTransport );
9597
return false;
@@ -262,7 +264,10 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
262264
try {
263265
response = conv( response );
264266
} catch ( e ) {
265-
return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
267+
return {
268+
state: "parsererror",
269+
error: conv ? e : "No conversion from " + prev + " to " + current
270+
};
266271
}
267272
}
268273
}
@@ -396,9 +401,10 @@ jQuery.extend({
396401
// Callbacks context
397402
callbackContext = s.context || s,
398403
// Context for global events is callbackContext if it is a DOM node or jQuery collection
399-
globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
400-
jQuery( callbackContext ) :
401-
jQuery.event,
404+
globalEventContext = s.context &&
405+
( callbackContext.nodeType || callbackContext.jquery ) ?
406+
jQuery( callbackContext ) :
407+
jQuery.event,
402408
// Deferreds
403409
deferred = jQuery.Deferred(),
404410
completeDeferred = jQuery.Callbacks("once memory"),
@@ -582,7 +588,8 @@ jQuery.extend({
582588
jqXHR.setRequestHeader(
583589
"Accept",
584590
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
585-
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
591+
s.accepts[ s.dataTypes[0] ] +
592+
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
586593
s.accepts[ "*" ]
587594
);
588595

@@ -592,7 +599,9 @@ jQuery.extend({
592599
}
593600

594601
// Allow custom headers/mimetypes and early abort
595-
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
602+
if ( s.beforeSend &&
603+
( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
604+
596605
// Abort if not done already and return
597606
return jqXHR.abort();
598607
}

src/ajax/jsonp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
2424
var callbackName, overwritten, responseContainer,
2525
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
2626
"url" :
27-
typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
27+
typeof s.data === "string" &&
28+
!( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
29+
rjsonp.test( s.data ) && "data"
2830
);
2931

3032
// Handle iff the expected data type is "jsonp" or we have a parameter to set

src/ajax/script.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ define([
66
// Install script dataType
77
jQuery.ajaxSetup({
88
accepts: {
9-
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
9+
script: "text/javascript, application/javascript, " +
10+
"application/ecmascript, application/x-ecmascript"
1011
},
1112
contents: {
1213
script: /(?:java|ecma)script/

src/ajax/xhr.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ define([
77
jQuery.ajaxSettings.xhr = function() {
88
try {
99
return new XMLHttpRequest();
10-
} catch( e ) {}
10+
} catch ( e ) {}
1111
};
1212

1313
var xhrId = 0,
@@ -45,7 +45,13 @@ jQuery.ajaxTransport(function( options ) {
4545
xhr = options.xhr(),
4646
id = ++xhrId;
4747

48-
xhr.open( options.type, options.url, options.async, options.username, options.password );
48+
xhr.open(
49+
options.type,
50+
options.url,
51+
options.async,
52+
options.username,
53+
options.password
54+
);
4955

5056
// Apply custom fields if provided
5157
if ( options.xhrFields ) {

src/attributes/attr.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ jQuery.extend({
5050
if ( value === null ) {
5151
jQuery.removeAttr( elem, name );
5252

53-
} else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
53+
} else if ( hooks && "set" in hooks &&
54+
(ret = hooks.set( elem, value, name )) !== undefined ) {
55+
5456
return ret;
5557

5658
} else {

src/attributes/classes.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ define([
22
"../core",
33
"../var/rnotwhite",
44
"../var/strundefined",
5-
"../data/var/data_priv",
5+
"../data/var/dataPriv",
66
"../core/init"
7-
], function( jQuery, rnotwhite, strundefined, data_priv ) {
7+
], function( jQuery, rnotwhite, strundefined, dataPriv ) {
88

99
var rclass = /[\t\r\n\f]/g;
1010

@@ -104,7 +104,9 @@ jQuery.fn.extend({
104104

105105
if ( jQuery.isFunction( value ) ) {
106106
return this.each(function( i ) {
107-
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
107+
jQuery( this ).toggleClass(
108+
value.call(this, i, this.className, stateVal), stateVal
109+
);
108110
});
109111
}
110112

@@ -129,14 +131,16 @@ jQuery.fn.extend({
129131
} else if ( type === strundefined || type === "boolean" ) {
130132
if ( this.className ) {
131133
// store className if set
132-
data_priv.set( this, "__className__", this.className );
134+
dataPriv.set( this, "__className__", this.className );
133135
}
134136

135137
// If the element has a class name or if we're passed `false`,
136138
// then remove the whole classname (if there was one, the above saved it).
137139
// Otherwise bring back whatever was previously saved (if anything),
138140
// falling back to the empty string if nothing was stored.
139-
this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
141+
this.className = this.className || value === false ?
142+
"" :
143+
dataPriv.get( this, "__className__" ) || "";
140144
}
141145
});
142146
},
@@ -146,7 +150,9 @@ jQuery.fn.extend({
146150
i = 0,
147151
l = this.length;
148152
for ( ; i < l; i++ ) {
149-
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
153+
if ( this[i].nodeType === 1 &&
154+
(" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
155+
150156
return true;
151157
}
152158
}

src/attributes/prop.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ jQuery.extend({
5656
propHooks: {
5757
tabIndex: {
5858
get: function( elem ) {
59-
return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
60-
elem.tabIndex :
61-
-1;
59+
return elem.hasAttribute( "tabindex" ) ||
60+
rfocusable.test( elem.nodeName ) || elem.href ?
61+
elem.tabIndex :
62+
-1;
6263
}
6364
}
6465
}

src/attributes/val.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jQuery.fn.extend({
1313

1414
if ( !arguments.length ) {
1515
if ( elem ) {
16-
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
16+
hooks = jQuery.valHooks[ elem.type ] ||
17+
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
1718

1819
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
1920
return ret;
@@ -100,8 +101,10 @@ jQuery.extend({
100101
// IE6-9 doesn't update selected after form reset (#2551)
101102
if ( ( option.selected || i === index ) &&
102103
// Don't return options that are disabled or in a disabled optgroup
103-
( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
104-
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
104+
( support.optDisabled ?
105+
!option.disabled : option.getAttribute( "disabled" ) === null ) &&
106+
( !option.parentNode.disabled ||
107+
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
105108

106109
// Get the specific value for the option
107110
value = jQuery( option ).val();

0 commit comments

Comments
 (0)