[gjs: 24/43] CI: Add no-return-assign to eslint rules
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 24/43] CI: Add no-return-assign to eslint rules
- Date: Wed, 14 Aug 2019 17:29:05 +0000 (UTC)
commit 38dab36327c7e426b85fb61b50a19a758201c78f
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Aug 3 23:03:21 2019 -0700
CI: Add no-return-assign to eslint rules
Returning an assignment expression is rarely what's intended, usually
it's a typo for ===.
We do it legitimately in a few cases, where using
expect(() => (prop = value)).toThrow() for testing read-only properties.
In this case an extra pair of parentheses marks it as intentional.
.eslintrc.yml | 1 +
installed-tests/js/testEverythingEncapsulated.js | 2 +-
installed-tests/js/testExceptions.js | 2 +-
installed-tests/js/testGIMarshalling.js | 2 +-
installed-tests/js/testLegacyClass.js | 4 ++--
5 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 819183b5..5236bd0a 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -93,6 +93,7 @@ rules:
- object: imports
property: mainloop
message: Use GLib main loops and timeouts
+ no-return-assign: error
no-tabs: error
no-unused-vars:
- error
diff --git a/installed-tests/js/testEverythingEncapsulated.js
b/installed-tests/js/testEverythingEncapsulated.js
index a5a71139..a0bee48f 100644
--- a/installed-tests/js/testEverythingEncapsulated.js
+++ b/installed-tests/js/testEverythingEncapsulated.js
@@ -216,7 +216,7 @@ describe('Introspected GObject', function () {
});
it('throws when setting a read-only field', function () {
- expect(() => obj.some_int8 = 41).toThrow();
+ expect(() => (obj.some_int8 = 41)).toThrow();
});
it('has normal Object methods', function () {
diff --git a/installed-tests/js/testExceptions.js b/installed-tests/js/testExceptions.js
index e8d6af69..66514f8e 100644
--- a/installed-tests/js/testExceptions.js
+++ b/installed-tests/js/testExceptions.js
@@ -24,7 +24,7 @@ const Bar = GObject.registerClass({
describe('Exceptions', function () {
it('are thrown from property setter', function () {
let foo = new Foo();
- expect(() => foo.prop = 'bar').toThrowError(/set/);
+ expect(() => (foo.prop = 'bar')).toThrowError(/set/);
});
it('are thrown from property getter', function () {
diff --git a/installed-tests/js/testGIMarshalling.js b/installed-tests/js/testGIMarshalling.js
index c4708735..e4102877 100644
--- a/installed-tests/js/testGIMarshalling.js
+++ b/installed-tests/js/testGIMarshalling.js
@@ -792,7 +792,7 @@ describe('GObject properties', function () {
}).pend('https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/32');
xit('throws when setting a read-only property', function () {
- expect(() => obj.some_readonly = 35).toThrow();
+ expect(() => (obj.some_readonly = 35)).toThrow();
}).pend('https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/32');
});
diff --git a/installed-tests/js/testLegacyClass.js b/installed-tests/js/testLegacyClass.js
index 17b5f3cb..493b34c3 100644
--- a/installed-tests/js/testLegacyClass.js
+++ b/installed-tests/js/testLegacyClass.js
@@ -259,7 +259,7 @@ describe('Class framework', function () {
let newAccessor = new Accessor(11);
expect(newAccessor.value).toEqual(11);
- expect(() => newAccessor.value = 12).toThrow();
+ expect(() => (newAccessor.value = 12)).toThrow();
newAccessor.value = 42;
expect(newAccessor.value).toEqual(42);
@@ -494,7 +494,7 @@ describe('An interface', function () {
it('does not have to have its optional methods implemented', function () {
let obj;
- expect(() => obj = new MinimalImplementationOfAnInterface()).not.toThrow();
+ expect(() => (obj = new MinimalImplementationOfAnInterface())).not.toThrow();
expect(obj.constructor.implements(AnInterface)).toBeTruthy();
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]