[gjs: 11/43] CI: Add curly to eslint rules
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 11/43] CI: Add curly to eslint rules
- Date: Wed, 14 Aug 2019 17:27:59 +0000 (UTC)
commit 47d74dfbcccafe8281502180bdae43ebb6e90c2f
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Aug 3 17:57:34 2019 -0700
CI: Add curly to eslint rules
This allows omitting the braces on a one-line block (note one-statement
is not necessarily one-line!) but enforces consistent brace style
between if and else clauses which can be a source of bugs.
.eslintrc.yml | 4 +++
examples/calc.js | 6 ++--
examples/gio-cat.js | 5 ++-
examples/gtk-application.js | 10 +++---
installed-tests/js/minijasmine.js | 3 +-
installed-tests/js/testEverythingBasic.js | 6 ++--
installed-tests/js/testGDBus.js | 5 ++-
installed-tests/js/testGIMarshalling.js | 3 +-
installed-tests/js/testGio.js | 6 ++--
installed-tests/js/testLegacyByteArray.js | 9 ++----
modules/_bootstrap/debugger.js | 51 +++++++++++++++----------------
modules/_legacy.js | 25 +++++++--------
modules/lang.js | 8 ++---
modules/overrides/GLib.js | 11 ++++---
modules/overrides/GObject.js | 6 ++--
modules/overrides/Gio.js | 31 ++++++++++---------
modules/overrides/Gtk.js | 12 ++++----
modules/signals.js | 12 +++-----
modules/tweener/equations.js | 9 +++---
modules/tweener/tweenList.js | 3 +-
modules/tweener/tweener.js | 31 ++++++++-----------
21 files changed, 116 insertions(+), 140 deletions(-)
---
diff --git a/.eslintrc.yml b/.eslintrc.yml
index d3a57932..c8cfe957 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -27,6 +27,10 @@ rules:
- error
- before: false
after: true
+ curly:
+ - error
+ - multi-or-nest
+ - consistent
indent:
- error
- 4
diff --git a/examples/calc.js b/examples/calc.js
index 58f0be20..0b45732e 100644
--- a/examples/calc.js
+++ b/examples/calc.js
@@ -10,9 +10,8 @@ var calcVal = '';
function updateDisplay() {
label.set_markup(`<span size='30000'>${calcVal}</span>`);
- if (calcVal === '') {
+ if (calcVal === '')
label.set_markup("<span size='30000'>0</span>");
- }
}
function clear() {
@@ -66,9 +65,8 @@ function packButtons(buttons, vbox) {
vbox.pack_start(hbox, true, true, 2);
- for (let i = 0; i <= 4; i++) {
+ for (let i = 0; i <= 4; i++)
hbox.pack_start(buttons[i], true, true, 1);
- }
}
function createButton(str, func) {
diff --git a/examples/gio-cat.js b/examples/gio-cat.js
index d0b81164..92d05347 100644
--- a/examples/gio-cat.js
+++ b/examples/gio-cat.js
@@ -23,8 +23,7 @@ function cat(filename) {
loop.run();
}
-if (ARGV.length != 1) {
+if (ARGV.length != 1)
printerr('Usage: gio-cat.js filename');
-} else {
+else
cat(ARGV[0]);
-}
diff --git a/examples/gtk-application.js b/examples/gtk-application.js
index fe3c6f11..99a3fd98 100644
--- a/examples/gtk-application.js
+++ b/examples/gtk-application.js
@@ -31,13 +31,12 @@ var ExampleApplication = GObject.registerClass({
flags: Gio.ApplicationFlags.FLAGS_NONE,
});
}
-
+
// Example property getter/setter
get exampleprop() {
- if (typeof this._exampleprop === 'undefined') {
+ if (typeof this._exampleprop === 'undefined')
return 'a default value';
- }
-
+
return this._exampleprop;
}
@@ -65,9 +64,8 @@ var ExampleApplication = GObject.registerClass({
exampleAction.connect('activate', (action, param) => {
param = param.deepUnpack().toString();
- if (param === 'exampleParameter') {
+ if (param === 'exampleParameter')
log('Yes!');
- }
});
this.add_action(exampleAction);
diff --git a/installed-tests/js/minijasmine.js b/installed-tests/js/minijasmine.js
index 6e7b92b3..a1a86a2f 100644
--- a/installed-tests/js/minijasmine.js
+++ b/installed-tests/js/minijasmine.js
@@ -74,9 +74,8 @@ class TapReporter {
this._failedSuites.push(result);
}
- if (result.status === 'disabled') {
+ if (result.status === 'disabled')
print('# Suite was disabled:', result.fullName);
- }
}
specStarted() {
diff --git a/installed-tests/js/testEverythingBasic.js b/installed-tests/js/testEverythingBasic.js
index 3332d91c..76c3397c 100644
--- a/installed-tests/js/testEverythingBasic.js
+++ b/installed-tests/js/testEverythingBasic.js
@@ -89,16 +89,18 @@ describe('Life, the Universe and Everything', function () {
if (skip[limit + bytes])
pending("This test doesn't work");
- if (bytes === '64')
+ if (bytes === '64') {
GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
'*cannot be safely stored*');
+ }
let val = Limits[bytes][limit];
expect(Regress[methodStem + bytes](val)).toBe(val);
- if (bytes === '64')
+ if (bytes === '64') {
GLib.test_assert_expected_messages_internal('Gjs',
'testEverythingBasic.js', 0, 'Ignore message');
+ }
}
['8', '16', '32', '64'].forEach(bytes => {
it(`marshals max value of unsigned ${bytes}-bit integers`, function () {
diff --git a/installed-tests/js/testGDBus.js b/installed-tests/js/testGDBus.js
index 6be052fe..50af1b01 100644
--- a/installed-tests/js/testGDBus.js
+++ b/installed-tests/js/testGDBus.js
@@ -117,11 +117,10 @@ class Test {
}
nonJsonFrobateStuff(i) {
- if (i == 42) {
+ if (i == 42)
return '42 it is!';
- } else {
+ else
return 'Oops';
- }
}
alwaysThrowException() {
diff --git a/installed-tests/js/testGIMarshalling.js b/installed-tests/js/testGIMarshalling.js
index be6c6fe8..a28c3c18 100644
--- a/installed-tests/js/testGIMarshalling.js
+++ b/installed-tests/js/testGIMarshalling.js
@@ -753,9 +753,8 @@ describe('GObject virtual function', function () {
_SimpleTestClass3.prototype.vfunc_doesnt_exist = function () {};
- if (GObject.Object.prototype.vfunc_doesnt_exist) {
+ if (GObject.Object.prototype.vfunc_doesnt_exist)
fail('Virtual function should not exist');
- }
expect(() => GObject.registerClass({GTypeName: 'SimpleTestClass3'}, _SimpleTestClass3)).toThrow();
});
diff --git a/installed-tests/js/testGio.js b/installed-tests/js/testGio.js
index 53d02752..677883b2 100644
--- a/installed-tests/js/testGio.js
+++ b/installed-tests/js/testGio.js
@@ -17,16 +17,14 @@ describe('ListStore iterator', function () {
beforeEach(function () {
list = new Gio.ListStore({item_type: Foo});
- for (let i = 0; i < 100; i++) {
+ for (let i = 0; i < 100; i++)
list.append(new Foo(i));
- }
});
it('ListStore iterates', function () {
let i = 0;
- for (let f of list) {
+ for (let f of list)
expect(f.value).toBe(i++);
- }
});
});
diff --git a/installed-tests/js/testLegacyByteArray.js b/installed-tests/js/testLegacyByteArray.js
index fad8ba87..6c64375b 100644
--- a/installed-tests/js/testLegacyByteArray.js
+++ b/installed-tests/js/testLegacyByteArray.js
@@ -18,22 +18,19 @@ describe('Legacy byte array', function() {
});
it('is initialized to zeroes', function() {
- for (let i = 0; i < a.length; ++i) {
+ for (let i = 0; i < a.length; ++i)
expect(a[i]).toEqual(0);
- }
});
});
it('assigns values correctly', function() {
let a = new ByteArray.ByteArray(256);
- for (let i = 0; i < a.length; ++i) {
+ for (let i = 0; i < a.length; ++i)
a[i] = 255 - i;
- }
- for (let i = 0; i < a.length; ++i) {
+ for (let i = 0; i < a.length; ++i)
expect(a[i]).toEqual(255 - i);
- }
});
describe('assignment past end', function() {
diff --git a/modules/_bootstrap/debugger.js b/modules/_bootstrap/debugger.js
index eddc115c..aafe6372 100644
--- a/modules/_bootstrap/debugger.js
+++ b/modules/_bootstrap/debugger.js
@@ -41,9 +41,8 @@ function summarizeObject(dv) {
const obj = {};
for (var name of dv.getOwnPropertyNames()) {
var v = dv.getOwnPropertyDescriptor(name).value;
- if (v instanceof Debugger.Object) {
+ if (v instanceof Debugger.Object)
v = '(...)';
- }
obj[name] = v;
}
return obj;
@@ -100,13 +99,14 @@ Object.defineProperty(Debugger.Frame.prototype, 'num', {
});
Debugger.Frame.prototype.describeFrame = function() {
- if (this.type == 'call')
+ if (this.type == 'call') {
return `${this.callee.name || '<anonymous>'}(${
this.arguments.map(dvToString).join(', ')})`;
- else if (this.type == 'global')
+ } else if (this.type == 'global') {
return 'toplevel';
- else
+ } else {
return `${this.type} code`;
+ }
};
Debugger.Frame.prototype.describePosition = function() {
@@ -368,11 +368,10 @@ function frameCommand(rest) {
focusedFrame = f;
showFrame(f, n);
} else if (rest === '') {
- if (topFrame === null) {
+ if (topFrame === null)
print('No stack.');
- } else {
+ else
showFrame();
- }
} else {
print('do what now?');
}
@@ -385,11 +384,11 @@ PARAMETER
· frame_num: frame to jump to`;
function upCommand() {
- if (focusedFrame === null)
+ if (focusedFrame === null) {
print('No stack.');
- else if (focusedFrame.older === null)
+ } else if (focusedFrame.older === null) {
print('Initial frame selected; you cannot go up.');
- else {
+ } else {
focusedFrame.older.younger = focusedFrame;
focusedFrame = focusedFrame.older;
showFrame();
@@ -400,11 +399,11 @@ upCommand.helpText = `USAGE
up`;
function downCommand() {
- if (focusedFrame === null)
+ if (focusedFrame === null) {
print('No stack.');
- else if (!focusedFrame.younger)
+ } else if (!focusedFrame.younger) {
print('Youngest frame selected; you cannot go down.');
- else {
+ } else {
focusedFrame = focusedFrame.younger;
showFrame();
}
@@ -684,9 +683,8 @@ function _printCommandsList() {
var cmdGroups = _groupCommands();
- for (var group of cmdGroups) {
+ for (var group of cmdGroups)
printcmd(group);
- }
}
function _groupCommands() {
@@ -697,7 +695,7 @@ function _groupCommands() {
if ([commentCommand, evalCommand].includes(cmd) ||
['#', '!'].includes(cmd))
continue;
-
+
if (typeof cmd === 'string') {
groups[groups.length - 1]['aliases'].push(cmd);
} else {
@@ -716,9 +714,8 @@ function _printCommand(cmd) {
if (cmd.aliases.length > 1) {
print('\nALIASES');
- for (var alias of cmd.aliases) {
+ for (var alias of cmd.aliases)
print(` · ${alias}`);
- }
}
}
@@ -729,11 +726,10 @@ function helpCommand(cmd) {
var cmdGroups = _groupCommands();
var command = cmdGroups.find(c => c.aliases.includes(cmd));
- if (command && command.helpText) {
+ if (command && command.helpText)
_printCommand(command);
- } else {
+ else
print(`No help found for ${cmd} command`);
- }
}
}
helpCommand.summary = 'Show help for the specified command else list all commands';
@@ -803,15 +799,16 @@ function repl() {
try {
prevcmd = cmd;
var result = runcmd(cmd);
- if (result === undefined)
- void result; // do nothing, return to prompt
- else if (Array.isArray(result))
+ if (result === undefined) {
+ // do nothing, return to prompt
+ } else if (Array.isArray(result)) {
return result[0];
- else if (result === null)
+ } else if (result === null) {
return null;
- else
+ } else {
throw new Error(
`Internal error: result of runcmd wasn't array or undefined: ${result}`);
+ }
} catch (exc) {
logError(exc, '*** Internal error: exception in the debugger code');
}
diff --git a/modules/_legacy.js b/modules/_legacy.js
index 6646b6f1..cad91377 100644
--- a/modules/_legacy.js
+++ b/modules/_legacy.js
@@ -61,11 +61,10 @@ function getMetaClass(params) {
function Class(params) {
let metaClass = getMetaClass(params);
- if (metaClass && metaClass != this.constructor) {
+ if (metaClass && metaClass != this.constructor)
return new metaClass(...arguments);
- } else {
+ else
return this._construct.apply(this, arguments);
- }
}
Class.__super__ = _Base;
@@ -74,7 +73,7 @@ Class.prototype.constructor = Class;
Class.prototype.__name__ = 'Class';
Class.prototype.wrapFunction = function(name, meth) {
- if (meth._origin)
+ if (meth._origin)
meth = meth._origin;
function wrapper() {
@@ -97,9 +96,9 @@ Class.prototype.toString = function() {
};
Class.prototype._construct = function(params) {
- if (!params.Name) {
+ if (!params.Name)
throw new TypeError("Classes require an explicit 'Name' parameter.");
- }
+
let name = params.Name;
let parent = params.Extends;
@@ -356,10 +355,11 @@ Interface.prototype._check = function (proto) {
let unimplementedFns = Object.getOwnPropertyNames(this.prototype)
.filter(p => this.prototype[p] === Interface.UNIMPLEMENTED)
.filter(p => !(p in proto) || proto[p] === Interface.UNIMPLEMENTED);
- if (unimplementedFns.length > 0)
+ if (unimplementedFns.length > 0) {
throw new Error(`The following members of ${
this.prototype.__name__} are not implemented yet: ${
unimplementedFns.join(', ')}`);
+ }
};
Interface.prototype.toString = function () {
@@ -446,9 +446,8 @@ function defineGObjectLegacyObjects(GObject) {
function _propertiesAsArray(params) {
let propertiesArray = [];
if (params.Properties) {
- for (let prop in params.Properties) {
+ for (let prop in params.Properties)
propertiesArray.push(params.Properties[prop]);
- }
}
return propertiesArray;
}
@@ -574,11 +573,10 @@ function defineGObjectLegacyObjects(GObject) {
// Overrides Lang.Class.implements()
implements: function (iface) {
- if (iface instanceof GObject.Interface) {
+ if (iface instanceof GObject.Interface)
return GObject.type_is_a(this.$gtype, iface.$gtype);
- } else {
+ else
return this.parent(iface);
- }
},
});
@@ -594,9 +592,8 @@ function defineGObjectLegacyObjects(GObject) {
GObjectInterface.prototype.__name__ = 'GObjectInterface';
GObjectInterface.prototype._construct = function (params) {
- if (!params.Name) {
+ if (!params.Name)
throw new TypeError("Interfaces require an explicit 'Name' parameter.");
- }
let gtypename = _createGTypeName(params);
delete params.GTypeName;
diff --git a/modules/lang.js b/modules/lang.js
index 4c41c8e8..ce256830 100644
--- a/modules/lang.js
+++ b/modules/lang.js
@@ -44,19 +44,17 @@ function _copyProperty(source, dest, property) {
}
function copyProperties(source, dest) {
- for (let property in source) {
+ for (let property in source)
_copyProperty(source, dest, property);
- }
}
function copyPublicProperties(source, dest) {
for (let property in source) {
if (typeof(property) == 'string' &&
- property.substring(0, 1) == '_') {
+ property.substring(0, 1) == '_')
continue;
- } else {
+ else
_copyProperty(source, dest, property);
- }
}
}
diff --git a/modules/overrides/GLib.js b/modules/overrides/GLib.js
index a59a48ae..14fbf47b 100644
--- a/modules/overrides/GLib.js
+++ b/modules/overrides/GLib.js
@@ -31,8 +31,9 @@ function _readSingleType(signature, forceSimple) {
if (SIMPLE_TYPES.indexOf(char) == -1) {
if (forceSimple)
throw new TypeError('Invalid GVariant signature (a simple type was expected)');
- } else
+ } else {
isSimple = true;
+ }
if (char == 'm' || char == 'a')
return [char].concat(_readSingleType(signature, false));
@@ -108,11 +109,12 @@ function _packVariant(signature, value) {
case 'v':
return GLib.Variant.new_variant(value);
case 'm':
- if (value != null)
+ if (value != null) {
return GLib.Variant.new_maybe(null, _packVariant(signature, value));
- else
+ } else {
return GLib.Variant.new_maybe(new GLib.VariantType(
_readSingleType(signature, false).join('')), null);
+ }
case 'a': {
let arrayType = _readSingleType(signature, false);
if (arrayType[0] == 's') {
@@ -314,9 +316,8 @@ function _init() {
this.log_structured = function(logDomain, logLevel, stringFields) {
let fields = {};
- for (let key in stringFields) {
+ for (let key in stringFields)
fields[key] = new GLib.Variant('s', stringFields[key]);
- }
GLib.log_variant(logDomain, logLevel, new GLib.Variant('a{sv}', fields));
};
diff --git a/modules/overrides/GObject.js b/modules/overrides/GObject.js
index 0bb7450e..9a8f6658 100644
--- a/modules/overrides/GObject.js
+++ b/modules/overrides/GObject.js
@@ -80,9 +80,10 @@ function registerClass(klass) {
}
if (!(klass.prototype instanceof GObject.Object) &&
- !(klass.prototype instanceof GObject.Interface))
+ !(klass.prototype instanceof GObject.Interface)) {
throw new TypeError('GObject.registerClass() used with invalid base ' +
`class (is ${Object.getPrototypeOf(klass).name})`);
+ }
// Find the "least derived" class with a _classInit static function; there
// definitely is one, since this class must inherit from GObject
@@ -119,9 +120,8 @@ function _createGTypeName(klass) {
function _propertiesAsArray(klass) {
let propertiesArray = [];
if (klass.hasOwnProperty(properties)) {
- for (let prop in klass[properties]) {
+ for (let prop in klass[properties])
propertiesArray.push(klass[properties][prop]);
- }
}
return propertiesArray;
}
diff --git a/modules/overrides/Gio.js b/modules/overrides/Gio.js
index 262b3bf4..91ea7eed 100644
--- a/modules/overrides/Gio.js
+++ b/modules/overrides/Gio.js
@@ -44,9 +44,10 @@ function _validateFDVariant(variant, fdList) {
case 'h': {
const val = variant.get_handle();
const numFds = fdList.get_length();
- if (val >= numFds)
+ if (val >= numFds) {
throw new Error(`handle ${val} is out of range of Gio.UnixFDList ` +
`containing ${numFds} FDs`);
+ }
return;
}
case 'v':
@@ -117,9 +118,10 @@ function _proxyInvoker(methodName, sync, inSignature, argArray) {
const inTypeString = `(${inSignature.join('')})`;
const inVariant = new GLib.Variant(inTypeString, argArray);
if (inTypeString.includes('h')) {
- if (!fdList)
+ if (!fdList) {
throw new Error(`Method ${methodName} with input type containing ` +
'\'h\' must have a Gio.UnixFDList as an argument');
+ }
_validateFDVariant(inVariant, fdList);
}
@@ -146,9 +148,8 @@ function _proxyInvoker(methodName, sync, inSignature, argArray) {
}
function _logReply(result, exc) {
- if (exc != null) {
+ if (exc != null)
log(`Ignored exception from dbus method: ${exc}`);
- }
}
function _makeProxyMethod(method, sync) {
@@ -248,7 +249,7 @@ function _makeProxyWrapper(interfaceXml) {
if (!cancellable)
cancellable = null;
- if (asyncCallback)
+ if (asyncCallback) {
obj.init_async(GLib.PRIORITY_DEFAULT, cancellable, (initable, result) => {
let caughtErrorWhenInitting = null;
try {
@@ -257,14 +258,14 @@ function _makeProxyWrapper(interfaceXml) {
caughtErrorWhenInitting = e;
}
- if (caughtErrorWhenInitting === null) {
+ if (caughtErrorWhenInitting === null)
asyncCallback(initable, null);
- } else {
+ else
asyncCallback(null, caughtErrorWhenInitting);
- }
});
- else
+ } else {
obj.init(cancellable);
+ }
return obj;
};
}
@@ -416,15 +417,14 @@ function _wrapJSObject(interfaceInfo, jsObj) {
function* _listModelIterator() {
let _index = 0;
const _len = this.get_n_items();
- while (_index < _len) {
+ while (_index < _len)
yield this.get_item(_index++);
- }
}
function _promisify(proto, asyncFunc, finishFunc) {
proto[`_original_${asyncFunc}`] = proto[asyncFunc];
proto[asyncFunc] = function(...args) {
- if (!args.every(arg => typeof arg !== 'function'))
+ if (!args.every(arg => typeof arg !== 'function'))
return this[`_original_${asyncFunc}`](...args);
return new Promise((resolve, reject) => {
const callStack = new Error().stack.split('\n').filter(line =>
!line.match(/promisify/)).join('\n');
@@ -435,9 +435,9 @@ function _promisify(proto, asyncFunc, finishFunc) {
result.shift();
resolve(result);
} catch (error) {
- if (error.stack)
+ if (error.stack)
error.stack += `### Promise created here: ###\n${callStack}`;
- else
+ else
error.stack = callStack;
reject(error);
}
@@ -537,9 +537,10 @@ function _init() {
// 'schema' is a deprecated alias for schema_id
const requiredProps = ['schema', 'schema-id', 'schema_id', 'schemaId',
'settings-schema', 'settings_schema', 'settingsSchema'];
- if (requiredProps.every(prop => !(prop in props)))
+ if (requiredProps.every(prop => !(prop in props))) {
throw new Error('One of property \'schema-id\' or ' +
'\'settings-schema\' are required for Gio.Settings');
+ }
const checkSchemasProps = ['schema', 'schema-id', 'schema_id', 'schemaId'];
const source = Gio.SettingsSchemaSource.get_default();
diff --git a/modules/overrides/Gtk.js b/modules/overrides/Gtk.js
index 82cc395f..f02bf12a 100644
--- a/modules/overrides/Gtk.js
+++ b/modules/overrides/Gtk.js
@@ -45,15 +45,14 @@ function _init() {
Gtk.Widget.prototype._init = function(params) {
if (this.constructor[Gtk.template]) {
Gtk.Widget.set_connect_func.call(this.constructor, (builder, obj, signalName, handlerName,
connectObj, flags) => {
- if (connectObj !== null) {
+ if (connectObj !== null)
throw new Error('Unsupported template signal attribute "object"');
- } else if (flags & GObject.ConnectFlags.SWAPPED) {
+ else if (flags & GObject.ConnectFlags.SWAPPED)
throw new Error('Unsupported template signal flag "swapped"');
- } else if (flags & GObject.ConnectFlags.AFTER) {
+ else if (flags & GObject.ConnectFlags.AFTER)
obj.connect_after(signalName, this[handlerName].bind(this));
- } else {
+ else
obj.connect(signalName, this[handlerName].bind(this));
- }
});
}
@@ -101,8 +100,9 @@ function _init() {
let [, contents] = file.load_contents(null);
Gtk.Widget.set_template.call(klass, contents);
}
- } else
+ } else {
Gtk.Widget.set_template.call(klass, template);
+ }
}
if (children) {
diff --git a/modules/signals.js b/modules/signals.js
index ea0a2bbb..229f014f 100644
--- a/modules/signals.js
+++ b/modules/signals.js
@@ -95,9 +95,8 @@ function _signalHandlerIsConnected(id) {
function _disconnectAll() {
if ('_signalConnections' in this) {
- while (this._signalConnections.length > 0) {
+ while (this._signalConnections.length > 0)
_disconnect.call(this, this._signalConnections[0].id);
- }
}
}
@@ -115,9 +114,8 @@ function _emit(name, ...args) {
let length = this._signalConnections.length;
for (i = 0; i < length; ++i) {
let connection = this._signalConnections[i];
- if (connection.name == name) {
+ if (connection.name == name)
handlers.push(connection);
- }
}
// create arg array which is emitter + everything passed in except
@@ -138,9 +136,8 @@ function _emit(name, ...args) {
// if the callback returns true, we don't call the next
// signal handlers
- if (ret === true) {
+ if (ret === true)
break;
- }
} catch (e) {
// just log any exceptions so that callbacks can't disrupt
// signal emission
@@ -151,9 +148,8 @@ function _emit(name, ...args) {
}
function _addSignalMethod(proto, functionName, func) {
- if (proto[functionName] && proto[functionName] != func) {
+ if (proto[functionName] && proto[functionName] != func)
log(`WARNING: addSignalMethods is replacing existing ${proto} ${functionName} method`);
- }
proto[functionName] = func;
}
diff --git a/modules/tweener/equations.js b/modules/tweener/equations.js
index d76f6ee7..51ff6980 100644
--- a/modules/tweener/equations.js
+++ b/modules/tweener/equations.js
@@ -643,15 +643,14 @@ function easeInBounce (t, b, c, d, pParams) {
* @return The correct value.
*/
function easeOutBounce (t, b, c, d, pParams) {
- if ((t /= d) < (1 / 2.75)) {
+ if ((t /= d) < (1 / 2.75))
return c * (7.5625 * t * t) + b;
- } else if (t < (2 / 2.75)) {
+ 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)) {
+ else if (t < (2.5 / 2.75))
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
- } else {
+ else
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
- }
}
/**
diff --git a/modules/tweener/tweenList.js b/modules/tweener/tweenList.js
index 3d0b3898..894a75d3 100644
--- a/modules/tweener/tweenList.js
+++ b/modules/tweener/tweenList.js
@@ -65,9 +65,8 @@ TweenList.prototype = {
var tween = new TweenList(this.scope, this.timeStart, this.timeComplete, this.userFrames,
this.transition, this.transitionParams);
tween.properties = new Array();
- for (let name in this.properties) {
+ for (let name in this.properties)
tween.properties[name] = this.properties[name];
- }
tween.skipUpdates = this.skipUpdates;
tween.updatesSkipped = this.updatesSkipped;
diff --git a/modules/tweener/tweener.js b/modules/tweener/tweener.js
index 35eb5281..ce6afeb3 100644
--- a/modules/tweener/tweener.js
+++ b/modules/tweener/tweener.js
@@ -149,9 +149,8 @@ function _startEngine() {
_engineExists = true;
_tweenList = new Array();
- if (!_ticker) {
+ if (!_ticker)
throw new Error('Must call setFrameTicker()');
- }
_prepareFrameId = _ticker.connect('prepare-frame',
_onEnterFrame);
@@ -273,9 +272,8 @@ function _updateTweenByIndex(i) {
if (tweening.properties[name].isSpecialProperty) {
// It's a special property, tunnel via the special property function
- if (_specialPropertyList[name].preProcess != undefined) {
+ if (_specialPropertyList[name].preProcess != undefined)
tweening.properties[name].valueComplete =
_specialPropertyList[name].preProcess(scope, _specialPropertyList[name].parameters,
tweening.properties[name].originalValueComplete, tweening.properties[name].extra);
- }
pv = _specialPropertyList[name].getValue(scope, _specialPropertyList[name].parameters,
tweening.properties[name].extra);
} else {
// Directly read property
@@ -511,10 +509,11 @@ function _addTweenOrCaller(target, tweeningParameters, isCaller) {
properties[istr].isSpecialProperty = true;
} else {
for (var i = 0; i < scopes.length; i++) {
- if (scopes[i][istr] == undefined)
+ 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');
+ }
}
}
}
@@ -533,11 +532,10 @@ function _addTweenOrCaller(target, tweeningParameters, isCaller) {
var transition;
// FIXME: Tweener allows you to use functions with an all lower-case name
- if (typeof obj.transition == 'string') {
+ if (typeof obj.transition == 'string')
transition = imports.tweener.equations[obj.transition];
- } else {
+ else
transition = obj.transition;
- }
if (!transition)
transition = imports.tweener.equations['easeOutExpo'];
@@ -662,9 +660,8 @@ function removeTweensByTime(scope, properties, timeStart, timeComplete) {
}
if (removedLocally &&
- _getNumberOfProperties(_tweenList[i].properties) == 0) {
+ _getNumberOfProperties(_tweenList[i].properties) == 0)
_removeTweenByIndex(i);
- }
}
}
@@ -734,9 +731,8 @@ function _affectTweens(affectFunction, scope, properties) {
// Must check whether this tween must have specific properties affected
var affectedProperties = new Array();
for (let j = 0; j < properties.length; j++) {
- if (_tweenList[i].properties[properties[j]]) {
+ if (_tweenList[i].properties[properties[j]])
affectedProperties.push(properties[j]);
- }
}
if (affectedProperties.length > 0) {
@@ -776,11 +772,10 @@ function _affectTweensWithFunction(func, args) {
var affected = false;
var scopes;
- if (scope instanceof Array) {
+ if (scope instanceof Array)
scopes = scope.concat();
- } else {
+ else
scopes = new Array(scope);
- }
for (let i = 1; args[i] != undefined; i++) {
if (typeof(args[i]) == 'string' && !_isInArray(args[i], properties)) {
@@ -790,15 +785,15 @@ function _affectTweensWithFunction(func, args) {
var specialProps = sps.splitValues(scope, null);
for (let j = 0; j < specialProps.length; j++)
properties.push(specialProps[j].name);
- } else
+ } else {
properties.push(args[i]);
+ }
}
}
// the return now value means: "affect at least one tween"
- for (let i = 0; i < scopes.length; i++) {
+ for (let i = 0; i < scopes.length; i++)
affected = affected || _affectTweens(func, scopes[i], properties);
- }
return affected;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]