From 43628ad9d616abd6900d92fc682f3e2a1d0d6386 Mon Sep 17 00:00:00 2001 From: Joel McKinnon Date: Wed, 27 May 2020 10:59:02 -0700 Subject: [PATCH] Lodash upgrade and cleanup (#2990) * Upgrades lodash * Replaces some usage of lodash with native functions. * Adds linting to catch cases where native functions could be used instead of lodash functions * Renamed testTools to testUtils Co-authored-by: Joshi Co-authored-by: David Tsay Co-authored-by: David Tsay <3614296+davetsay@users.noreply.github.com> Co-authored-by: Andrew Henry --- .eslintrc.js | 6 +++++- example/generator/GeneratorMetadataProvider.js | 2 +- package.json | 3 ++- .../src/policies/EditPersistableObjectsPolicy.js | 2 +- .../containment/src/PersistableCompositionPolicy.js | 2 +- platform/core/src/actions/ActionCapability.js | 2 +- .../import-export/src/actions/ExportAsJSONAction.js | 2 +- .../import-export/src/actions/ImportAsJSONAction.js | 2 +- .../search/src/services/GenericSearchProvider.js | 4 ++-- platform/telemetry/src/TelemetryCapability.js | 6 +++--- src/MCT.js | 2 +- src/MCTSpec.js | 6 +++--- src/adapter/actions/ActionDialogDecorator.js | 2 +- src/adapter/capabilities/AdapterCapability.js | 2 +- .../capabilities/AlternateCompositionCapability.js | 2 +- src/adapter/capabilities/patchViewCapability.js | 3 +++ src/adapter/runs/AlternateCompositionInitializer.js | 2 +- src/adapter/runs/LegacyTelemetryProvider.js | 2 +- src/adapter/runs/TimeSettingsURLHandler.js | 2 +- src/adapter/services/LegacyObjectAPIInterceptor.js | 2 +- .../services/MissingModelCompatibilityDecorator.js | 2 +- src/adapter/views/installLegacyViews.js | 2 +- src/api/composition/CompositionAPI.js | 2 +- src/api/composition/CompositionCollection.js | 2 +- src/api/composition/DefaultCompositionProvider.js | 8 ++++---- src/api/objects/MutableObject.js | 2 +- src/api/objects/ObjectAPI.js | 2 +- src/api/objects/RootRegistry.js | 2 +- src/api/objects/test/object-utilsSpec.js | 2 +- src/api/telemetry/DefaultMetadataProvider.js | 8 ++++---- src/api/telemetry/TelemetryAPI.js | 6 +++--- src/api/telemetry/TelemetryMetadataManager.js | 8 ++++---- src/plugins/LADTable/components/LADTable.vue | 2 +- src/plugins/LADTable/components/LadTableSet.vue | 4 ++-- .../condition/components/ConditionCollection.vue | 2 +- .../components/inspector/ConditionalStylesView.vue | 7 ++++--- .../components/inspector/MultiSelectStylesView.vue | 5 +++-- src/plugins/condition/pluginSpec.js | 2 +- src/plugins/condition/utils/operations.js | 6 ++---- src/plugins/condition/utils/styleUtils.js | 4 +++- .../displayLayout/components/DisplayLayout.vue | 4 ++-- src/plugins/displayLayout/components/LayoutFrame.vue | 1 + src/plugins/displayLayout/components/LineView.vue | 1 + src/plugins/displayLayout/plugin.js | 2 +- src/plugins/filters/components/FilterObject.vue | 3 ++- src/plugins/filters/components/FiltersView.vue | 3 ++- src/plugins/folderView/components/ListView.vue | 1 + src/plugins/imagery/components/ImageryViewLayout.vue | 2 +- src/plugins/plot/src/chart/MCTChartController.js | 2 +- src/plugins/plot/src/configuration/Collection.js | 9 ++------- src/plugins/plot/src/configuration/Model.js | 2 +- src/plugins/plot/src/configuration/PlotSeries.js | 6 ++++-- .../plot/src/configuration/SeriesCollection.js | 4 ++-- src/plugins/plot/src/draw/Draw2D.js | 2 +- src/plugins/plot/src/draw/DrawWebGL.js | 2 +- .../plot/src/inspector/PlotOptionsController.js | 2 +- .../plot/src/inspector/PlotSeriesFormController.js | 2 +- .../plot/src/inspector/PlotYAxisFormController.js | 4 ++-- .../plot/src/telemetry/StackedPlotController.js | 2 +- src/plugins/staticRootPlugin/StaticModelProvider.js | 2 +- src/plugins/summaryWidget/src/ConditionManager.js | 5 +++-- src/plugins/summaryWidget/src/SummaryWidget.js | 2 +- src/plugins/summaryWidget/src/input/ObjectSelect.js | 2 +- .../summaryWidget/src/telemetry/EvaluatorPool.js | 2 +- .../src/telemetry/SummaryWidgetEvaluator.js | 12 +++++++++--- .../src/views/SummaryWidgetViewProvider.js | 2 +- .../telemetryMean/src/MeanTelemetryProvider.js | 2 +- .../telemetryTable/TableConfigurationViewProvider.js | 2 +- .../telemetryTable/TelemetryTableConfiguration.js | 5 +++-- .../collections/SortedTableRowCollection.js | 6 +++--- .../components/TelemetryFilterIndicator.vue | 2 ++ src/plugins/telemetryTable/pluginSpec.js | 2 +- src/{testTools.js => testUtils.js} | 0 src/ui/layout/CreateButton.vue | 2 +- webpack.config.js | 3 ++- 75 files changed, 131 insertions(+), 108 deletions(-) rename src/{testTools.js => testUtils.js} (100%) diff --git a/.eslintrc.js b/.eslintrc.js index 3cf7ec2e20..0cb8f3c4f7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,7 +10,8 @@ module.exports = { }, "extends": [ "eslint:recommended", - "plugin:vue/recommended" + "plugin:vue/recommended", + "plugin:you-dont-need-lodash-underscore/compatible" ], "parser": "vue-eslint-parser", "parserOptions": { @@ -22,6 +23,9 @@ module.exports = { } }, "rules": { + "you-dont-need-lodash-underscore/omit": "off", + "you-dont-need-lodash-underscore/throttle": "off", + "you-dont-need-lodash-underscore/flatten": "off", "no-bitwise": "error", "curly": "error", "eqeqeq": "error", diff --git a/example/generator/GeneratorMetadataProvider.js b/example/generator/GeneratorMetadataProvider.js index b9ddf23c3d..9ca9a08f4c 100644 --- a/example/generator/GeneratorMetadataProvider.js +++ b/example/generator/GeneratorMetadataProvider.js @@ -100,7 +100,7 @@ define([ }; GeneratorMetadataProvider.prototype.getMetadata = function (domainObject) { - return _.extend( + return Object.assign( {}, domainObject.telemetry, METADATA_BY_TYPE[domainObject.type] diff --git a/package.json b/package.json index 707357d7a8..8b6fab4940 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "d3-time-format": "2.1.x", "eslint": "5.2.0", "eslint-plugin-vue": "^6.0.0", + "eslint-plugin-you-dont-need-lodash-underscore": "^6.10.0", "eventemitter3": "^1.2.0", "exports-loader": "^0.7.0", "express": "^4.13.1", @@ -48,7 +49,7 @@ "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^3.0.0", "location-bar": "^3.0.1", - "lodash": "^3.10.1", + "lodash": "^4.17.12", "markdown-toc": "^0.11.7", "marked": "^0.3.5", "mini-css-extract-plugin": "^0.4.1", diff --git a/platform/commonUI/edit/src/policies/EditPersistableObjectsPolicy.js b/platform/commonUI/edit/src/policies/EditPersistableObjectsPolicy.js index 7377aab47b..e384e4970a 100644 --- a/platform/commonUI/edit/src/policies/EditPersistableObjectsPolicy.js +++ b/platform/commonUI/edit/src/policies/EditPersistableObjectsPolicy.js @@ -21,7 +21,7 @@ *****************************************************************************/ define( - ['../../../../../src/api/objects/object-utils'], + ['objectUtils'], function (objectUtils) { /** diff --git a/platform/containment/src/PersistableCompositionPolicy.js b/platform/containment/src/PersistableCompositionPolicy.js index 0a1b3c9aa9..df9d228222 100644 --- a/platform/containment/src/PersistableCompositionPolicy.js +++ b/platform/containment/src/PersistableCompositionPolicy.js @@ -26,7 +26,7 @@ * @namespace platform/containment */ define( - ['../../../src/api/objects/object-utils'], + ['objectUtils'], function (objectUtils) { function PersistableCompositionPolicy(openmct) { diff --git a/platform/core/src/actions/ActionCapability.js b/platform/core/src/actions/ActionCapability.js index 3fa38e3820..0506711959 100644 --- a/platform/core/src/actions/ActionCapability.js +++ b/platform/core/src/actions/ActionCapability.js @@ -81,7 +81,7 @@ define( baseContext = context || {}; } - var actionContext = _.extend({}, baseContext); + var actionContext = Object.assign({}, baseContext); actionContext.domainObject = this.domainObject; return this.actionService.getActions(actionContext); diff --git a/platform/import-export/src/actions/ExportAsJSONAction.js b/platform/import-export/src/actions/ExportAsJSONAction.js index a0b37c054f..48156ebbfd 100644 --- a/platform/import-export/src/actions/ExportAsJSONAction.js +++ b/platform/import-export/src/actions/ExportAsJSONAction.js @@ -121,7 +121,7 @@ define(['lodash'], function (_) { */ ExportAsJSONAction.prototype.rewriteLink = function (child, parent) { this.externalIdentifiers.push(this.getId(child)); - var index = _.findIndex(parent.composition, function (id) { + var index = parent.composition.findIndex(id => { return _.isEqual(child.identifier, id); }); var copyOfChild = this.copyObject(child); diff --git a/platform/import-export/src/actions/ImportAsJSONAction.js b/platform/import-export/src/actions/ImportAsJSONAction.js index 8411d12dad..40dd338e15 100644 --- a/platform/import-export/src/actions/ImportAsJSONAction.js +++ b/platform/import-export/src/actions/ImportAsJSONAction.js @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -define(['zepto', '../../../../src/api/objects/object-utils.js'], function ($, objectUtils) { +define(['zepto', 'objectUtils'], function ($, objectUtils) { /** * The ImportAsJSONAction is available from context menus and allows a user diff --git a/platform/search/src/services/GenericSearchProvider.js b/platform/search/src/services/GenericSearchProvider.js index 5bfebe24e9..1a6399440f 100644 --- a/platform/search/src/services/GenericSearchProvider.js +++ b/platform/search/src/services/GenericSearchProvider.js @@ -25,7 +25,7 @@ * Module defining GenericSearchProvider. Created by shale on 07/16/2015. */ define([ - '../../../../src/api/objects/object-utils', + 'objectUtils', 'lodash' ], function ( objectUtils, @@ -191,7 +191,7 @@ define([ } var domainObject = objectUtils.toNewFormat(model, id); - var composition = _.find(this.openmct.composition.registry, function (p) { + var composition = this.openmct.composition.registry.find(p => { return p.appliesTo(domainObject); }); diff --git a/platform/telemetry/src/TelemetryCapability.js b/platform/telemetry/src/TelemetryCapability.js index c5ac36cd3d..66d4f8cc8a 100644 --- a/platform/telemetry/src/TelemetryCapability.js +++ b/platform/telemetry/src/TelemetryCapability.js @@ -25,7 +25,7 @@ */ define( [ - '../../../src/api/objects/object-utils', + 'objectUtils', 'lodash' ], function ( @@ -235,7 +235,7 @@ define( var defaultRange = metadata.valuesForHints(['range'])[0]; defaultRange = defaultRange ? defaultRange.key : undefined; - var sourceMap = _.indexBy(metadata.values(), 'key'); + var sourceMap = _.keyBy(metadata.values(), 'key'); var isLegacyProvider = telemetryAPI.findRequestProvider(domainObject) === telemetryAPI.legacyProvider; @@ -300,7 +300,7 @@ define( var defaultRange = metadata.valuesForHints(['range'])[0]; defaultRange = defaultRange ? defaultRange.key : undefined; - var sourceMap = _.indexBy(metadata.values(), 'key'); + var sourceMap = _.keyBy(metadata.values(), 'key'); var isLegacyProvider = telemetryAPI.findSubscriptionProvider(domainObject) === telemetryAPI.legacyProvider; diff --git a/src/MCT.js b/src/MCT.js index db900a9924..9eedf2bee7 100644 --- a/src/MCT.js +++ b/src/MCT.js @@ -28,7 +28,7 @@ define([ './api/api', './api/overlays/OverlayAPI', './selection/Selection', - './api/objects/object-utils', + 'objectUtils', './plugins/plugins', './adapter/indicators/legacy-indicators-plugin', './plugins/buildInfo/plugin', diff --git a/src/MCTSpec.js b/src/MCTSpec.js index 7b37121fd9..53417f4314 100644 --- a/src/MCTSpec.js +++ b/src/MCTSpec.js @@ -23,8 +23,8 @@ define([ './plugins/plugins', 'legacyRegistry', - 'testTools' -], function (plugins, legacyRegistry, testTools) { + 'testUtils' +], function (plugins, legacyRegistry, testUtils) { describe("MCT", function () { var openmct; var mockPlugin; @@ -38,7 +38,7 @@ define([ mockListener = jasmine.createSpy('listener'); oldBundles = legacyRegistry.list(); - openmct = testTools.createOpenMct(); + openmct = testUtils.createOpenMct(); openmct.install(mockPlugin); openmct.install(mockPlugin2); diff --git a/src/adapter/actions/ActionDialogDecorator.js b/src/adapter/actions/ActionDialogDecorator.js index c4d38b180e..bd6b2d01fb 100644 --- a/src/adapter/actions/ActionDialogDecorator.js +++ b/src/adapter/actions/ActionDialogDecorator.js @@ -21,7 +21,7 @@ *****************************************************************************/ define([ - '../../api/objects/object-utils' + 'objectUtils' ], function (objectUtils) { function ActionDialogDecorator(mct, actionService) { this.mct = mct; diff --git a/src/adapter/capabilities/AdapterCapability.js b/src/adapter/capabilities/AdapterCapability.js index 70db1d87ad..4e51161123 100644 --- a/src/adapter/capabilities/AdapterCapability.js +++ b/src/adapter/capabilities/AdapterCapability.js @@ -20,7 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -define(['../../api/objects/object-utils'], function (objectUtils) { +define(['objectUtils'], function (objectUtils) { function AdapterCapability(domainObject) { this.domainObject = domainObject; } diff --git a/src/adapter/capabilities/AlternateCompositionCapability.js b/src/adapter/capabilities/AlternateCompositionCapability.js index a8e3f7d829..7670ae899f 100644 --- a/src/adapter/capabilities/AlternateCompositionCapability.js +++ b/src/adapter/capabilities/AlternateCompositionCapability.js @@ -24,7 +24,7 @@ * Module defining AlternateCompositionCapability. Created by vwoeltje on 11/7/14. */ define([ - '../../api/objects/object-utils', + 'objectUtils', '../../../platform/core/src/capabilities/ContextualDomainObject' ], function (objectUtils, ContextualDomainObject) { function AlternateCompositionCapability($injector, domainObject) { diff --git a/src/adapter/capabilities/patchViewCapability.js b/src/adapter/capabilities/patchViewCapability.js index 48f1081e03..f8f7a13cd2 100644 --- a/src/adapter/capabilities/patchViewCapability.js +++ b/src/adapter/capabilities/patchViewCapability.js @@ -31,6 +31,7 @@ define([ var capability = viewConstructor(domainObject); var oldInvoke = capability.invoke.bind(capability); + /* eslint-disable you-dont-need-lodash-underscore/map */ capability.invoke = function () { var availableViews = oldInvoke(); var newDomainObject = capability @@ -52,6 +53,8 @@ define([ .map('view') .value(); }; + /* eslint-enable you-dont-need-lodash-underscore/map */ + return capability; }; } diff --git a/src/adapter/runs/AlternateCompositionInitializer.js b/src/adapter/runs/AlternateCompositionInitializer.js index e73f33114e..ea4222ed51 100644 --- a/src/adapter/runs/AlternateCompositionInitializer.js +++ b/src/adapter/runs/AlternateCompositionInitializer.js @@ -22,7 +22,7 @@ define([ '../capabilities/AlternateCompositionCapability', - '../../api/objects/object-utils' + 'objectUtils' ], function ( AlternateCompositionCapability, objectUtils diff --git a/src/adapter/runs/LegacyTelemetryProvider.js b/src/adapter/runs/LegacyTelemetryProvider.js index 4387d92f87..5fda222803 100644 --- a/src/adapter/runs/LegacyTelemetryProvider.js +++ b/src/adapter/runs/LegacyTelemetryProvider.js @@ -21,7 +21,7 @@ *****************************************************************************/ define([ - '../../api/objects/object-utils' + 'objectUtils' ], function ( utils ) { diff --git a/src/adapter/runs/TimeSettingsURLHandler.js b/src/adapter/runs/TimeSettingsURLHandler.js index 34f7ec6986..1806cc66dc 100644 --- a/src/adapter/runs/TimeSettingsURLHandler.js +++ b/src/adapter/runs/TimeSettingsURLHandler.js @@ -78,7 +78,7 @@ define([ }; TimeSettingsURLHandler.prototype.parseQueryParams = function () { - var searchParams = _.pick(this.$location.search(), _.values(SEARCH)); + var searchParams = _.pick(this.$location.search(), Object.values(SEARCH)); var parsedParams = { clock: searchParams[SEARCH.MODE], timeSystem: searchParams[SEARCH.TIME_SYSTEM] diff --git a/src/adapter/services/LegacyObjectAPIInterceptor.js b/src/adapter/services/LegacyObjectAPIInterceptor.js index 5c323c4de5..d71dcd1837 100644 --- a/src/adapter/services/LegacyObjectAPIInterceptor.js +++ b/src/adapter/services/LegacyObjectAPIInterceptor.js @@ -21,7 +21,7 @@ *****************************************************************************/ define([ - '../../api/objects/object-utils' + 'objectUtils' ], function ( utils ) { diff --git a/src/adapter/services/MissingModelCompatibilityDecorator.js b/src/adapter/services/MissingModelCompatibilityDecorator.js index e9cbd3cb6c..214ebdf1f9 100644 --- a/src/adapter/services/MissingModelCompatibilityDecorator.js +++ b/src/adapter/services/MissingModelCompatibilityDecorator.js @@ -21,7 +21,7 @@ *****************************************************************************/ define([ - '../../api/objects/object-utils' + 'objectUtils' ], function ( objectUtils ) { diff --git a/src/adapter/views/installLegacyViews.js b/src/adapter/views/installLegacyViews.js index d98796976f..1f8e7639ab 100644 --- a/src/adapter/views/installLegacyViews.js +++ b/src/adapter/views/installLegacyViews.js @@ -1,7 +1,7 @@ define([ './LegacyViewProvider', './TypeInspectorViewProvider', - '../../api/objects/object-utils' + 'objectUtils' ], function ( LegacyViewProvider, TypeInspectorViewProvider, diff --git a/src/api/composition/CompositionAPI.js b/src/api/composition/CompositionAPI.js index ea122c290d..ba3aa55ddf 100644 --- a/src/api/composition/CompositionAPI.js +++ b/src/api/composition/CompositionAPI.js @@ -70,7 +70,7 @@ define([ * @memberof module:openmct.CompositionAPI# */ CompositionAPI.prototype.get = function (domainObject) { - var provider = _.find(this.registry, function (p) { + var provider = this.registry.find(p => { return p.appliesTo(domainObject); }); diff --git a/src/api/composition/CompositionCollection.js b/src/api/composition/CompositionCollection.js index 51c4a986fa..37fc583189 100644 --- a/src/api/composition/CompositionCollection.js +++ b/src/api/composition/CompositionCollection.js @@ -122,7 +122,7 @@ define([ throw new Error('Event not supported by composition: ' + event); } - var index = _.findIndex(this.listeners[event], function (l) { + var index = this.listeners[event].findIndex(l => { return l.callback === callback && l.context === context; }); diff --git a/src/api/composition/DefaultCompositionProvider.js b/src/api/composition/DefaultCompositionProvider.js index ca10ca64b0..bfd8c33a59 100644 --- a/src/api/composition/DefaultCompositionProvider.js +++ b/src/api/composition/DefaultCompositionProvider.js @@ -22,7 +22,7 @@ define([ 'lodash', - '../objects/object-utils' + 'objectUtils' ], function ( _, objectUtils @@ -143,7 +143,7 @@ define([ var keyString = objectUtils.makeKeyString(domainObject.identifier); var objectListeners = this.listeningTo[keyString]; - var index = _.findIndex(objectListeners[event], function (l) { + var index = objectListeners[event].findIndex(l => { return l.callback === callback && l.context === context; }); @@ -196,8 +196,8 @@ define([ * @private */ DefaultCompositionProvider.prototype.includes = function (parent, childId) { - return parent.composition.findIndex(composee => - this.publicAPI.objects.areIdsEqual(composee, childId)) !== -1; + return parent.composition.some(composee => + this.publicAPI.objects.areIdsEqual(composee, childId)); }; DefaultCompositionProvider.prototype.reorder = function (domainObject, oldIndex, newIndex) { diff --git a/src/api/objects/MutableObject.js b/src/api/objects/MutableObject.js index 78feb6fc53..7768b4452f 100644 --- a/src/api/objects/MutableObject.js +++ b/src/api/objects/MutableObject.js @@ -21,7 +21,7 @@ *****************************************************************************/ define([ - './object-utils.js', + 'objectUtils', 'lodash' ], function ( utils, diff --git a/src/api/objects/ObjectAPI.js b/src/api/objects/ObjectAPI.js index d40b78a4c4..3d874eb295 100644 --- a/src/api/objects/ObjectAPI.js +++ b/src/api/objects/ObjectAPI.js @@ -22,7 +22,7 @@ define([ 'lodash', - './object-utils', + 'objectUtils', './MutableObject', './RootRegistry', './RootObjectProvider', diff --git a/src/api/objects/RootRegistry.js b/src/api/objects/RootRegistry.js index 089cfe9081..90186f2929 100644 --- a/src/api/objects/RootRegistry.js +++ b/src/api/objects/RootRegistry.js @@ -43,7 +43,7 @@ define([ } RootRegistry.prototype.addRoot = function (key) { - if (isKey(key) || (_.isArray(key) && _.every(key, isKey))) { + if (isKey(key) || (Array.isArray(key) && key.every(isKey))) { this.providers.push(function () { return key; }); diff --git a/src/api/objects/test/object-utilsSpec.js b/src/api/objects/test/object-utilsSpec.js index 9a98b246e8..31ed81af79 100644 --- a/src/api/objects/test/object-utilsSpec.js +++ b/src/api/objects/test/object-utilsSpec.js @@ -1,5 +1,5 @@ define([ - '../object-utils' + 'objectUtils' ], function ( objectUtils ) { diff --git a/src/api/telemetry/DefaultMetadataProvider.js b/src/api/telemetry/DefaultMetadataProvider.js index 2f6aa94ed0..a4bb276caf 100644 --- a/src/api/telemetry/DefaultMetadataProvider.js +++ b/src/api/telemetry/DefaultMetadataProvider.js @@ -85,9 +85,9 @@ define([ value: +e.value }; }), 'e.value'); - valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value'); - valueMetadata.max = _.max(valueMetadata.values); - valueMetadata.min = _.min(valueMetadata.values); + valueMetadata.values = valueMetadata.enumerations.map(e => e.value); + valueMetadata.max = Math.max(valueMetadata.values); + valueMetadata.min = Math.min(valueMetadata.values); } valueMetadatas.push(valueMetadata); @@ -103,7 +103,7 @@ define([ var metadata = domainObject.telemetry || {}; if (this.typeHasTelemetry(domainObject)) { var typeMetadata = this.typeService.getType(domainObject.type).typeDef.telemetry; - _.extend(metadata, typeMetadata); + Object.assign(metadata, typeMetadata); if (!metadata.values) { metadata.values = valueMetadatasFromOldFormat(metadata); } diff --git a/src/api/telemetry/TelemetryAPI.js b/src/api/telemetry/TelemetryAPI.js index 9de8638eb3..41c49e4027 100644 --- a/src/api/telemetry/TelemetryAPI.js +++ b/src/api/telemetry/TelemetryAPI.js @@ -24,7 +24,7 @@ define([ './TelemetryMetadataManager', './TelemetryValueFormatter', './DefaultMetadataProvider', - '../objects/object-utils', + 'objectUtils', 'lodash' ], function ( TelemetryMetadataManager, @@ -370,7 +370,7 @@ define([ TelemetryAPI.prototype.commonValuesForHints = function (metadatas, hints) { var options = metadatas.map(function (metadata) { var values = metadata.valuesForHints(hints); - return _.indexBy(values, 'key'); + return _.keyBy(values, 'key'); }).reduce(function (a, b) { var results = {}; Object.keys(a).forEach(function (key) { @@ -383,7 +383,7 @@ define([ var sortKeys = hints.map(function (h) { return 'hints.' + h; }); - return _.sortByAll(options, sortKeys); + return _.sortBy(options, sortKeys); }; /** diff --git a/src/api/telemetry/TelemetryMetadataManager.js b/src/api/telemetry/TelemetryMetadataManager.js index 5b93eee6d6..8e8dcc4c9d 100644 --- a/src/api/telemetry/TelemetryMetadataManager.js +++ b/src/api/telemetry/TelemetryMetadataManager.js @@ -57,13 +57,13 @@ define([ if (valueMetadata.format === 'enum') { if (!valueMetadata.values) { - valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value'); + valueMetadata.values = valueMetadata.enumerations.map(e => e.value); } if (!valueMetadata.hasOwnProperty('max')) { - valueMetadata.max = _.max(valueMetadata.values) + 1; + valueMetadata.max = Math.max(valueMetadata.values) + 1; } if (!valueMetadata.hasOwnProperty('min')) { - valueMetadata.min = _.min(valueMetadata.values) - 1; + valueMetadata.min = Math.min(valueMetadata.values) - 1; } } @@ -121,7 +121,7 @@ define([ return metadata.hints[hint]; } }); - return _.sortByAll(matchingMetadata, ...iteratees); + return _.sortBy(matchingMetadata, ...iteratees); }; TelemetryMetadataManager.prototype.getFilterableValues = function () { diff --git a/src/plugins/LADTable/components/LADTable.vue b/src/plugins/LADTable/components/LADTable.vue index f304603a7b..d163d78932 100644 --- a/src/plugins/LADTable/components/LADTable.vue +++ b/src/plugins/LADTable/components/LADTable.vue @@ -75,7 +75,7 @@ export default { this.items.push(item); }, removeItem(identifier) { - let index = _.findIndex(this.items, (item) => this.openmct.objects.makeKeyString(identifier) === item.key); + let index = this.items.findIndex(item => this.openmct.objects.makeKeyString(identifier) === item.key); this.items.splice(index, 1); }, diff --git a/src/plugins/LADTable/components/LadTableSet.vue b/src/plugins/LADTable/components/LadTableSet.vue index bdb764a5b7..db16fba60e 100644 --- a/src/plugins/LADTable/components/LadTableSet.vue +++ b/src/plugins/LADTable/components/LadTableSet.vue @@ -102,7 +102,7 @@ export default { this.compositions.push({composition, addCallback, removeCallback}); }, removePrimary(identifier) { - let index = _.findIndex(this.primaryTelemetryObjects, (primary) => this.openmct.objects.makeKeyString(identifier) === primary.key), + let index = this.primaryTelemetryObjects.findIndex(primary => this.openmct.objects.makeKeyString(identifier) === primary.key), primary = this.primaryTelemetryObjects[index]; this.$set(this.secondaryTelemetryObjects, primary.key, undefined); @@ -130,7 +130,7 @@ export default { removeSecondary(primary) { return (identifier) => { let array = this.secondaryTelemetryObjects[primary.key], - index = _.findIndex(array, (secondary) => this.openmct.objects.makeKeyString(identifier) === secondary.key); + index = array.findIndex(secondary => this.openmct.objects.makeKeyString(identifier) === secondary.key); array.splice(index, 1); diff --git a/src/plugins/condition/components/ConditionCollection.vue b/src/plugins/condition/components/ConditionCollection.vue index 4cb042b7b7..54c797d966 100644 --- a/src/plugins/condition/components/ConditionCollection.vue +++ b/src/plugins/condition/components/ConditionCollection.vue @@ -200,7 +200,7 @@ export default { this.$emit('telemetryUpdated', this.telemetryObjs); }, removeTelemetryObject(identifier) { - let index = _.findIndex(this.telemetryObjs, (obj) => { + let index = this.telemetryObjs.findIndex(obj => { let objId = this.openmct.objects.makeKeyString(obj.identifier); let id = this.openmct.objects.makeKeyString(identifier); return objId === id; diff --git a/src/plugins/condition/components/inspector/ConditionalStylesView.vue b/src/plugins/condition/components/inspector/ConditionalStylesView.vue index 0d88d551cc..cd99ea8fb0 100644 --- a/src/plugins/condition/components/inspector/ConditionalStylesView.vue +++ b/src/plugins/condition/components/inspector/ConditionalStylesView.vue @@ -108,6 +108,7 @@ import ConditionError from "@/plugins/condition/components/ConditionError.vue"; import Vue from 'vue'; import PreviewAction from "@/ui/preview/PreviewAction.js"; import {getApplicableStylesForItem} from "@/plugins/condition/utils/styleUtils"; +import isEmpty from 'lodash/isEmpty'; export default { name: 'ConditionalStylesView', @@ -288,7 +289,7 @@ export default { delete domainObjectStyles[this.itemId].conditionSetIdentifier; domainObjectStyles[this.itemId].styles = undefined; delete domainObjectStyles[this.itemId].styles; - if (_.isEmpty(domainObjectStyles[this.itemId])) { + if (isEmpty(domainObjectStyles[this.itemId])) { delete domainObjectStyles[this.itemId]; } } else { @@ -299,7 +300,7 @@ export default { domainObjectStyles.styles = undefined; delete domainObjectStyles.styles; } - if (_.isEmpty(domainObjectStyles)) { + if (isEmpty(domainObjectStyles)) { domainObjectStyles = undefined; } @@ -337,7 +338,7 @@ export default { delete domainObjectStyles[this.itemId]; } }); - if (_.isEmpty(domainObjectStyles)) { + if (isEmpty(domainObjectStyles)) { domainObjectStyles = undefined; } this.persist(domainObjectStyles); diff --git a/src/plugins/condition/components/inspector/MultiSelectStylesView.vue b/src/plugins/condition/components/inspector/MultiSelectStylesView.vue index 2099cfe33a..1a7290e91e 100644 --- a/src/plugins/condition/components/inspector/MultiSelectStylesView.vue +++ b/src/plugins/condition/components/inspector/MultiSelectStylesView.vue @@ -50,6 +50,7 @@ import StyleEditor from "./StyleEditor.vue"; import PreviewAction from "@/ui/preview/PreviewAction.js"; import { getApplicableStylesForItem, getConsolidatedStyleValues, getConditionalStyleForItem } from "@/plugins/condition/utils/styleUtils"; +import isEmpty from 'lodash/isEmpty'; export default { name: 'MultiSelectStylesView', @@ -178,7 +179,7 @@ export default { domainObjectStyles[itemId] = undefined; delete domainObjectStyles[this.itemId]; - if (_.isEmpty(domainObjectStyles)) { + if (isEmpty(domainObjectStyles)) { domainObjectStyles = undefined; } this.persist(this.domainObject, domainObjectStyles); @@ -239,7 +240,7 @@ export default { if (this.isStaticAndConditionalStyles) { this.removeConditionalStyles(domainObjectStyles, item.id); } - if (_.isEmpty(itemStaticStyle)) { + if (isEmpty(itemStaticStyle)) { itemStaticStyle = undefined; domainObjectStyles[item.id] = undefined; } else { diff --git a/src/plugins/condition/pluginSpec.js b/src/plugins/condition/pluginSpec.js index 16b74e1d1b..93a1930bc4 100644 --- a/src/plugins/condition/pluginSpec.js +++ b/src/plugins/condition/pluginSpec.js @@ -20,7 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -import { createOpenMct } from "testTools"; +import { createOpenMct } from "testUtils"; import ConditionPlugin from "./plugin"; describe('the plugin', function () { diff --git a/src/plugins/condition/utils/operations.js b/src/plugins/condition/utils/operations.js index 51bc010d76..86d67d47d9 100644 --- a/src/plugins/condition/utils/operations.js +++ b/src/plugins/condition/utils/operations.js @@ -20,8 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -import _ from 'lodash'; - const convertToNumbers = (input) => { let numberInputs = []; input.forEach(inputValue => numberInputs.push(Number(inputValue))); @@ -257,7 +255,7 @@ export const OPERATIONS = [ const lhsValue = input[0] !== undefined ? input[0].toString() : ''; if (input[1]) { const values = input[1].split(','); - return values.find((value) => lhsValue === _.trim(value.toString())); + return values.find((value) => lhsValue === value.toString().trim()); } return false; }, @@ -274,7 +272,7 @@ export const OPERATIONS = [ const lhsValue = input[0] !== undefined ? input[0].toString() : ''; if (input[1]) { const values = input[1].split(','); - const found = values.find((value) => lhsValue === _.trim(value.toString())); + const found = values.find((value) => lhsValue === value.toString().trim()); return !found; } return false; diff --git a/src/plugins/condition/utils/styleUtils.js b/src/plugins/condition/utils/styleUtils.js index 4872d3dacb..24bf82a1d7 100644 --- a/src/plugins/condition/utils/styleUtils.js +++ b/src/plugins/condition/utils/styleUtils.js @@ -19,6 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ +import isEmpty from 'lodash/isEmpty'; + const NONE_VALUE = '__no_value'; const styleProps = { @@ -154,7 +156,7 @@ export const getApplicableStylesForItem = (domainObject, item) => { }; export const getStylesWithoutNoneValue = (style) => { - if (_.isEmpty(style) || !style) { + if (isEmpty(style) || !style) { return; } let styleObj = {}; diff --git a/src/plugins/displayLayout/components/DisplayLayout.vue b/src/plugins/displayLayout/components/DisplayLayout.vue index a247c601a8..f31c232ed0 100644 --- a/src/plugins/displayLayout/components/DisplayLayout.vue +++ b/src/plugins/displayLayout/components/DisplayLayout.vue @@ -68,7 +68,6 @@