[gjs: 3/5] maint: Add more eslint rules for restricted syntax
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 3/5] maint: Add more eslint rules for restricted syntax
- Date: Thu, 3 Sep 2020 21:04:25 +0000 (UTC)
commit 0f3c532b818f302e18bef5838986c4deb6cc475e
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Aug 15 12:08:23 2020 -0700
maint: Add more eslint rules for restricted syntax
We do want people to stop using Lang.copyProperties.
In addition, 'x instanceof Array' is not correct, use Array.isArray()
instead.
.eslintrc.yml | 5 +++++
modules/script/tweener/tweener.js | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/.eslintrc.yml b/.eslintrc.yml
index a61641258..b50a57604 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -108,6 +108,9 @@ rules:
no-prototype-builtins: 'off'
no-restricted-properties:
- error
+ - object: Lang
+ property: copyProperties
+ message: Use Object.assign()
- object: Lang
property: bind
message: Use arrow notation or Function.prototype.bind()
@@ -129,6 +132,8 @@ rules:
BlockStatement[body.length=1]
CallExpression[arguments.length=0][callee.object.type="Super"][callee.property.name="_init"]
message: _init() that only calls super._init() is unnecessary
+ - selector: BinaryExpression[operator="instanceof"][right.name="Array"]
+ message: Use Array.isArray()
no-return-assign: error
no-return-await: error
no-self-compare: error
diff --git a/modules/script/tweener/tweener.js b/modules/script/tweener/tweener.js
index 540d48537..11a909d2c 100644
--- a/modules/script/tweener/tweener.js
+++ b/modules/script/tweener/tweener.js
@@ -484,7 +484,7 @@ function _addTweenOrCaller(target, tweeningParameters, isCaller) {
return false;
var scopes; // List of objects to tween
- if (target instanceof Array) {
+ if (Array.isArray(target)) {
// The first argument is an array
scopes = target.concat(); // XXX: To copy the array I guess
} else {
@@ -770,7 +770,7 @@ function _affectTweensWithFunction(func, args) {
var affected = false;
var scopes;
- if (scope instanceof Array)
+ if (Array.isArray(scope))
scopes = scope.concat();
else
scopes = new Array(scope);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]