Skip to content

Commit

Permalink
Build: Require strict mode in Node.js scripts via ESLint
Browse files Browse the repository at this point in the history
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.

Closes gh-4499

(cherry picked from commit bbad821)
  • Loading branch information
mgol committed Oct 8, 2019
1 parent ff5a43e commit ac2da4e
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .eslintrc-node.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"env": {
"es6": true,
"node": true
},

"rules": {
"strict": ["error", "global"]
}
}
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand Down
2 changes: 2 additions & 0 deletions build/release.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var fs = require( "fs" );

module.exports = function( Release ) {
Expand Down
2 changes: 2 additions & 0 deletions build/release/cdn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var
fs = require( "fs" ),
shell = require( "shelljs" ),
Expand Down
2 changes: 2 additions & 0 deletions build/release/dist.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

module.exports = function( Release, files, complete ) {

var
Expand Down
2 changes: 2 additions & 0 deletions build/release/ensure-sizzle.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var fs = require( "fs" ),
npm = require( "npm" ),
chalk = require( "chalk" ),
Expand Down
5 changes: 2 additions & 3 deletions build/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" ),
Expand Down
5 changes: 2 additions & 3 deletions build/tasks/dist.js
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
5 changes: 2 additions & 3 deletions build/tasks/node_smoke_tests.js
Original file line number Diff line number Diff line change
@@ -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/";
Expand Down
2 changes: 2 additions & 0 deletions build/tasks/qunit_fixture.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var fs = require( "fs" );

module.exports = function( grunt ) {
Expand Down
2 changes: 2 additions & 0 deletions build/tasks/sourcemap.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

var fs = require( "fs" );

module.exports = function( grunt ) {
Expand Down
5 changes: 2 additions & 3 deletions build/tasks/testswarm.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit ac2da4e

Please sign in to comment.