Skip to content

Commit 030191a

Browse files
committed
Build: Skip running ESLint on Node.js 0.x
ESLint 3.0 drops support for Node.js older than 4.x. To be able to update to this version and yet not block our contributors from building jQuery on older Node.js (at least until it's supported by upstream) this commit makes ESLint skipped on older Node; a proper message is displayed then. Fixes gh-3222
1 parent 6e605af commit 030191a

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

Gruntfile.js

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ module.exports = function( grunt ) {
1414

1515
var fs = require( "fs" ),
1616
gzip = require( "gzip-js" ),
17+
oldNode = /^v0\./.test( process.version );
1718

18-
// Skip jsdom-related tests in Node.js 0.10 & 0.12
19-
runJsdomTests = !/^v0/.test( process.version );
19+
// Support: Node.js <4
20+
// Skip running tasks that dropped support for Node.js 0.10 & 0.12
21+
// in those Node versions.
22+
function runIfNewNode( task ) {
23+
return oldNode ? "print_old_node_message:" + task : task;
24+
}
2025

2126
if ( !grunt.option( "filename" ) ) {
2227
grunt.option( "filename", "jquery.js" );
@@ -176,33 +181,50 @@ module.exports = function( grunt ) {
176181
} );
177182

178183
// Load grunt tasks from NPM packages
179-
require( "load-grunt-tasks" )( grunt );
184+
// Support: Node.js <4
185+
// Don't load the eslint task in old Node.js, it won't parse.
186+
require( "load-grunt-tasks" )( grunt, {
187+
pattern: oldNode ? [ "grunt-*", "!grunt-eslint" ] : [ "grunt-*" ]
188+
} );
180189

181190
// Integrate jQuery specific tasks
182191
grunt.loadTasks( "build/tasks" );
183192

184-
grunt.registerTask( "lint", [ "jsonlint", "eslint:all" ] );
193+
grunt.registerTask( "print_old_node_message", function() {
194+
var task = [].slice.call( arguments ).join( ":" );
195+
grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
196+
} );
185197

186-
// Don't run Node-related tests in Node.js < 1.0.0 as they require an old
187-
// jsdom version that needs compiling, making it harder for people to compile
188-
// jQuery on Windows. (see gh-2519)
189-
grunt.registerTask( "test_fast", runJsdomTests ? [ "node_smoke_tests" ] : [] );
198+
grunt.registerTask( "lint", [
199+
"jsonlint",
200+
runIfNewNode( "eslint:all" )
201+
] );
202+
203+
grunt.registerTask( "test_fast", [ runIfNewNode( "node_smoke_tests" ) ] );
190204

191205
grunt.registerTask( "test", [ "test_fast" ].concat(
192-
runJsdomTests ? [ "promises_aplus_tests" ] : []
206+
[ runIfNewNode( "promises_aplus_tests" ) ]
193207
) );
194208

195209
// Short list as a high frequency watch task
196210
grunt.registerTask( "dev", [
197211
"build:*:*",
198-
"newer:eslint:dev",
212+
runIfNewNode( "newer:eslint:dev" ),
199213
"uglify",
200214
"remove_map_comment",
201215
"dist:*"
202216
]
203217
);
204218

205-
grunt.registerTask( "default", [ "dev", "eslint:dist", "test_fast", "compare_size" ] );
206-
207-
grunt.registerTask( "precommit_lint", [ "newer:jsonlint", "newer:eslint:all" ] );
219+
grunt.registerTask( "default", [
220+
"dev",
221+
runIfNewNode( "eslint:dist" ),
222+
"test_fast",
223+
"compare_size"
224+
] );
225+
226+
grunt.registerTask( "precommit_lint", [
227+
"newer:jsonlint",
228+
runIfNewNode( "newer:eslint:all" )
229+
] );
208230
};

0 commit comments

Comments
 (0)