[gjs: 5/43] js: Run eslint --fix on all JS files
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 5/43] js: Run eslint --fix on all JS files
- Date: Wed, 14 Aug 2019 17:27:29 +0000 (UTC)
commit 386f85e8fc32762013c817386dfe8bf49b6cd02f
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Aug 3 22:36:22 2019 -0700
js: Run eslint --fix on all JS files
In a few cases (notably with template strings) the eslint fixer needs a
helping hand, edit these cases manually.
installed-tests/js/minijasmine.js | 10 +-
installed-tests/js/modules/alwaysThrows.js | 2 +-
installed-tests/js/modules/foobar.js | 4 +-
installed-tests/js/modules/modunicode.js | 2 +-
installed-tests/js/modules/subA/subB/__init__.js | 8 +-
installed-tests/js/modules/subA/subB/foobar.js | 4 +-
installed-tests/js/testCairo.js | 2 +-
installed-tests/js/testEverythingBasic.js | 84 ++++-----
installed-tests/js/testEverythingEncapsulated.js | 10 +-
installed-tests/js/testExceptions.js | 16 +-
installed-tests/js/testGDBus.js | 32 ++--
installed-tests/js/testGIMarshalling.js | 40 +++--
installed-tests/js/testGLib.js | 2 +-
installed-tests/js/testGObjectClass.js | 30 ++--
installed-tests/js/testGObjectInterface.js | 44 ++---
installed-tests/js/testGtk.js | 4 +-
installed-tests/js/testImporter.js | 2 +-
installed-tests/js/testLang.js | 12 +-
installed-tests/js/testLegacyClass.js | 78 +++++----
installed-tests/js/testLegacyGObject.js | 143 ++++++++-------
installed-tests/js/testLegacyGtk.js | 2 +-
installed-tests/js/testLocale.js | 2 +-
installed-tests/js/testParamSpec.js | 2 +-
installed-tests/js/testSignals.js | 10 +-
installed-tests/js/testTweener.js | 113 +++++++-----
installed-tests/js/testself.js | 8 +-
modules/_bootstrap/debugger.js | 2 +-
modules/_legacy.js | 28 +--
modules/cairo.js | 126 ++++++-------
modules/format.js | 4 +-
modules/lang.js | 10 +-
modules/mainloop.js | 4 +-
modules/overrides/GLib.js | 14 +-
modules/overrides/GObject.js | 102 +++++++----
modules/overrides/Gio.js | 76 ++++----
modules/overrides/Gtk.js | 2 +-
modules/package.js | 26 +--
modules/signals.js | 34 ++--
modules/tweener/equations.js | 214 +++++++++++++----------
modules/tweener/tweenList.js | 8 +-
modules/tweener/tweener.js | 27 +--
41 files changed, 748 insertions(+), 595 deletions(-)
---
diff --git a/installed-tests/js/minijasmine.js b/installed-tests/js/minijasmine.js
index b7a6e4f4..a6ca8fa1 100644
--- a/installed-tests/js/minijasmine.js
+++ b/installed-tests/js/minijasmine.js
@@ -54,14 +54,14 @@ class TapReporter {
}
jasmineStarted(info) {
- print('1..' + info.totalSpecsDefined);
+ print(`1..${info.totalSpecsDefined}`);
}
jasmineDone() {
this._failedSuites.forEach(failure => {
failure.failedExpectations.forEach(result => {
print('not ok - An error was thrown outside a test');
- print('# ' + result.message);
+ print(`# ${result.message}`);
});
});
@@ -91,10 +91,10 @@ class TapReporter {
} else {
tap_report = 'ok';
}
- tap_report += ' ' + this._specCount + ' ' + result.fullName;
+ tap_report += ` ${this._specCount} ${result.fullName}`;
if (result.status === 'pending' || result.status === 'disabled') {
let reason = result.pendingReason || result.status;
- tap_report += ' # SKIP ' + reason;
+ tap_report += ` # SKIP ${reason}`;
}
print(tap_report);
@@ -104,7 +104,7 @@ class TapReporter {
print('# Message:', _removeNewlines(failedExpectation.message));
print('# Stack:');
let stackTrace = _filterStack(failedExpectation.stack).trim();
- print(stackTrace.split('\n').map((str) => '# ' + str).join('\n'));
+ print(stackTrace.split('\n').map((str) => `# ${str}`).join('\n'));
});
}
}
diff --git a/installed-tests/js/modules/alwaysThrows.js b/installed-tests/js/modules/alwaysThrows.js
index 50af1ff1..13f7b227 100644
--- a/installed-tests/js/modules/alwaysThrows.js
+++ b/installed-tests/js/modules/alwaysThrows.js
@@ -1,4 +1,4 @@
// line 0
// line 1
// line 2
-throw new Error("This is an error that always happens on line 3");
+throw new Error('This is an error that always happens on line 3');
diff --git a/installed-tests/js/modules/foobar.js b/installed-tests/js/modules/foobar.js
index a3b42db2..f2736ac8 100644
--- a/installed-tests/js/modules/foobar.js
+++ b/installed-tests/js/modules/foobar.js
@@ -2,8 +2,8 @@
/* exported bar, foo, testToString, toString */
-var foo = "This is foo";
-var bar = "This is bar";
+var foo = 'This is foo';
+var bar = 'This is bar';
var toString = x => x;
diff --git a/installed-tests/js/modules/modunicode.js b/installed-tests/js/modules/modunicode.js
index e5ca6ca1..55033455 100644
--- a/installed-tests/js/modules/modunicode.js
+++ b/installed-tests/js/modules/modunicode.js
@@ -1,4 +1,4 @@
/* exported uval */
// This file is written in UTF-8.
-var uval = "const ♥ utf8";
+var uval = 'const ♥ utf8';
diff --git a/installed-tests/js/modules/subA/subB/__init__.js
b/installed-tests/js/modules/subA/subB/__init__.js
index ce3c2257..7bf2132f 100644
--- a/installed-tests/js/modules/subA/subB/__init__.js
+++ b/installed-tests/js/modules/subA/subB/__init__.js
@@ -1,7 +1,7 @@
/* exported ImporterClass, testImporterFunction */
function testImporterFunction() {
- return "__init__ function tested";
+ return '__init__ function tested';
}
function ImporterClass() {
@@ -9,11 +9,11 @@ function ImporterClass() {
}
ImporterClass.prototype = {
- _init : function() {
- this._a = "__init__ class tested";
+ _init: function() {
+ this._a = '__init__ class tested';
},
- testMethod : function() {
+ testMethod: function() {
return this._a;
}
};
diff --git a/installed-tests/js/modules/subA/subB/foobar.js b/installed-tests/js/modules/subA/subB/foobar.js
index 6520d968..92c69b3f 100644
--- a/installed-tests/js/modules/subA/subB/foobar.js
+++ b/installed-tests/js/modules/subA/subB/foobar.js
@@ -2,5 +2,5 @@
/* exported bar, foo */
-var foo = "This is foo";
-var bar = "This is bar";
+var foo = 'This is foo';
+var bar = 'This is bar';
diff --git a/installed-tests/js/testCairo.js b/installed-tests/js/testCairo.js
index 4905ae92..656326fc 100644
--- a/installed-tests/js/testCairo.js
+++ b/installed-tests/js/testCairo.js
@@ -152,7 +152,7 @@ describe('Cairo', function () {
cr.rotate(180);
cr.identityMatrix();
- cr.showText("foobar");
+ cr.showText('foobar');
cr.moveTo(0, 0);
cr.setDash([], 1);
diff --git a/installed-tests/js/testEverythingBasic.js b/installed-tests/js/testEverythingBasic.js
index 5746c466..ff079031 100644
--- a/installed-tests/js/testEverythingBasic.js
+++ b/installed-tests/js/testEverythingBasic.js
@@ -17,29 +17,29 @@ describe('Life, the Universe and Everything', function () {
});
[8, 16, 32, 64].forEach(bits => {
- it('includes ' + bits + '-bit integers', function () {
- let method = 'test_int' + bits;
+ it(`includes ${bits}-bit integers`, function () {
+ let method = `test_int${bits}`;
expect(Regress[method](42)).toBe(42);
expect(Regress[method](-42)).toBe(-42);
});
- it('includes unsigned ' + bits + '-bit integers', function () {
- let method = 'test_uint' + bits;
+ it(`includes unsigned ${bits}-bit integers`, function () {
+ let method = `test_uint${bits}`;
expect(Regress[method](42)).toBe(42);
});
});
['short', 'int', 'long', 'ssize', 'float', 'double'].forEach(type => {
- it('includes ' + type + 's', function () {
- let method = 'test_' + type;
+ it(`includes ${type}s`, function () {
+ let method = `test_${type}`;
expect(Regress[method](42)).toBe(42);
expect(Regress[method](-42)).toBe(-42);
});
});
['ushort', 'uint', 'ulong', 'size'].forEach(type => {
- it('includes ' + type + 's', function () {
- let method = 'test_' + type;
+ it(`includes ${type}s`, function () {
+ let method = `test_${type}`;
expect(Regress[method](42)).toBe(42);
});
});
@@ -86,12 +86,12 @@ describe('Life, the Universe and Everything', function () {
};
function run_test(bytes, limit, method_stem) {
- if(skip[limit + bytes])
+ if (skip[limit + bytes])
pending("This test doesn't work");
if (bytes === '64')
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
- "*cannot be safely stored*");
+ '*cannot be safely stored*');
let val = Limits[bytes][limit];
expect(Regress[method_stem + bytes](val)).toBe(val);
@@ -101,24 +101,24 @@ describe('Life, the Universe and Everything', function () {
'testEverythingBasic.js', 0, 'Ignore message');
}
['8', '16', '32', '64'].forEach(bytes => {
- it('marshals max value of unsigned ' + bytes + '-bit integers', function () {
+ it(`marshals max value of unsigned ${bytes}-bit integers`, function () {
run_test(bytes, 'UMAX', 'test_uint');
});
- it('marshals min value of signed ' + bytes + '-bit integers', function () {
+ it(`marshals min value of signed ${bytes}-bit integers`, function () {
run_test(bytes, 'MIN', 'test_int');
});
- it('marshals max value of signed ' + bytes + '-bit integers', function () {
+ it(`marshals max value of signed ${bytes}-bit integers`, function () {
run_test(bytes, 'MAX', 'test_int');
});
});
it('warns when conversion is lossy', function () {
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
- "*cannot be safely stored*");
+ '*cannot be safely stored*');
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
- "*cannot be safely stored*");
+ '*cannot be safely stored*');
void GLib.MAXINT64;
void GLib.MAXUINT64;
GLib.test_assert_expected_messages_internal('Gjs',
@@ -129,8 +129,8 @@ describe('Life, the Universe and Everything', function () {
describe('No implicit conversion to unsigned', function () {
['uint8', 'uint16', 'uint32', 'uint64', 'uint', 'size'].forEach(type => {
- it('for ' + type, function () {
- expect(() => Regress['test_' + type](-42)).toThrow();
+ it(`for ${type}`, function () {
+ expect(() => Regress[`test_${type}`](-42)).toThrow();
});
});
});
@@ -158,14 +158,14 @@ describe('Life, the Universe and Everything', function () {
});
it('in after out', function () {
- const str = "hello";
+ const str = 'hello';
let len = Regress.test_int_out_utf8(str);
expect(len).toEqual(str.length);
});
describe('UTF-8 strings', function () {
- const CONST_STR = "const \u2665 utf8";
- const NONCONST_STR = "nonconst \u2665 utf8";
+ const CONST_STR = 'const \u2665 utf8';
+ const NONCONST_STR = 'nonconst \u2665 utf8';
it('as return types', function () {
expect(Regress.test_utf8_const_return()).toEqual(CONST_STR);
@@ -192,7 +192,7 @@ describe('Life, the Universe and Everything', function () {
});
it('static methods', function () {
- let v = Regress.TestObj.new_from_file("/enoent");
+ let v = Regress.TestObj.new_from_file('/enoent');
expect(v instanceof Regress.TestObj).toBeTruthy();
});
@@ -222,7 +222,7 @@ describe('Life, the Universe and Everything', function () {
it('array callbacks', function () {
let callback = jasmine.createSpy('callback').and.returnValue(7);
expect(Regress.test_array_callback(callback)).toEqual(14);
- expect(callback).toHaveBeenCalledWith([-1, 0, 1, 2], ["one", "two", "three"]);
+ expect(callback).toHaveBeenCalledWith([-1, 0, 1, 2], ['one', 'two', 'three']);
});
it('null array callback', function () {
@@ -231,14 +231,16 @@ describe('Life, the Universe and Everything', function () {
it('callback with transfer-full return value', function () {
function callback() {
- return Regress.TestObj.new_from_file("/enoent");
+ return Regress.TestObj.new_from_file('/enoent');
}
Regress.test_callback_return_full(callback);
});
it('callback with destroy-notify', function () {
let testObj = {
- test: function (data) { return data; },
+ test: function (data) {
+ return data;
+ },
};
spyOn(testObj, 'test').and.callThrough();
expect(Regress.test_callback_destroy_notify(function () {
@@ -281,43 +283,43 @@ describe('Life, the Universe and Everything', function () {
});
['glist', 'gslist'].forEach(list => {
- describe(list + ' types', function () {
+ describe(`${list} types`, function () {
const STR_LIST = ['1', '2', '3'];
it('return with transfer-none', function () {
- expect(Regress['test_' + list + '_nothing_return']()).toEqual(STR_LIST);
- expect(Regress['test_' + list + '_nothing_return2']()).toEqual(STR_LIST);
+ expect(Regress[`test_${list}_nothing_return`]()).toEqual(STR_LIST);
+ expect(Regress[`test_${list}_nothing_return2`]()).toEqual(STR_LIST);
});
it('return with transfer-container', function () {
- expect(Regress['test_' + list + '_container_return']()).toEqual(STR_LIST);
+ expect(Regress[`test_${list}_container_return`]()).toEqual(STR_LIST);
});
it('return with transfer-full', function () {
- expect(Regress['test_' + list + '_everything_return']()).toEqual(STR_LIST);
+ expect(Regress[`test_${list}_everything_return`]()).toEqual(STR_LIST);
});
it('in with transfer-none', function () {
- Regress['test_' + list + '_nothing_in'](STR_LIST);
- Regress['test_' + list + '_nothing_in2'](STR_LIST);
+ Regress[`test_${list}_nothing_in`](STR_LIST);
+ Regress[`test_${list}_nothing_in2`](STR_LIST);
});
xit('in with transfer-container', function () {
- Regress['test_' + list + '_container_in'](STR_LIST);
+ Regress[`test_${list}_container_in`](STR_LIST);
}).pend('Function not added to gobject-introspection test suite yet');
});
});
['int', 'gint8', 'gint16', 'gint32', 'gint64'].forEach(inttype => {
- it('arrays of ' + inttype + ' in', function () {
- expect(Regress['test_array_' + inttype + '_in']([1, 2, 3, 4])).toEqual(10);
+ it(`arrays of ${inttype} in`, function () {
+ expect(Regress[`test_array_${inttype}_in`]([1, 2, 3, 4])).toEqual(10);
});
});
it('implicit conversions from strings to int arrays', function () {
- expect(Regress.test_array_gint8_in("\x01\x02\x03\x04")).toEqual(10);
- expect(Regress.test_array_gint16_in("\x01\x02\x03\x04")).toEqual(10);
- expect(Regress.test_array_gint16_in("\u0100\u0200\u0300\u0400")).toEqual(2560);
+ expect(Regress.test_array_gint8_in('\x01\x02\x03\x04')).toEqual(10);
+ expect(Regress.test_array_gint16_in('\x01\x02\x03\x04')).toEqual(10);
+ expect(Regress.test_array_gint16_in('\u0100\u0200\u0300\u0400')).toEqual(2560);
});
it('GType arrays', function () {
@@ -356,8 +358,8 @@ describe('Life, the Universe and Everything', function () {
expect(ints).toEqual([22, 33, 44]);
});
- describe('GHash type', function () {;
- const EXPECTED_HASH = { baz: 'bat', foo: 'bar', qux: 'quux' };
+ describe('GHash type', function () {
+ const EXPECTED_HASH = {baz: 'bat', foo: 'bar', qux: 'quux'};
it('null GHash in', function () {
Regress.test_ghash_null_in(null);
@@ -380,7 +382,7 @@ describe('Life, the Universe and Everything', function () {
});
it('nested GHash', function () {
- const EXPECTED_NESTED_HASH = { wibble: EXPECTED_HASH };
+ const EXPECTED_NESTED_HASH = {wibble: EXPECTED_HASH};
expect(Regress.test_ghash_nested_everything_return())
.toEqual(EXPECTED_NESTED_HASH);
@@ -419,7 +421,7 @@ describe('Life, the Universe and Everything', function () {
xit('can be answered with GObject.set()', function() {
let o = new Regress.TestObj();
- o.set({ string: 'Answer', int: 42 });
+ o.set({string: 'Answer', int: 42});
expect(o.string).toBe('Answer');
expect(o.int).toBe(42);
}).pend('https://gitlab.gnome.org/GNOME/gobject-introspection/issues/113');
diff --git a/installed-tests/js/testEverythingEncapsulated.js
b/installed-tests/js/testEverythingEncapsulated.js
index 9e83253e..fdb455db 100644
--- a/installed-tests/js/testEverythingEncapsulated.js
+++ b/installed-tests/js/testEverythingEncapsulated.js
@@ -66,7 +66,7 @@ describe('Introspected structs', function () {
});
it('catches bad field names', function () {
- expect(() => new Regress.TestStructA({ junk: 42 })).toThrow();
+ expect(() => new Regress.TestStructA({junk: 42})).toThrow();
});
it('copies an object from another object of the same type', function () {
@@ -123,7 +123,7 @@ describe('Introspected boxed types', function () {
});
it('catches bad field names', function () {
- expect(() => new Regress.TestSimpleBoxedA({ junk: 42 })).toThrow();
+ expect(() => new Regress.TestSimpleBoxedA({junk: 42})).toThrow();
});
it('copies an object from another object of the same type', function () {
@@ -149,12 +149,12 @@ describe('Introspected boxed types', function () {
});
it('assigns nested struct field from an instance', function () {
- simple_boxed.nested_a = new Regress.TestSimpleBoxedA({ some_int: 53 });
+ simple_boxed.nested_a = new Regress.TestSimpleBoxedA({some_int: 53});
expect(simple_boxed.nested_a.some_int).toEqual(53);
});
it('assigns nested struct field directly from a hash of field values', function () {
- simple_boxed.nested_a = { some_int: 63 };
+ simple_boxed.nested_a = {some_int: 63};
expect(simple_boxed.nested_a.some_int).toEqual(63);
});
});
@@ -185,7 +185,7 @@ describe('Introspected boxed types', function () {
// The two real world structs that have this behavior are
// Clutter.Color and Clutter.ActorBox.
it('constructs using a custom constructor in backwards compatibility mode', function () {
- let boxed = new Regress.TestBoxedB({ some_int8: 7, some_long: 5 });
+ let boxed = new Regress.TestBoxedB({some_int8: 7, some_long: 5});
expect(boxed.some_int8).toEqual(7);
expect(boxed.some_long).toEqual(5);
});
diff --git a/installed-tests/js/testExceptions.js b/installed-tests/js/testExceptions.js
index e1790dd1..50622d4e 100644
--- a/installed-tests/js/testExceptions.js
+++ b/installed-tests/js/testExceptions.js
@@ -38,7 +38,7 @@ describe('Exceptions', function () {
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
'JS ERROR: Error: set*');
- new Foo({ prop: 'bar' });
+ new Foo({prop: 'bar'});
GLib.test_assert_expected_messages_internal('Gjs', 'testExceptions.js', 0,
'testExceptionInPropertySetterFromConstructor');
@@ -91,7 +91,7 @@ describe('logError', function () {
try {
let file = Gio.file_new_for_path("\\/,.^!@&$_don't exist");
file.read(null);
- } catch(e) {
+ } catch (e) {
logError(e);
}
});
@@ -100,8 +100,8 @@ describe('logError', function () {
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
'JS ERROR: Gio.IOErrorEnum: a message\nmarker@*');
try {
- throw new Gio.IOErrorEnum({ message: 'a message', code: 0 });
- } catch(e) {
+ throw new Gio.IOErrorEnum({message: 'a message', code: 0});
+ } catch (e) {
logError(e);
}
});
@@ -109,7 +109,7 @@ describe('logError', function () {
it('also logs an error for a created GError that is not thrown', function marker() {
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
'JS ERROR: Gio.IOErrorEnum: a message\nmarker@*');
- logError(new Gio.IOErrorEnum({ message: 'a message', code: 0 }));
+ logError(new Gio.IOErrorEnum({message: 'a message', code: 0}));
});
it('logs an error created with the GLib.Error constructor', function marker() {
@@ -138,7 +138,7 @@ describe('logError', function () {
try {
let file = Gio.file_new_for_path("\\/,.^!@&$_don't exist");
file.read(null);
- } catch(e) {
+ } catch (e) {
logError(e, 'prefix');
}
});
@@ -147,8 +147,8 @@ describe('logError', function () {
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
'JS ERROR: prefix: Gio.IOErrorEnum: a message\nmarker@*');
try {
- throw new Gio.IOErrorEnum({ message: 'a message', code: 0 });
- } catch(e) {
+ throw new Gio.IOErrorEnum({message: 'a message', code: 0});
+ } catch (e) {
logError(e, 'prefix');
}
});
diff --git a/installed-tests/js/testGDBus.js b/installed-tests/js/testGDBus.js
index c6cff2db..b7ac134d 100644
--- a/installed-tests/js/testGDBus.js
+++ b/installed-tests/js/testGDBus.js
@@ -99,7 +99,7 @@ var TestIface = `<node>
const PROP_READ_ONLY_INITIAL_VALUE = Math.random();
const PROP_READ_WRITE_INITIAL_VALUE = 58;
-const PROP_WRITE_ONLY_INITIAL_VALUE = "Initial value";
+const PROP_WRITE_ONLY_INITIAL_VALUE = 'Initial value';
/* Test is the actual object exporting the dbus methods */
class Test {
@@ -113,19 +113,19 @@ class Test {
}
frobateStuff(args) {
- return { hello: new GLib.Variant('s', 'world') };
+ return {hello: new GLib.Variant('s', 'world')};
}
nonJsonFrobateStuff(i) {
if (i == 42) {
- return "42 it is!";
+ return '42 it is!';
} else {
- return "Oops";
+ return 'Oops';
}
}
alwaysThrowException() {
- throw Error("Exception!");
+ throw Error('Exception!');
}
thisDoesNotExist() {
@@ -133,15 +133,15 @@ class Test {
}
noInParameter() {
- return "Yes!";
+ return 'Yes!';
}
multipleInArgs(a, b, c, d, e) {
- return a + " " + b + " " + c + " " + d + " " + e;
+ return `${a} ${b} ${c} ${d} ${e}`;
}
emitSignal() {
- this._impl.emit_signal('signalFoo', GLib.Variant.new('(s)', [ "foobar" ]));
+ this._impl.emit_signal('signalFoo', GLib.Variant.new('(s)', ['foobar']));
}
noReturnValue() {
@@ -153,22 +153,22 @@ class Test {
* multipleOutValues is "sss", while oneArrayOut is "as"
*/
multipleOutValues() {
- return [ "Hello", "World", "!" ];
+ return ['Hello', 'World', '!'];
}
oneArrayOut() {
- return [ "Hello", "World", "!" ];
+ return ['Hello', 'World', '!'];
}
/* Same thing again. In this case multipleArrayOut is "asas",
* while arrayOfArrayOut is "aas".
*/
multipleArrayOut() {
- return [[ "Hello", "World" ], [ "World", "Hello" ]];
+ return [['Hello', 'World'], ['World', 'Hello']];
}
arrayOfArrayOut() {
- return [[ "Hello", "World" ], [ "World", "Hello" ]];
+ return [['Hello', 'World'], ['World', 'Hello']];
}
arrayOutBadSig() {
@@ -286,11 +286,11 @@ describe('Exported DBus object', function () {
own_name_id = Gio.DBus.session.own_name('org.gnome.gjs.Test',
Gio.BusNameOwnerFlags.NONE,
name => {
- log("Acquired name " + name);
+ log(`Acquired name ${name}`);
loop.quit();
},
name => {
- log("Lost name " + name);
+ log(`Lost name ${name}`);
});
loop.run();
new ProxyClass(Gio.DBus.session, 'org.gnome.gjs.Test',
@@ -491,7 +491,7 @@ describe('Exported DBus object', function () {
});
it('can call a remote method that is implemented asynchronously', function () {
- let someString = "Hello world!";
+ let someString = 'Hello world!';
let someInt = 42;
proxy.echoRemote(someString, someInt,
@@ -506,7 +506,7 @@ describe('Exported DBus object', function () {
it('can send and receive bytes from a remote method', function () {
let loop = GLib.MainLoop.new(null, false);
- let someBytes = [ 0, 63, 234 ];
+ let someBytes = [0, 63, 234];
someBytes.forEach(b => {
proxy.byteEchoRemote(b, ([result], excp) => {
expect(excp).toBeNull();
diff --git a/installed-tests/js/testGIMarshalling.js b/installed-tests/js/testGIMarshalling.js
index 11cbb8eb..4de1b045 100644
--- a/installed-tests/js/testGIMarshalling.js
+++ b/installed-tests/js/testGIMarshalling.js
@@ -186,8 +186,8 @@ describe('GArray', function () {
['return', 'out'].forEach(method => {
['none', 'container', 'full'].forEach(transfer => {
- it('can be passed as ' + method + ' with transfer ' + transfer, function () {
- expect(GIMarshallingTests['garray_utf8_' + transfer + '_' + method]())
+ it(`can be passed as ${method} with transfer ${transfer}`, function () {
+ expect(GIMarshallingTests[`garray_utf8_${transfer}_${method}`]())
.toEqual(['0', '1', '2']);
});
});
@@ -259,7 +259,7 @@ describe('GBytes', function() {
});
it('can be created from a string and is encoded in UTF-8', function () {
- let bytes = GLib.Bytes.new("const \u2665 utf8");
+ let bytes = GLib.Bytes.new('const \u2665 utf8');
expect(() => GIMarshallingTests.utf8_as_uint8array_in(bytes.toArray()))
.not.toThrow();
});
@@ -294,8 +294,8 @@ describe('GPtrArray', function () {
['return', 'out'].forEach(method => {
['none', 'container', 'full'].forEach(transfer => {
- it('can be passed as ' + method + ' with transfer ' + transfer, function () {
- expect(GIMarshallingTests['gptrarray_utf8_' + transfer + '_' + method]())
+ it(`can be passed as ${method} with transfer ${transfer}`, function () {
+ expect(GIMarshallingTests[`gptrarray_utf8_${transfer}_${method}`]())
.toEqual(refArray);
});
});
@@ -383,8 +383,8 @@ describe('GHashTable', function () {
['return', 'out'].forEach(method => {
['none', 'container', 'full'].forEach(transfer => {
- it('can be passed as ' + method + ' with transfer ' + transfer, function () {
- expect(GIMarshallingTests['ghashtable_utf8_' + transfer + '_' + method]())
+ it(`can be passed as ${method} with transfer ${transfer}`, function () {
+ expect(GIMarshallingTests[`ghashtable_utf8_${transfer}_${method}`]())
.toEqual(STRING_DICT);
});
});
@@ -508,7 +508,7 @@ describe('GValue', function () {
let Cairo;
try {
Cairo = imports.cairo;
- } catch(e) {
+ } catch (e) {
pending('Compiled without Cairo support');
return;
}
@@ -584,12 +584,24 @@ describe('Callback', function () {
});
const VFuncTester = GObject.registerClass(class VFuncTester extends GIMarshallingTests.Object {
- vfunc_vfunc_return_value_only() { return 42; }
- vfunc_vfunc_one_out_parameter() { return 43; }
- vfunc_vfunc_multiple_out_parameters() { return [44, 45]; }
- vfunc_vfunc_return_value_and_one_out_parameter() { return [46, 47]; }
- vfunc_vfunc_return_value_and_multiple_out_parameters() { return [48, 49, 50]; }
- vfunc_vfunc_array_out_parameter() { return [50, 51]; }
+ vfunc_vfunc_return_value_only() {
+ return 42;
+ }
+ vfunc_vfunc_one_out_parameter() {
+ return 43;
+ }
+ vfunc_vfunc_multiple_out_parameters() {
+ return [44, 45];
+ }
+ vfunc_vfunc_return_value_and_one_out_parameter() {
+ return [46, 47];
+ }
+ vfunc_vfunc_return_value_and_multiple_out_parameters() {
+ return [48, 49, 50];
+ }
+ vfunc_vfunc_array_out_parameter() {
+ return [50, 51];
+ }
vfunc_vfunc_meth_with_err(x) {
switch (x) {
case -1:
diff --git a/installed-tests/js/testGLib.js b/installed-tests/js/testGLib.js
index d5edbff0..602cff16 100644
--- a/installed-tests/js/testGLib.js
+++ b/installed-tests/js/testGLib.js
@@ -20,7 +20,7 @@ describe('GVariant constructor', function () {
'/a/object/path',
'asig', //nature
new GLib.Variant('s', 'variant'),
- [ 7, 3 ]
+ [7, 3]
]);
expect(struct_variant.n_children()).toEqual(5);
diff --git a/installed-tests/js/testGObjectClass.js b/installed-tests/js/testGObjectClass.js
index 925dbd76..852501b4 100644
--- a/installed-tests/js/testGObjectClass.js
+++ b/installed-tests/js/testGObjectClass.js
@@ -18,17 +18,17 @@ const MyObject = GObject.registerClass({
},
Signals: {
'empty': {},
- 'minimal': { param_types: [ GObject.TYPE_INT, GObject.TYPE_INT ] },
+ 'minimal': {param_types: [GObject.TYPE_INT, GObject.TYPE_INT]},
'full': {
flags: GObject.SignalFlags.RUN_LAST,
accumulator: GObject.AccumulatorType.FIRST_WINS,
return_type: GObject.TYPE_INT,
param_types: [],
},
- 'run-last': { flags: GObject.SignalFlags.RUN_LAST },
+ 'run-last': {flags: GObject.SignalFlags.RUN_LAST},
'detailed': {
flags: GObject.SignalFlags.RUN_FIRST | GObject.SignalFlags.DETAILED,
- param_types: [ GObject.TYPE_STRING ],
+ param_types: [GObject.TYPE_STRING],
},
},
}, class MyObject extends GObject.Object {
@@ -120,7 +120,7 @@ const MyAbstractObject = GObject.registerClass({
});
const MyApplication = GObject.registerClass({
- Signals: { 'custom': { param_types: [ GObject.TYPE_INT ] } },
+ Signals: {'custom': {param_types: [GObject.TYPE_INT]}},
}, class MyApplication extends Gio.Application {
emit_custom(n) {
this.emit('custom', n);
@@ -128,7 +128,7 @@ const MyApplication = GObject.registerClass({
});
const MyInitable = GObject.registerClass({
- Implements: [ Gio.Initable ],
+ Implements: [Gio.Initable],
}, class MyInitable extends GObject.Object {
vfunc_init(cancellable) {
if (!(cancellable instanceof Gio.Cancellable))
@@ -140,7 +140,7 @@ const MyInitable = GObject.registerClass({
const Derived = GObject.registerClass(class Derived extends MyObject {
_init() {
- super._init({ readwrite: 'yes' });
+ super._init({readwrite: 'yes'});
}
});
@@ -174,7 +174,7 @@ describe('GObject class with decorator', function () {
});
it('constructs with a hash of property values', function () {
- let myInstance2 = new MyObject({ readwrite: 'baz', construct: 'asdf' });
+ let myInstance2 = new MyObject({readwrite: 'baz', construct: 'asdf'});
expect(myInstance2.readwrite).toEqual('baz');
expect(myInstance2.readonly).toEqual('bar');
expect(myInstance2.construct).toEqual('asdf');
@@ -257,18 +257,22 @@ describe('GObject class with decorator', function () {
});
it('calls run-last default handler last', function () {
- let stack = [ ];
+ let stack = [];
let runLastSpy = jasmine.createSpy('runLastSpy')
- .and.callFake(() => { stack.push(1); });
+ .and.callFake(() => {
+ stack.push(1);
+ });
myInstance.connect('run-last', runLastSpy);
- myInstance.emit_run_last(() => { stack.push(2); });
+ myInstance.emit_run_last(() => {
+ stack.push(2);
+ });
expect(stack).toEqual([1, 2]);
});
it("can inherit from something that's not GObject.Object", function () {
// ...and still get all the goodies of GObject.Class
- let instance = new MyApplication({ application_id: 'org.gjs.Application' });
+ let instance = new MyApplication({application_id: 'org.gjs.Application'});
let customSpy = jasmine.createSpy('customSpy');
instance.connect('custom', customSpy);
@@ -324,7 +328,7 @@ describe('GObject class with decorator', function () {
},
}, class InterfacePropObject extends GObject.Object {});
let file = Gio.File.new_for_path('dummy');
- expect(() => new InterfacePropObject({ file: file })).not.toThrow();
+ expect(() => new InterfacePropObject({file: file})).not.toThrow();
});
it('can override a property from the parent class', function () {
@@ -337,7 +341,7 @@ describe('GObject class with decorator', function () {
return this._subclass_readwrite;
}
set readwrite(val) {
- this._subclass_readwrite = 'subclass' + val;
+ this._subclass_readwrite = `subclass${val}`;
}
});
let obj = new OverrideObject();
diff --git a/installed-tests/js/testGObjectInterface.js b/installed-tests/js/testGObjectInterface.js
index 48ddf56a..b4cee294 100644
--- a/installed-tests/js/testGObjectInterface.js
+++ b/installed-tests/js/testGObjectInterface.js
@@ -5,7 +5,7 @@ const Mainloop = imports.mainloop;
const AGObjectInterface = GObject.registerClass({
GTypeName: 'ArbitraryGTypeName',
- Requires: [ GObject.Object ],
+ Requires: [GObject.Object],
Properties: {
'interface-prop': GObject.ParamSpec.string('interface-prop',
'Interface property', 'Must be overridden in implementation',
@@ -26,16 +26,16 @@ const AGObjectInterface = GObject.registerClass({
});
const InterfaceRequiringGObjectInterface = GObject.registerClass({
- Requires: [ AGObjectInterface ],
+ Requires: [AGObjectInterface],
}, class InterfaceRequiringGObjectInterface extends GObject.Interface {
optionalG() {
- return 'InterfaceRequiringGObjectInterface.optionalG()\n' +
- AGObjectInterface.optionalG(this);
+ return `InterfaceRequiringGObjectInterface.optionalG()\n${
+ AGObjectInterface.optionalG(this)}`;
}
});
const GObjectImplementingGObjectInterface = GObject.registerClass({
- Implements: [ AGObjectInterface ],
+ Implements: [AGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface),
@@ -62,7 +62,7 @@ const GObjectImplementingGObjectInterface = GObject.registerClass({
});
const MinimalImplementationOfAGObjectInterface = GObject.registerClass({
- Implements: [ AGObjectInterface ],
+ Implements: [AGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface)
@@ -72,7 +72,7 @@ const MinimalImplementationOfAGObjectInterface = GObject.registerClass({
});
const ImplementationOfTwoInterfaces = GObject.registerClass({
- Implements: [ AGObjectInterface, InterfaceRequiringGObjectInterface ],
+ Implements: [AGObjectInterface, InterfaceRequiringGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface)
@@ -115,8 +115,9 @@ describe('GObject interface', function () {
it('can be implemented by a GObject class', function () {
let obj;
- expect(() => { obj = new GObjectImplementingGObjectInterface(); })
- .not.toThrow();
+ expect(() => {
+ obj = new GObjectImplementingGObjectInterface();
+ }).not.toThrow();
expect(obj instanceof AGObjectInterface).toBeTruthy();
});
@@ -136,7 +137,7 @@ describe('GObject interface', function () {
it('must have its required function implemented', function () {
const BadObject = GObject.registerClass({
- Implements: [ AGObjectInterface ],
+ Implements: [AGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface)
@@ -148,8 +149,9 @@ describe('GObject interface', function () {
it("doesn't have to have its optional function implemented", function () {
let obj;
- expect(() => { obj = new MinimalImplementationOfAGObjectInterface(); })
- .not.toThrow();
+ expect(() => {
+ obj = new MinimalImplementationOfAGObjectInterface();
+ }).not.toThrow();
expect(obj instanceof AGObjectInterface).toBeTruthy();
});
@@ -165,7 +167,9 @@ describe('GObject interface', function () {
it('can require another interface', function () {
let obj;
- expect(() => { obj = new ImplementationOfTwoInterfaces(); }).not.toThrow();
+ expect(() => {
+ obj = new ImplementationOfTwoInterfaces();
+ }).not.toThrow();
expect(obj instanceof AGObjectInterface).toBeTruthy();
expect(obj instanceof InterfaceRequiringGObjectInterface).toBeTruthy();
});
@@ -178,7 +182,7 @@ describe('GObject interface', function () {
it("defers to the last interface's optional function", function () {
const MinimalImplementationOfTwoInterfaces = GObject.registerClass({
- Implements: [ AGObjectInterface, InterfaceRequiringGObjectInterface ],
+ Implements: [AGObjectInterface, InterfaceRequiringGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface)
@@ -193,7 +197,7 @@ describe('GObject interface', function () {
it('must be implemented by a class that implements all required interfaces', function () {
expect(() => GObject.registerClass({
- Implements: [ InterfaceRequiringGObjectInterface ],
+ Implements: [InterfaceRequiringGObjectInterface],
}, class BadObject {
required() {}
})).toThrow();
@@ -201,7 +205,7 @@ describe('GObject interface', function () {
it('must be implemented by a class that implements required interfaces in correct order', function () {
expect(() => GObject.registerClass({
- Implements: [ InterfaceRequiringGObjectInterface, AGObjectInterface ],
+ Implements: [InterfaceRequiringGObjectInterface, AGObjectInterface],
}, class BadObject {
required() {}
})).toThrow();
@@ -209,10 +213,10 @@ describe('GObject interface', function () {
it('can require an interface from C', function () {
const InitableInterface = GObject.registerClass({
- Requires: [ GObject.Object, Gio.Initable ]
+ Requires: [GObject.Object, Gio.Initable]
}, class InitableInterface extends GObject.Interface {});
expect(() => GObject.registerClass({
- Implements: [ InitableInterface ],
+ Implements: [InitableInterface],
}, class BadObject {})).toThrow();
});
@@ -254,7 +258,7 @@ describe('GObject interface', function () {
"Object class * doesn't implement property 'interface-prop' from " +
"interface 'ArbitraryGTypeName'");
GObject.registerClass({
- Implements: [ AGObjectInterface ],
+ Implements: [AGObjectInterface],
}, class MyNaughtyObject extends GObject.Object {
requiredG() {}
});
@@ -278,7 +282,7 @@ describe('GObject interface', function () {
it('can be reimplemented by a subclass of a class that already implements it', function () {
const SubImplementer = GObject.registerClass({
- Implements: [ AGObjectInterface ],
+ Implements: [AGObjectInterface],
}, class SubImplementer extends GObjectImplementingGObjectInterface {});
let obj = new SubImplementer();
expect(obj instanceof AGObjectInterface).toBeTruthy();
diff --git a/installed-tests/js/testGtk.js b/installed-tests/js/testGtk.js
index 6cae626b..02b89ff2 100755
--- a/installed-tests/js/testGtk.js
+++ b/installed-tests/js/testGtk.js
@@ -100,12 +100,12 @@ const MyComplexGtkSubclassFromFile = GObject.registerClass({
const SubclassSubclass = GObject.registerClass(
class SubclassSubclass extends MyComplexGtkSubclass {});
-function validateTemplate(description, ClassName, pending=false) {
+function validateTemplate(description, ClassName, pending = false) {
let suite = pending ? xdescribe : describe;
suite(description, function () {
let win, content;
beforeEach(function () {
- win = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL });
+ win = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
content = new ClassName();
content.label_child.emit('grab-focus');
win.add(content);
diff --git a/installed-tests/js/testImporter.js b/installed-tests/js/testImporter.js
index a68e1ad5..0f5a1a61 100644
--- a/installed-tests/js/testImporter.js
+++ b/installed-tests/js/testImporter.js
@@ -64,7 +64,7 @@ describe('Importer', function () {
it('throws an import error when trying to import a nonexistent module', function () {
expect(() => imports.nonexistentModuleName)
- .toThrow(jasmine.objectContaining({ name: 'ImportError' }));
+ .toThrow(jasmine.objectContaining({name: 'ImportError'}));
});
it('throws an error when evaluating the module file throws an error', function () {
diff --git a/installed-tests/js/testLang.js b/installed-tests/js/testLang.js
index ebef53ba..4e2697a0 100644
--- a/installed-tests/js/testLang.js
+++ b/installed-tests/js/testLang.js
@@ -6,12 +6,12 @@ const Lang = imports.lang;
describe('Lang module', function () {
it('counts properties with Lang.countProperties()', function () {
- var foo = { 'a' : 10, 'b' : 11 };
+ var foo = {'a': 10, 'b': 11};
expect(Lang.countProperties(foo)).toEqual(2);
});
it('copies properties from one object to another with Lang.copyProperties()', function () {
- var foo = { 'a' : 10, 'b' : 11 };
+ var foo = {'a': 10, 'b': 11};
var bar = {};
Lang.copyProperties(foo, bar);
@@ -19,17 +19,17 @@ describe('Lang module', function () {
});
it('copies properties without an underscore with Lang.copyPublicProperties()', function () {
- var foo = { 'a' : 10, 'b' : 11, '_c' : 12 };
+ var foo = {'a': 10, 'b': 11, '_c': 12};
var bar = {};
Lang.copyPublicProperties(foo, bar);
- expect(bar).toEqual({ 'a': 10, 'b': 11 });
+ expect(bar).toEqual({'a': 10, 'b': 11});
});
it('copies property getters and setters', function () {
var foo = {
- 'a' : 10,
- 'b' : 11,
+ 'a': 10,
+ 'b': 11,
get c() {
return this.a;
},
diff --git a/installed-tests/js/testLegacyClass.js b/installed-tests/js/testLegacyClass.js
index 3268ce6f..ae59099c 100644
--- a/installed-tests/js/testLegacyClass.js
+++ b/installed-tests/js/testLegacyClass.js
@@ -97,8 +97,8 @@ describe('A metaclass', function () {
});
it('gets all the properties from its class and metaclass', function () {
- expect(instanceOne).toEqual(jasmine.objectContaining({ one: 1, two: 2 }));
- expect(instanceTwo).toEqual(jasmine.objectContaining({ one: 1, two: 2 }));
+ expect(instanceOne).toEqual(jasmine.objectContaining({one: 1, two: 2}));
+ expect(instanceTwo).toEqual(jasmine.objectContaining({one: 1, two: 2}));
});
it('gets dynamically defined properties from metaclass', function () {
@@ -112,7 +112,7 @@ describe('A metaclass', function () {
expect(CustomMetaSubclass.DYNAMIC_CONSTANT).toEqual(2);
let instance = new CustomMetaSubclass();
- expect(instance).toEqual(jasmine.objectContaining({ one: 1, two: 2, three: 3 }));
+ expect(instance).toEqual(jasmine.objectContaining({one: 1, two: 2, three: 3}));
expect(instance.dynamic_method()).toEqual(73);
});
@@ -127,7 +127,8 @@ const MagicBase = new Lang.Class({
Name: 'MagicBase',
_init: function(a, buffer) {
- if (buffer) buffer.push(a);
+ if (buffer)
+ buffer.push(a);
this.a = a;
},
@@ -148,7 +149,8 @@ const Magic = new Lang.Class({
_init: function(a, b, buffer) {
this.parent(a, buffer);
- if (buffer) buffer.push(b);
+ if (buffer)
+ buffer.push(b);
this.b = b;
},
@@ -159,7 +161,7 @@ const Magic = new Lang.Class({
},
bar: function(a, buffer) {
- this.foo(a, 2*a, buffer);
+ this.foo(a, 2 * a, buffer);
return this.parent(a);
}
});
@@ -238,7 +240,7 @@ describe('Class framework', function () {
toString: function() {
let oldToString = this.parent();
- return oldToString + '; hello';
+ return `${oldToString}; hello`;
}
});
@@ -294,7 +296,7 @@ describe('Class framework', function () {
});
it('allows ES6 classes to inherit from abstract base classes', function() {
- class AbstractImpl extends AbstractBase {};
+ class AbstractImpl extends AbstractBase {}
let newAbstract = new AbstractImpl();
expect(newAbstract.foo).toEqual(42);
@@ -351,7 +353,7 @@ const AnInterface = new Lang.Interface({
},
argumentGeneric: function (arg) {
- return 'AnInterface.argumentGeneric(' + arg + ')';
+ return `AnInterface.argumentGeneric(${arg})`;
},
usesThis: function () {
@@ -373,22 +375,22 @@ const AnInterface = new Lang.Interface({
const InterfaceRequiringOtherInterface = new Lang.Interface({
Name: 'InterfaceRequiringOtherInterface',
- Requires: [ AnInterface ],
+ Requires: [AnInterface],
optional: function () {
- return 'InterfaceRequiringOtherInterface.optional()\n' +
- AnInterface.prototype.optional.apply(this, arguments);
+ return `InterfaceRequiringOtherInterface.optional()\n${
+ AnInterface.prototype.optional.apply(this, arguments)}`;
},
optionalGeneric: function () {
- return 'InterfaceRequiringOtherInterface.optionalGeneric()\n' +
- AnInterface.optionalGeneric(this);
+ return `InterfaceRequiringOtherInterface.optionalGeneric()\n${
+ AnInterface.optionalGeneric(this)}`;
}
});
const ObjectImplementingAnInterface = new Lang.Class({
Name: 'ObjectImplementingAnInterface',
- Implements: [ AnInterface ],
+ Implements: [AnInterface],
_init: function () {
this.parent();
@@ -405,25 +407,25 @@ const ObjectImplementingAnInterface = new Lang.Class({
},
argumentGeneric: function (arg) {
- return AnInterface.argumentGeneric(this, arg + ' (hello from class)');
+ return AnInterface.argumentGeneric(this, `${arg} (hello from class)`);
}
});
const InterfaceRequiringClassAndInterface = new Lang.Interface({
Name: 'InterfaceRequiringClassAndInterface',
- Requires: [ ObjectImplementingAnInterface, InterfaceRequiringOtherInterface ],
+ Requires: [ObjectImplementingAnInterface, InterfaceRequiringOtherInterface],
});
const MinimalImplementationOfAnInterface = new Lang.Class({
Name: 'MinimalImplementationOfAnInterface',
- Implements: [ AnInterface ],
+ Implements: [AnInterface],
required: function () {}
});
const ImplementationOfTwoInterfaces = new Lang.Class({
Name: 'ImplementationOfTwoInterfaces',
- Implements: [ AnInterface, InterfaceRequiringOtherInterface ],
+ Implements: [AnInterface, InterfaceRequiringOtherInterface],
required: function () {},
@@ -452,7 +454,9 @@ describe('An interface', function () {
it('can be implemented by a class', function () {
let obj;
- expect(() => { obj = new ObjectImplementingAnInterface(); }).not.toThrow();
+ expect(() => {
+ obj = new ObjectImplementingAnInterface();
+ }).not.toThrow();
expect(obj.constructor.implements(AnInterface)).toBeTruthy();
});
@@ -524,7 +528,7 @@ describe('An interface', function () {
it('can have its property getter overridden', function () {
const ObjectWithGetter = new Lang.Class({
Name: 'ObjectWithGetter',
- Implements: [ AnInterface ],
+ Implements: [AnInterface],
required: function () {},
get some_prop() {
return 'ObjectWithGetter.some_prop getter';
@@ -537,7 +541,7 @@ describe('An interface', function () {
it('can have its property setter overridden', function () {
const ObjectWithSetter = new Lang.Class({
Name: 'ObjectWithSetter',
- Implements: [ AnInterface ],
+ Implements: [AnInterface],
required: function () {},
set some_prop(value) { /* setter without getter */// jshint ignore:line
this.overridden_some_prop_setter_called = true;
@@ -551,7 +555,9 @@ describe('An interface', function () {
it('can require another interface', function () {
let obj;
- expect(() => { obj = new ImplementationOfTwoInterfaces(); }).not.toThrow();
+ expect(() => {
+ obj = new ImplementationOfTwoInterfaces();
+ }).not.toThrow();
expect(obj.constructor.implements(AnInterface)).toBeTruthy();
expect(obj.constructor.implements(InterfaceRequiringOtherInterface)).toBeTruthy();
});
@@ -583,7 +589,7 @@ describe('An interface', function () {
it('has its optional function defer to that of the last interface', function () {
const MinimalImplementationOfTwoInterfaces = new Lang.Class({
Name: 'MinimalImplementationOfTwoInterfaces',
- Implements: [ AnInterface, InterfaceRequiringOtherInterface ],
+ Implements: [AnInterface, InterfaceRequiringOtherInterface],
required: function () {}
});
@@ -595,7 +601,7 @@ describe('An interface', function () {
it('must have all its required interfaces implemented', function () {
expect(() => new Lang.Class({
Name: 'ObjectWithNotEnoughInterfaces',
- Implements: [ InterfaceRequiringOtherInterface ],
+ Implements: [InterfaceRequiringOtherInterface],
required: function () {}
})).toThrow();
});
@@ -603,7 +609,7 @@ describe('An interface', function () {
it('must have all its required interfaces implemented in the correct order', function () {
expect(() => new Lang.Class({
Name: 'ObjectWithInterfacesInWrongOrder',
- Implements: [ InterfaceRequiringOtherInterface, AnInterface ],
+ Implements: [InterfaceRequiringOtherInterface, AnInterface],
required: function () {}
})).toThrow();
});
@@ -614,7 +620,7 @@ describe('An interface', function () {
const ObjectInheritingFromInterfaceImplementation = new Lang.Class({
Name: 'ObjectInheritingFromInterfaceImplementation',
Extends: ObjectImplementingAnInterface,
- Implements: [ InterfaceRequiringOtherInterface ],
+ Implements: [InterfaceRequiringOtherInterface],
});
obj = new ObjectInheritingFromInterfaceImplementation();
}).not.toThrow();
@@ -628,7 +634,7 @@ describe('An interface', function () {
const ObjectImplementingInterfaceRequiringParentObject = new Lang.Class({
Name: 'ObjectImplementingInterfaceRequiringParentObject',
Extends: ObjectImplementingAnInterface,
- Implements: [ InterfaceRequiringOtherInterface, InterfaceRequiringClassAndInterface ]
+ Implements: [InterfaceRequiringOtherInterface, InterfaceRequiringClassAndInterface]
});
obj = new ObjectImplementingInterfaceRequiringParentObject();
}).not.toThrow();
@@ -640,7 +646,7 @@ describe('An interface', function () {
it('must be implemented by an object which subclasses the required class', function () {
expect(() => new Lang.Class({
Name: 'ObjectWithoutRequiredParent',
- Implements: [ AnInterface, InterfaceRequiringOtherInterface, InterfaceRequiringClassAndInterface
],
+ Implements: [AnInterface, InterfaceRequiringOtherInterface, InterfaceRequiringClassAndInterface],
required: function () {},
})).toThrow();
});
@@ -663,7 +669,7 @@ describe('An interface', function () {
const SubImplementer = new Lang.Class({
Name: 'SubImplementer',
Extends: ObjectImplementingAnInterface,
- Implements: [ AnInterface ]
+ Implements: [AnInterface]
});
let obj = new SubImplementer();
expect(obj.constructor.implements(AnInterface)).toBeTruthy();
@@ -689,8 +695,12 @@ describe('ES6 class inheriting from Lang.Class', function () {
chainUpToMe() {},
overrideMe() {},
- get property() { return this._property + 1; },
- set property(value) { this._property = value - 2; },
+ get property() {
+ return this._property + 1;
+ },
+ set property(value) {
+ this._property = value - 2;
+ },
});
Legacy.staticMethod = function () {};
spyOn(Legacy, 'staticMethod');
@@ -703,7 +713,9 @@ describe('ES6 class inheriting from Lang.Class', function () {
super(someval);
}
- chainUpToMe() { super.chainUpToMe(); }
+ chainUpToMe() {
+ super.chainUpToMe();
+ }
overrideMe() {}
};
});
diff --git a/installed-tests/js/testLegacyGObject.js b/installed-tests/js/testLegacyGObject.js
index 1d92887b..d03e744c 100644
--- a/installed-tests/js/testLegacyGObject.js
+++ b/installed-tests/js/testLegacyGObject.js
@@ -24,17 +24,17 @@ const MyObject = new GObject.Class({
},
Signals: {
'empty': { },
- 'minimal': { param_types: [ GObject.TYPE_INT, GObject.TYPE_INT ] },
+ 'minimal': {param_types: [GObject.TYPE_INT, GObject.TYPE_INT]},
'full': {
flags: GObject.SignalFlags.RUN_LAST,
accumulator: GObject.AccumulatorType.FIRST_WINS,
return_type: GObject.TYPE_INT,
param_types: [],
},
- 'run-last': { flags: GObject.SignalFlags.RUN_LAST },
+ 'run-last': {flags: GObject.SignalFlags.RUN_LAST},
'detailed': {
flags: GObject.SignalFlags.RUN_FIRST | GObject.SignalFlags.DETAILED,
- param_types: [ GObject.TYPE_STRING ],
+ param_types: [GObject.TYPE_STRING],
},
},
@@ -127,7 +127,7 @@ const MyObject = new GObject.Class({
const MyApplication = new Lang.Class({
Name: 'MyApplication',
Extends: Gio.Application,
- Signals: { 'custom': { param_types: [ GObject.TYPE_INT ] } },
+ Signals: {'custom': {param_types: [GObject.TYPE_INT]}},
_init: function(params) {
this.parent(params);
@@ -141,7 +141,7 @@ const MyApplication = new Lang.Class({
const MyInitable = new Lang.Class({
Name: 'MyInitable',
Extends: GObject.Object,
- Implements: [ Gio.Initable ],
+ Implements: [Gio.Initable],
_init: function(params) {
this.parent(params);
@@ -162,7 +162,7 @@ const Derived = new Lang.Class({
Extends: MyObject,
_init: function() {
- this.parent({ readwrite: 'yes' });
+ this.parent({readwrite: 'yes'});
}
});
@@ -199,7 +199,7 @@ describe('GObject class', function () {
});
it('constructs with a hash of property values', function () {
- let myInstance2 = new MyObject({ readwrite: 'baz', construct: 'asdf' });
+ let myInstance2 = new MyObject({readwrite: 'baz', construct: 'asdf'});
expect(myInstance2.readwrite).toEqual('baz');
expect(myInstance2.readonly).toEqual('bar');
expect(myInstance2.construct).toEqual('asdf');
@@ -282,18 +282,22 @@ describe('GObject class', function () {
});
it('calls run-last default handler last', function () {
- let stack = [ ];
+ let stack = [];
let runLastSpy = jasmine.createSpy('runLastSpy')
- .and.callFake(() => { stack.push(1); });
+ .and.callFake(() => {
+ stack.push(1);
+ });
myInstance.connect('run-last', runLastSpy);
- myInstance.emit_run_last(() => { stack.push(2); });
+ myInstance.emit_run_last(() => {
+ stack.push(2);
+ });
expect(stack).toEqual([1, 2]);
});
it("can inherit from something that's not GObject.Object", function () {
// ...and still get all the goodies of GObject.Class
- let instance = new MyApplication({ application_id: 'org.gjs.Application' });
+ let instance = new MyApplication({application_id: 'org.gjs.Application'});
let customSpy = jasmine.createSpy('customSpy');
instance.connect('custom', customSpy);
@@ -346,7 +350,7 @@ describe('GObject class', function () {
},
});
let file = Gio.File.new_for_path('dummy');
- expect(() => new InterfacePropObject({ file: file })).not.toThrow();
+ expect(() => new InterfacePropObject({file: file})).not.toThrow();
});
it('can override a property from the parent class', function () {
@@ -360,7 +364,7 @@ describe('GObject class', function () {
return this._subclass_readwrite;
},
set readwrite(val) {
- this._subclass_readwrite = 'subclass' + val;
+ this._subclass_readwrite = `subclass${val}`;
},
});
let obj = new OverrideObject();
@@ -386,9 +390,9 @@ const AnInterface = new Lang.Interface({
const GObjectImplementingLangInterface = new Lang.Class({
Name: 'GObjectImplementingLangInterface',
Extends: GObject.Object,
- Implements: [ AnInterface ],
+ Implements: [AnInterface],
- _init: function (props={}) {
+ _init: function (props = {}) {
this.parent(props);
}
});
@@ -396,7 +400,7 @@ const GObjectImplementingLangInterface = new Lang.Class({
const AGObjectInterface = new Lang.Interface({
Name: 'AGObjectInterface',
GTypeName: 'ArbitraryGTypeName',
- Requires: [ GObject.Object ],
+ Requires: [GObject.Object],
Properties: {
'interface-prop': GObject.ParamSpec.string('interface-prop',
'Interface property', 'Must be overridden in implementation',
@@ -415,18 +419,18 @@ const AGObjectInterface = new Lang.Interface({
const InterfaceRequiringGObjectInterface = new Lang.Interface({
Name: 'InterfaceRequiringGObjectInterface',
- Requires: [ AGObjectInterface ],
+ Requires: [AGObjectInterface],
optionalG: function () {
- return 'InterfaceRequiringGObjectInterface.optionalG()\n' +
- AGObjectInterface.optionalG(this);
+ return `InterfaceRequiringGObjectInterface.optionalG()\n${
+ AGObjectInterface.optionalG(this)}`;
}
});
const GObjectImplementingGObjectInterface = new Lang.Class({
Name: 'GObjectImplementingGObjectInterface',
Extends: GObject.Object,
- Implements: [ AGObjectInterface ],
+ Implements: [AGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface),
@@ -446,7 +450,7 @@ const GObjectImplementingGObjectInterface = new Lang.Class({
return 'meh';
},
- _init: function (props={}) {
+ _init: function (props = {}) {
this.parent(props);
},
requiredG: function () {},
@@ -458,13 +462,13 @@ const GObjectImplementingGObjectInterface = new Lang.Class({
const MinimalImplementationOfAGObjectInterface = new Lang.Class({
Name: 'MinimalImplementationOfAGObjectInterface',
Extends: GObject.Object,
- Implements: [ AGObjectInterface ],
+ Implements: [AGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface)
},
- _init: function (props={}) {
+ _init: function (props = {}) {
this.parent(props);
},
requiredG: function () {}
@@ -473,13 +477,13 @@ const MinimalImplementationOfAGObjectInterface = new Lang.Class({
const ImplementationOfTwoInterfaces = new Lang.Class({
Name: 'ImplementationOfTwoInterfaces',
Extends: GObject.Object,
- Implements: [ AGObjectInterface, InterfaceRequiringGObjectInterface ],
+ Implements: [AGObjectInterface, InterfaceRequiringGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface)
},
- _init: function (props={}) {
+ _init: function (props = {}) {
this.parent(props);
},
requiredG: function () {},
@@ -491,8 +495,9 @@ const ImplementationOfTwoInterfaces = new Lang.Class({
describe('GObject interface', function () {
it('class can implement a Lang.Interface', function () {
let obj;
- expect(() => { obj = new GObjectImplementingLangInterface(); })
- .not.toThrow();
+ expect(() => {
+ obj = new GObjectImplementingLangInterface();
+ }).not.toThrow();
expect(obj.constructor.implements(AnInterface)).toBeTruthy();
});
@@ -500,7 +505,7 @@ describe('GObject interface', function () {
expect(() => new Lang.Interface({
Name: 'GObjectInterfaceNotRequiringGObject',
GTypeName: 'GTypeNameNotRequiringGObject',
- Requires: [ Gio.Initable ]
+ Requires: [Gio.Initable]
})).toThrow();
});
@@ -508,15 +513,16 @@ describe('GObject interface', function () {
const ObjectImplementingLangInterfaceAndCInterface = new Lang.Class({
Name: 'ObjectImplementingLangInterfaceAndCInterface',
Extends: GObject.Object,
- Implements: [ AnInterface, Gio.Initable ],
+ Implements: [AnInterface, Gio.Initable],
- _init: function (props={}) {
+ _init: function (props = {}) {
this.parent(props);
}
});
let obj;
- expect(() => { obj = new ObjectImplementingLangInterfaceAndCInterface(); })
- .not.toThrow();
+ expect(() => {
+ obj = new ObjectImplementingLangInterfaceAndCInterface();
+ }).not.toThrow();
expect(obj.constructor.implements(AnInterface)).toBeTruthy();
expect(obj.constructor.implements(Gio.Initable)).toBeTruthy();
});
@@ -540,8 +546,9 @@ describe('GObject interface', function () {
it('can be implemented by a GObject class', function () {
let obj;
- expect(() => { obj = new GObjectImplementingGObjectInterface(); })
- .not.toThrow();
+ expect(() => {
+ obj = new GObjectImplementingGObjectInterface();
+ }).not.toThrow();
expect(obj.constructor.implements(AGObjectInterface)).toBeTruthy();
});
@@ -556,21 +563,22 @@ describe('GObject interface', function () {
const GObjectImplementingBothKindsOfInterface = new Lang.Class({
Name: 'GObjectImplementingBothKindsOfInterface',
Extends: GObject.Object,
- Implements: [ AnInterface, AGObjectInterface ],
+ Implements: [AnInterface, AGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface)
},
- _init: function (props={}) {
+ _init: function (props = {}) {
this.parent(props);
},
required: function () {},
requiredG: function () {}
});
let obj;
- expect(() => { obj = new GObjectImplementingBothKindsOfInterface(); })
- .not.toThrow();
+ expect(() => {
+ obj = new GObjectImplementingBothKindsOfInterface();
+ }).not.toThrow();
expect(obj.constructor.implements(AnInterface)).toBeTruthy();
expect(obj.constructor.implements(AGObjectInterface)).toBeTruthy();
});
@@ -586,7 +594,7 @@ describe('GObject interface', function () {
expect(() => new Lang.Class({
Name: 'BadObject',
Extends: GObject.Object,
- Implements: [ AGObjectInterface ],
+ Implements: [AGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface)
@@ -596,8 +604,9 @@ describe('GObject interface', function () {
it("doesn't have to have its optional function implemented", function () {
let obj;
- expect(() => { obj = new MinimalImplementationOfAGObjectInterface(); })
- .not.toThrow();
+ expect(() => {
+ obj = new MinimalImplementationOfAGObjectInterface();
+ }).not.toThrow();
expect(obj.constructor.implements(AGObjectInterface)).toBeTruthy();
});
@@ -613,7 +622,9 @@ describe('GObject interface', function () {
it('can require another interface', function () {
let obj;
- expect(() => { obj = new ImplementationOfTwoInterfaces(); }).not.toThrow();
+ expect(() => {
+ obj = new ImplementationOfTwoInterfaces();
+ }).not.toThrow();
expect(obj.constructor.implements(AGObjectInterface)).toBeTruthy();
expect(obj.constructor.implements(InterfaceRequiringGObjectInterface))
.toBeTruthy();
@@ -629,13 +640,13 @@ describe('GObject interface', function () {
const MinimalImplementationOfTwoInterfaces = new Lang.Class({
Name: 'MinimalImplementationOfTwoInterfaces',
Extends: GObject.Object,
- Implements: [ AGObjectInterface, InterfaceRequiringGObjectInterface ],
+ Implements: [AGObjectInterface, InterfaceRequiringGObjectInterface],
Properties: {
'interface-prop': GObject.ParamSpec.override('interface-prop',
AGObjectInterface)
},
- _init: function (props={}) {
+ _init: function (props = {}) {
this.parent(props);
},
requiredG: function () {}
@@ -648,7 +659,7 @@ describe('GObject interface', function () {
it('must be implemented by a class that implements all required interfaces', function () {
expect(() => new Lang.Class({
Name: 'BadObject',
- Implements: [ InterfaceRequiringGObjectInterface ],
+ Implements: [InterfaceRequiringGObjectInterface],
required: function () {}
})).toThrow();
});
@@ -656,7 +667,7 @@ describe('GObject interface', function () {
it('must be implemented by a class that implements required interfaces in correct order', function () {
expect(() => new Lang.Class({
Name: 'BadObject',
- Implements: [ InterfaceRequiringGObjectInterface, AGObjectInterface ],
+ Implements: [InterfaceRequiringGObjectInterface, AGObjectInterface],
required: function () {}
})).toThrow();
});
@@ -664,11 +675,11 @@ describe('GObject interface', function () {
it('can require an interface from C', function () {
const InitableInterface = new Lang.Interface({
Name: 'InitableInterface',
- Requires: [ GObject.Object, Gio.Initable ]
+ Requires: [GObject.Object, Gio.Initable]
});
expect(() => new Lang.Class({
Name: 'BadObject',
- Implements: [ InitableInterface ]
+ Implements: [InitableInterface]
})).toThrow();
});
@@ -712,8 +723,8 @@ describe('GObject interface', function () {
new Lang.Class({
Name: 'MyNaughtyObject',
Extends: GObject.Object,
- Implements: [ AGObjectInterface ],
- _init: function (props={}) {
+ Implements: [AGObjectInterface],
+ _init: function (props = {}) {
this.parent(props);
},
requiredG: function () {}
@@ -736,7 +747,7 @@ describe('GObject interface', function () {
});
const MyMetaInterface = new Lang.Interface({
Name: 'MyMetaInterface',
- Requires: [ MyMetaObject ]
+ Requires: [MyMetaObject]
});
expect(MyMetaInterface instanceof GObject.Interface).toBeTruthy();
});
@@ -755,7 +766,7 @@ describe('GObject interface', function () {
const SubImplementer = new Lang.Class({
Name: 'SubImplementer',
Extends: GObjectImplementingGObjectInterface,
- Implements: [ AGObjectInterface ]
+ Implements: [AGObjectInterface]
});
let obj = new SubImplementer();
expect(obj.constructor.implements(AGObjectInterface)).toBeTruthy();
@@ -766,13 +777,13 @@ describe('GObject interface', function () {
const LegacyInterface1 = new Lang.Interface({
Name: 'LegacyInterface1',
Requires: [GObject.Object],
- Signals: { 'legacy-iface1-signal': {} },
+ Signals: {'legacy-iface1-signal': {}},
});
const LegacyInterface2 = new Lang.Interface({
Name: 'LegacyInterface2',
Requires: [GObject.Object],
- Signals: { 'legacy-iface2-signal': {} },
+ Signals: {'legacy-iface2-signal': {}},
});
const Legacy = new Lang.Class({
@@ -799,11 +810,19 @@ const Legacy = new Lang.Class({
chainUpToMe() {},
overrideMe() {},
- get property() { return this._property + 1; },
- set property(value) { this._property = value - 2; },
+ get property() {
+ return this._property + 1;
+ },
+ set property(value) {
+ this._property = value - 2;
+ },
- get override_property() { return this._override_property + 1; },
- set override_property(value) { this._override_property = value - 2; },
+ get override_property() {
+ return this._override_property + 1;
+ },
+ set override_property(value) {
+ this._override_property = value - 2;
+ },
});
Legacy.staticMethod = function () {};
@@ -820,8 +839,12 @@ const Shiny = GObject.registerClass({
overrideMe() {}
- get override_property() { return this._override_property + 2; }
- set override_property(value) { this._override_property = value - 1; }
+ get override_property() {
+ return this._override_property + 2;
+ }
+ set override_property(value) {
+ this._override_property = value - 1;
+ }
});
describe('ES6 GObject class inheriting from GObject.Class', function () {
diff --git a/installed-tests/js/testLegacyGtk.js b/installed-tests/js/testLegacyGtk.js
index 1a138ef2..ee78e576 100644
--- a/installed-tests/js/testLegacyGtk.js
+++ b/installed-tests/js/testLegacyGtk.js
@@ -71,7 +71,7 @@ function validateTemplate(description, ClassName) {
describe(description, function () {
let win, content;
beforeEach(function () {
- win = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL });
+ win = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
content = new ClassName();
win.add(content);
});
diff --git a/installed-tests/js/testLocale.js b/installed-tests/js/testLocale.js
index edd8a6e7..f6084487 100644
--- a/installed-tests/js/testLocale.js
+++ b/installed-tests/js/testLocale.js
@@ -6,7 +6,7 @@ describe('JS_SetLocaleCallbacks', function () {
// Requesting the weekday name tests locale_to_unicode
it('toLocaleDateString() works', function () {
let date = new Date('12/15/1981');
- let datestr = date.toLocaleDateString('pt-BR', { weekday: 'long' });
+ let datestr = date.toLocaleDateString('pt-BR', {weekday: 'long'});
expect(datestr).toEqual('terça-feira');
});
diff --git a/installed-tests/js/testParamSpec.js b/installed-tests/js/testParamSpec.js
index 7ac0ad45..77cb0299 100644
--- a/installed-tests/js/testParamSpec.js
+++ b/installed-tests/js/testParamSpec.js
@@ -7,7 +7,7 @@ let blurb = 'This is the foo property';
let flags = GObject.ParamFlags.READABLE;
function testParamSpec(type, params, defaultValue) {
- describe('GObject.ParamSpec.' + type, function () {
+ describe(`GObject.ParamSpec.${type}`, function () {
let paramSpec;
beforeEach(function () {
paramSpec = GObject.ParamSpec[type].apply(GObject.ParamSpec,
diff --git a/installed-tests/js/testSignals.js b/installed-tests/js/testSignals.js
index bdb449c6..c66ef8b4 100644
--- a/installed-tests/js/testSignals.js
+++ b/installed-tests/js/testSignals.js
@@ -30,17 +30,17 @@ function testSignals(klass) {
it('calls a signal handler when a signal is emitted', function () {
foo.connect('bar', bar);
- foo.emit('bar', "This is a", "This is b");
+ foo.emit('bar', 'This is a', 'This is b');
expect(bar).toHaveBeenCalledWith(foo, 'This is a', 'This is b');
});
it('does not call a signal handler after the signal is disconnected', function () {
let id = foo.connect('bar', bar);
- foo.emit('bar', "This is a", "This is b");
+ foo.emit('bar', 'This is a', 'This is b');
bar.calls.reset();
foo.disconnect(id);
// this emission should do nothing
- foo.emit('bar', "Another a", "Another b");
+ foo.emit('bar', 'Another a', 'Another b');
expect(bar).not.toHaveBeenCalled();
});
@@ -109,7 +109,7 @@ function testSignals(klass) {
foo.connect('bar', bar);
foo.connect('bar', bar2);
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
- 'JS ERROR: Exception in callback for signal: *');
+ 'JS ERROR: Exception in callback for signal: *');
foo.emit('bar');
});
@@ -120,7 +120,7 @@ function testSignals(klass) {
it('does not disconnect the callback', function () {
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
- 'JS ERROR: Exception in callback for signal: *');
+ 'JS ERROR: Exception in callback for signal: *');
foo.emit('bar');
expect(bar).toHaveBeenCalledTimes(2);
expect(bar2).toHaveBeenCalledTimes(2);
diff --git a/installed-tests/js/testTweener.js b/installed-tests/js/testTweener.js
index 9e891ae7..14951bda 100644
--- a/installed-tests/js/testTweener.js
+++ b/installed-tests/js/testTweener.js
@@ -6,10 +6,10 @@ function installFrameTicker() {
let ticker = {
FRAME_RATE: 50,
- _init : function() {
+ _init: function() {
},
- start : function() {
+ start: function() {
this._currentTime = 0;
this._timeoutID = setInterval(() => {
@@ -18,7 +18,7 @@ function installFrameTicker() {
}, Math.floor(1000 / this.FRAME_RATE));
},
- stop : function() {
+ stop: function() {
if ('_timeoutID' in this) {
clearInterval(this._timeoutID);
delete this._timeoutID;
@@ -27,7 +27,7 @@ function installFrameTicker() {
this._currentTime = 0;
},
- getTime : function() {
+ getTime: function() {
return this._currentTime;
}
};
@@ -65,8 +65,8 @@ describe('Tweener', function () {
y: 0
};
- Tweener.addTween(objectA, { x: 10, y: 10, time: 1, transition: "linear" });
- Tweener.addTween(objectB, { x: 10, y: 10, time: 1, delay: 0.5, transition: "linear" });
+ Tweener.addTween(objectA, {x: 10, y: 10, time: 1, transition: 'linear'});
+ Tweener.addTween(objectB, {x: 10, y: 10, time: 1, delay: 0.5, transition: 'linear'});
jasmine.clock().tick(1001);
@@ -103,16 +103,16 @@ describe('Tweener', function () {
baaz: 0
};
- Tweener.addTween(objectA, { foo: 100, time: 0.1 });
- Tweener.addTween(objectC, { baaz: 100, time: 0.1 });
- Tweener.addTween(objectB, { bar: 100, time: 0.1 });
+ Tweener.addTween(objectA, {foo: 100, time: 0.1});
+ Tweener.addTween(objectC, {baaz: 100, time: 0.1});
+ Tweener.addTween(objectB, {bar: 100, time: 0.1});
Tweener.pauseTweens(objectA);
// This should do nothing
expect(Tweener.pauseTweens(objectB, 'quux')).toBeFalsy();
/* Pause and resume should be equal to doing nothing */
- Tweener.pauseTweens(objectC, "baaz");
- Tweener.resumeTweens(objectC, "baaz");
+ Tweener.pauseTweens(objectC, 'baaz');
+ Tweener.resumeTweens(objectC, 'baaz');
jasmine.clock().tick(101);
@@ -128,12 +128,12 @@ describe('Tweener', function () {
baaz: 0
};
- Tweener.addTween(object, { foo: 50, time: 0.1 });
- Tweener.addTween(object, { bar: 50, time: 0.1 });
- Tweener.addTween(object, { baaz: 50, time: 0.1});
+ Tweener.addTween(object, {foo: 50, time: 0.1});
+ Tweener.addTween(object, {bar: 50, time: 0.1});
+ Tweener.addTween(object, {baaz: 50, time: 0.1});
/* The Tween on property foo should still be run after removing the other two */
- Tweener.removeTweens(object, "bar", "baaz");
+ Tweener.removeTweens(object, 'bar', 'baaz');
jasmine.clock().tick(101);
@@ -147,8 +147,8 @@ describe('Tweener', function () {
foo: 0
};
- Tweener.addTween(objectA, { foo: 100, time: 0.1 });
- Tweener.addTween(objectA, { foo: 0, time: 0.1 });
+ Tweener.addTween(objectA, {foo: 100, time: 0.1});
+ Tweener.addTween(objectA, {foo: 0, time: 0.1});
jasmine.clock().tick(101);
@@ -163,8 +163,8 @@ describe('Tweener', function () {
/* In this case both tweens should be executed, as they don't
* act on the object at the same time (the second one has a
* delay equal to the running time of the first one) */
- Tweener.addTween(objectB, { bar: 100, time: 0.1 });
- Tweener.addTween(objectB, { bar: 150, time: 0.1, delay: 0.1 });
+ Tweener.addTween(objectB, {bar: 100, time: 0.1});
+ Tweener.addTween(objectB, {bar: 150, time: 0.1, delay: 0.1});
jasmine.clock(0).tick(201);
@@ -179,8 +179,8 @@ describe('Tweener', function () {
bar: 0
};
- Tweener.addTween(objectA, { foo: 100, time: 0.1 });
- Tweener.addTween(objectB, { bar: 100, time: 0.1 });
+ Tweener.addTween(objectA, {foo: 100, time: 0.1});
+ Tweener.addTween(objectB, {bar: 100, time: 0.1});
Tweener.pauseAllTweens();
@@ -202,8 +202,8 @@ describe('Tweener', function () {
bar: 0
};
- Tweener.addTween(objectA, { foo: 100, time: 0.1 });
- Tweener.addTween(objectB, { bar: 100, time: 0.1 });
+ Tweener.addTween(objectA, {foo: 100, time: 0.1});
+ Tweener.addTween(objectB, {bar: 100, time: 0.1});
Tweener.removeAllTweens();
@@ -218,8 +218,10 @@ describe('Tweener', function () {
foo: 100
};
- Tweener.addTween(object, { foo: 50, time: 0, delay: 0 });
- Tweener.addTween(object, { foo: 200, time: 0.1,
+ Tweener.addTween(object, {foo: 50, time: 0, delay: 0});
+ Tweener.addTween(object, {
+ foo: 200,
+ time: 0.1,
onStart: () => {
/* The immediate tween should set it to 50 before we run */
expect(object.foo).toEqual(50);
@@ -237,7 +239,9 @@ describe('Tweener', function () {
};
Tweener.addCaller(object, {
- onUpdate: () => { object.foo += 1; },
+ onUpdate: () => {
+ object.foo += 1;
+ },
count: 10,
time: 0.1,
});
@@ -257,13 +261,13 @@ describe('Tweener', function () {
expect(Tweener.getTweenCount(object)).toEqual(0);
- Tweener.addTween(object, { foo: 100, time: 0.1 });
+ Tweener.addTween(object, {foo: 100, time: 0.1});
expect(Tweener.getTweenCount(object)).toEqual(1);
- Tweener.addTween(object, { bar: 100, time: 0.1 });
+ Tweener.addTween(object, {bar: 100, time: 0.1});
expect(Tweener.getTweenCount(object)).toEqual(2);
- Tweener.addTween(object, { baaz: 100, time: 0.1 });
+ Tweener.addTween(object, {baaz: 100, time: 0.1});
expect(Tweener.getTweenCount(object)).toEqual(3);
- Tweener.addTween(object, { quux: 100, time: 0.1 });
+ Tweener.addTween(object, {quux: 100, time: 0.1});
expect(Tweener.getTweenCount(object)).toEqual(4);
Tweener.removeTweens(object, 'bar', 'baaz');
@@ -273,8 +277,12 @@ describe('Tweener', function () {
it('can register special properties', function () {
Tweener.registerSpecialProperty(
'negative_x',
- function(obj) { return -obj.x; },
- function(obj, val) { obj.x = -val; }
+ function(obj) {
+ return -obj.x;
+ },
+ function(obj, val) {
+ obj.x = -val;
+ }
);
var objectA = {
@@ -282,7 +290,7 @@ describe('Tweener', function () {
y: 0
};
- Tweener.addTween(objectA, { negative_x: 10, y: 10, time: 1, transition: "linear" });
+ Tweener.addTween(objectA, {negative_x: 10, y: 10, time: 1, transition: 'linear'});
jasmine.clock().tick(1001);
@@ -292,10 +300,12 @@ describe('Tweener', function () {
it('can register special modifiers for properties', function () {
Tweener.registerSpecialPropertyModifier('discrete',
- discrete_modifier,
- discrete_get);
+ discrete_modifier,
+ discrete_get);
function discrete_modifier(props) {
- return props.map(function (prop) { return { name: prop, parameters: null }; });
+ return props.map(function (prop) {
+ return {name: prop, parameters: null};
+ });
}
function discrete_get(begin, end, time, params) {
return Math.floor(begin + time * (end - begin));
@@ -308,9 +318,10 @@ describe('Tweener', function () {
yFraction: false
};
- Tweener.addTween(objectA, { x: 10, y: 10, time: 1,
- discrete: ["x"],
- transition: "linear",
+ Tweener.addTween(objectA, {
+ x: 10, y: 10, time: 1,
+ discrete: ['x'],
+ transition: 'linear',
onUpdate: function() {
if (objectA.x != Math.floor(objectA.x))
objectA.xFraction = true;
@@ -330,8 +341,10 @@ describe('Tweener', function () {
it('can split properties into more than one special property', function () {
Tweener.registerSpecialPropertySplitter(
'xnegy',
- function(val) { return [ { name: "x", value: val },
- { name: "y", value: -val } ]; }
+ function(val) {
+ return [{name: 'x', value: val},
+ {name: 'y', value: -val}];
+ }
);
var objectA = {
@@ -339,7 +352,7 @@ describe('Tweener', function () {
y: 0
};
- Tweener.addTween(objectA, { xnegy: 10, time: 1, transition: "linear" });
+ Tweener.addTween(objectA, {xnegy: 10, time: 1, transition: 'linear'});
jasmine.clock().tick(1001);
@@ -355,12 +368,14 @@ describe('Tweener', function () {
d: 0
};
- var tweenA = { a: 10, b: 10, c: 10, d: 10, time: 0.1,
+ var tweenA = {
+ a: 10, b: 10, c: 10, d: 10, time: 0.1,
onStart: start,
onOverwrite: overwrite,
onComplete: complete,
};
- var tweenB = { a: 20, b: 20, c: 20, d: 20, time: 0.1,
+ var tweenB = {
+ a: 20, b: 20, c: 20, d: 20, time: 0.1,
onStart: start,
onOverwrite: overwrite,
onComplete: complete,
@@ -384,7 +399,8 @@ describe('Tweener', function () {
d: 0
};
- var tweenA = { a: 10, b: 10, c: 10, d: 10, time: 0.1,
+ var tweenA = {
+ a: 10, b: 10, c: 10, d: 10, time: 0.1,
onStart: () => {
start();
Tweener.addTween(object, tweenB);
@@ -392,7 +408,8 @@ describe('Tweener', function () {
onOverwrite: overwrite,
onComplete: complete,
};
- var tweenB = { a: 20, b: 20, c: 20, d: 20, time: 0.1,
+ var tweenB = {
+ a: 20, b: 20, c: 20, d: 20, time: 0.1,
onStart: start,
onOverwrite: overwrite,
onComplete: complete,
@@ -418,8 +435,8 @@ describe('Tweener', function () {
y: 0
};
- Tweener.addTween(objectA, { x: 300, y: 300, time: 1, max: 255, transition: "linear" });
- Tweener.addTween(objectB, { x: -200, y: -200, time: 1, delay: 0.5, min: 0, transition: "linear" });
+ Tweener.addTween(objectA, {x: 300, y: 300, time: 1, max: 255, transition: 'linear'});
+ Tweener.addTween(objectB, {x: -200, y: -200, time: 1, delay: 0.5, min: 0, transition: 'linear'});
jasmine.clock().tick(1001);
diff --git a/installed-tests/js/testself.js b/installed-tests/js/testself.js
index 5899ab50..810acb72 100644
--- a/installed-tests/js/testself.js
+++ b/installed-tests/js/testself.js
@@ -3,8 +3,8 @@ describe('Test harness internal consistency', function () {
var someUndefined;
var someNumber = 1;
var someOtherNumber = 42;
- var someString = "hello";
- var someOtherString = "world";
+ var someString = 'hello';
+ var someOtherString = 'world';
expect(true).toBeTruthy();
expect(false).toBeFalsy();
@@ -22,7 +22,9 @@ describe('Test harness internal consistency', function () {
expect(0 / 0).toBeNaN();
expect(someNumber).not.toBeNaN();
- expect(() => { throw {}; }).toThrow();
+ expect(() => {
+ throw {};
+ }).toThrow();
expect(() => expect(true).toThrow()).toThrow();
expect(() => true).not.toThrow();
diff --git a/modules/_bootstrap/debugger.js b/modules/_bootstrap/debugger.js
index f3cbb9ef..02ccb35a 100644
--- a/modules/_bootstrap/debugger.js
+++ b/modules/_bootstrap/debugger.js
@@ -350,7 +350,7 @@ PARAMETER
function frameCommand(rest) {
let n, f;
if (rest.match(/[0-9]+/)) {
- n = +rest;
+ n = Number(rest);
f = topFrame;
if (f === null) {
print('No stack.');
diff --git a/modules/_legacy.js b/modules/_legacy.js
index 8c4b22c3..40b69276 100644
--- a/modules/_legacy.js
+++ b/modules/_legacy.js
@@ -20,7 +20,7 @@ _Base.prototype._construct = function() {
};
_Base.prototype.__name__ = '_Base';
_Base.prototype.toString = function() {
- return '[object ' + this.__name__ + ']';
+ return `[object ${this.__name__}]`;
};
function _parent() {
@@ -34,7 +34,7 @@ function _parent() {
let previous = parent ? parent.prototype[name] : undefined;
if (!previous)
- throw new TypeError("The method '" + name + "' is not on the superclass");
+ throw new TypeError(`The method '${name}' is not on the superclass`);
return previous.apply(this, arguments);
}
@@ -74,7 +74,8 @@ Class.prototype.constructor = Class;
Class.prototype.__name__ = 'Class';
Class.prototype.wrapFunction = function(name, meth) {
- if (meth._origin) meth = meth._origin;
+ if (meth._origin)
+ meth = meth._origin;
function wrapper() {
let prevCaller = this.__caller__;
@@ -92,7 +93,7 @@ Class.prototype.wrapFunction = function(name, meth) {
};
Class.prototype.toString = function() {
- return '[object ' + this.__name__ + ' for ' + this.prototype.__name__ + ']';
+ return `[object ${this.__name__} for ${this.prototype.__name__}]`;
};
Class.prototype._construct = function(params) {
@@ -107,7 +108,7 @@ Class.prototype._construct = function(params) {
let newClass = function() {
if (params.Abstract && new.target.name === name)
- throw new TypeError('Cannot instantiate abstract class ' + name);
+ throw new TypeError(`Cannot instantiate abstract class ${name}`);
this.__caller__ = null;
@@ -347,8 +348,8 @@ Interface.prototype._check = function (proto) {
// is just so that we print something if there is garbage in Requires.
required.prototype.__name__ || required.name || required);
if (unfulfilledReqs.length > 0) {
- throw new Error('The following interfaces must be implemented before ' +
- this.prototype.__name__ + ': ' + unfulfilledReqs.join(', '));
+ throw new Error(`The following interfaces must be implemented before ${
+ this.prototype.__name__}: ${unfulfilledReqs.join(', ')}`);
}
// Check that this interface's required methods are implemented
@@ -356,12 +357,13 @@ Interface.prototype._check = function (proto) {
.filter((p) => this.prototype[p] === Interface.UNIMPLEMENTED)
.filter((p) => !(p in proto) || proto[p] === Interface.UNIMPLEMENTED);
if (unimplementedFns.length > 0)
- throw new Error('The following members of ' + this.prototype.__name__ +
- ' are not implemented yet: ' + unimplementedFns.join(', '));
+ throw new Error(`The following members of ${
+ this.prototype.__name__} are not implemented yet: ${
+ unimplementedFns.join(', ')}`);
};
Interface.prototype.toString = function () {
- return '[interface ' + this.__name__ + ' for ' + this.prototype.__name__ + ']';
+ return `[interface ${this.__name__} for ${this.prototype.__name__}]`;
};
Interface.prototype._init = function (params) {
@@ -425,7 +427,7 @@ function defineGObjectLegacyObjects(GObject) {
try {
obj.signal_id = Gi.signal_new(gtype, signalName, flags, accumulator, rtype, paramtypes);
} catch (e) {
- throw new TypeError('Invalid signal ' + signalName + ': ' + e.message);
+ throw new TypeError(`Invalid signal ${signalName}: ${e.message}`);
}
}
}
@@ -434,7 +436,7 @@ function defineGObjectLegacyObjects(GObject) {
if (params.GTypeName)
return params.GTypeName;
else
- return 'Gjs_' + params.Name.replace(/[^a-z0-9_+-]/gi, '_');
+ return `Gjs_${params.Name.replace(/[^a-z0-9_+-]/gi, '_')}`;
}
function _getGObjectInterfaces(interfaces) {
@@ -520,7 +522,7 @@ function defineGObjectLegacyObjects(GObject) {
let parent = params.Extends;
if (!this._isValidClass(parent))
- throw new TypeError('GObject.Class used with invalid base class (is ' + parent + ')');
+ throw new TypeError(`GObject.Class used with invalid base class (is ${parent})`);
let interfaces = params.Implements || [];
if (parent instanceof Class)
diff --git a/modules/cairo.js b/modules/cairo.js
index 25b834a0..c07d1ada 100644
--- a/modules/cairo.js
+++ b/modules/cairo.js
@@ -29,16 +29,16 @@ var Antialias = {
};
var Content = {
- COLOR : 0x1000,
- ALPHA : 0x2000,
- COLOR_ALPHA : 0x3000
+ COLOR: 0x1000,
+ ALPHA: 0x2000,
+ COLOR_ALPHA: 0x3000
};
var Extend = {
- NONE : 0,
- REPEAT : 1,
- REFLECT : 2,
- PAD : 3
+ NONE: 0,
+ REPEAT: 1,
+ REFLECT: 2,
+ PAD: 3
};
var FillRule = {
@@ -47,12 +47,12 @@ var FillRule = {
};
var Filter = {
- FAST : 0,
- GOOD : 1,
- BEST : 2,
- NEAREST : 3,
- BILINEAR : 4,
- GAUSSIAN : 5
+ FAST: 0,
+ GOOD: 1,
+ BEST: 2,
+ NEAREST: 3,
+ BILINEAR: 4,
+ GAUSSIAN: 5
};
var FontSlant = {
@@ -62,15 +62,15 @@ var FontSlant = {
};
var FontWeight = {
- NORMAL : 0,
- BOLD : 1
+ NORMAL: 0,
+ BOLD: 1
};
var Format = {
- ARGB32 : 0,
- RGB24 : 1,
- A8 : 2,
- A1 : 3,
+ ARGB32: 0,
+ RGB24: 1,
+ A8: 2,
+ A1: 3,
// The value of 4 is reserved by a deprecated enum value
RGB16_565: 5
};
@@ -91,56 +91,56 @@ var Operator = {
CLEAR: 0,
SOURCE: 1,
OVER: 2,
- IN : 3,
- OUT : 4,
- ATOP : 5,
- DEST : 6,
- DEST_OVER : 7,
- DEST_IN : 8,
- DEST_OUT : 9,
- DEST_ATOP : 10,
- XOR : 11,
- ADD : 12,
- SATURATE : 13,
- MULTIPLY : 14,
- SCREEN : 15,
- OVERLAY : 16,
- DARKEN : 17,
- LIGHTEN : 18,
- COLOR_DODGE : 19,
- COLOR_BURN : 20,
- HARD_LIGHT : 21,
- SOFT_LIGHT : 22,
- DIFFERENCE : 23,
- EXCLUSION : 24,
- HSL_HUE : 25,
- HSL_SATURATION : 26,
- HSL_COLOR : 27,
- HSL_LUMINOSITY : 28
+ IN: 3,
+ OUT: 4,
+ ATOP: 5,
+ DEST: 6,
+ DEST_OVER: 7,
+ DEST_IN: 8,
+ DEST_OUT: 9,
+ DEST_ATOP: 10,
+ XOR: 11,
+ ADD: 12,
+ SATURATE: 13,
+ MULTIPLY: 14,
+ SCREEN: 15,
+ OVERLAY: 16,
+ DARKEN: 17,
+ LIGHTEN: 18,
+ COLOR_DODGE: 19,
+ COLOR_BURN: 20,
+ HARD_LIGHT: 21,
+ SOFT_LIGHT: 22,
+ DIFFERENCE: 23,
+ EXCLUSION: 24,
+ HSL_HUE: 25,
+ HSL_SATURATION: 26,
+ HSL_COLOR: 27,
+ HSL_LUMINOSITY: 28
};
var PatternType = {
- SOLID : 0,
- SURFACE : 1,
- LINEAR : 2,
- RADIAL : 3
+ SOLID: 0,
+ SURFACE: 1,
+ LINEAR: 2,
+ RADIAL: 3
};
var SurfaceType = {
- IMAGE : 0,
- PDF : 1,
- PS : 2,
- XLIB : 3,
- XCB : 4,
- GLITZ : 5,
- QUARTZ : 6,
- WIN32 : 7,
- BEOS : 8,
- DIRECTFB : 9,
- SVG : 10,
- OS2 : 11,
- WIN32_PRINTING : 12,
- QUARTZ_IMAGE : 13
+ IMAGE: 0,
+ PDF: 1,
+ PS: 2,
+ XLIB: 3,
+ XCB: 4,
+ GLITZ: 5,
+ QUARTZ: 6,
+ WIN32: 7,
+ BEOS: 8,
+ DIRECTFB: 9,
+ SVG: 10,
+ OS2: 11,
+ WIN32_PRINTING: 12,
+ QUARTZ_IMAGE: 13
};
// Merge stuff defined in native code
diff --git a/modules/format.js b/modules/format.js
index 70dcfd0d..fd994502 100644
--- a/modules/format.js
+++ b/modules/format.js
@@ -21,7 +21,7 @@ function vprintf(str, args) {
if (usePos == false && i == 0)
usePos = pos > 0;
if (usePos && pos == 0 || !usePos && pos > 0)
- throw new Error("Numbered and unnumbered conversion specifications cannot be mixed");
+ throw new Error('Numbered and unnumbered conversion specifications cannot be mixed');
let fillChar = (widthGroup && widthGroup[0] == '0') ? '0' : ' ';
let width = parseInt(widthGroup, 10) || 0;
@@ -61,7 +61,7 @@ function vprintf(str, args) {
s = parseFloat(getArg()).toFixed(parseInt(precisionGroup));
break;
default:
- throw new Error('Unsupported conversion character %' + genericGroup);
+ throw new Error(`Unsupported conversion character %${genericGroup}`);
}
return fillWidth(s, fillChar, width);
});
diff --git a/modules/lang.js b/modules/lang.js
index 3cf2c5f5..0b4c3143 100644
--- a/modules/lang.js
+++ b/modules/lang.js
@@ -72,15 +72,13 @@ function copyPublicProperties(source, dest) {
*/
function bind(obj, callback) {
if (typeof(obj) != 'object') {
- throw new Error(
- "first argument to Lang.bind() must be an object, not " +
- typeof(obj));
+ throw new Error(`first argument to Lang.bind() must be an object, not ${
+ typeof(obj)}`);
}
if (typeof(callback) != 'function') {
- throw new Error(
- "second argument to Lang.bind() must be a function, not " +
- typeof(callback));
+ throw new Error(`second argument to Lang.bind() must be a function, not ${
+ typeof(callback)}`);
}
// Use ES5 Function.prototype.bind, but only if not passing any bindArguments,
diff --git a/modules/mainloop.js b/modules/mainloop.js
index 590d76d6..4437d403 100644
--- a/modules/mainloop.js
+++ b/modules/mainloop.js
@@ -38,13 +38,13 @@ function run(name) {
function quit(name) {
if (!_mainLoops[name])
- throw new Error("No main loop with this id");
+ throw new Error('No main loop with this id');
let loop = _mainLoops[name];
_mainLoops[name] = null;
if (!loop.is_running())
- throw new Error("Main loop was stopped already");
+ throw new Error('Main loop was stopped already');
loop.quit();
}
diff --git a/modules/overrides/GLib.js b/modules/overrides/GLib.js
index 2dbe50f5..ffdb39c2 100644
--- a/modules/overrides/GLib.js
+++ b/modules/overrides/GLib.js
@@ -61,7 +61,7 @@ function _read_single_type(signature, forceSimple) {
// Valid types are simple types, arrays, maybes, tuples, dictionary entries and variants
if (!isSimple && char != 'v')
- throw new TypeError('Invalid GVariant signature (' + char + ' is not a valid type)');
+ throw new TypeError(`Invalid GVariant signature (${char} is not a valid type)`);
return [char];
}
@@ -152,7 +152,7 @@ function _pack_variant(signature, value) {
}
case '(':
- let children = [ ];
+ let children = [];
for (let i = 0; i < value.length; i++) {
let next = signature[0];
if (next == ')')
@@ -174,7 +174,7 @@ function _pack_variant(signature, value) {
return GLib.Variant.new_dict_entry(key, child);
default:
- throw new TypeError('Invalid GVariant signature (unexpected character ' + char + ')');
+ throw new TypeError(`Invalid GVariant signature (unexpected character ${char})`);
}
}
@@ -244,7 +244,7 @@ function _unpack_variant(variant, deep, recursive = false) {
// fall through
case '(':
case '{':
- let ret = [ ];
+ let ret = [];
let nElements = variant.n_children();
for (let i = 0; i < nElements; i++) {
let val = variant.get_child_value(i);
@@ -267,7 +267,9 @@ function _init() {
// small HACK: we add a matches() method to standard Errors so that
// you can do "if (e.matches(Ns.FooError, Ns.FooError.SOME_CODE))"
// without checking instanceof
- Error.prototype.matches = function() { return false; };
+ Error.prototype.matches = function() {
+ return false;
+ };
this.Variant._new_internal = function(sig, value) {
let signature = Array.prototype.slice.call(sig);
@@ -298,7 +300,7 @@ function _init() {
};
this.Variant.prototype.toString = function() {
- return '[object variant of type "' + this.get_type_string() + '"]';
+ return `[object variant of type "${this.get_type_string()}"]`;
};
this.Bytes.prototype.toArray = function() {
diff --git a/modules/overrides/GObject.js b/modules/overrides/GObject.js
index d33f7429..5ada6045 100644
--- a/modules/overrides/GObject.js
+++ b/modules/overrides/GObject.js
@@ -105,7 +105,7 @@ function _createSignals(gtype, signals) {
try {
obj.signal_id = Gi.signal_new(gtype, signalName, flags, accumulator, rtype, paramtypes);
} catch (e) {
- throw new TypeError('Invalid signal ' + signalName + ': ' + e.message);
+ throw new TypeError(`Invalid signal ${signalName}: ${e.message}`);
}
}
}
@@ -179,8 +179,10 @@ function _init() {
function _makeDummyClass(obj, name, upperName, gtypeName, actual) {
let gtype = GObject.type_from_name(gtypeName);
- obj['TYPE_' + upperName] = gtype;
- obj[name] = function(v) { return new actual(v); };
+ obj[`TYPE_${upperName}`] = gtype;
+ obj[name] = function(v) {
+ return new actual(v);
+ };
obj[name].$gtype = gtype;
}
@@ -292,33 +294,69 @@ function _init() {
GObject.ParamSpec.override = Gi.override_property;
Object.defineProperties(GObject.ParamSpec.prototype, {
- 'name': { configurable: false,
- enumerable: false,
- get: function() { return this.get_name() } },
- '_nick': { configurable: false,
- enumerable: false,
- get: function() { return this.get_nick() } },
- 'nick': { configurable: false,
- enumerable: false,
- get: function() { return this.get_nick() } },
- '_blurb': { configurable: false,
- enumerable: false,
- get: function() { return this.get_blurb() } },
- 'blurb': { configurable: false,
- enumerable: false,
- get: function() { return this.get_blurb() } },
- 'default_value': { configurable: false,
- enumerable: false,
- get: function() { return this.get_default_value() } },
- 'flags': { configurable: false,
- enumerable: false,
- get: function() { return GjsPrivate.param_spec_get_flags(this) } },
- 'value_type': { configurable: false,
- enumerable: false,
- get: function() { return GjsPrivate.param_spec_get_value_type(this) } },
- 'owner_type': { configurable: false,
- enumerable: false,
- get: function() { return GjsPrivate.param_spec_get_owner_type(this) } },
+ 'name': {
+ configurable: false,
+ enumerable: false,
+ get: function() {
+ return this.get_name();
+ },
+ },
+ '_nick': {
+ configurable: false,
+ enumerable: false,
+ get: function() {
+ return this.get_nick();
+ },
+ },
+ 'nick': {
+ configurable: false,
+ enumerable: false,
+ get: function() {
+ return this.get_nick();
+ },
+ },
+ '_blurb': {
+ configurable: false,
+ enumerable: false,
+ get: function() {
+ return this.get_blurb();
+ },
+ },
+ 'blurb': {
+ configurable: false,
+ enumerable: false,
+ get: function() {
+ return this.get_blurb();
+ },
+ },
+ 'default_value': {
+ configurable: false,
+ enumerable: false,
+ get: function() {
+ return this.get_default_value();
+ },
+ },
+ 'flags': {
+ configurable: false,
+ enumerable: false,
+ get: function() {
+ return GjsPrivate.param_spec_get_flags(this);
+ },
+ },
+ 'value_type': {
+ configurable: false,
+ enumerable: false,
+ get: function() {
+ return GjsPrivate.param_spec_get_value_type(this);
+ },
+ },
+ 'owner_type': {
+ configurable: false,
+ enumerable: false,
+ get: function() {
+ return GjsPrivate.param_spec_get_owner_type(this);
+ },
+ },
});
let {GObjectMeta, GObjectInterface} = Legacy.defineGObjectLegacyObjects(GObject);
@@ -439,7 +477,9 @@ function _init() {
* implementation of the interface.
*/
GObject.NotImplementedError = class NotImplementedError extends Error {
- get name() { return 'NotImplementedError'; }
+ get name() {
+ return 'NotImplementedError';
+ }
};
// These will be copied in the Gtk overrides
diff --git a/modules/overrides/Gio.js b/modules/overrides/Gio.js
index 4ab135fa..6cf42896 100644
--- a/modules/overrides/Gio.js
+++ b/modules/overrides/Gio.js
@@ -88,8 +88,8 @@ function _proxyInvoker(methodName, sync, inSignature, arg_array) {
var maxNumberArgs = signatureLength + 4;
if (arg_array.length < minNumberArgs) {
- throw new Error('Not enough arguments passed for method: ' + methodName +
- '. Expected ' + minNumberArgs + ', got ' + arg_array.length);
+ throw new Error(`Not enough arguments passed for method: ${
+ methodName}. Expected ${minNumberArgs}, got ${arg_array.length}`);
} else if (arg_array.length > maxNumberArgs) {
throw new Error(`Too many arguments passed for method ${methodName}. ` +
`Maximum is ${maxNumberArgs} including one callback, ` +
@@ -147,7 +147,7 @@ function _proxyInvoker(methodName, sync, inSignature, arg_array) {
function _logReply(result, exc) {
if (exc != null) {
- log('Ignored exception from dbus method: ' + exc.toString());
+ log(`Ignored exception from dbus method: ${exc}`);
}
}
@@ -155,7 +155,7 @@ function _makeProxyMethod(method, sync) {
var i;
var name = method.name;
var inArgs = method.in_args;
- var inSignature = [ ];
+ var inSignature = [];
for (i = 0; i < inArgs.length; i++)
inSignature.push(inArgs[i].signature);
@@ -178,18 +178,16 @@ function _propertySetter(name, signature, value) {
this.set_cached_property(name, variant);
this.call('org.freedesktop.DBus.Properties.Set',
- new GLib.Variant('(ssv)',
- [this.g_interface_name,
- name, variant]),
- Gio.DBusCallFlags.NONE, -1, null,
- (proxy, result) => {
- try {
- this.call_finish(result);
- } catch(e) {
- log('Could not set property ' + name + ' on remote object ' +
- this.g_object_path + ': ' + e.message);
- }
- });
+ new GLib.Variant('(ssv)', [this.g_interface_name, name, variant]),
+ Gio.DBusCallFlags.NONE, -1, null,
+ (proxy, result) => {
+ try {
+ this.call_finish(result);
+ } catch (e) {
+ log(`Could not set property ${name} on remote object ${
+ this.g_object_path}: ${e.message}`);
+ }
+ });
}
function _addDBusConvenience() {
@@ -203,8 +201,8 @@ function _addDBusConvenience() {
let i, methods = info.methods;
for (i = 0; i < methods.length; i++) {
var method = methods[i];
- this[method.name + 'Remote'] = _makeProxyMethod(methods[i], false);
- this[method.name + 'Sync'] = _makeProxyMethod(methods[i], true);
+ this[`${method.name}Remote`] = _makeProxyMethod(methods[i], false);
+ this[`${method.name}Sync`] = _makeProxyMethod(methods[i], true);
}
let properties = info.properties;
@@ -239,12 +237,14 @@ function _makeProxyWrapper(interfaceXml) {
var iname = info.name;
return function(bus, name, object, asyncCallback, cancellable,
flags = Gio.DBusProxyFlags.NONE) {
- var obj = new Gio.DBusProxy({ g_connection: bus,
+ var obj = new Gio.DBusProxy({
+ g_connection: bus,
g_interface_name: iname,
g_interface_info: info,
g_name: name,
g_flags: flags,
- g_object_path: object });
+ g_object_path: object,
+ });
if (!cancellable)
cancellable = null;
@@ -253,7 +253,7 @@ function _makeProxyWrapper(interfaceXml) {
let caughtErrorWhenInitting = null;
try {
initable.init_finish(result);
- } catch(e) {
+ } catch (e) {
caughtErrorWhenInitting = e;
}
@@ -315,7 +315,7 @@ function _makeOutSignature(args) {
for (var i = 0; i < args.length; i++)
ret += args[i].signature;
- return ret + ')';
+ return `${ret})`;
}
function _handleMethodCall(info, impl, method_name, parameters, invocation) {
@@ -332,9 +332,9 @@ function _handleMethodCall(info, impl, method_name, parameters, invocation) {
let name = e.name;
if (name.indexOf('.') == -1) {
// likely to be a normal JS error
- name = 'org.gnome.gjs.JSError.' + name;
+ name = `org.gnome.gjs.JSError.${name}`;
}
- logError(e, 'Exception in method call: ' + method_name);
+ logError(e, `Exception in method call: ${method_name}`);
invocation.return_dbus_error(name, e.message);
}
return;
@@ -361,18 +361,20 @@ function _handleMethodCall(info, impl, method_name, parameters, invocation) {
retval = new GLib.Variant(outSignature, retval);
}
invocation.return_value_with_unix_fd_list(retval, outFdList);
- } catch(e) {
+ } catch (e) {
// if we don't do this, the other side will never see a reply
invocation.return_dbus_error('org.gnome.gjs.JSError.ValueError',
- 'Service implementation returned an incorrect value type');
+ 'Service implementation returned an incorrect value type');
}
- } else if (this[method_name + 'Async']) {
+ } else if (this[`${method_name}Async`]) {
const fdList = invocation.get_message().get_unix_fd_list();
this[`${method_name}Async`](parameters.deep_unpack(), invocation, fdList);
} else {
- log('Missing handler for DBus method ' + method_name);
- invocation.return_gerror(new Gio.DBusError({ code: Gio.DBusError.UNKNOWN_METHOD,
- message: 'Method ' + method_name + ' is not
implemented' }));
+ log(`Missing handler for DBus method ${method_name}`);
+ invocation.return_gerror(new Gio.DBusError({
+ code: Gio.DBusError.UNKNOWN_METHOD,
+ message: `Method ${method_name} is not implemented`,
+ }));
}
}
@@ -397,7 +399,7 @@ function _wrapJSObject(interfaceInfo, jsObj) {
info = Gio.DBusInterfaceInfo.new_for_xml(interfaceInfo);
info.cache_build();
- var impl = new GjsPrivate.DBusImplementation({ g_interface_info: info });
+ var impl = new GjsPrivate.DBusImplementation({g_interface_info: info});
impl.connect('handle-method-call', function(impl, method_name, parameters, invocation) {
return _handleMethodCall.call(jsObj, info, impl, method_name, parameters, invocation);
});
@@ -456,17 +458,17 @@ function _init() {
},
// Namespace some functions
- get: Gio.bus_get,
+ get: Gio.bus_get,
get_finish: Gio.bus_get_finish,
- get_sync: Gio.bus_get_sync,
+ get_sync: Gio.bus_get_sync,
- own_name: Gio.bus_own_name,
+ own_name: Gio.bus_own_name,
own_name_on_connection: Gio.bus_own_name_on_connection,
- unown_name: Gio.bus_unown_name,
+ unown_name: Gio.bus_unown_name,
- watch_name: Gio.bus_watch_name,
+ watch_name: Gio.bus_watch_name,
watch_name_on_connection: Gio.bus_watch_name_on_connection,
- unwatch_name: Gio.bus_unwatch_name
+ unwatch_name: Gio.bus_unwatch_name
};
Gio.DBusConnection.prototype.watch_name = function(name, flags, appeared, vanished) {
diff --git a/modules/overrides/Gtk.js b/modules/overrides/Gtk.js
index 239c0c2e..82cc395f 100644
--- a/modules/overrides/Gtk.js
+++ b/modules/overrides/Gtk.js
@@ -68,7 +68,7 @@ function _init() {
let internalChildren = this.constructor[Gtk.internalChildren] || [];
for (let child of internalChildren) {
- this['_' + child.replace(/-/g, '_')] =
+ this[`_${child.replace(/-/g, '_')}`] =
this.get_template_child(this.constructor, child);
}
}
diff --git a/modules/package.js b/modules/package.js
index 20613df2..aeaa6652 100644
--- a/modules/package.js
+++ b/modules/package.js
@@ -61,7 +61,7 @@ function _findEffectiveEntryPointName() {
function _runningFromSource() {
let binary = Gio.File.new_for_path(System.programInvocationName);
- let sourceBinary = Gio.File.new_for_path('./src/' + name);
+ let sourceBinary = Gio.File.new_for_path(`./src/${name}`);
return binary.equal(sourceBinary);
}
@@ -71,7 +71,7 @@ function _runningFromMesonSource() {
}
function _makeNamePath(name) {
- return '/' + name.replace(/\./g, '/');
+ return `/${name.replace(/\./g, '/')}`;
}
/**
@@ -159,10 +159,10 @@ function init(params) {
GLib.setenv('GSETTINGS_SCHEMA_DIR', pkgdatadir, true);
try {
let resource = Gio.Resource.load(GLib.build_filenamev([bld, 'src',
- name + '.src.gresource']));
+ `${name}.src.gresource`]));
resource._register();
- moduledir = 'resource://' + _makeNamePath(name) + '/js';
- } catch(e) {
+ moduledir = `resource://${_makeNamePath(name)}/js`;
+ } catch (e) {
moduledir = GLib.build_filenamev([src, 'src']);
}
} else {
@@ -175,11 +175,11 @@ function init(params) {
try {
let resource = Gio.Resource.load(GLib.build_filenamev([pkgdatadir,
- name + '.src.gresource']));
+ `${name}.src.gresource`]));
resource._register();
- moduledir = 'resource://' + _makeNamePath(name) + '/js';
- } catch(e) {
+ moduledir = `resource://${_makeNamePath(name)}/js`;
+ } catch (e) {
moduledir = pkgdatadir;
}
}
@@ -190,9 +190,9 @@ function init(params) {
try {
let resource = Gio.Resource.load(GLib.build_filenamev([pkgdatadir,
- name + '.data.gresource']));
+ `${name}.data.gresource`]));
resource._register();
- } catch(e) { }
+ } catch (e) { }
}
/**
@@ -281,7 +281,7 @@ function checkSymbol(lib, version, symbol) {
try {
Lib = imports.gi[lib];
- } catch(e) {
+ } catch (e) {
return false;
}
@@ -319,7 +319,9 @@ function initGettext() {
let gettext = imports.gettext;
window._ = gettext.gettext;
window.C_ = gettext.pgettext;
- window.N_ = function(x) { return x; }
+ window.N_ = function(x) {
+ return x;
+ };
}
function initFormat() {
diff --git a/modules/signals.js b/modules/signals.js
index 99181ae0..3e086e2a 100644
--- a/modules/signals.js
+++ b/modules/signals.js
@@ -34,7 +34,7 @@ function _connect(name, callback) {
// be paranoid about callback arg since we'd start to throw from emit()
// if it was messed up
if (typeof(callback) != 'function')
- throw new Error("When connecting signal must give a callback that is a function");
+ throw new Error('When connecting signal must give a callback that is a function');
// we instantiate the "signal machinery" only on-demand if anything
// gets connected.
@@ -49,11 +49,12 @@ function _connect(name, callback) {
// this makes it O(n) in total connections to emit, but I think
// it's right to optimize for low memory and reentrancy-safety
// rather than speed
- this._signalConnections.push({ 'id' : id,
- 'name' : name,
- 'callback' : callback,
- 'disconnected' : false
- });
+ this._signalConnections.push({
+ 'id': id,
+ 'name': name,
+ 'callback': callback,
+ 'disconnected': false,
+ });
return id;
}
@@ -65,7 +66,7 @@ function _disconnect(id) {
let connection = this._signalConnections[i];
if (connection.id == id) {
if (connection.disconnected)
- throw new Error("Signal handler id " + id + " already disconnected");
+ throw new Error(`Signal handler id ${id} already disconnected`);
// set a flag to deal with removal during emission
connection.disconnected = true;
@@ -75,7 +76,7 @@ function _disconnect(id) {
}
}
}
- throw new Error("No signal connection " + id + " found");
+ throw new Error(`No signal connection ${id} found`);
}
function _signalHandlerIsConnected(id) {
@@ -125,7 +126,7 @@ function _emit(name, ...args) {
// which does pass it in. Also if we pass in the emitter here,
// people don't create closures with the emitter in them,
// which would be a cycle.
- let arg_array = [ this, ...args ];
+ let arg_array = [this, ...args];
length = handlers.length;
for (i = 0; i < length; ++i) {
@@ -140,10 +141,10 @@ function _emit(name, ...args) {
if (ret === true) {
break;
}
- } catch(e) {
+ } catch (e) {
// just log any exceptions so that callbacks can't disrupt
// signal emission
- logError(e, "Exception in callback for signal: "+name);
+ logError(e, `Exception in callback for signal: ${name}`);
}
}
}
@@ -151,20 +152,19 @@ function _emit(name, ...args) {
function _addSignalMethod(proto, functionName, func) {
if (proto[functionName] && proto[functionName] != func) {
- log("WARNING: addSignalMethods is replacing existing " +
- proto + " " + functionName + " method");
+ log(`WARNING: addSignalMethods is replacing existing ${proto} ${functionName} method`);
}
proto[functionName] = func;
}
function addSignalMethods(proto) {
- _addSignalMethod(proto, "connect", _connect);
- _addSignalMethod(proto, "disconnect", _disconnect);
- _addSignalMethod(proto, "emit", _emit);
+ _addSignalMethod(proto, 'connect', _connect);
+ _addSignalMethod(proto, 'disconnect', _disconnect);
+ _addSignalMethod(proto, 'emit', _emit);
_addSignalMethod(proto, 'signalHandlerIsConnected', _signalHandlerIsConnected);
// this one is not in GObject, but useful
- _addSignalMethod(proto, "disconnectAll", _disconnectAll);
+ _addSignalMethod(proto, 'disconnectAll', _disconnectAll);
}
var WithSignals = new Lang.Interface({
diff --git a/modules/tweener/equations.js b/modules/tweener/equations.js
index 1b333627..c4c4568e 100644
--- a/modules/tweener/equations.js
+++ b/modules/tweener/equations.js
@@ -50,11 +50,11 @@ easeOutInSine, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, linear */
* @return The correct value.
*/
function easeNone (t, b, c, d, p_params) {
- return c*t/d + b;
+ return c * t / d + b;
}
/* Useful alias */
-function linear (t, b, c ,d, p_params) {
+function linear (t, b, c, d, p_params) {
return easeNone (t, b, c, d, p_params);
}
@@ -68,7 +68,7 @@ function linear (t, b, c ,d, p_params) {
* @return The correct value.
*/
function easeInQuad (t, b, c, d, p_params) {
- return c*(t/=d)*t + b;
+ return c * (t /= d) * t + b;
}
/**
@@ -81,7 +81,7 @@ function easeInQuad (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutQuad (t, b, c, d, p_params) {
- return -c *(t/=d)*(t-2) + b;
+ return -c * (t /= d) * (t - 2) + b;
}
/**
@@ -94,8 +94,9 @@ function easeOutQuad (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutQuad (t, b, c, d, p_params) {
- if ((t/=d/2) < 1) return c/2*t*t + b;
- return -c/2 * ((--t)*(t-2) - 1) + b;
+ if ((t /= d / 2) < 1)
+ return c / 2 * t * t + b;
+ return -c / 2 * ((--t) * (t - 2) - 1) + b;
}
/**
@@ -108,8 +109,9 @@ function easeInOutQuad (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInQuad (t, b, c, d, p_params) {
- if (t < d/2) return easeOutQuad (t*2, b, c/2, d, p_params);
- return easeInQuad((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutQuad (t * 2, b, c / 2, d, p_params);
+ return easeInQuad((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
/**
@@ -122,7 +124,7 @@ function easeOutInQuad (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInCubic (t, b, c, d, p_params) {
- return c*(t/=d)*t*t + b;
+ return c * (t /= d) * t * t + b;
}
/**
@@ -135,7 +137,7 @@ function easeInCubic (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutCubic (t, b, c, d, p_params) {
- return c*((t=t/d-1)*t*t + 1) + b;
+ return c * ((t = t / d - 1) * t * t + 1) + b;
}
/**
@@ -148,8 +150,9 @@ function easeOutCubic (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutCubic (t, b, c, d, p_params) {
- if ((t/=d/2) < 1) return c/2*t*t*t + b;
- return c/2*((t-=2)*t*t + 2) + b;
+ if ((t /= d / 2) < 1)
+ return c / 2 * t * t * t + b;
+ return c / 2 * ((t -= 2) * t * t + 2) + b;
}
/**
@@ -162,8 +165,9 @@ function easeInOutCubic (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInCubic (t, b, c, d, p_params) {
- if (t < d/2) return easeOutCubic (t*2, b, c/2, d, p_params);
- return easeInCubic((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutCubic (t * 2, b, c / 2, d, p_params);
+ return easeInCubic((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
/**
@@ -176,7 +180,7 @@ function easeOutInCubic (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInQuart (t, b, c, d, p_params) {
- return c*(t/=d)*t*t*t + b;
+ return c * (t /= d) * t * t * t + b;
}
/**
@@ -189,7 +193,7 @@ function easeInQuart (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutQuart (t, b, c, d, p_params) {
- return -c * ((t=t/d-1)*t*t*t - 1) + b;
+ return -c * ((t = t / d - 1) * t * t * t - 1) + b;
}
/**
@@ -202,8 +206,9 @@ function easeOutQuart (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutQuart (t, b, c, d, p_params) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
- return -c/2 * ((t-=2)*t*t*t - 2) + b;
+ if ((t /= d / 2) < 1)
+ return c / 2 * t * t * t * t + b;
+ return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
}
/**
@@ -216,8 +221,9 @@ function easeInOutQuart (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInQuart (t, b, c, d, p_params) {
- if (t < d/2) return easeOutQuart (t*2, b, c/2, d, p_params);
- return easeInQuart((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutQuart (t * 2, b, c / 2, d, p_params);
+ return easeInQuart((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
/**
@@ -230,7 +236,7 @@ function easeOutInQuart (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInQuint (t, b, c, d, p_params) {
- return c*(t/=d)*t*t*t*t + b;
+ return c * (t /= d) * t * t * t * t + b;
}
/**
@@ -243,7 +249,7 @@ function easeInQuint (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutQuint (t, b, c, d, p_params) {
- return c*((t=t/d-1)*t*t*t*t + 1) + b;
+ return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
}
/**
@@ -256,8 +262,9 @@ function easeOutQuint (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutQuint (t, b, c, d, p_params) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
- return c/2*((t-=2)*t*t*t*t + 2) + b;
+ if ((t /= d / 2) < 1)
+ return c / 2 * t * t * t * t * t + b;
+ return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
}
/**
@@ -270,8 +277,9 @@ function easeInOutQuint (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInQuint (t, b, c, d, p_params) {
- if (t < d/2) return easeOutQuint (t*2, b, c/2, d, p_params);
- return easeInQuint((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutQuint (t * 2, b, c / 2, d, p_params);
+ return easeInQuint((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
/**
@@ -284,7 +292,7 @@ function easeOutInQuint (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInSine (t, b, c, d, p_params) {
- return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
+ return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
}
/**
@@ -297,7 +305,7 @@ function easeInSine (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutSine (t, b, c, d, p_params) {
- return c * Math.sin(t/d * (Math.PI/2)) + b;
+ return c * Math.sin(t / d * (Math.PI / 2)) + b;
}
/**
@@ -310,7 +318,7 @@ function easeOutSine (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutSine (t, b, c, d, p_params) {
- return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
+ return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
}
/**
@@ -323,8 +331,9 @@ function easeInOutSine (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInSine (t, b, c, d, p_params) {
- if (t < d/2) return easeOutSine (t*2, b, c/2, d, p_params);
- return easeInSine((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutSine (t * 2, b, c / 2, d, p_params);
+ return easeInSine((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
/**
@@ -337,7 +346,7 @@ function easeOutInSine (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInExpo (t, b, c, d, p_params) {
- return (t<=0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
+ return (t <= 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
}
/**
@@ -350,7 +359,7 @@ function easeInExpo (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutExpo (t, b, c, d, p_params) {
- return (t>=d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
+ return (t >= d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
}
/**
@@ -363,10 +372,13 @@ function easeOutExpo (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutExpo (t, b, c, d, p_params) {
- if (t<=0) return b;
- if (t>=d) return b+c;
- if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
- return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
+ if (t <= 0)
+ return b;
+ if (t >= d)
+ return b + c;
+ if ((t /= d / 2) < 1)
+ return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
+ return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
}
/**
@@ -379,8 +391,9 @@ function easeInOutExpo (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInExpo (t, b, c, d, p_params) {
- if (t < d/2) return easeOutExpo (t*2, b, c/2, d, p_params);
- return easeInExpo((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutExpo (t * 2, b, c / 2, d, p_params);
+ return easeInExpo((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
/**
@@ -393,7 +406,7 @@ function easeOutInExpo (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInCirc (t, b, c, d, p_params) {
- return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
+ return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
}
/**
@@ -406,7 +419,7 @@ function easeInCirc (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutCirc (t, b, c, d, p_params) {
- return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
+ return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
}
/**
@@ -419,8 +432,9 @@ function easeOutCirc (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutCirc (t, b, c, d, p_params) {
- if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
- return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
+ if ((t /= d / 2) < 1)
+ return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
+ return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
}
/**
@@ -433,8 +447,9 @@ function easeInOutCirc (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInCirc (t, b, c, d, p_params) {
- if (t < d/2) return easeOutCirc (t*2, b, c/2, d, p_params);
- return easeInCirc((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutCirc (t * 2, b, c / 2, d, p_params);
+ return easeInCirc((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
/**
@@ -449,18 +464,20 @@ function easeOutInCirc (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInElastic (t, b, c, d, p_params) {
- if (t<=0) return b;
- if ((t/=d)>=1) return b+c;
- var p = !Boolean(p_params) || isNaN(p_params.period) ? d*.3 : p_params.period;
+ if (t <= 0)
+ return b;
+ if ((t /= d) >= 1)
+ return b + c;
+ var p = !p_params || isNaN(p_params.period) ? d * .3 : p_params.period;
var s;
- var a = !Boolean(p_params) || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;
- if (!Boolean(a) || a < Math.abs(c)) {
+ var a = !p_params || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;
+ if (!a || a < Math.abs(c)) {
a = c;
- s = p/4;
+ s = p / 4;
} else {
- s = p/(2*Math.PI) * Math.asin (c/a);
+ s = p / (2 * Math.PI) * Math.asin (c / a);
}
- return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin( (t * d - s) * (2 * Math.PI) / p )) + b;
}
/**
@@ -475,18 +492,20 @@ function easeInElastic (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutElastic (t, b, c, d, p_params) {
- if (t<=0) return b;
- if ((t/=d)>=1) return b+c;
- var p = !Boolean(p_params) || isNaN(p_params.period) ? d*.3 : p_params.period;
+ if (t <= 0)
+ return b;
+ if ((t /= d) >= 1)
+ return b + c;
+ var p = !p_params || isNaN(p_params.period) ? d * .3 : p_params.period;
var s;
- var a = !Boolean(p_params) || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;
- if (!Boolean(a) || a < Math.abs(c)) {
+ var a = !p_params || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;
+ if (!a || a < Math.abs(c)) {
a = c;
- s = p/4;
+ s = p / 4;
} else {
- s = p/(2*Math.PI) * Math.asin (c/a);
+ s = p / (2 * Math.PI) * Math.asin (c / a);
}
- return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
+ return (a * Math.pow(2, -10 * t) * Math.sin( (t * d - s) * (2 * Math.PI) / p ) + c + b);
}
/**
@@ -501,19 +520,22 @@ function easeOutElastic (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutElastic (t, b, c, d, p_params) {
- if (t<=0) return b;
- if ((t/=d/2)>=2) return b+c;
- var p = !Boolean(p_params) || isNaN(p_params.period) ? d*(.3*1.5) : p_params.period;
+ if (t <= 0)
+ return b;
+ if ((t /= d / 2) >= 2)
+ return b + c;
+ var p = !p_params || isNaN(p_params.period) ? d * (.3 * 1.5) : p_params.period;
var s;
- var a = !Boolean(p_params) || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;
- if (!Boolean(a) || a < Math.abs(c)) {
+ var a = !p_params || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;
+ if (!a || a < Math.abs(c)) {
a = c;
- s = p/4;
+ s = p / 4;
} else {
- s = p/(2*Math.PI) * Math.asin (c/a);
+ s = p / (2 * Math.PI) * Math.asin (c / a);
}
- if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
+ if (t < 1)
+ return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin( (t * d - s) * (2 * Math.PI) / p )) + b;
+ return a * Math.pow(2, -10 * (t -= 1)) * Math.sin( (t * d - s) * (2 * Math.PI) / p ) * .5 + c + b;
}
/**
@@ -528,8 +550,9 @@ function easeInOutElastic (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInElastic (t, b, c, d, p_params) {
- if (t < d/2) return easeOutElastic (t*2, b, c/2, d, p_params);
- return easeInElastic((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutElastic (t * 2, b, c / 2, d, p_params);
+ return easeInElastic((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
/**
@@ -543,8 +566,8 @@ function easeOutInElastic (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInBack (t, b, c, d, p_params) {
- var s = !Boolean(p_params) || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;
- return c*(t/=d)*t*((s+1)*t - s) + b;
+ var s = !p_params || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;
+ return c * (t /= d) * t * ((s + 1) * t - s) + b;
}
/**
@@ -558,8 +581,8 @@ function easeInBack (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutBack (t, b, c, d, p_params) {
- var s = !Boolean(p_params) || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;
- return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
+ var s = !p_params || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;
+ return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
}
/**
@@ -573,9 +596,10 @@ function easeOutBack (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutBack (t, b, c, d, p_params) {
- var s = !Boolean(p_params) || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;
- if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
- return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
+ var s = !p_params || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;
+ if ((t /= d / 2) < 1)
+ return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
+ return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
}
/**
@@ -589,8 +613,9 @@ function easeInOutBack (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInBack (t, b, c, d, p_params) {
- if (t < d/2) return easeOutBack (t*2, b, c/2, d, p_params);
- return easeInBack((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutBack (t * 2, b, c / 2, d, p_params);
+ return easeInBack((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
/**
@@ -603,7 +628,7 @@ function easeOutInBack (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInBounce (t, b, c, d, p_params) {
- return c - easeOutBounce (d-t, 0, c, d) + b;
+ return c - easeOutBounce (d - t, 0, c, d) + b;
}
/**
@@ -616,14 +641,14 @@ function easeInBounce (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutBounce (t, b, c, d, p_params) {
- if ((t/=d) < (1/2.75)) {
- return c*(7.5625*t*t) + b;
- } else if (t < (2/2.75)) {
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
- } else if (t < (2.5/2.75)) {
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
+ if ((t /= d) < (1 / 2.75)) {
+ return c * (7.5625 * t * t) + b;
+ } else if (t < (2 / 2.75)) {
+ return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
+ } else if (t < (2.5 / 2.75)) {
+ return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
} else {
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
+ return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
}
}
@@ -637,8 +662,10 @@ function easeOutBounce (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeInOutBounce (t, b, c, d, p_params) {
- if (t < d/2) return easeInBounce (t*2, 0, c, d) * .5 + b;
- else return easeOutBounce (t*2-d, 0, c, d) * .5 + c*.5 + b;
+ if (t < d / 2)
+ return easeInBounce (t * 2, 0, c, d) * .5 + b;
+ else
+ return easeOutBounce (t * 2 - d, 0, c, d) * .5 + c * .5 + b;
}
/**
@@ -651,6 +678,7 @@ function easeInOutBounce (t, b, c, d, p_params) {
* @return The correct value.
*/
function easeOutInBounce (t, b, c, d, p_params) {
- if (t < d/2) return easeOutBounce (t*2, b, c/2, d, p_params);
- return easeInBounce((t*2)-d, b+c/2, c/2, d, p_params);
+ if (t < d / 2)
+ return easeOutBounce (t * 2, b, c / 2, d, p_params);
+ return easeInBounce((t * 2) - d, b + c / 2, c / 2, d, p_params);
}
diff --git a/modules/tweener/tweenList.js b/modules/tweener/tweenList.js
index 140b1402..fa5876cb 100644
--- a/modules/tweener/tweenList.js
+++ b/modules/tweener/tweenList.js
@@ -35,14 +35,14 @@ http://code.google.com/p/tweener/wiki/License
*/
function TweenList(scope, timeStart, timeComplete,
- useFrames, transition, transitionParams) {
+ useFrames, transition, transitionParams) {
this._init(scope, timeStart, timeComplete, useFrames, transition,
- transitionParams);
+ transitionParams);
}
TweenList.prototype = {
_init: function(scope, timeStart, timeComplete,
- userFrames, transition, transitionParams) {
+ userFrames, transition, transitionParams) {
this.scope = scope;
this.timeStart = timeStart;
this.timeComplete = timeComplete;
@@ -63,7 +63,7 @@ TweenList.prototype = {
clone: function(omitEvents) {
var tween = new TweenList(this.scope, this.timeStart, this.timeComplete, this.userFrames,
- this.transition, this.transitionParams);
+ this.transition, this.transitionParams);
tween.properties = new Array();
for (let name in this.properties) {
tween.properties[name] = this.properties[name];
diff --git a/modules/tweener/tweener.js b/modules/tweener/tweener.js
index ce19770a..ba1e9c34 100644
--- a/modules/tweener/tweener.js
+++ b/modules/tweener/tweener.js
@@ -75,10 +75,10 @@ function FrameTicker() {
FrameTicker.prototype = {
FRAME_RATE: 65,
- _init : function() {
+ _init: function() {
},
- start : function() {
+ start: function() {
this._currentTime = 0;
let me = this;
@@ -93,7 +93,7 @@ FrameTicker.prototype = {
});
},
- stop : function() {
+ stop: function() {
if ('_timeoutID' in this) {
GLib.source_remove(this._timeoutID);
delete this._timeoutID;
@@ -102,7 +102,7 @@ FrameTicker.prototype = {
this._currentTime = 0;
},
- getTime : function() {
+ getTime: function() {
return this._currentTime;
}
};
@@ -200,14 +200,13 @@ function _resumeTweenByIndex(i) {
}
/* FIXME: any way to get the function name from the fn itself? */
-function _callOnFunction(fn, fnname, scope, fallbackScope, params)
-{
+function _callOnFunction(fn, fnname, scope, fallbackScope, params) {
if (fn) {
var eventScope = scope ? scope : fallbackScope;
try {
fn.apply(eventScope, params);
} catch (e) {
- logError(e, 'Error calling ' + fnname);
+ logError(e, `Error calling ${fnname}`);
}
}
}
@@ -230,7 +229,7 @@ function _updateTweenByIndex(i) {
if (tweening.isCaller) {
do {
- t = ((tweening.timeComplete - tweening.timeStart)/tweening.count) *
+ t = ((tweening.timeComplete - tweening.timeStart) / tweening.count) *
(tweening.timesCalled + 1);
b = tweening.timeStart;
c = tweening.timeComplete - tweening.timeStart;
@@ -511,15 +510,19 @@ function _addTweenOrCaller(target, tweeningParameters, isCaller) {
} else {
for (var i = 0; i < scopes.length; i++) {
if (scopes[i][istr] == undefined)
- log('The property ' + istr + ' doesn\'t seem to be a normal object property of ' +
scopes[i] + ' or a registered special property');
+ log(`The property ${istr} doesn't seem to be a ` +
+ `normal object property of ${scopes[i]} or a ` +
+ 'registered special property');
}
}
}
}
// Creates the main engine if it isn't active
- if (!_inited) _init();
- if (!_engineExists) _startEngine();
+ if (!_inited)
+ _init();
+ if (!_engineExists)
+ _startEngine();
// Creates a "safer", more strict tweening object
var time = obj.time || 0;
@@ -599,7 +602,7 @@ function _addTweenOrCaller(target, tweeningParameters, isCaller) {
// Immediate update and removal if it's an immediate tween
// If not deleted, it executes at the end of this frame execution
if (time == 0 && delay == 0) {
- var myT = _tweenList.length-1;
+ var myT = _tweenList.length - 1;
_updateTweenByIndex(myT);
_removeTweenByIndex(myT);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]