Skip to content

Commit 69bee9c

Browse files
committed
Build: Update jscs and lint files
Fixes gh-2056
1 parent 7895751 commit 69bee9c

File tree

125 files changed

+8670
-7932
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+8670
-7932
lines changed

.jscsrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"preset": "jquery",
33

4+
// remove after https://github.com/jscs-dev/node-jscs/issues/1685
5+
// and https://github.com/jscs-dev/node-jscs/issues/1686
6+
"requireCapitalizedComments": null,
7+
48
"excludeFiles": [ "external", "src/intro.js", "src/outro.js",
5-
"test/node_smoke_tests/lib/ensure_iterability.js" ]
9+
"test/node_smoke_tests/lib/ensure_iterability.js", "node_modules" ]
610
}

Gruntfile.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = function( grunt ) {
2020
// But our modules can
2121
delete srcHintOptions.onevar;
2222

23-
grunt.initConfig({
23+
grunt.initConfig( {
2424
pkg: grunt.file.readJSON( "package.json" ),
2525
dst: readOptionalJSON( "dist/.destination.json" ),
2626
"compare_size": {
@@ -53,6 +53,7 @@ module.exports = function( grunt ) {
5353
"core",
5454
"selector"
5555
],
56+
5657
// Exclude specified modules if the module matching the key is removed
5758
removeWith: {
5859
ajax: [ "manipulation/_evalUrl", "event/ajax" ],
@@ -108,7 +109,12 @@ module.exports = function( grunt ) {
108109
gruntfile: "Gruntfile.js",
109110

110111
// Check parts of tests that pass
111-
test: [ "test/data/testrunner.js", "test/unit/animation.js", "test/unit/tween.js" ],
112+
test: [
113+
"test/data/testrunner.js",
114+
"test/unit/animation.js",
115+
"test/unit/tween.js",
116+
"test/unit/wrap.js"
117+
],
112118
release: [ "build/*.js", "!build/release-notes.js" ],
113119
tasks: "build/tasks/*.js"
114120
},
@@ -162,7 +168,7 @@ module.exports = function( grunt ) {
162168
}
163169
}
164170
}
165-
});
171+
} );
166172

167173
// Load grunt tasks from NPM packages
168174
require( "load-grunt-tasks" )( grunt );
@@ -177,7 +183,7 @@ module.exports = function( grunt ) {
177183
grunt.registerTask( "test", [ "test_fast", "promises_aplus_tests" ] );
178184

179185
// Short list as a high frequency watch task
180-
grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] );
186+
grunt.registerTask( "dev", [ "build:*:*", "uglify", "remove_map_comment", "dist:*" ] );
181187

182188
grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );
183189
};

build/release.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = function( Release ) {
99

1010
npmTags = Release.npmTags;
1111

12-
Release.define({
12+
Release.define( {
1313
npmPublish: true,
1414
issueTracker: "github",
1515
/**
@@ -36,6 +36,7 @@ module.exports = function( Release ) {
3636
* for publishing the distribution repo instead
3737
*/
3838
npmTags: function() {
39+
3940
// origRepo is not defined if dist was skipped
4041
Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
4142
return npmTags();
@@ -47,9 +48,9 @@ module.exports = function( Release ) {
4748
dist: function( callback ) {
4849
cdn.makeArchives( Release, function() {
4950
dist( Release, callback );
50-
});
51+
} );
5152
}
52-
});
53+
} );
5354
};
5455

