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:
Joel McKinnon 2020-08-10 10:59:18 -07:00 committed by GitHub
parent 0b4a843617
commit ef965ebdfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 262 additions and 246 deletions

View File

@ -120,6 +120,12 @@ module.exports = {
"no-useless-computed-key": "error", "no-useless-computed-key": "error",
// https://eslint.org/docs/rules/rest-spread-spacing // https://eslint.org/docs/rules/rest-spread-spacing
"rest-spread-spacing": ["error"], "rest-spread-spacing": ["error"],
// https://eslint.org/docs/rules/array-callback-return
"array-callback-return": "error",
// https://eslint.org/docs/rules/no-invalid-this
"no-invalid-this": "error", // Believe this one actually surfaces some bugs
// https://eslint.org/docs/rules/func-style
"func-style": ["error", "declaration"],
// https://eslint.org/docs/rules/no-unused-expressions // https://eslint.org/docs/rules/no-unused-expressions
"no-unused-expressions": "error", "no-unused-expressions": "error",
// https://eslint.org/docs/rules/no-useless-concat // https://eslint.org/docs/rules/no-useless-concat

View File

@ -72,6 +72,7 @@ define([
}); });
var messageId; var messageId;
let self = this;
function callback(message) { function callback(message) {
if (message.error) { if (message.error) {
deferred.reject(message.error); deferred.reject(message.error);
@ -79,7 +80,8 @@ define([
deferred.resolve(message.data); deferred.resolve(message.data);
} }
delete this.callbacks[messageId]; delete self.callbacks[messageId];
} }
messageId = this.dispatch('request', request, callback.bind(this)); messageId = this.dispatch('request', request, callback.bind(this));

View File

@ -54,12 +54,12 @@
"markdown-toc": "^0.11.7", "markdown-toc": "^0.11.7",
"marked": "^0.3.5", "marked": "^0.3.5",
"mini-css-extract-plugin": "^0.4.1", "mini-css-extract-plugin": "^0.4.1",
"minimist": "^1.1.1", "minimist": "^1.2.5",
"moment": "2.25.3", "moment": "2.25.3",
"moment-duration-format": "^2.2.2", "moment-duration-format": "^2.2.2",
"moment-timezone": "0.5.28", "moment-timezone": "0.5.28",
"node-bourbon": "^4.2.3", "node-bourbon": "^4.2.3",
"node-sass": "^4.9.2", "node-sass": "^4.14.1",
"painterro": "^1.0.35", "painterro": "^1.0.35",
"printj": "^1.2.1", "printj": "^1.2.1",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",

View File

@ -164,7 +164,7 @@ function (
} }
function saveAfterClone(clonedObject) { function saveAfterClone(clonedObject) {
return this.openmct.editor.save().then(() => { return self.openmct.editor.save().then(() => {
// Force mutation for search indexing // Force mutation for search indexing
return clonedObject; return clonedObject;
}); });

View File

@ -56,10 +56,11 @@ define(
*/ */
CreateWizard.prototype.getFormStructure = function (includeLocation) { CreateWizard.prototype.getFormStructure = function (includeLocation) {
var sections = [], var sections = [],
domainObject = this.domainObject; domainObject = this.domainObject,
self = this;
function validateLocation(parent) { function validateLocation(parent) {
return parent && this.openmct.composition.checkPolicy(parent.useCapability('adapter'), domainObject.useCapability('adapter')); return parent && self.openmct.composition.checkPolicy(parent.useCapability('adapter'), domainObject.useCapability('adapter'));
} }
sections.push({ sections.push({

View File

@ -60,7 +60,7 @@ define(
] ]
); );
mockCopyService.perform.and.callFake(function () { mockCopyService.perform.and.callFake(() => {
var performPromise, var performPromise,
callExtensions, callExtensions,
spy; spy;
@ -79,7 +79,7 @@ define(
} }
}; };
spy = this.perform; spy = mockCopyService.perform;
Object.keys(callExtensions).forEach(function (key) { Object.keys(callExtensions).forEach(function (key) {
spy.calls.mostRecent()[key] = callExtensions[key]; spy.calls.mostRecent()[key] = callExtensions[key];

View File

@ -63,11 +63,11 @@ define(
] ]
); );
mockLinkService.perform.and.callFake(function (object) { mockLinkService.perform.and.callFake(object => {
var performPromise = new ControlledPromise(); var performPromise = new ControlledPromise();
this.perform.calls.mostRecent().promise = performPromise; mockLinkService.perform.calls.mostRecent().promise = performPromise;
this.perform.calls.all()[this.perform.calls.count() - 1].promise = mockLinkService.perform.calls.all()[mockLinkService.perform.calls.count() - 1].promise =
performPromise; performPromise;
return performPromise.then(function (overrideObject) { return performPromise.then(function (overrideObject) {

View File

@ -60,7 +60,7 @@ define(
] ]
); );
mockMoveService.perform.and.callFake(function () { mockMoveService.perform.and.callFake(() => {
var performPromise, var performPromise,
callExtensions, callExtensions,
spy; spy;
@ -79,7 +79,7 @@ define(
} }
}; };
spy = this.perform; spy = mockMoveService.perform;
Object.keys(callExtensions).forEach(function (key) { Object.keys(callExtensions).forEach(function (key) {
spy.calls.mostRecent()[key] = callExtensions[key]; spy.calls.mostRecent()[key] = callExtensions[key];

View File

@ -47,6 +47,7 @@ define(["zepto"], function ($) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
input.trigger("click"); input.trigger("click");
input.on('change', function (event) { input.on('change', function (event) {
// eslint-disable-next-line no-invalid-this
file = this.files[0]; file = this.files[0];
input.remove(); input.remove();
if (file) { if (file) {

View File

@ -19,6 +19,7 @@
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/* eslint-disable no-invalid-this */
/** /**
* Module defining CustomRegistrars. Created by vwoeltje on 11/3/14. * Module defining CustomRegistrars. Created by vwoeltje on 11/3/14.

View File

@ -91,18 +91,19 @@ define([
}); });
it('filters results with a function', function () { it('filters results with a function', function () {
var modelResults = { const modelResults = {
hits: [ hits: [
{model: {thing: 1}}, {model: {thing: 1}},
{model: {thing: 2}}, {model: {thing: 2}},
{model: {thing: 3}} {model: {thing: 3}}
], ],
total: 3 total: 3
}, };
filterFunc = function (model) { let filtered = aggregator.applyFilter(modelResults, filterFunc);
return model.thing < 2;
}, function filterFunc(model) {
filtered = aggregator.applyFilter(modelResults, filterFunc); return model.thing < 2;
}
expect(filtered.hits).toEqual([ expect(filtered.hits).toEqual([
{model: {thing: 1}} {model: {thing: 1}}

View File

@ -33,14 +33,11 @@ define(
_ _
) { ) {
var ZERO = function () { const EMPTY_SERIES = {
return 0; getPointCount: () => 0,
}, getDomainValue: () => 0,
EMPTY_SERIES = { getRangeValue: () => 0
getPointCount: ZERO, };
getDomainValue: ZERO,
getRangeValue: ZERO
};
/** /**
* Provides metadata about telemetry associated with a * Provides metadata about telemetry associated with a

View File

@ -114,7 +114,7 @@ define([
hints hints
) { ) {
function hasHint(hint) { function hasHint(hint) {
/*jshint validthis: true */ // eslint-disable-next-line no-invalid-this
return this.hints.hasOwnProperty(hint); return this.hints.hasOwnProperty(hint);
} }

View File

@ -339,6 +339,7 @@ define([
} }
for (var height = 0; height < rowHeight * count * 2; height += rowHeight / 2) { for (var height = 0; height < rowHeight * count * 2; height += rowHeight / 2) {
// eslint-disable-next-line no-invalid-this
promiseChain = promiseChain.then(setHeight.bind(this, height)); promiseChain = promiseChain.then(setHeight.bind(this, height));
} }

View File

@ -169,28 +169,7 @@ export default {
}, },
dropCondition(targetIndex) { dropCondition(targetIndex) {
const oldIndexArr = Object.keys(this.conditionCollection); const oldIndexArr = Object.keys(this.conditionCollection);
const move = function (arr, old_index, new_index) { const newIndexArr = this.rearrangeIndices(oldIndexArr, this.moveIndex, targetIndex);
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 reorderPlan = []; const reorderPlan = [];
for (let i = 0; i < oldIndexArr.length; i++) { for (let i = 0; i < oldIndexArr.length; i++) {
@ -205,6 +184,26 @@ export default {
dragComplete() { dragComplete() {
this.isDragging = false; 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) { addTelemetryObject(domainObject) {
this.telemetryObjs.push(domainObject); this.telemetryObjs.push(domainObject);
this.$emit('telemetryUpdated', this.telemetryObjs); this.$emit('telemetryUpdated', this.telemetryObjs);

View File

@ -223,20 +223,22 @@ export default {
}, },
addConditionSet() { addConditionSet() {
let conditionSetDomainObject; let conditionSetDomainObject;
const handleItemSelection = (item) => { let self = this;
function handleItemSelection(item) {
if (item) { if (item) {
conditionSetDomainObject = item; conditionSetDomainObject = item;
} }
}; }
const dismissDialog = (overlay, initialize) => { function dismissDialog(overlay, initialize) {
overlay.dismiss(); overlay.dismiss();
if (initialize && conditionSetDomainObject) { if (initialize && conditionSetDomainObject) {
this.conditionSetDomainObject = conditionSetDomainObject; self.conditionSetDomainObject = conditionSetDomainObject;
this.conditionalStyles = []; self.conditionalStyles = [];
this.initializeConditionalStyles(); self.initializeConditionalStyles();
} }
}; }
let vm = new Vue({ let vm = new Vue({
provide: { provide: {

View File

@ -431,20 +431,22 @@ export default {
}, },
addConditionSet() { addConditionSet() {
let conditionSetDomainObject; let conditionSetDomainObject;
const handleItemSelection = (item) => { let self = this;
function handleItemSelection(item) {
if (item) { if (item) {
conditionSetDomainObject = item; conditionSetDomainObject = item;
} }
}; }
const dismissDialog = (overlay, initialize) => { function dismissDialog(overlay, initialize) {
overlay.dismiss(); overlay.dismiss();
if (initialize && conditionSetDomainObject) { if (initialize && conditionSetDomainObject) {
this.conditionSetDomainObject = conditionSetDomainObject; self.conditionSetDomainObject = conditionSetDomainObject;
this.conditionalStyles = []; self.conditionalStyles = [];
this.initializeConditionalStyles(); self.initializeConditionalStyles();
} }
}; }
let vm = new Vue({ let vm = new Vue({
provide: { provide: {

View File

@ -21,7 +21,7 @@
*****************************************************************************/ *****************************************************************************/
import { TRIGGER } from "./constants"; import { TRIGGER } from "./constants";
export const evaluateResults = (results, trigger) => { export function evaluateResults(results, trigger) {
if (trigger && trigger === TRIGGER.XOR) { if (trigger && trigger === TRIGGER.XOR) {
return matchExact(results, 1); return matchExact(results, 1);
} else if (trigger && trigger === TRIGGER.NOT) { } else if (trigger && trigger === TRIGGER.NOT) {
@ -31,7 +31,7 @@ export const evaluateResults = (results, trigger) => {
} else { } else {
return matchAny(results); return matchAny(results);
} }
}; }
function matchAll(results) { function matchAll(results) {
for (const result of results) { for (const result of results) {

View File

@ -20,23 +20,23 @@
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
const convertToNumbers = (input) => { function convertToNumbers(input) {
let numberInputs = []; let numberInputs = [];
input.forEach(inputValue => numberInputs.push(Number(inputValue))); input.forEach(inputValue => numberInputs.push(Number(inputValue)));
return numberInputs; return numberInputs;
}; }
const convertToStrings = (input) => { function convertToStrings(input) {
let stringInputs = []; let stringInputs = [];
input.forEach(inputValue => stringInputs.push(inputValue !== undefined ? inputValue.toString() : '')); input.forEach(inputValue => stringInputs.push(inputValue !== undefined ? inputValue.toString() : ''));
return stringInputs; return stringInputs;
}; }
const joinValues = (values, length) => { function joinValues(values, length) {
return values.slice(0, length).join(', '); return values.slice(0, length).join(', ');
}; }
export const OPERATIONS = [ export const OPERATIONS = [
{ {
@ -313,8 +313,8 @@ export const INPUT_TYPES = {
'number': 'number' 'number': 'number'
}; };
export const getOperatorText = (operationName, values) => { export function getOperatorText(operationName, values) {
const found = OPERATIONS.find((operation) => operation.name === operationName); const found = OPERATIONS.find((operation) => operation.name === operationName);
return found ? found.getDescription(values) : ''; return found ? found.getDescription(values) : '';
}; }

View File

@ -64,7 +64,7 @@ const styleProps = {
} }
}; };
const aggregateStyleValues = (accumulator, currentStyle) => { function aggregateStyleValues(accumulator, currentStyle) {
const styleKeys = Object.keys(currentStyle); const styleKeys = Object.keys(currentStyle);
const properties = Object.keys(styleProps); const properties = Object.keys(styleProps);
properties.forEach((property) => { properties.forEach((property) => {
@ -79,11 +79,24 @@ const aggregateStyleValues = (accumulator, currentStyle) => {
}); });
return accumulator; 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. // 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 // 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 aggregatedStyleValues = multipleItemStyles.reduce(aggregateStyleValues, {});
let styleValues = {}; let styleValues = {};
@ -105,22 +118,9 @@ export const getConsolidatedStyleValues = (multipleItemStyles) => {
styles: styleValues, styles: styleValues,
mixedStyles mixedStyles
}; };
}; }
const getStaticStyleForItem = (domainObject, id) => { export function getConditionalStyleForItem(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) => {
let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles; let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles;
if (domainObjectStyles) { if (domainObjectStyles) {
if (id) { if (id) {
@ -131,9 +131,9 @@ export const getConditionalStyleForItem = (domainObject, id) => {
return domainObjectStyles.styles; return domainObjectStyles.styles;
} }
} }
}; }
export const getConditionSetIdentifierForItem = (domainObject, id) => { export function getConditionSetIdentifierForItem(domainObject, id) {
let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles; let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles;
if (domainObjectStyles) { if (domainObjectStyles) {
if (id) { if (id) {
@ -144,10 +144,10 @@ export const getConditionSetIdentifierForItem = (domainObject, id) => {
return domainObjectStyles.conditionSetIdentifier; return domainObjectStyles.conditionSetIdentifier;
} }
} }
}; }
//Returns either existing static styles or uses SVG defaults if available //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 type = item && item.type;
const id = item && item.id; const id = item && item.id;
let style = {}; let style = {};
@ -170,9 +170,9 @@ export const getApplicableStylesForItem = (domainObject, item) => {
}); });
return style; return style;
}; }
export const getStylesWithoutNoneValue = (style) => { export function getStylesWithoutNoneValue(style) {
if (isEmpty(style) || !style) { if (isEmpty(style) || !style) {
return; return;
} }
@ -190,4 +190,4 @@ export const getStylesWithoutNoneValue = (style) => {
}); });
return styleObj; return styleObj;
}; }

View File

@ -20,12 +20,22 @@
* at runtime from the About dialog for additional information. * 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, currentTimestamp,
compareTimestamp, compareTimestamp,
timeSystems, timeSystems,
currentTimeSystem currentTimeSystem
) => { ) {
let latest = { ...currentTimestamp }; let latest = { ...currentTimestamp };
const compare = { ...compareTimestamp }; const compare = { ...compareTimestamp };
const key = currentTimeSystem.key; const key = currentTimeSystem.key;
@ -38,20 +48,10 @@ export const getLatestTimestamp = (
latest = updateLatestTimeStamp(compare, timeSystems); latest = updateLatestTimeStamp(compare, timeSystems);
} }
return latest;
};
function updateLatestTimeStamp(timestamp, timeSystems) {
let latest = {};
timeSystems.forEach(timeSystem => {
latest[timeSystem.key] = timestamp[timeSystem.key];
});
return latest; return latest;
} }
export const subscribeForStaleness = (callback, timeout) => { export function subscribeForStaleness(callback, timeout) {
let stalenessTimer = setTimeout(() => { let stalenessTimer = setTimeout(() => {
clearTimeout(stalenessTimer); clearTimeout(stalenessTimer);
callback(); callback();
@ -74,4 +74,4 @@ export const subscribeForStaleness = (callback, timeout) => {
} }
} }
}; };
}; }

View File

@ -137,7 +137,7 @@ export default {
setObject(domainObject) { setObject(domainObject) {
this.domainObject = domainObject; this.domainObject = domainObject;
this.currentObjectPath = [this.domainObject].concat(this.objectPath.slice()); this.currentObjectPath = [this.domainObject].concat(this.objectPath.slice());
this.$nextTick(function () { this.$nextTick(() => {
let childContext = this.$refs.objectFrame.getSelectionContext(); let childContext = this.$refs.objectFrame.getSelectionContext();
childContext.item = domainObject; childContext.item = domainObject;
childContext.layoutItem = this.item; childContext.layoutItem = this.item;

View File

@ -115,7 +115,7 @@ export default {
this.setSelection(); this.setSelection();
}, },
setSelection() { setSelection() {
this.$nextTick(function () { this.$nextTick(() => {
if (this.$refs && this.$refs.objectFrame) { if (this.$refs && this.$refs.objectFrame) {
let childContext = this.$refs.objectFrame.getSelectionContext(); let childContext = this.$refs.objectFrame.getSelectionContext();
childContext.item = this.domainObject; childContext.item = this.domainObject;

View File

@ -4,14 +4,14 @@ import Vue from 'vue';
export default function ImageryViewProvider(openmct) { export default function ImageryViewProvider(openmct) {
const type = 'example.imagery'; const type = 'example.imagery';
const hasImageTelemetry = function (domainObject) { function hasImageTelemetry(domainObject) {
const metadata = openmct.telemetry.getMetadata(domainObject); const metadata = openmct.telemetry.getMetadata(domainObject);
if (!metadata) { if (!metadata) {
return false; return false;
} }
return metadata.valuesForHints(['image']).length > 0; return metadata.valuesForHints(['image']).length > 0;
}; }
return { return {
key: type, key: type,

View File

@ -190,7 +190,7 @@ export default {
} }
}, },
updated: function () { updated: function () {
this.$nextTick(function () { this.$nextTick(() => {
this.focusOnEntryId(); this.focusOnEntryId();
}); });
}, },

View File

@ -7,7 +7,7 @@ const TIME_BOUNDS = {
END_DELTA: 'tc.endDelta' END_DELTA: 'tc.endDelta'
}; };
export const getHistoricLinkInFixedMode = (openmct, bounds, historicLink) => { export function getHistoricLinkInFixedMode(openmct, bounds, historicLink) {
if (historicLink.includes('tc.mode=fixed')) { if (historicLink.includes('tc.mode=fixed')) {
return historicLink; return historicLink;
} }
@ -35,9 +35,9 @@ export const getHistoricLinkInFixedMode = (openmct, bounds, historicLink) => {
}); });
return params.join('&'); return params.join('&');
}; }
export const getNotebookDefaultEntries = (notebookStorage, domainObject) => { export function getNotebookDefaultEntries(notebookStorage, domainObject) {
if (!notebookStorage || !domainObject) { if (!notebookStorage || !domainObject) {
return null; return null;
} }
@ -64,9 +64,9 @@ export const getNotebookDefaultEntries = (notebookStorage, domainObject) => {
} }
return entries[defaultSection.id][defaultPage.id]; return entries[defaultSection.id][defaultPage.id];
}; }
export const createNewEmbed = (snapshotMeta, snapshot = '') => { export function createNewEmbed(snapshotMeta, snapshot = '') {
const { const {
bounds, bounds,
link, link,
@ -100,9 +100,9 @@ export const createNewEmbed = (snapshotMeta, snapshot = '') => {
snapshot, snapshot,
type type
}; };
}; }
export const addNotebookEntry = (openmct, domainObject, notebookStorage, embed = null) => { export function addNotebookEntry(openmct, domainObject, notebookStorage, embed = null) {
if (!openmct || !domainObject || !notebookStorage) { if (!openmct || !domainObject || !notebookStorage) {
return; return;
} }
@ -131,9 +131,9 @@ export const addNotebookEntry = (openmct, domainObject, notebookStorage, embed =
openmct.objects.mutate(domainObject, 'configuration.entries', entries); openmct.objects.mutate(domainObject, 'configuration.entries', entries);
return id; return id;
}; }
export const getNotebookEntries = (domainObject, selectedSection, selectedPage) => { export function getNotebookEntries(domainObject, selectedSection, selectedPage) {
if (!domainObject || !selectedSection || !selectedPage) { if (!domainObject || !selectedSection || !selectedPage) {
return null; return null;
} }
@ -152,9 +152,9 @@ export const getNotebookEntries = (domainObject, selectedSection, selectedPage)
} }
return entries[selectedSection.id][selectedPage.id]; return entries[selectedSection.id][selectedPage.id];
}; }
export const getEntryPosById = (entryId, domainObject, selectedSection, selectedPage) => { export function getEntryPosById(entryId, domainObject, selectedSection, selectedPage) {
if (!domainObject || !selectedSection || !selectedPage) { if (!domainObject || !selectedSection || !selectedPage) {
return; return;
} }
@ -170,9 +170,9 @@ export const getEntryPosById = (entryId, domainObject, selectedSection, selected
}); });
return foundId; return foundId;
}; }
export const deleteNotebookEntries = (openmct, domainObject, selectedSection, selectedPage) => { export function deleteNotebookEntries(openmct, domainObject, selectedSection, selectedPage) {
if (!domainObject || !selectedSection) { if (!domainObject || !selectedSection) {
return; return;
} }
@ -194,4 +194,4 @@ export const deleteNotebookEntries = (openmct, domainObject, selectedSection, se
delete entries[selectedSection.id][selectedPage.id]; delete entries[selectedSection.id][selectedPage.id];
openmct.objects.mutate(domainObject, 'configuration.entries', entries); openmct.objects.mutate(domainObject, 'configuration.entries', entries);
}; }

View File

@ -226,6 +226,8 @@ define([
.then(object => { .then(object => {
telemetryObjects[element.id] = object; telemetryObjects[element.id] = object;
}); });
} else {
return Promise.resolve(false);
} }
}); });

View File

@ -38,11 +38,11 @@ define([
} }
}); });
this.on('change:frozen', function (frozen, oldValue, model) { this.on('change:frozen', ((frozen, oldValue, model) => {
if (!frozen) { if (!frozen) {
model.set('range', this.get('range')); model.set('range', this.get('range'));
} }
}); }));
if (this.get('range')) { if (this.get('range')) {
this.set('range', this.get('range')); this.set('range', this.get('range'));

View File

@ -60,14 +60,14 @@ define([
}, },
listenToSeriesCollection: function (seriesCollection) { listenToSeriesCollection: function (seriesCollection) {
this.seriesCollection = seriesCollection; this.seriesCollection = seriesCollection;
this.listenTo(this.seriesCollection, 'add', function (series) { this.listenTo(this.seriesCollection, 'add', (series => {
this.trackSeries(series); this.trackSeries(series);
this.updateFromSeries(this.seriesCollection); this.updateFromSeries(this.seriesCollection);
}, this); }), this);
this.listenTo(this.seriesCollection, 'remove', function (series) { this.listenTo(this.seriesCollection, 'remove', (series => {
this.untrackSeries(series); this.untrackSeries(series);
this.updateFromSeries(this.seriesCollection); this.updateFromSeries(this.seriesCollection);
}, this); }), this);
this.seriesCollection.forEach(this.trackSeries, this); this.seriesCollection.forEach(this.trackSeries, this);
this.updateFromSeries(this.seriesCollection); this.updateFromSeries(this.seriesCollection);
}, },
@ -144,16 +144,16 @@ define([
}, this); }, this);
}, },
trackSeries: function (series) { trackSeries: function (series) {
this.listenTo(series, 'change:stats', function (seriesStats) { this.listenTo(series, 'change:stats', seriesStats => {
if (!seriesStats) { if (!seriesStats) {
this.resetStats(); this.resetStats();
} else { } else {
this.updateStats(seriesStats); this.updateStats(seriesStats);
} }
}, this); });
this.listenTo(series, 'change:yKey', function () { this.listenTo(series, 'change:yKey', () => {
this.updateFromSeries(this.seriesCollection); this.updateFromSeries(this.seriesCollection);
}, this); });
}, },
untrackSeries: function (series) { untrackSeries: function (series) {
this.stopListening(series); this.stopListening(series);

View File

@ -122,6 +122,8 @@ define([
} }
var formPath = 'form.' + formProp; var formPath = 'form.' + formProp;
let self = this;
if (!coerce) { if (!coerce) {
coerce = function (v) { coerce = function (v) {
return v; return v;
@ -142,11 +144,11 @@ define([
} }
this.listenTo(this.model, 'change:' + prop, function (newVal, oldVal) { this.listenTo(this.model, 'change:' + prop, function (newVal, oldVal) {
if (!_.isEqual(coerce(_.get(this.$scope, formPath)), coerce(newVal))) { if (!_.isEqual(coerce(_.get(self.$scope, formPath)), coerce(newVal))) {
_.set(this.$scope, formPath, coerce(newVal)); _.set(self.$scope, formPath, coerce(newVal));
} }
}, this); });
this.model.listenTo(this.$scope, 'change:' + formPath, function (newVal, oldVal) { this.model.listenTo(this.$scope, 'change:' + formPath, (newVal, oldVal) => {
var validationResult = validate(newVal, this.model); var validationResult = validate(newVal, this.model);
if (validationResult === true) { if (validationResult === true) {
delete this.$scope.validation[formProp]; delete this.$scope.validation[formProp];
@ -170,7 +172,7 @@ define([
); );
} }
} }
}, this); });
_.set(this.$scope, formPath, coerce(this.model.get(prop))); _.set(this.$scope, formPath, coerce(this.model.get(prop)));
}; };

View File

@ -28,7 +28,7 @@ define([
) { ) {
function extend(props) { function extend(props) {
/*jshint validthis: true*/ // eslint-disable-next-line no-invalid-this
var parent = this, var parent = this,
child, child,
Surrogate; Surrogate;
@ -37,6 +37,7 @@ define([
child = props.constructor; child = props.constructor;
} else { } else {
child = function () { child = function () {
// eslint-disable-next-line no-invalid-this
return parent.apply(this, arguments); return parent.apply(this, arguments);
}; };
} }

View File

@ -220,21 +220,18 @@ define([
if (!point) { if (!point) {
this.$scope.highlights = []; this.$scope.highlights = [];
this.$scope.series.map(function (series) { this.$scope.series.forEach(series => delete series.closest);
delete series.closest;
});
} else { } else {
this.$scope.highlights = this.$scope.series this.$scope.highlights = this.$scope.series
.filter(function (series) { .filter(series => series.data.length > 0)
return series.data.length > 0; .map(series => {
}).map(function (series) {
series.closest = series.nearestPoint(point); series.closest = series.nearestPoint(point);
return { return {
series: series, series: series,
point: series.closest point: series.closest
}; };
}, this); });
} }
this.$scope.$digest(); this.$scope.$digest();

View File

@ -134,11 +134,11 @@ define([
}; };
PlotController.prototype.addSeries = function (series) { PlotController.prototype.addSeries = function (series) {
this.listenTo(series, 'change:yKey', function () { this.listenTo(series, 'change:yKey', () => {
this.loadSeriesData(series); this.loadSeriesData(series);
}, this); }, this);
this.listenTo(series, 'change:interpolate', function () { this.listenTo(series, 'change:interpolate', () => {
this.loadSeriesData(series); this.loadSeriesData(series);
}, this); }, this);
@ -184,18 +184,18 @@ define([
}; };
PlotController.prototype.loadMoreData = function (range, purge) { PlotController.prototype.loadMoreData = function (range, purge) {
this.config.series.map(function (plotSeries) { this.config.series.forEach(plotSeries => {
this.startLoading(); this.startLoading();
plotSeries.load({ plotSeries.load({
size: this.$element[0].offsetWidth, size: this.$element[0].offsetWidth,
start: range.min, start: range.min,
end: range.max end: range.max
}) })
.then(this.stopLoading.bind(this)); .then(this.stopLoading());
if (purge) { if (purge) {
plotSeries.purgeRecordsOutsideRange(range); plotSeries.purgeRecordsOutsideRange(range);
} }
}, this); });
}; };
/** /**

View File

@ -16,7 +16,7 @@ define([
var cachedProvider; var cachedProvider;
var loadProvider = function () { function loadProvider() {
return fetch(exportUrl) return fetch(exportUrl)
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
@ -26,16 +26,15 @@ define([
return cachedProvider; return cachedProvider;
}); });
}
}; function getProvider() {
var getProvider = function () {
if (!cachedProvider) { if (!cachedProvider) {
cachedProvider = loadProvider(); cachedProvider = loadProvider();
} }
return Promise.resolve(cachedProvider); return Promise.resolve(cachedProvider);
}; }
return function install(openmct) { return function install(openmct) {
openmct.objects.addRoot(rootIdentifier); openmct.objects.addRoot(rootIdentifier);

View File

@ -159,6 +159,7 @@ define([
*/ */
function onDragStart(event) { function onDragStart(event) {
$('.t-drag-indicator').each(function () { $('.t-drag-indicator').each(function () {
// eslint-disable-next-line no-invalid-this
$(this).html($('.widget-rule-header', self.domElement).clone().get(0)); $(this).html($('.widget-rule-header', self.domElement).clone().get(0));
}); });
self.widgetDnD.setDragImage($('.widget-rule-header', self.domElement).clone().get(0)); self.widgetDnD.setDragImage($('.widget-rule-header', self.domElement).clone().get(0));
@ -203,6 +204,7 @@ define([
Object.keys(this.textInputs).forEach(function (inputKey) { Object.keys(this.textInputs).forEach(function (inputKey) {
self.textInputs[inputKey].prop('value', self.config[inputKey] || ''); self.textInputs[inputKey].prop('value', self.config[inputKey] || '');
self.listenTo(self.textInputs[inputKey], 'input', function () { self.listenTo(self.textInputs[inputKey], 'input', function () {
// eslint-disable-next-line no-invalid-this
onTextInput(this, inputKey); onTextInput(this, inputKey);
}); });
}); });
@ -221,6 +223,7 @@ define([
this.listenTo(this.grippy, 'mousedown', onDragStart); this.listenTo(this.grippy, 'mousedown', onDragStart);
this.widgetDnD.on('drop', function () { this.widgetDnD.on('drop', function () {
// eslint-disable-next-line no-invalid-this
this.domElement.show(); this.domElement.show();
$('.t-drag-indicator').hide(); $('.t-drag-indicator').hide();
}, this); }, this);

View File

@ -41,6 +41,7 @@ function (
$('.c-palette', domElement).addClass('c-palette--color'); $('.c-palette', domElement).addClass('c-palette--color');
$('.c-palette__item', domElement).each(function () { $('.c-palette__item', domElement).each(function () {
// eslint-disable-next-line no-invalid-this
var elem = this; var elem = this;
$(elem).css('background-color', elem.dataset.item); $(elem).css('background-color', elem.dataset.item);
}); });

View File

@ -56,6 +56,7 @@ define([
$('.c-palette', domElement).addClass('c-palette--icon'); $('.c-palette', domElement).addClass('c-palette--icon');
$('.c-palette-item', domElement).each(function () { $('.c-palette-item', domElement).each(function () {
// eslint-disable-next-line no-invalid-this
var elem = this; var elem = this;
$(elem).addClass(elem.dataset.item); $(elem).addClass(elem.dataset.item);
}); });

View File

@ -48,22 +48,22 @@ define(['../../src/input/KeySelect'], function (KeySelect) {
'triggerCallback' 'triggerCallback'
]); ]);
mockObjectSelect.on.and.callFake(function (event, callback) { mockObjectSelect.on.and.callFake((event, callback) => {
this.callbacks = this.callbacks || {}; mockObjectSelect.callbacks = mockObjectSelect.callbacks || {};
this.callbacks[event] = callback; mockObjectSelect.callbacks[event] = callback;
}); });
mockObjectSelect.triggerCallback.and.callFake(function (event, key) { mockObjectSelect.triggerCallback.and.callFake((event, key) => {
this.callbacks[event](key); mockObjectSelect.callbacks[event](key);
}); });
mockManager.on.and.callFake(function (event, callback) { mockManager.on.and.callFake((event, callback) => {
this.callbacks = this.callbacks || {}; mockManager.callbacks = mockManager.callbacks || {};
this.callbacks[event] = callback; mockManager.callbacks[event] = callback;
}); });
mockManager.triggerCallback.and.callFake(function (event) { mockManager.triggerCallback.and.callFake(event => {
this.callbacks[event](); mockManager.callbacks[event]();
}); });
mockManager.getTelemetryMetadata.and.callFake(function (key) { mockManager.getTelemetryMetadata.and.callFake(function (key) {

View File

@ -31,16 +31,16 @@ define(['../../src/input/ObjectSelect'], function (ObjectSelect) {
'getComposition' 'getComposition'
]); ]);
mockManager.on.and.callFake(function (event, callback) { mockManager.on.and.callFake((event, callback) => {
this.callbacks = this.callbacks || {}; mockManager.callbacks = mockManager.callbacks || {};
this.callbacks[event] = callback; mockManager.callbacks[event] = callback;
}); });
mockManager.triggerCallback.and.callFake(function (event, newObj) { mockManager.triggerCallback.and.callFake((event, newObj) => {
if (event === 'add') { if (event === 'add') {
this.callbacks.add(newObj); mockManager.callbacks.add(newObj);
} else { } else {
this.callbacks[event](); mockManager.callbacks[event]();
} }
}); });

View File

@ -65,22 +65,22 @@ define(['../../src/input/OperationSelect'], function (OperationSelect) {
return (mockOperations[operation].appliesTo.includes(type)); return (mockOperations[operation].appliesTo.includes(type));
}); });
mockKeySelect.on.and.callFake(function (event, callback) { mockKeySelect.on.and.callFake((event, callback) => {
this.callbacks = this.callbacks || {}; mockKeySelect.callbacks = mockKeySelect.callbacks || {};
this.callbacks[event] = callback; mockKeySelect.callbacks[event] = callback;
}); });
mockKeySelect.triggerCallback.and.callFake(function (event, key) { mockKeySelect.triggerCallback.and.callFake((event, key) => {
this.callbacks[event](key); mockKeySelect.callbacks[event](key);
}); });
mockManager.on.and.callFake(function (event, callback) { mockManager.on.and.callFake((event, callback) => {
this.callbacks = this.callbacks || {}; mockManager.callbacks = mockManager.callbacks || {};
this.callbacks[event] = callback; mockManager.callbacks[event] = callback;
}); });
mockManager.triggerCallback.and.callFake(function (event) { mockManager.triggerCallback.and.callFake(event => {
this.callbacks[event](); mockManager.callbacks[event]();
}); });
mockManager.getTelemetryPropertyType.and.callFake(function (object, key) { mockManager.getTelemetryPropertyType.and.callFake(function (object, key) {

View File

@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/*jshint latedef: nofunc */ /* eslint-disable no-invalid-this */
define([ define([
"./MeanTelemetryProvider", "./MeanTelemetryProvider",
"./MockTelemetryApi" "./MockTelemetryApi"

View File

@ -1,6 +1,6 @@
const dataAttribute = 'theme'; const dataAttribute = 'theme';
export const installTheme = (openmct, themeName) => { export function installTheme(openmct, themeName) {
const currentTheme = document.querySelector(`link[data-${dataAttribute}]`); const currentTheme = document.querySelector(`link[data-${dataAttribute}]`);
if (currentTheme) { if (currentTheme) {
currentTheme.remove(); currentTheme.remove();
@ -15,4 +15,4 @@ export const installTheme = (openmct, themeName) => {
newTheme.dataset[dataAttribute] = themeName; newTheme.dataset[dataAttribute] = themeName;
document.head.appendChild(newTheme); document.head.appendChild(newTheme);
}; }

View File

@ -144,13 +144,14 @@ export default {
start: this.bounds.start, start: this.bounds.start,
end: this.bounds.end end: this.bounds.end
}; };
let self = this;
const isNotEqual = function (entry) { function isNotEqual(entry) {
const start = entry.start !== this.start; const start = entry.start !== self.start;
const end = entry.end !== this.end; const end = entry.end !== self.end;
return start || end; return start || end;
}; }
currentHistory = currentHistory.filter(isNotEqual, timespan); currentHistory = currentHistory.filter(isNotEqual, timespan);

View File

@ -71,13 +71,16 @@ function validateConfiguration(config, openmct) {
}, {}); }, {});
return config.menuOptions.map(function (menuOption) { return config.menuOptions.map(function (menuOption) {
let message = '';
if (menuOption.timeSystem && !systems[menuOption.timeSystem]) { if (menuOption.timeSystem && !systems[menuOption.timeSystem]) {
return `Time system '${menuOption.timeSystem}' has not been registered: \r\n ${JSON.stringify(menuOption)}`; message = `Time system '${menuOption.timeSystem}' has not been registered: \r\n ${JSON.stringify(menuOption)}`;
} }
if (menuOption.clock && !clocks[menuOption.clock]) { if (menuOption.clock && !clocks[menuOption.clock]) {
return `Clock '${menuOption.clock}' has not been registered: \r\n ${JSON.stringify(menuOption)}`; message = `Clock '${menuOption.clock}' has not been registered: \r\n ${JSON.stringify(menuOption)}`;
} }
return message;
}).filter(isTruthy).join('\n'); }).filter(isTruthy).join('\n');
} }

View File

@ -29,7 +29,6 @@ define(
EventEmitter, EventEmitter,
_ _
) { ) {
/** /**
* Manages selection state for Open MCT * Manages selection state for Open MCT
* @private * @private
@ -115,9 +114,7 @@ define(
* @private * @private
*/ */
Selection.prototype.setSelectionStyles = function (selectable) { Selection.prototype.setSelectionStyles = function (selectable) {
this.selected.map(selectionPath => { this.selected.forEach(selectionPath => this.removeSelectionAttributes(selectionPath));
this.removeSelectionAttributes(selectionPath);
});
this.addSelectionAttributes(selectable); this.addSelectionAttributes(selectable);
}; };

View File

@ -98,32 +98,6 @@ import AppLogo from './AppLogo.vue';
import Indicators from './status-bar/Indicators.vue'; import Indicators from './status-bar/Indicators.vue';
import NotificationBanner from './status-bar/NotificationBanner.vue'; import NotificationBanner from './status-bar/NotificationBanner.vue';
var enterFullScreen = () => {
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
} else if (docElm.mozRequestFullScreen) { /* Firefox */
docElm.mozRequestFullScreen();
} else if (docElm.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
docElm.webkitRequestFullscreen();
} else if (docElm.msRequestFullscreen) { /* IE/Edge */
docElm.msRequestFullscreen();
}
};
var exitFullScreen = () => {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
};
export default { export default {
inject: ['openmct'], inject: ['openmct'],
components: { components: {
@ -168,6 +142,30 @@ export default {
this.openmct.selection.on('change', this.toggleHasToolbar); this.openmct.selection.on('change', this.toggleHasToolbar);
}, },
methods: { methods: {
enterFullScreen() {
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
} else if (docElm.mozRequestFullScreen) { /* Firefox */
docElm.mozRequestFullScreen();
} else if (docElm.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
docElm.webkitRequestFullscreen();
} else if (docElm.msRequestFullscreen) { /* IE/Edge */
docElm.msRequestFullscreen();
}
},
exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
},
toggleShellHead() { toggleShellHead() {
this.headExpanded = !this.headExpanded; this.headExpanded = !this.headExpanded;
@ -183,10 +181,10 @@ export default {
fullScreenToggle() { fullScreenToggle() {
if (this.fullScreen) { if (this.fullScreen) {
this.fullScreen = false; this.fullScreen = false;
exitFullScreen(); this.exitFullScreen();
} else { } else {
this.fullScreen = true; this.fullScreen = true;
enterFullScreen(); this.enterFullScreen();
} }
}, },
openInNewTab(event) { openInNewTab(event) {

View File

@ -47,10 +47,8 @@ define([], function () {
var structure = []; var structure = [];
providers.map(function (provider) { providers.forEach(provider => {
provider.toolbar(selection).forEach(function (item) { provider.toolbar(selection).forEach(item => structure.push(item));
structure.push(item);
});
}); });
return structure; return structure;

View File

@ -57,7 +57,7 @@ define([
path = path.split('/'); path = path.split('/');
} }
return pathToObjects(path).then((objects) => { return pathToObjects(path).then(objects => {
isRoutingInProgress = false; isRoutingInProgress = false;
if (currentNavigation !== navigateCall) { if (currentNavigation !== navigateCall) {
@ -72,7 +72,7 @@ define([
// API for this. // API for this.
openmct.router.path = objects.reverse(); openmct.router.path = objects.reverse();
unobserve = this.openmct.objects.observe(openmct.router.path[0], '*', (newObject) => { unobserve = openmct.objects.observe(openmct.router.path[0], '*', (newObject) => {
openmct.router.path[0] = newObject; openmct.router.path[0] = newObject;
browseObject = newObject; browseObject = newObject;
}); });

View File

@ -167,7 +167,7 @@ export default {
let value = {}; let value = {};
let values = {}; let values = {};
toolbarItem.formKeys.map(key => { toolbarItem.formKeys.forEach(key => {
values[key] = []; values[key] = [];
if (toolbarItem.applicableSelectedItems) { if (toolbarItem.applicableSelectedItems) {
@ -221,7 +221,7 @@ export default {
// If value is an object, iterate the toolbar structure and mutate all keys in form. // If value is an object, iterate the toolbar structure and mutate all keys in form.
// Otherwise, mutate the property. // Otherwise, mutate the property.
if (value === Object(value)) { if (value === Object(value)) {
this.structure.map(s => { this.structure.forEach(s => {
if (s.formKeys) { if (s.formKeys) {
s.formKeys.forEach(key => { s.formKeys.forEach(key => {
if (item.applicableSelectedItems) { if (item.applicableSelectedItems) {