From 211f68a113793917c723fcc008ad5ba107080439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Fri, 4 Oct 2019 16:50:23 +0200 Subject: [PATCH] Build: Require strict mode in Node.js scripts via ESLint So far, only browser-based JS files were required to be in strict mode (in the function form). This commit adds such a requirement to Node.js scripts where the global form is preferred. All Node.js scripts in sloppy mode were converted to strict mode. --- .eslintrc-node.json | 4 ++++ Gruntfile.js | 4 ++-- build/release.js | 2 ++ build/release/cdn.js | 2 ++ build/release/dist.js | 2 ++ build/tasks/build.js | 5 ++--- build/tasks/dist.js | 5 ++--- build/tasks/node_smoke_tests.js | 5 ++--- build/tasks/qunit_fixture.js | 2 ++ build/tasks/sourcemap.js | 2 ++ build/tasks/testswarm.js | 5 ++--- 11 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.eslintrc-node.json b/.eslintrc-node.json index 589144272c..544a92cdc8 100644 --- a/.eslintrc-node.json +++ b/.eslintrc-node.json @@ -10,5 +10,9 @@ "env": { "es6": true, "node": true + }, + + "rules": { + "strict": ["error", "global"] } } diff --git a/Gruntfile.js b/Gruntfile.js index 012ce95dba..e740690afd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,6 @@ -module.exports = function( grunt ) { - "use strict"; +"use strict"; +module.exports = function( grunt ) { function readOptionalJSON( filepath ) { var stripJSONComments = require( "strip-json-comments" ), data = {}; diff --git a/build/release.js b/build/release.js index f666bf1160..6011066ff0 100644 --- a/build/release.js +++ b/build/release.js @@ -1,3 +1,5 @@ +"use strict"; + var fs = require( "fs" ); module.exports = function( Release ) { diff --git a/build/release/cdn.js b/build/release/cdn.js index c65c53e8ca..3d96d01791 100644 --- a/build/release/cdn.js +++ b/build/release/cdn.js @@ -1,3 +1,5 @@ +"use strict"; + var fs = require( "fs" ), shell = require( "shelljs" ), diff --git a/build/release/dist.js b/build/release/dist.js index 0b1e04a7f6..0ca396811a 100644 --- a/build/release/dist.js +++ b/build/release/dist.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function( Release, files, complete ) { var diff --git a/build/tasks/build.js b/build/tasks/build.js index d536f538c2..63dfc1ee86 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -4,10 +4,9 @@ * and includes/excludes specified modules */ -module.exports = function( grunt ) { - - "use strict"; +"use strict"; +module.exports = function( grunt ) { var fs = require( "fs" ), requirejs = require( "requirejs" ), Insight = require( "insight" ), diff --git a/build/tasks/dist.js b/build/tasks/dist.js index fa6920c889..f19929b896 100644 --- a/build/tasks/dist.js +++ b/build/tasks/dist.js @@ -1,7 +1,6 @@ -module.exports = function( grunt ) { - - "use strict"; +"use strict"; +module.exports = function( grunt ) { var fs = require( "fs" ), filename = grunt.option( "filename" ), distpaths = [ diff --git a/build/tasks/node_smoke_tests.js b/build/tasks/node_smoke_tests.js index e3d69db883..40c49a4d98 100644 --- a/build/tasks/node_smoke_tests.js +++ b/build/tasks/node_smoke_tests.js @@ -1,7 +1,6 @@ -module.exports = ( grunt ) => { - - "use strict"; +"use strict"; +module.exports = ( grunt ) => { const fs = require( "fs" ); const spawnTest = require( "./lib/spawn_test.js" ); const testsDir = "./test/node_smoke_tests/"; diff --git a/build/tasks/qunit_fixture.js b/build/tasks/qunit_fixture.js index 3f332dad03..138ca662dd 100644 --- a/build/tasks/qunit_fixture.js +++ b/build/tasks/qunit_fixture.js @@ -1,3 +1,5 @@ +"use strict"; + var fs = require( "fs" ); module.exports = function( grunt ) { diff --git a/build/tasks/sourcemap.js b/build/tasks/sourcemap.js index 3f21b2afd0..509374f2ee 100644 --- a/build/tasks/sourcemap.js +++ b/build/tasks/sourcemap.js @@ -1,3 +1,5 @@ +"use strict"; + var fs = require( "fs" ); module.exports = function( grunt ) { diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index 88e883d0f9..d2653e0e05 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -1,7 +1,6 @@ -module.exports = function( grunt ) { - - "use strict"; +"use strict"; +module.exports = function( grunt ) { grunt.registerTask( "testswarm", function( commit, configFile, projectName, browserSets, timeout, testMode ) { var jobName, config, tests,