5556
module.exports.dependencies = [

build/tasks/build.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ module.exports = function( grunt ) {
1616
baseUrl: "src",
1717
name: "jquery",
1818
out: "dist/jquery.js",
19+
1920
// We have multiple minify steps
2021
optimize: "none",
22+
2123
// Include dependencies loaded with require
2224
findNestedDependencies: true,
25+
2326
// Avoid inserting define() placeholder
2427
skipModuleInsertion: true,
28+
2529
// Avoid breaking semicolons inserted by r.js
2630
skipSemiColonInsertion: true,
2731
wrap: {
@@ -47,22 +51,25 @@ module.exports = function( grunt ) {
4751
*/
4852
function convert( name, path, contents ) {
4953
var amdName;
54+
5055
// Convert var modules
5156
if ( /.\/var\//.test( path ) ) {
5257
contents = contents
53-
.replace( /define\([\w\W]*?return/, "var " + (/var\/([\w-]+)/.exec(name)[1]) + " =" )
58+
.replace( /define\([\w\W]*?return/, "var " + ( /var\/([\w-]+)/.exec( name )[ 1 ] ) + " =" )
5459
.replace( rdefineEnd, "" );
5560

5661
// Sizzle treatment
5762
} else if ( /^sizzle$/.test( name ) ) {
5863
contents = "var Sizzle =\n" + contents
64+
5965
// Remove EXPOSE lines from Sizzle
6066
.replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" );
6167

6268
} else {
6369

6470
contents = contents
6571
.replace( /\s*return\s+[^\}]+(\}\s*?\);[^\w\}]*)$/, "$1" )
72+
6673
// Multiple exports
6774
.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
6875

@@ -82,13 +89,15 @@ module.exports = function( grunt ) {
8289
contents = contents
8390
.replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" );
8491
}
92+
8593
// AMD Name
86-
if ( (amdName = grunt.option( "amd" )) != null && /^exports\/amd$/.test( name ) ) {
87-
if (amdName) {
94+
if ( ( amdName = grunt.option( "amd" ) ) != null && /^exports\/amd$/.test( name ) ) {
95+
if ( amdName ) {
8896
grunt.log.writeln( "Naming jQuery with AMD name: " + amdName );
8997
} else {
9098
grunt.log.writeln( "AMD name now anonymous" );
9199
}
100+
92101
// Remove the comma for anonymous defines
93102
contents = contents
94103
.replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" );
@@ -121,7 +130,8 @@ module.exports = function( grunt ) {
121130
excludeList = function( list, prepend ) {
122131
if ( list ) {
123132
prepend = prepend ? prepend + "/" : "";
124-
list.forEach(function( module ) {
133+
list.forEach( function( module ) {
134+
125135
// Exclude var modules as well
126136
if ( module === "var" ) {
127137
excludeList(
@@ -130,20 +140,22 @@ module.exports = function( grunt ) {
130140
return;
131141
}
132142
if ( prepend ) {
143+
133144
// Skip if this is not a js file and we're walking files in a dir
134-
if ( !(module = /([\w-\/]+)\.js$/.exec( module )) ) {
145+
if ( !( module = /([\w-\/]+)\.js$/.exec( module ) ) ) {
135146
return;
136147
}
148+
137149
// Prepend folder name if passed
138150
// Remove .js extension
139-
module = prepend + module[1];
151+
module = prepend + module[ 1 ];
140152
}
141153

142154
// Avoid infinite recursion
143155
if ( excluded.indexOf( module ) === -1 ) {
144156
excluder( "-" + module );
145157
}
146-
});
158+
} );
147159
}
148160
},
149161
/**
@@ -158,12 +170,15 @@ module.exports = function( grunt ) {
158170
module = m[ 2 ];
159171

160172
if ( exclude ) {
173+
161174
// Can't exclude certain modules
162175
if ( minimum.indexOf( module ) === -1 ) {
176+
163177
// Add to excluded
164178
if ( excluded.indexOf( module ) === -1 ) {
165179
grunt.log.writeln( flag );
166180
excluded.push( module );
181+
167182
// Exclude all files in the folder of the same name
168183
// These are the removable dependencies
169184
// It's fine if the directory is not there
@@ -173,10 +188,11 @@ module.exports = function( grunt ) {
173188
grunt.verbose.writeln( e );
174189
}
175190
}
191+
176192
// Check removeWith list
177193
excludeList( removeWith[ module ] );
178194
} else {
179-
grunt.log.error( "Module \"" + module + "\" is a minimum requirement.");
195+
grunt.log.error( "Module \"" + module + "\" is a minimum requirement." );
180196
if ( module === "selector" ) {
181197
grunt.log.error(
182198
"If you meant to replace Sizzle, use -sizzle instead."
@@ -215,13 +231,13 @@ module.exports = function( grunt ) {
215231

216232
// Handle Sizzle exclusion
217233
// Replace with selector-native
218-
if ( (index = excluded.indexOf( "sizzle" )) > -1 ) {
234+
if ( ( index = excluded.indexOf( "sizzle" ) ) > -1 ) {
219235
config.rawText.selector = "define(['./selector-native']);";
220236
excluded.splice( index, 1 );
221237
}
222238

223239
// Replace exports/global with a noop noConflict
224-
if ( (index = excluded.indexOf( "exports/global" )) > -1 ) {
240+
if ( ( index = excluded.indexOf( "exports/global" ) ) > -1 ) {
225241
config.rawText[ "exports/global" ] = "define(['../core']," +
226242
"function( jQuery ) {\njQuery.noConflict = function() {};\n});";
227243
excluded.splice( index, 1 );
@@ -233,9 +249,11 @@ module.exports = function( grunt ) {
233249
// append excluded modules to version
234250
if ( excluded.length ) {
235251
version += " -" + excluded.join( ",-" );
252+
236253
// set pkg.version to version with excludes, so minified file picks it up
237254
grunt.config.set( "pkg.version", version );
238255
grunt.verbose.writeln( "Version changed to " + version );
256+
239257
// Have to use shallow or core will get excluded since it is a dependency
240258
config.excludeShallow = excluded;
241259
}
@@ -247,8 +265,10 @@ module.exports = function( grunt ) {
247265
*/
248266
config.out = function( compiled ) {
249267
compiled = compiled
268+
250269
// Embed Version
251270
.replace( /@VERSION/g, version )
271+
252272
// Embed Date
253273
// yyyy-mm-ddThh:mmZ
254274
.replace( /@DATE/g, ( new Date() ).toISOString().replace( /:\d+\.\d+Z$/, "Z" ) );
@@ -259,9 +279,10 @@ module.exports = function( grunt ) {
259279

260280
// Turn off opt-in if necessary
261281
if ( !optIn ) {
282+
262283
// Overwrite the default inclusions with the explicit ones provided
263284
config.rawText.jquery = "define([" +
264-
(included.length ? included.join(",") : "") +
285+
( included.length ? included.join( "," ) : "" ) +
265286
"]);";
266287
}
267288

@@ -272,8 +293,8 @@ module.exports = function( grunt ) {
272293
done();
273294
}, function( err ) {
274295
done( err );
275-
});
276-
});
296+
} );
297+
} );
277298

278299
// Special "alias" task to make custom build creation less grawlix-y
279300
// Translation example
@@ -289,6 +310,6 @@ module.exports = function( grunt ) {
289310

290311
grunt.log.writeln( "Creating custom build...\n" );
291312

292-
grunt.task.run([ "build:*:*" + (modules ? ":" + modules : ""), "uglify", "dist" ]);
293-
});
313+
grunt.task.run( [ "build:*:*" + ( modules ? ":" + modules : "" ), "uglify", "dist" ] );
314+
} );
294315
};

build/tasks/dist.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ module.exports = function( grunt ) {
2121
flags = Object.keys( this.flags );
2222

2323
// Combine all output target paths
24-
paths = [].concat( stored, flags ).filter(function( path ) {
24+
paths = [].concat( stored, flags ).filter( function( path ) {
2525
return path !== "*";
26-
});
26+
} );
2727

2828
// Ensure the dist files are pure ASCII
2929
nonascii = false;
3030

31-
distpaths.forEach(function( filename ) {
31+
distpaths.forEach( function( filename ) {
3232
var i, c,
3333
text = fs.readFileSync( filename, "utf8" );
3434

@@ -53,7 +53,7 @@ module.exports = function( grunt ) {
5353
}
5454

5555
// Optionally copy dist files to other locations
56-
paths.forEach(function( path ) {
56+
paths.forEach( function( path ) {
5757
var created;
5858

5959
if ( !/\/$/.test( path ) ) {
@@ -63,9 +63,9 @@ module.exports = function( grunt ) {
6363
created = path + filename.replace( "dist/", "" );
6464
grunt.file.write( created, text );
6565
grunt.log.writeln( "File '" + created + "' created." );
66-
});
67-
});
66+
} );
67+
} );
6868

6969
return !nonascii;
70-
});
70+
} );
7171
};

