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

@ -56,6 +56,7 @@ define(
//navigate back to parent because nothing to show.
return domainObject.getCapability("location").getOriginal().then(function (original) {
parent = original.getCapability("context").getParent();
return parent.getCapability("action").perform("navigate");
});
}
@ -78,9 +79,10 @@ define(
*/
CancelAction.appliesTo = function (context) {
var domainObject = (context || {}).domainObject;
return domainObject !== undefined &&
domainObject.hasCapability('editor') &&
domainObject.getCapability('editor').isEditContextRoot();
return domainObject !== undefined
&& domainObject.hasCapability('editor')
&& domainObject.getCapability('editor').isEditContextRoot();
};
return CancelAction;

View File

@ -91,9 +91,9 @@ define(
// Only allow editing of types that support it and are not already
// being edited
return type && type.hasFeature('creation') &&
domainObject.hasCapability('editor') &&
!domainObject.getCapability('editor').isEditContextRoot();
return type && type.hasFeature('creation')
&& domainObject.hasCapability('editor')
&& !domainObject.getCapability('editor').isEditContextRoot();
};
return EditAction;

View File

@ -24,7 +24,6 @@ define(
[],
function () {
/**
* Add one domain object to another's composition.
* @constructor
@ -42,8 +41,9 @@ define(
// Link these objects
function doLink() {
var composition = self.domainObject &&
self.domainObject.getCapability('composition');
var composition = self.domainObject
&& self.domainObject.getCapability('composition');
return composition && composition.add(self.selectedObject);
}

View File

@ -99,4 +99,3 @@ define(
);

View File

@ -51,6 +51,7 @@ define(
// Property definition is same as form row definition
var row = JSON.parse(JSON.stringify(property.getDefinition()));
row.key = index;
return row;
}).filter(function (row) {
// Only show properties which are editable

View File

@ -86,10 +86,11 @@ define(
*/
SaveAction.appliesTo = function (context) {
var domainObject = (context || {}).domainObject;
return domainObject !== undefined &&
domainObject.hasCapability('editor') &&
domainObject.getCapability('editor').isEditContextRoot() &&
domainObject.getModel().persisted !== undefined;
return domainObject !== undefined
&& domainObject.hasCapability('editor')
&& domainObject.getCapability('editor').isEditContextRoot()
&& domainObject.getModel().persisted !== undefined;
};
return SaveAction;

View File

@ -20,7 +20,6 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'../creation/CreateWizard',
'./SaveInProgressDialog'
@ -50,6 +49,7 @@ function (
this.injectObjectService = function () {
this.objectService = $injector.get("objectService");
};
this.dialogService = dialogService;
this.copyService = copyService;
this.notificationService = notificationService;
@ -75,6 +75,7 @@ function (
if (!this.objectService) {
this.injectObjectService();
}
return this.objectService;
};
@ -118,11 +119,13 @@ function (
function showBlockingDialog(object) {
dialog.show();
return object;
}
function hideBlockingDialog(object) {
dialog.hide();
return object;
}
@ -138,11 +141,12 @@ function (
function allowClone(objectToClone) {
var allowed =
(objectToClone.getId() === domainObject.getId()) ||
objectToClone.getCapability('location').isOriginal();
(objectToClone.getId() === domainObject.getId())
|| objectToClone.getCapability('location').isOriginal();
if (allowed) {
toUndirty.push(objectToClone);
}
return allowed;
}
@ -163,11 +167,11 @@ function (
return this.openmct.editor.save().then(() => {
// Force mutation for search indexing
return clonedObject;
})
});
}
function finishEditing(clonedObject) {
return fetchObject(clonedObject.getId())
return fetchObject(clonedObject.getId());
}
function indexForSearch(savedObject) {
@ -180,6 +184,7 @@ function (
function onSuccess(object) {
self.notificationService.info("Save Succeeded");
return object;
}
@ -188,6 +193,7 @@ function (
if (reason !== "user canceled") {
self.notificationService.error("Save Failed");
}
throw reason;
}
@ -205,7 +211,6 @@ function (
.catch(onFailure);
};
/**
* Check if this action is applicable in a given context.
* This will ensure that a domain object is present in the context,
@ -214,10 +219,11 @@ function (
*/
SaveAsAction.appliesTo = function (context) {
var domainObject = (context || {}).domainObject;
return domainObject !== undefined &&
domainObject.hasCapability('editor') &&
domainObject.getCapability('editor').isEditContextRoot() &&
domainObject.getModel().persisted === undefined;
return domainObject !== undefined
&& domainObject.hasCapability('editor')
&& domainObject.getCapability('editor').isEditContextRoot()
&& domainObject.getModel().persisted === undefined;
};
return SaveAsAction;

View File

@ -83,6 +83,7 @@ define(
*/
EditorCapability.prototype.save = function () {
console.warn('DEPRECATED: cannot save via edit capability, use openmct.editor instead.');
return Promise.resolve();
};
@ -95,6 +96,7 @@ define(
*/
EditorCapability.prototype.finish = function () {
console.warn('DEPRECATED: cannot finish via edit capability, use openmct.editor instead.');
return Promise.resolve();
};

View File

@ -56,9 +56,10 @@ define(
capabilities.persistence = function (domainObject) {
var original =
(typeof persistenceCapability === 'function') ?
persistenceCapability(domainObject) :
persistenceCapability;
(typeof persistenceCapability === 'function')
? persistenceCapability(domainObject)
: persistenceCapability;
return new TransactionalPersistenceCapability(
self.$q,
self.transactionService,
@ -66,6 +67,7 @@ define(
domainObject
);
};
return capabilities;
};

View File

@ -64,6 +64,7 @@ define(
wrappedPersistence.persist.bind(wrappedPersistence),
wrappedPersistence.refresh.bind(wrappedPersistence)
);
//Need to return a promise from this function
return this.$q.when(true);
} else {
@ -74,6 +75,7 @@ define(
TransactionalPersistenceCapability.prototype.refresh = function () {
this.transactionManager
.clearTransactionsFor(this.domainObject.getId());
return this.persistenceCapability.refresh();
};

View File

@ -48,9 +48,9 @@ define(
// Maintain all "conclude-editing" and "save" actions in the
// present context.
function updateActions() {
$scope.saveActions = $scope.action ?
$scope.action.getActions(SAVE_ACTION_CONTEXT) :
[];
$scope.saveActions = $scope.action
? $scope.action.getActions(SAVE_ACTION_CONTEXT)
: [];
$scope.saveActionsAsMenuOptions = $scope.saveActions.map(actionToMenuOption);
@ -58,9 +58,9 @@ define(
clickedAction.perform();
};
$scope.otherEditActions = $scope.action ?
$scope.action.getActions(OTHERS_ACTION_CONTEXT) :
[];
$scope.otherEditActions = $scope.action
? $scope.action.getActions(OTHERS_ACTION_CONTEXT)
: [];
// Required because Angular does not allow 'bind'
// in expressions.

View File

@ -30,11 +30,11 @@ define(
function cancelEditing(domainObject) {
var navigatedObject = domainObject,
editorCapability = navigatedObject &&
navigatedObject.getCapability("editor");
editorCapability = navigatedObject
&& navigatedObject.getCapability("editor");
return editorCapability &&
editorCapability.finish();
return editorCapability
&& editorCapability.finish();
}
/**

View File

@ -35,8 +35,8 @@ define(
// Update root object based on represented object
function updateRoot(domainObject) {
var root = self.rootDomainObject,
context = domainObject &&
domainObject.getCapability('context'),
context = domainObject
&& domainObject.getCapability('context'),
newRoot = context && context.getTrueRoot(),
oldId = root && root.getId(),
newId = newRoot && newRoot.getId();
@ -51,6 +51,7 @@ define(
// Update root when represented object changes
$scope.$watch('domainObject', updateRoot);
}
/**
* Get the root-level domain object, as reported by the
* represented domain object.

View File

@ -104,7 +104,6 @@ define(
// We will disable this.
};
/**
* Metadata associated with a Create action.
* @typedef {ActionMetadata} CreateActionMetadata

View File

@ -38,9 +38,9 @@ define(
function CreateMenuController($scope) {
// Update the set of Create actions
function refreshActions() {
$scope.createActions = $scope.action ?
$scope.action.getActions('create') :
[];
$scope.createActions = $scope.action
? $scope.action.getActions('create')
: [];
}
// Listen for new instances of the represented object's

View File

@ -114,6 +114,7 @@ define(
this.domainObject.useCapability("mutation", function () {
return formModel;
});
return this.domainObject;
};

View File

@ -73,12 +73,13 @@ define(
// as a child contained by that parent.
function addToComposition() {
var compositionCapability = parent.getCapability('composition'),
addResult = compositionCapability &&
compositionCapability.add(newObject);
addResult = compositionCapability
&& compositionCapability.add(newObject);
return self.$q.when(addResult).then(function (result) {
if (!result) {
self.$log.error("Could not modify " + parent.getId());
return undefined;
}
@ -92,6 +93,7 @@ define(
// what space to create the new object's model in.
if (!persistence || !newObjectPersistence) {
self.$log.warn(NON_PERSISTENT_WARNING);
return self.$q.reject(new Error(NON_PERSISTENT_WARNING));
}
@ -99,8 +101,6 @@ define(
return newObjectPersistence.persist().then(addToComposition);
};
return CreationService;
}
);

View File

@ -38,8 +38,8 @@ define(
// * treeModel: The model for the embedded tree representation,
// used for bi-directional object selection.
function setLocatingObject(domainObject, priorObject) {
var context = domainObject &&
domainObject.getCapability("context"),
var context = domainObject
&& domainObject.getCapability("context"),
contextRoot = context && context.getRoot();
if (contextRoot && contextRoot !== $scope.rootObject) {
@ -65,11 +65,12 @@ define(
$scope.ngModel[$scope.field] = domainObject;
// Restrict which locations can be selected
if (domainObject &&
$scope.structure &&
$scope.structure.validate) {
if (domainObject
&& $scope.structure
&& $scope.structure.validate) {
if (!$scope.structure.validate(domainObject)) {
setLocatingObject(priorObject, undefined);
return;
}
}
@ -78,7 +79,7 @@ define(
if ($scope.ngModelController) {
$scope.ngModelController.$setValidity(
'composition',
!!$scope.treeModel.selectedObject
Boolean($scope.treeModel.selectedObject)
);
}
}

View File

@ -45,6 +45,7 @@ define(
// because it may be saved elsewhere
if ((key === 'edit' && category === 'view-control') || key === 'properties') {
let newStyleObject = objectUtils.toNewFormat(domainObject, domainObject.getId());
return this.openmct.objects.isPersistable(newStyleObject);
}

View File

@ -74,6 +74,7 @@ define(
model.configuration = model.configuration || {};
model.configuration[this.key] = configuration;
}
domainObject.useCapability('mutation', function () {
return model;
});

View File

@ -41,6 +41,7 @@ define(['./Transaction'], function (Transaction) {
Transaction.prototype.commit.bind(this),
Transaction.prototype.cancel.bind(this)
);
return Promise.resolve(true);
};

View File

@ -41,8 +41,12 @@ define([], function () {
* pair of callbacks from the transaction
*/
Transaction.prototype.add = function (commit, cancel) {
var callback = { commit: commit, cancel: cancel };
var callback = {
commit: commit,
cancel: cancel
};
this.callbacks.push(callback);
return function () {
this.callbacks = this.callbacks.filter(function (c) {
return c !== callback;
@ -91,6 +95,5 @@ define([], function () {
};
});
return Transaction;
});

View File

@ -50,7 +50,7 @@ define([], function () {
* @returns {boolean} true if callbacks have been added
*/
TransactionManager.prototype.isScheduled = function (id) {
return !!this.clearTransactionFns[id];
return Boolean(this.clearTransactionFns[id]);
};
/**
@ -77,6 +77,7 @@ define([], function () {
return promiseFn().then(nextFn);
};
}
/**
* Clear any existing persistence calls for object with given ID. This ensures only the most recent persistence
* call is executed. This should prevent stale objects being persisted and overwriting fresh ones.

View File

@ -48,9 +48,9 @@ define(
* #cancel} are called
*/
TransactionService.prototype.startTransaction = function () {
var transaction = this.isActive() ?
new NestedTransaction(this.transactions[0]) :
new Transaction(this.$log);
var transaction = this.isActive()
? new NestedTransaction(this.transactions[0])
: new Transaction(this.$log);
this.transactions.push(transaction);
};
@ -99,13 +99,16 @@ define(
if (!transaction) {
return Promise.reject();
}
if (!this.isActive()) {
return transaction.commit()
.then(function (r) {
this.cacheService.flush();
return r;
}.bind(this));
}
return transaction.commit();
};
@ -119,6 +122,7 @@ define(
*/
TransactionService.prototype.cancel = function () {
var transaction = this.transactions.pop();
return transaction ? transaction.cancel() : Promise.reject();
};