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",
// https://eslint.org/docs/rules/rest-spread-spacing
"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
"no-unused-expressions": "error",
// https://eslint.org/docs/rules/no-useless-concat

View File

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

View File

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

View File

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

View File

@ -56,10 +56,11 @@ define(
*/
CreateWizard.prototype.getFormStructure = function (includeLocation) {
var sections = [],
domainObject = this.domainObject;
domainObject = this.domainObject,
self = this;
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({

View File

@ -60,7 +60,7 @@ define(
]
);
mockCopyService.perform.and.callFake(function () {
mockCopyService.perform.and.callFake(() => {
var performPromise,
callExtensions,
spy;
@ -79,7 +79,7 @@ define(
}
};
spy = this.perform;
spy = mockCopyService.perform;
Object.keys(callExtensions).forEach(function (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();
this.perform.calls.mostRecent().promise = performPromise;
this.perform.calls.all()[this.perform.calls.count() - 1].promise =
mockLinkService.perform.calls.mostRecent().promise = performPromise;
mockLinkService.perform.calls.all()[mockLinkService.perform.calls.count() - 1].promise =
performPromise;
return performPromise.then(function (overrideObject) {

View File

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

View File

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

View File

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

View File

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

View File

@ -33,13 +33,10 @@ define(
_
) {
var ZERO = function () {
return 0;
},
EMPTY_SERIES = {
getPointCount: ZERO,
getDomainValue: ZERO,
getRangeValue: ZERO
const EMPTY_SERIES = {
getPointCount: () => 0,
getDomainValue: () => 0,
getRangeValue: () => 0
};
/**

View File

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

View File

@ -339,6 +339,7 @@ define([
}
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));
}

View File

@ -169,7 +169,22 @@ export default {
},
dropCondition(targetIndex) {
const oldIndexArr = Object.keys(this.conditionCollection);
const move = function (arr, old_index, new_index) {
const newIndexArr = this.rearrangeIndices(oldIndexArr, this.moveIndex, targetIndex);
const reorderPlan = [];
for (let i = 0; i < oldIndexArr.length; i++) {
reorderPlan.push({
oldIndex: Number(newIndexArr[i]),
newIndex: i
});
}
this.reorder(reorderPlan);
},
dragComplete() {
this.isDragging = false;
},
rearrangeIndices(arr, old_index, new_index) {
while (old_index < 0) {
old_index += arr.length;
}
@ -188,22 +203,6 @@ export default {
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
return arr;
};
const newIndexArr = move(oldIndexArr, this.moveIndex, targetIndex);
const reorderPlan = [];
for (let i = 0; i < oldIndexArr.length; i++) {
reorderPlan.push({
oldIndex: Number(newIndexArr[i]),
newIndex: i
});
}
this.reorder(reorderPlan);
},
dragComplete() {
this.isDragging = false;
},
addTelemetryObject(domainObject) {
this.telemetryObjs.push(domainObject);

View File

@ -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: {

View File

@ -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) => {
overlay.dismiss();
if (initialize && conditionSetDomainObject) {
this.conditionSetDomainObject = conditionSetDomainObject;
this.conditionalStyles = [];
this.initializeConditionalStyles();
}
};
function dismissDialog(overlay, initialize) {
overlay.dismiss();
if (initialize && conditionSetDomainObject) {
self.conditionSetDomainObject = conditionSetDomainObject;
self.conditionalStyles = [];
self.initializeConditionalStyles();
}
}
let vm = new Vue({
provide: {

View File

@ -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) {

View File

@ -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) : '';
};
}

View File

@ -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;
};
}

View File

@ -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) => {
}
}
};
};
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -226,6 +226,8 @@ define([
.then(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) {
model.set('range', this.get('range'));
}
});
}));
if (this.get('range')) {
this.set('range', this.get('range'));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -159,6 +159,7 @@ define([
*/
function onDragStart(event) {
$('.t-drag-indicator').each(function () {
// eslint-disable-next-line no-invalid-this
$(this).html($('.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) {
self.textInputs[inputKey].prop('value', self.config[inputKey] || '');
self.listenTo(self.textInputs[inputKey], 'input', function () {
// eslint-disable-next-line no-invalid-this
onTextInput(this, inputKey);
});
});
@ -221,6 +223,7 @@ define([
this.listenTo(this.grippy, 'mousedown', onDragStart);
this.widgetDnD.on('drop', function () {
// eslint-disable-next-line no-invalid-this
this.domElement.show();
$('.t-drag-indicator').hide();
}, this);

View File

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

View File

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

View File

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

View File

@ -31,16 +31,16 @@ define(['../../src/input/ObjectSelect'], function (ObjectSelect) {
'getComposition'
]);
mockManager.on.and.callFake(function (event, callback) {
this.callbacks = this.callbacks || {};
this.callbacks[event] = callback;
mockManager.on.and.callFake((event, callback) => {
mockManager.callbacks = mockManager.callbacks || {};
mockManager.callbacks[event] = callback;
});
mockManager.triggerCallback.and.callFake(function (event, newObj) {
mockManager.triggerCallback.and.callFake((event, newObj) => {
if (event === 'add') {
this.callbacks.add(newObj);
mockManager.callbacks.add(newObj);
} 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));
});
mockKeySelect.on.and.callFake(function (event, callback) {
this.callbacks = this.callbacks || {};
this.callbacks[event] = callback;
mockKeySelect.on.and.callFake((event, callback) => {
mockKeySelect.callbacks = mockKeySelect.callbacks || {};
mockKeySelect.callbacks[event] = callback;
});
mockKeySelect.triggerCallback.and.callFake(function (event, key) {
this.callbacks[event](key);
mockKeySelect.triggerCallback.and.callFake((event, key) => {
mockKeySelect.callbacks[event](key);
});
mockManager.on.and.callFake(function (event, callback) {
this.callbacks = this.callbacks || {};
this.callbacks[event] = callback;
mockManager.on.and.callFake((event, callback) => {
mockManager.callbacks = mockManager.callbacks || {};
mockManager.callbacks[event] = callback;
});
mockManager.triggerCallback.and.callFake(function (event) {
this.callbacks[event]();
mockManager.triggerCallback.and.callFake(event => {
mockManager.callbacks[event]();
});
mockManager.getTelemetryPropertyType.and.callFake(function (object, key) {

View File

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

View File

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

View File

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

View File

@ -71,13 +71,16 @@ function validateConfiguration(config, openmct) {
}, {});
return config.menuOptions.map(function (menuOption) {
let message = '';
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]) {
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');
}

View File

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

View File

@ -98,32 +98,6 @@ import AppLogo from './AppLogo.vue';
import Indicators from './status-bar/Indicators.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 {
inject: ['openmct'],
components: {
@ -168,6 +142,30 @@ export default {
this.openmct.selection.on('change', this.toggleHasToolbar);
},
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() {
this.headExpanded = !this.headExpanded;
@ -183,10 +181,10 @@ export default {
fullScreenToggle() {
if (this.fullScreen) {
this.fullScreen = false;
exitFullScreen();
this.exitFullScreen();
} else {
this.fullScreen = true;
enterFullScreen();
this.enterFullScreen();
}
},
openInNewTab(event) {

View File

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

View File

@ -57,7 +57,7 @@ define([
path = path.split('/');
}
return pathToObjects(path).then((objects) => {
return pathToObjects(path).then(objects => {
isRoutingInProgress = false;
if (currentNavigation !== navigateCall) {
@ -72,7 +72,7 @@ define([
// API for this.
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;
browseObject = newObject;
});

View File

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