build/tasks/install_jsdom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ module.exports = function( grunt ) {
2323
args: [ "install", "jsdom@" + version ],
2424
opts: { stdio: "inherit" }
2525
}, this.async() );
26-
});
26+
} );
2727
};

build/tasks/sourcemap.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ var fs = require( "fs" );
33
module.exports = function( grunt ) {
44
var minLoc = Object.keys( grunt.config( "uglify.all.files" ) )[ 0 ];
55
grunt.registerTask( "remove_map_comment", function() {
6+
67
// Remove the source map comment; it causes way too many problems.
78
// The map file is still generated for manual associations
89
// https://github.com/jquery/jquery/issues/1707
910
var text = fs.readFileSync( minLoc, "utf8" )
1011
.replace( /\/\/# sourceMappingURL=\S+/, "" );
1112
fs.writeFileSync( minLoc, text );
12-
});
13+
} );
1314
};

build/tasks/testswarm.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ module.exports = function( grunt ) {
1414
config = grunt.file.readJSON( configFile )[ projectName ];
1515
browserSets = browserSets || config.browserSets;
1616
if ( browserSets[ 0 ] === "[" ) {
17+
1718
// We got an array, parse it
1819
browserSets = JSON.parse( browserSets );
1920
}
2021
timeout = timeout || 1000 * 60 * 15;
21-
tests = grunt.config([ this.name, "tests" ]);
22+
tests = grunt.config( [ this.name, "tests" ] );
2223

2324
if ( pull ) {
2425
jobName = "Pull <a href='https://github.com/jquery/jquery/pull/" +
@@ -28,18 +29,18 @@ module.exports = function( grunt ) {
2829
commit + "'>" + commit.substr( 0, 10 ) + "</a>";
2930
}
3031

31-
tests.forEach(function( test ) {
32+
tests.forEach( function( test ) {
3233
runs[ test ] = config.testUrl + commit + "/test/index.html?module=" + test;
33-
});
34+
} );
3435

35-
testswarm.createClient({
36+
testswarm.createClient( {
3637
url: config.swarmUrl
3738
} )
3839
.addReporter( testswarm.reporters.cli )
3940
.auth( {
4041
id: config.authUsername,
4142
token: config.authToken
42-
})
43+
} )
4344
.addjob(
4445
{
4546
name: jobName,
@@ -54,5 +55,5 @@ module.exports = function( grunt ) {
5455
done( passed );
5556
}
5657
);
57-
});
58+
} );
5859
};

0 commit comments

Comments
 (0)