[gjs: 18/43] CI: Add no-array-constructor to eslint rules



commit d7a0e4a77fdd5d816d6b81b43ad9e7a23d835ec4
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Aug 3 21:02:28 2019 -0700

    CI: Add no-array-constructor to eslint rules
    
    This forbids new Array(), preferring instead []. This is a good practice
    because otherwise it's possible for client code to redefine the Array
    global and break internal code.

 .eslintrc.yml                | 1 +
 modules/tweener/tweenList.js | 2 +-
 modules/tweener/tweener.js   | 6 +++---
 3 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 87b03249..9e5b5d1c 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -62,6 +62,7 @@ rules:
     - error
     - unix
   lines-between-class-members: error
+  no-array-constructor: error
   no-constant-condition:
     - error
     - checkLoops: false
diff --git a/modules/tweener/tweenList.js b/modules/tweener/tweenList.js
index 894a75d3..ec55ce11 100644
--- a/modules/tweener/tweenList.js
+++ b/modules/tweener/tweenList.js
@@ -64,7 +64,7 @@ TweenList.prototype = {
     clone: function(omitEvents) {
         var tween = new TweenList(this.scope, this.timeStart, this.timeComplete, this.userFrames,
             this.transition, this.transitionParams);
-        tween.properties = new Array();
+        tween.properties = [];
         for (let name in this.properties)
             tween.properties[name] = this.properties[name];
         tween.skipUpdates = this.skipUpdates;
diff --git a/modules/tweener/tweener.js b/modules/tweener/tweener.js
index 66f637e2..e6a0a999 100644
--- a/modules/tweener/tweener.js
+++ b/modules/tweener/tweener.js
@@ -147,7 +147,7 @@ function _startEngine() {
         return;
 
     _engineExists = true;
-    _tweenList = new Array();
+    _tweenList = [];
 
     if (!_ticker)
         throw new Error('Must call setFrameTicker()');
@@ -729,7 +729,7 @@ function _affectTweens(affectFunction, scope, properties) {
             affected = true;
         } else {
             // Must check whether this tween must have specific properties affected
-            var affectedProperties = new Array();
+            var affectedProperties = [];
             for (let j = 0; j < properties.length; j++) {
                 if (_tweenList[i].properties[properties[j]])
                     affectedProperties.push(properties[j]);
@@ -767,7 +767,7 @@ function _isInArray(string, array) {
 }
 
 function _affectTweensWithFunction(func, args) {
-    var properties = new Array();
+    var properties = [];
     var scope = args[0];
     var affected = false;
     var scopes;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]