[gjs: 22/43] CI: Add no-new-object to eslint rules
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 22/43] CI: Add no-new-object to eslint rules
- Date: Wed, 14 Aug 2019 17:28:55 +0000 (UTC)
commit 77d4263278d6905552f980868a3e0f37af3c3513
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Aug 3 22:49:24 2019 -0700
CI: Add no-new-object to eslint rules
Similar to no-array-constructor, this forbids new Object(), preferring
instead {}. This is a good practice because otherwise it's possible for
client code to redefine the Object 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 d45a9765..4d1029bb 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -80,6 +80,7 @@ rules:
- allow:
- '!!'
no-lonely-if: error
+ no-new-object: error
no-prototype-builtins: 'off'
no-restricted-properties:
- error
diff --git a/modules/tweener/tweenList.js b/modules/tweener/tweenList.js
index ec55ce11..3b851da6 100644
--- a/modules/tweener/tweenList.js
+++ b/modules/tweener/tweenList.js
@@ -51,7 +51,7 @@ TweenList.prototype = {
this.transitionParams = transitionParams;
/* Other default information */
- this.properties = new Object();
+ this.properties = {};
this.isPaused = false;
this.timePaused = undefined;
this.isCaller = false;
diff --git a/modules/tweener/tweener.js b/modules/tweener/tweener.js
index 95c29a7a..c0981be3 100644
--- a/modules/tweener/tweener.js
+++ b/modules/tweener/tweener.js
@@ -397,8 +397,8 @@ var restrictedWords = {
};
function _constructPropertyList(obj) {
- var properties = new Object();
- var modifiedProperties = new Object();
+ var properties = {};
+ var modifiedProperties = {};
for (let istr in obj) {
if (restrictedWords[istr])
@@ -543,7 +543,7 @@ function _addTweenOrCaller(target, tweeningParameters, isCaller) {
for (let i = 0; i < scopes.length; i++) {
if (!isCaller) {
// Make a copy of the properties
- var copyProperties = new Object();
+ var copyProperties = {};
for (istr in properties) {
copyProperties[istr] = new PropertyInfo(properties[istr].valueStart,
properties[istr].valueComplete,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]