diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2021-10-29 23:43:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 23:43:13 +0200 |
commit | 9735edd5cb7b5ef30bb8acc4d7596a1410a971cc (patch) | |
tree | f4328df74215a4b7f0f78a3ef44d23d32939cb5d /Gruntfile.js | |
parent | e124893132d7a979d7987f978e968a1f889348b6 (diff) | |
download | jquery-9735edd5cb7b5ef30bb8acc4d7596a1410a971cc.tar.gz jquery-9735edd5cb7b5ef30bb8acc4d7596a1410a971cc.zip |
Build: Update ESLint & eslint-plugin-import, fixing the build
Latest `main` started failing the build after some transitive dependencies
got updated, incorrectly recognizing some files with default exports as unused.
Since the new ESLint no longer supports Node 10 which we have to build on due
to use in our CI, skip ESLint in Node 10.
Ref gh-3225
Closes gh-4961
Diffstat (limited to 'Gruntfile.js')
-rw-r--r-- | Gruntfile.js | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/Gruntfile.js b/Gruntfile.js index fc35a843a..b10ebb2dc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,11 +12,18 @@ module.exports = function( grunt ) { return data; } + // Support: Node.js <12 + // Skip running tasks that dropped support for Node.js 10 + // in this Node version. + function runIfNewNode( task ) { + return oldNode ? "print_old_node_message:" + task : task; + } + var fs = require( "fs" ), gzip = require( "gzip-js" ), + oldNode = /^v10\./.test( process.version ), isTravis = process.env.TRAVIS, - travisBrowsers = process.env.BROWSERS && process.env.BROWSERS.split( "," ), - CLIEngine = require( "eslint" ).CLIEngine; + travisBrowsers = process.env.BROWSERS && process.env.BROWSERS.split( "," ); if ( !grunt.option( "filename" ) ) { grunt.option( "filename", "jquery.js" ); @@ -117,9 +124,14 @@ module.exports = function( grunt ) { // Ignore files from .eslintignore // See https://github.com/sindresorhus/grunt-eslint/issues/119 - ...new CLIEngine() - .getConfigForFile( "Gruntfile.js" ) - .ignorePatterns.map( ( p ) => `!${ p }` ) + ...fs + .readFileSync( `${ __dirname }/.eslintignore`, "utf-8" ) + .split( "\n" ) + .filter( filePath => filePath ) + .map( filePath => filePath[ 0 ] === "!" ? + filePath.slice( 1 ) : + `!${ filePath }` + ) ] } }, @@ -334,11 +346,18 @@ module.exports = function( grunt ) { } ); // Load grunt tasks from NPM packages - require( "load-grunt-tasks" )( grunt ); + require( "load-grunt-tasks" )( grunt, { + pattern: oldNode ? [ "grunt-*", "!grunt-eslint" ] : [ "grunt-*" ] + } ); // Integrate jQuery specific tasks grunt.loadTasks( "build/tasks" ); + grunt.registerTask( "print_old_node_message", ( ...args ) => { + var task = args.join( ":" ); + grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." ); + } ); + grunt.registerTask( "lint", [ "jsonlint", @@ -346,16 +365,16 @@ module.exports = function( grunt ) { // would run the dist target first which would point to errors in the built // file, making it harder to fix them. We want to check the built file only // if we already know the source files pass the linter. - "eslint:dev", - "eslint:dist" + runIfNewNode( "eslint:dev" ), + runIfNewNode( "eslint:dist" ) ] ); grunt.registerTask( "lint:newer", [ "newer:jsonlint", // Don't replace it with just the task; see the above comment. - "newer:eslint:dev", - "newer:eslint:dist" + runIfNewNode( "newer:eslint:dev" ), + runIfNewNode( "newer:eslint:dist" ) ] ); grunt.registerTask( "test:fast", "node_smoke_tests" ); @@ -378,7 +397,7 @@ module.exports = function( grunt ) { grunt.registerTask( "dev", [ "build:*:*", - "newer:eslint:dev", + runIfNewNode( "newer:eslint:dev" ), "newer:uglify", "remove_map_comment", "dist:*", @@ -387,14 +406,14 @@ module.exports = function( grunt ) { ] ); grunt.registerTask( "default", [ - "eslint:dev", + runIfNewNode( "eslint:dev" ), "build:*:*", "amd", "uglify", "remove_map_comment", "dist:*", "test:prepare", - "eslint:dist", + runIfNewNode( "eslint:dist" ), "test:fast", "compare_size" ] ); |