[gjs: 2/7] maint: Add linter rule for multiline object literals




commit 8c50f934bc81f224c6d8f521116ddaa5583eef66
Author: Philip Chimento <philip chimento gmail com>
Date:   Wed May 5 16:38:52 2021 -0700

    maint: Add linter rule for multiline object literals
    
    This prevents formatting like
    
    doSomething({ a: 1,
                  b: 2,
                  c: 3 });
    
    which is often seen in GJS examples floating around the internet.

 .eslintrc.yml                          |  1 +
 installed-tests/js/testFundamental.js  | 12 ++++++------
 installed-tests/js/testGObjectClass.js |  6 +++---
 3 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 733db371..7ddf0e38 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -189,6 +189,7 @@ rules:
   object-curly-newline:
     - error
     - consistent: true
+      multiline: true
   object-curly-spacing: error
   object-shorthand: error
   operator-assignment: error
diff --git a/installed-tests/js/testFundamental.js b/installed-tests/js/testFundamental.js
index a4d0c0f7..7fd111b9 100644
--- a/installed-tests/js/testFundamental.js
+++ b/installed-tests/js/testFundamental.js
@@ -8,13 +8,13 @@ const TestObj = GObject.registerClass({
     Signals: {
         'test-fundamental-value-funcs': {param_types: [Regress.TestFundamentalObject.$gtype]},
         'test-fundamental-value-funcs-subtype': {param_types: [Regress.TestFundamentalSubObject.$gtype]},
-        'test-fundamental-no-funcs': {param_types:
-            Regress.TestFundamentalObjectNoGetSetFunc
-                ? [Regress.TestFundamentalObjectNoGetSetFunc.$gtype] : []},
+        'test-fundamental-no-funcs': {
+            param_types: Regress.TestFundamentalObjectNoGetSetFunc
+                ? [Regress.TestFundamentalObjectNoGetSetFunc.$gtype] : [],
+        },
         'test-fundamental-no-funcs-subtype': {
-            param_types:
-                Regress.TestFundamentalSubObjectNoGetSetFunc
-                    ? [Regress.TestFundamentalSubObjectNoGetSetFunc.$gtype] : [],
+            param_types: Regress.TestFundamentalSubObjectNoGetSetFunc
+                ? [Regress.TestFundamentalSubObjectNoGetSetFunc.$gtype] : [],
         },
     },
 }, class TestObj extends GObject.Object {});
diff --git a/installed-tests/js/testGObjectClass.js b/installed-tests/js/testGObjectClass.js
index 5512dc0e..15878a9b 100644
--- a/installed-tests/js/testGObjectClass.js
+++ b/installed-tests/js/testGObjectClass.js
@@ -981,9 +981,9 @@ describe('GObject class with JSObject property', function () {
     });
 
     it('assigns a Function on construct', function () {
-        expect(() => new MyObjectWithJSObjectProperty({jsobj_prop: () => {
-            return true;
-        }})).not.toThrow();
+        expect(() => new MyObjectWithJSObjectProperty({
+            jsobj_prop: () => true,
+        })).not.toThrow();
     });
 
     it('throws an error when using a boolean value on construct', function () {


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