New eslint rules auto fix (#3058)

* no-implicit-coercion and no-unneeded-ternary

* End every line with a semicolon

* Spacing and formatting

* Enabled semi-spacing

* Applies npm run lint:fix to code after master merge

* Fix merge issues

* Switched operator-linebreak to 'before'

Co-authored-by: Joshi <simplyrender@gmail.com>
This commit is contained in:
Andrew Henry
2020-07-31 12:11:03 -07:00
committed by GitHub
parent 573a63d359
commit a09da30768
739 changed files with 4660 additions and 2339 deletions

View File

@@ -54,7 +54,7 @@ define([
timerTemplate
) {
return {
name:"platform/features/clock",
name: "platform/features/clock",
definition: {
"name": "Clocks/Timers",
"descriptions": "Domain objects for displaying current & relative times.",

View File

@@ -37,16 +37,16 @@ define(
*/
function FollowTimerAction(timerService, context) {
var domainObject =
context.domainObject &&
context.domainObject.useCapability('adapter');
context.domainObject
&& context.domainObject.useCapability('adapter');
this.perform =
timerService.setTimer.bind(timerService, domainObject);
}
FollowTimerAction.appliesTo = function (context) {
var model =
(context.domainObject && context.domainObject.getModel()) ||
{};
(context.domainObject && context.domainObject.getModel())
|| {};
return model.type === 'timer';
};

View File

@@ -44,14 +44,13 @@ define(
PauseTimerAction.appliesTo = function (context) {
var model =
(context.domainObject && context.domainObject.getModel()) ||
{};
(context.domainObject && context.domainObject.getModel())
|| {};
// We show this variant for timers which have
// a target time, or is in a playing state.
return model.type === 'timer' &&
model.timerState === 'started';
return model.type === 'timer'
&& model.timerState === 'started';
};
PauseTimerAction.prototype.perform = function () {

View File

@@ -44,12 +44,12 @@ define(
RestartTimerAction.appliesTo = function (context) {
var model =
(context.domainObject && context.domainObject.getModel()) ||
{};
(context.domainObject && context.domainObject.getModel())
|| {};
// We show this variant for timers which already have a target time.
return model.type === 'timer' &&
model.timerState !== 'stopped';
return model.type === 'timer'
&& model.timerState !== 'stopped';
};
RestartTimerAction.prototype.perform = function () {

View File

@@ -44,13 +44,13 @@ define(
StartTimerAction.appliesTo = function (context) {
var model =
(context.domainObject && context.domainObject.getModel()) ||
{};
(context.domainObject && context.domainObject.getModel())
|| {};
// We show this variant for timers which do not yet have
// a target time.
return model.type === 'timer' &&
model.timerState !== 'started';
return model.type === 'timer'
&& model.timerState !== 'started';
};
StartTimerAction.prototype.perform = function () {
@@ -65,6 +65,7 @@ define(
} else {
model.timestamp = now();
}
model.timerState = 'started';
model.pausedTime = undefined;
}

View File

@@ -44,14 +44,13 @@ define(
StopTimerAction.appliesTo = function (context) {
var model =
(context.domainObject && context.domainObject.getModel()) ||
{};
(context.domainObject && context.domainObject.getModel())
|| {};
// We show this variant for timers which do not yet have
// a target time.
return model.type === 'timer' &&
model.timerState !== 'stopped';
return model.type === 'timer'
&& model.timerState !== 'stopped';
};
StopTimerAction.prototype.perform = function () {

View File

@@ -46,8 +46,8 @@ function (
self = this;
function update() {
var m = zoneName ?
moment.utc(lastTimestamp).tz(zoneName) : moment.utc(lastTimestamp);
var m = zoneName
? moment.utc(lastTimestamp).tz(zoneName) : moment.utc(lastTimestamp);
self.zoneAbbr = m.zoneAbbr();
self.textValue = timeFormat && m.format(timeFormat);
self.ampmValue = m.format("A"); // Just the AM or PM part
@@ -64,11 +64,11 @@ function (
baseFormat = model.clockFormat[0];
self.use24 = model.clockFormat[1] === 'clock24';
timeFormat = self.use24 ?
baseFormat.replace('hh', "HH") : baseFormat;
timeFormat = self.use24
? baseFormat.replace('hh', "HH") : baseFormat;
// If wrong timezone is provided, the UTC will be used
zoneName = momentTimezone.tz.names().includes(model.timezone) ?
model.timezone : "UTC";
zoneName = momentTimezone.tz.names().includes(model.timezone)
? model.timezone : "UTC";
update();
}
}

View File

@@ -40,8 +40,9 @@ define(
var unlisten;
function triggerRefresh() {
var persistence = $scope.domainObject &&
$scope.domainObject.getCapability('persistence');
var persistence = $scope.domainObject
&& $scope.domainObject.getCapability('persistence');
return persistence && persistence.refresh();
}

View File

@@ -26,7 +26,6 @@ define(
var FORMATTER = new TimerFormatter();
/**
* Controller for views of a Timer domain object.
*
@@ -50,10 +49,10 @@ define(
if (formatter && !isNaN(timeDelta)) {
self.textValue = formatter(timeDelta);
self.signValue = timeDelta < 0 ? "-" :
timeDelta >= 1000 ? "+" : "";
self.signCssClass = timeDelta < 0 ? "icon-minus" :
timeDelta >= 1000 ? "icon-plus" : "";
self.signValue = timeDelta < 0 ? "-"
: timeDelta >= 1000 ? "+" : "";
self.signCssClass = timeDelta < 0 ? "icon-minus"
: timeDelta >= 1000 ? "icon-plus" : "";
} else {
self.textValue = "";
self.signValue = "";
@@ -74,11 +73,11 @@ define(
}
function updateActions(actionCapability, actionKey) {
self.relevantAction = actionCapability &&
actionCapability.getActions(actionKey)[0];
self.relevantAction = actionCapability
&& actionCapability.getActions(actionKey)[0];
self.stopAction = relativeTimerState !== 'stopped' ?
actionCapability && actionCapability.getActions('timer.stop')[0] : undefined;
self.stopAction = relativeTimerState !== 'stopped'
? actionCapability && actionCapability.getActions('timer.stop')[0] : undefined;
}
@@ -88,8 +87,8 @@ define(
function handleLegacyTimer(model) {
if (model.timerState === undefined) {
model.timerState = model.timestamp === undefined ?
'stopped' : 'started';
model.timerState = model.timestamp === undefined
? 'stopped' : 'started';
}
}
@@ -101,8 +100,8 @@ define(
formatKey = model.timerFormat,
timerState = model.timerState,
actionCapability = domainObject.getCapability('action'),
actionKey = (timerState !== 'started') ?
'timer.start' : 'timer.pause';
actionKey = (timerState !== 'started')
? 'timer.start' : 'timer.pause';
updateFormat(formatKey);
updateTimestamp(timestamp);
@@ -146,6 +145,7 @@ define(
if (lastSign !== self.signValue || lastText !== self.textValue) {
$scope.$apply();
}
if (active) {
$window.requestAnimationFrame(tick);
}
@@ -174,8 +174,8 @@ define(
* @returns {string} cssclass to display
*/
TimerController.prototype.buttonCssClass = function () {
return this.relevantAction ?
this.relevantAction.getMetadata().cssClass : "";
return this.relevantAction
? this.relevantAction.getMetadata().cssClass : "";
};
/**
@@ -184,11 +184,10 @@ define(
* @returns {string} name of the action
*/
TimerController.prototype.buttonText = function () {
return this.relevantAction ?
this.relevantAction.getMetadata().name : "";
return this.relevantAction
? this.relevantAction.getMetadata().name : "";
};
/**
* Perform the action associated with the start/pause button.
*/

View File

@@ -66,13 +66,12 @@ define(['EventEmitter'], function (EventEmitter) {
return this.timer;
};
/**
* Check if there is a currently active timer.
* @return {boolean} true if there is a timer
*/
TimerService.prototype.hasTimer = function () {
return !!this.timer;
return Boolean(this.timer);
};
/**
@@ -82,17 +81,17 @@ define(['EventEmitter'], function (EventEmitter) {
*/
TimerService.prototype.convert = function (timestamp) {
var clock = this.time.clock();
var canConvert = this.hasTimer() &&
!!clock &&
this.timer.timerState !== 'stopped';
var canConvert = this.hasTimer()
&& Boolean(clock)
&& this.timer.timerState !== 'stopped';
if (!canConvert) {
return undefined;
}
var now = clock.currentValue();
var delta = this.timer.timerState === 'paused' ?
now - this.timer.pausedTime : 0;
var delta = this.timer.timerState === 'paused'
? now - this.timer.pausedTime : 0;
var epoch = this.timer.timestamp;
return timestamp - epoch - delta;
@@ -106,6 +105,7 @@ define(['EventEmitter'], function (EventEmitter) {
*/
TimerService.prototype.now = function () {
var clock = this.time.clock();
return clock && this.convert(clock.currentValue());
};

View File

@@ -33,10 +33,12 @@ define([
beforeEach(function () {
testModel = {};
testContext = { domainObject: jasmine.createSpyObj('domainObject', [
'getModel',
'useCapability'
]) };
testContext = {
domainObject: jasmine.createSpyObj('domainObject', [
'getModel',
'useCapability'
])
};
testAdaptedObject = { foo: 'bar' };
testContext.domainObject.getModel.and.returnValue(testModel);
testContext.domainObject.useCapability.and.callFake(function (c) {

View File

@@ -61,6 +61,7 @@ define(
mockDomainObject.useCapability.and.callFake(function (c, v) {
if (c === 'mutation') {
testModel = v(testModel) || testModel;
return asPromise(true);
}
});

View File

@@ -61,6 +61,7 @@ define(
mockDomainObject.useCapability.and.callFake(function (c, v) {
if (c === 'mutation') {
testModel = v(testModel) || testModel;
return asPromise(true);
}
});

View File

@@ -61,6 +61,7 @@ define(
mockDomainObject.useCapability.and.callFake(function (c, v) {
if (c === 'mutation') {
testModel = v(testModel) || testModel;
return asPromise(true);
}
});

View File

@@ -61,6 +61,7 @@ define(
mockDomainObject.useCapability.and.callFake(function (c, v) {
if (c === 'mutation') {
testModel = v(testModel) || testModel;
return asPromise(true);
}
});

View File

@@ -24,8 +24,6 @@ define(
["../../src/controllers/RefreshingController"],
function (RefreshingController) {
describe("The refreshing controller", function () {
var mockScope,
mockTicker,

View File

@@ -92,9 +92,18 @@ define(
}[k]];
});
mockStart.getMetadata.and.returnValue({cssClass: "icon-play", name: "Start"});
mockPause.getMetadata.and.returnValue({cssClass: "icon-pause", name: "Pause"});
mockStop.getMetadata.and.returnValue({cssClass: "icon-box", name: "Stop"});
mockStart.getMetadata.and.returnValue({
cssClass: "icon-play",
name: "Start"
});
mockPause.getMetadata.and.returnValue({
cssClass: "icon-pause",
name: "Pause"
});
mockStop.getMetadata.and.returnValue({
cssClass: "icon-box",
name: "Stop"
});
mockScope.domainObject = mockDomainObject;
testModel = {};