mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
ESLint rules: array-callback-return, no-invalid-this, func-style (#3151)
* satisfied array-callback-return rule * satisfying no-invalid-this rule * fixed invalid-this issues * changed isNotEqual to arrow function * added rule func-style * added return false to satisfy array-callback-return rule Co-authored-by: Joel McKinnon <jmckinnon@apple.com> Co-authored-by: Joshi <simplyrender@gmail.com> Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
@ -169,28 +169,7 @@ export default {
|
||||
},
|
||||
dropCondition(targetIndex) {
|
||||
const oldIndexArr = Object.keys(this.conditionCollection);
|
||||
const move = function (arr, old_index, new_index) {
|
||||
while (old_index < 0) {
|
||||
old_index += arr.length;
|
||||
}
|
||||
|
||||
while (new_index < 0) {
|
||||
new_index += arr.length;
|
||||
}
|
||||
|
||||
if (new_index >= arr.length) {
|
||||
var k = new_index - arr.length;
|
||||
while ((k--) + 1) {
|
||||
arr.push(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
|
||||
|
||||
return arr;
|
||||
};
|
||||
|
||||
const newIndexArr = move(oldIndexArr, this.moveIndex, targetIndex);
|
||||
const newIndexArr = this.rearrangeIndices(oldIndexArr, this.moveIndex, targetIndex);
|
||||
const reorderPlan = [];
|
||||
|
||||
for (let i = 0; i < oldIndexArr.length; i++) {
|
||||
@ -205,6 +184,26 @@ export default {
|
||||
dragComplete() {
|
||||
this.isDragging = false;
|
||||
},
|
||||
rearrangeIndices(arr, old_index, new_index) {
|
||||
while (old_index < 0) {
|
||||
old_index += arr.length;
|
||||
}
|
||||
|
||||
while (new_index < 0) {
|
||||
new_index += arr.length;
|
||||
}
|
||||
|
||||
if (new_index >= arr.length) {
|
||||
var k = new_index - arr.length;
|
||||
while ((k--) + 1) {
|
||||
arr.push(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
|
||||
|
||||
return arr;
|
||||
},
|
||||
addTelemetryObject(domainObject) {
|
||||
this.telemetryObjs.push(domainObject);
|
||||
this.$emit('telemetryUpdated', this.telemetryObjs);
|
||||
|
@ -223,20 +223,22 @@ export default {
|
||||
},
|
||||
addConditionSet() {
|
||||
let conditionSetDomainObject;
|
||||
const handleItemSelection = (item) => {
|
||||
let self = this;
|
||||
|
||||
function handleItemSelection(item) {
|
||||
if (item) {
|
||||
conditionSetDomainObject = item;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const dismissDialog = (overlay, initialize) => {
|
||||
function dismissDialog(overlay, initialize) {
|
||||
overlay.dismiss();
|
||||
if (initialize && conditionSetDomainObject) {
|
||||
this.conditionSetDomainObject = conditionSetDomainObject;
|
||||
this.conditionalStyles = [];
|
||||
this.initializeConditionalStyles();
|
||||
self.conditionSetDomainObject = conditionSetDomainObject;
|
||||
self.conditionalStyles = [];
|
||||
self.initializeConditionalStyles();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let vm = new Vue({
|
||||
provide: {
|
||||
|
@ -431,20 +431,22 @@ export default {
|
||||
},
|
||||
addConditionSet() {
|
||||
let conditionSetDomainObject;
|
||||
const handleItemSelection = (item) => {
|
||||
let self = this;
|
||||
function handleItemSelection(item) {
|
||||
if (item) {
|
||||
conditionSetDomainObject = item;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const dismissDialog = (overlay, initialize) => {
|
||||
function dismissDialog(overlay, initialize) {
|
||||
overlay.dismiss();
|
||||
|
||||
if (initialize && conditionSetDomainObject) {
|
||||
this.conditionSetDomainObject = conditionSetDomainObject;
|
||||
this.conditionalStyles = [];
|
||||
this.initializeConditionalStyles();
|
||||
self.conditionSetDomainObject = conditionSetDomainObject;
|
||||
self.conditionalStyles = [];
|
||||
self.initializeConditionalStyles();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let vm = new Vue({
|
||||
provide: {
|
||||
|
@ -21,7 +21,7 @@
|
||||
*****************************************************************************/
|
||||
import { TRIGGER } from "./constants";
|
||||
|
||||
export const evaluateResults = (results, trigger) => {
|
||||
export function evaluateResults(results, trigger) {
|
||||
if (trigger && trigger === TRIGGER.XOR) {
|
||||
return matchExact(results, 1);
|
||||
} else if (trigger && trigger === TRIGGER.NOT) {
|
||||
@ -31,7 +31,7 @@ export const evaluateResults = (results, trigger) => {
|
||||
} else {
|
||||
return matchAny(results);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function matchAll(results) {
|
||||
for (const result of results) {
|
||||
|
@ -20,23 +20,23 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
const convertToNumbers = (input) => {
|
||||
function convertToNumbers(input) {
|
||||
let numberInputs = [];
|
||||
input.forEach(inputValue => numberInputs.push(Number(inputValue)));
|
||||
|
||||
return numberInputs;
|
||||
};
|
||||
}
|
||||
|
||||
const convertToStrings = (input) => {
|
||||
function convertToStrings(input) {
|
||||
let stringInputs = [];
|
||||
input.forEach(inputValue => stringInputs.push(inputValue !== undefined ? inputValue.toString() : ''));
|
||||
|
||||
return stringInputs;
|
||||
};
|
||||
}
|
||||
|
||||
const joinValues = (values, length) => {
|
||||
function joinValues(values, length) {
|
||||
return values.slice(0, length).join(', ');
|
||||
};
|
||||
}
|
||||
|
||||
export const OPERATIONS = [
|
||||
{
|
||||
@ -313,8 +313,8 @@ export const INPUT_TYPES = {
|
||||
'number': 'number'
|
||||
};
|
||||
|
||||
export const getOperatorText = (operationName, values) => {
|
||||
export function getOperatorText(operationName, values) {
|
||||
const found = OPERATIONS.find((operation) => operation.name === operationName);
|
||||
|
||||
return found ? found.getDescription(values) : '';
|
||||
};
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ const styleProps = {
|
||||
}
|
||||
};
|
||||
|
||||
const aggregateStyleValues = (accumulator, currentStyle) => {
|
||||
function aggregateStyleValues(accumulator, currentStyle) {
|
||||
const styleKeys = Object.keys(currentStyle);
|
||||
const properties = Object.keys(styleProps);
|
||||
properties.forEach((property) => {
|
||||
@ -79,11 +79,24 @@ const aggregateStyleValues = (accumulator, currentStyle) => {
|
||||
});
|
||||
|
||||
return accumulator;
|
||||
};
|
||||
}
|
||||
|
||||
function getStaticStyleForItem(domainObject, id) {
|
||||
let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles;
|
||||
if (domainObjectStyles) {
|
||||
if (id) {
|
||||
if (domainObjectStyles[id] && domainObjectStyles[id].staticStyle) {
|
||||
return domainObjectStyles[id].staticStyle.style;
|
||||
}
|
||||
} else if (domainObjectStyles.staticStyle) {
|
||||
return domainObjectStyles.staticStyle.style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a union of styles used by multiple items.
|
||||
// Styles that are common to all items but don't have the same value are added to the mixedStyles list
|
||||
export const getConsolidatedStyleValues = (multipleItemStyles) => {
|
||||
export function getConsolidatedStyleValues(multipleItemStyles) {
|
||||
let aggregatedStyleValues = multipleItemStyles.reduce(aggregateStyleValues, {});
|
||||
|
||||
let styleValues = {};
|
||||
@ -105,22 +118,9 @@ export const getConsolidatedStyleValues = (multipleItemStyles) => {
|
||||
styles: styleValues,
|
||||
mixedStyles
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
const getStaticStyleForItem = (domainObject, id) => {
|
||||
let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles;
|
||||
if (domainObjectStyles) {
|
||||
if (id) {
|
||||
if (domainObjectStyles[id] && domainObjectStyles[id].staticStyle) {
|
||||
return domainObjectStyles[id].staticStyle.style;
|
||||
}
|
||||
} else if (domainObjectStyles.staticStyle) {
|
||||
return domainObjectStyles.staticStyle.style;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const getConditionalStyleForItem = (domainObject, id) => {
|
||||
export function getConditionalStyleForItem(domainObject, id) {
|
||||
let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles;
|
||||
if (domainObjectStyles) {
|
||||
if (id) {
|
||||
@ -131,9 +131,9 @@ export const getConditionalStyleForItem = (domainObject, id) => {
|
||||
return domainObjectStyles.styles;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const getConditionSetIdentifierForItem = (domainObject, id) => {
|
||||
export function getConditionSetIdentifierForItem(domainObject, id) {
|
||||
let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles;
|
||||
if (domainObjectStyles) {
|
||||
if (id) {
|
||||
@ -144,10 +144,10 @@ export const getConditionSetIdentifierForItem = (domainObject, id) => {
|
||||
return domainObjectStyles.conditionSetIdentifier;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//Returns either existing static styles or uses SVG defaults if available
|
||||
export const getApplicableStylesForItem = (domainObject, item) => {
|
||||
export function getApplicableStylesForItem(domainObject, item) {
|
||||
const type = item && item.type;
|
||||
const id = item && item.id;
|
||||
let style = {};
|
||||
@ -170,9 +170,9 @@ export const getApplicableStylesForItem = (domainObject, item) => {
|
||||
});
|
||||
|
||||
return style;
|
||||
};
|
||||
}
|
||||
|
||||
export const getStylesWithoutNoneValue = (style) => {
|
||||
export function getStylesWithoutNoneValue(style) {
|
||||
if (isEmpty(style) || !style) {
|
||||
return;
|
||||
}
|
||||
@ -190,4 +190,4 @@ export const getStylesWithoutNoneValue = (style) => {
|
||||
});
|
||||
|
||||
return styleObj;
|
||||
};
|
||||
}
|
||||
|
@ -20,12 +20,22 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
export const getLatestTimestamp = (
|
||||
function updateLatestTimeStamp(timestamp, timeSystems) {
|
||||
let latest = {};
|
||||
|
||||
timeSystems.forEach(timeSystem => {
|
||||
latest[timeSystem.key] = timestamp[timeSystem.key];
|
||||
});
|
||||
|
||||
return latest;
|
||||
}
|
||||
|
||||
export function getLatestTimestamp(
|
||||
currentTimestamp,
|
||||
compareTimestamp,
|
||||
timeSystems,
|
||||
currentTimeSystem
|
||||
) => {
|
||||
) {
|
||||
let latest = { ...currentTimestamp };
|
||||
const compare = { ...compareTimestamp };
|
||||
const key = currentTimeSystem.key;
|
||||
@ -38,20 +48,10 @@ export const getLatestTimestamp = (
|
||||
latest = updateLatestTimeStamp(compare, timeSystems);
|
||||
}
|
||||
|
||||
return latest;
|
||||
};
|
||||
|
||||
function updateLatestTimeStamp(timestamp, timeSystems) {
|
||||
let latest = {};
|
||||
|
||||
timeSystems.forEach(timeSystem => {
|
||||
latest[timeSystem.key] = timestamp[timeSystem.key];
|
||||
});
|
||||
|
||||
return latest;
|
||||
}
|
||||
|
||||
export const subscribeForStaleness = (callback, timeout) => {
|
||||
export function subscribeForStaleness(callback, timeout) {
|
||||
let stalenessTimer = setTimeout(() => {
|
||||
clearTimeout(stalenessTimer);
|
||||
callback();
|
||||
@ -74,4 +74,4 @@ export const subscribeForStaleness = (callback, timeout) => {
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user