diff --git a/.eslintrc.js b/.eslintrc.js index f7ffebb956..3cf7ec2e20 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,11 +8,9 @@ module.exports = { "globals": { "_": "readonly" }, - "plugins": ["lodash"], "extends": [ "eslint:recommended", - "plugin:vue/recommended", - "plugin:lodash/recommended" + "plugin:vue/recommended" ], "parser": "vue-eslint-parser", "parserOptions": { @@ -24,16 +22,6 @@ module.exports = { } }, "rules": { - "lodash/prefer-lodash-method": "off", - "lodash/prefer-lodash-typecheck": "off", - "lodash/prefer-constant": "off", - "lodash/prefer-noop": "off", - "lodash/prefer-matches": "off", - "lodash/prefer-includes": "off", - "lodash/prefer-startswith": "off", - "lodash/prefer-get": "off", - "lodash/prefer-is-nil": "off", - "lodash/import-scope": "off", "no-bitwise": "error", "curly": "error", "eqeqeq": "error", diff --git a/package.json b/package.json index 870d17ef05..9a68e1fb3f 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "d3-time": "1.0.x", "d3-time-format": "2.1.x", "eslint": "5.2.0", - "eslint-plugin-lodash": "^6.0.0", "eslint-plugin-vue": "^6.0.0", "eventemitter3": "^1.2.0", "exports-loader": "^0.7.0", @@ -48,7 +47,7 @@ "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^3.0.0", "location-bar": "^3.0.1", - "lodash": "^4.17.12", + "lodash": "^3.10.1", "markdown-toc": "^0.11.7", "marked": "^0.3.5", "mini-css-extract-plugin": "^0.4.1", diff --git a/platform/telemetry/src/TelemetryCapability.js b/platform/telemetry/src/TelemetryCapability.js index c2bbe5cadb..c5ac36cd3d 100644 --- a/platform/telemetry/src/TelemetryCapability.js +++ b/platform/telemetry/src/TelemetryCapability.js @@ -25,7 +25,8 @@ */ define( [ - '../../../src/api/objects/object-utils' + '../../../src/api/objects/object-utils', + 'lodash' ], function ( objectUtils, @@ -234,8 +235,7 @@ define( var defaultRange = metadata.valuesForHints(['range'])[0]; defaultRange = defaultRange ? defaultRange.key : undefined; - const keyBy = (array, k) => (array || []).reduce((r, x) => ({ ...r, [k ? x[k] : x]: x }), {}); - var sourceMap = keyBy(metadata.values(), 'key'); + var sourceMap = _.indexBy(metadata.values(), 'key'); var isLegacyProvider = telemetryAPI.findRequestProvider(domainObject) === telemetryAPI.legacyProvider; @@ -300,8 +300,7 @@ define( var defaultRange = metadata.valuesForHints(['range'])[0]; defaultRange = defaultRange ? defaultRange.key : undefined; - const keyBy = (array, k) => (array || []).reduce((r, x) => ({ ...r, [k ? x[k] : x]: x }), {}); - var sourceMap = keyBy(metadata.values(), 'key'); + var sourceMap = _.indexBy(metadata.values(), 'key'); var isLegacyProvider = telemetryAPI.findSubscriptionProvider(domainObject) === telemetryAPI.legacyProvider; diff --git a/src/api/composition/DefaultCompositionProvider.js b/src/api/composition/DefaultCompositionProvider.js index 566427a1ae..ca10ca64b0 100644 --- a/src/api/composition/DefaultCompositionProvider.js +++ b/src/api/composition/DefaultCompositionProvider.js @@ -196,8 +196,8 @@ define([ * @private */ DefaultCompositionProvider.prototype.includes = function (parent, childId) { - return parent.composition.some(composee => - this.publicAPI.objects.areIdsEqual(composee, childId)); + return parent.composition.findIndex(composee => + this.publicAPI.objects.areIdsEqual(composee, childId)) !== -1; }; DefaultCompositionProvider.prototype.reorder = function (domainObject, oldIndex, newIndex) { diff --git a/src/api/telemetry/DefaultMetadataProvider.js b/src/api/telemetry/DefaultMetadataProvider.js index 8c9a4787a5..2f6aa94ed0 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 = Object.entries(valueMetadata.enumerations).reduce((a, [key, {value}]) => {a [key] = value; return a}, []); - valueMetadata.max = Math.max(...valueMetadata.values); - valueMetadata.min = Math.min(...valueMetadata.values); + valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value'); + valueMetadata.max = _.max(valueMetadata.values); + valueMetadata.min = _.min(valueMetadata.values); } valueMetadatas.push(valueMetadata); diff --git a/src/api/telemetry/TelemetryAPI.js b/src/api/telemetry/TelemetryAPI.js index d45eb742cd..9de8638eb3 100644 --- a/src/api/telemetry/TelemetryAPI.js +++ b/src/api/telemetry/TelemetryAPI.js @@ -370,7 +370,7 @@ define([ TelemetryAPI.prototype.commonValuesForHints = function (metadatas, hints) { var options = metadatas.map(function (metadata) { var values = metadata.valuesForHints(hints); - return _.keyBy(values, 'key'); + return _.indexBy(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 _.sortBy(options, sortKeys); + return _.sortByAll(options, sortKeys); }; /** diff --git a/src/api/telemetry/TelemetryMetadataManager.js b/src/api/telemetry/TelemetryMetadataManager.js index 049d1712aa..5b93eee6d6 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 = Object.entries(valueMetadata.enumerations).reduce((a, [key, {value}]) => {a [key] = value; return a}, []); + valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value'); } if (!valueMetadata.hasOwnProperty('max')) { - valueMetadata.max = Math.max(...valueMetadata.values) + 1; + valueMetadata.max = _.max(valueMetadata.values) + 1; } if (!valueMetadata.hasOwnProperty('min')) { - valueMetadata.min = Math.min(...valueMetadata.values) - 1; + valueMetadata.min = _.min(valueMetadata.values) - 1; } } @@ -121,7 +121,7 @@ define([ return metadata.hints[hint]; } }); - return _.sortBy(matchingMetadata, ...iteratees); + return _.sortByAll(matchingMetadata, ...iteratees); }; TelemetryMetadataManager.prototype.getFilterableValues = function () { diff --git a/src/plugins/imagery/components/ImageryViewLayout.vue b/src/plugins/imagery/components/ImageryViewLayout.vue index 0821eeabd9..c308e4c366 100644 --- a/src/plugins/imagery/components/ImageryViewLayout.vue +++ b/src/plugins/imagery/components/ImageryViewLayout.vue @@ -220,7 +220,7 @@ export default { return; } - const index = _.sortedIndexBy(this.imageHistory, datum, this.timeFormat.format.bind(this.timeFormat)); + const index = _.sortedIndex(this.imageHistory, datum, this.timeFormat.format.bind(this.timeFormat)); this.imageHistory.splice(index, 0, datum); }, updateValues(datum) { diff --git a/src/plugins/plot/src/chart/MCTChartController.js b/src/plugins/plot/src/chart/MCTChartController.js index 65224ad504..aa086d412d 100644 --- a/src/plugins/plot/src/chart/MCTChartController.js +++ b/src/plugins/plot/src/chart/MCTChartController.js @@ -152,7 +152,7 @@ function ( MCTChartController.prototype.destroy = function () { this.isDestroyed = true; this.stopListening(); - this.lines.map(line => line.destroy()); + _.invoke(this.lines, 'destroy'); DrawLoader.releaseDrawAPI(this.drawAPI); }; diff --git a/src/plugins/plot/src/telemetry/StackedPlotController.js b/src/plugins/plot/src/telemetry/StackedPlotController.js index 2ae348ef7a..f2be95448a 100644 --- a/src/plugins/plot/src/telemetry/StackedPlotController.js +++ b/src/plugins/plot/src/telemetry/StackedPlotController.js @@ -76,7 +76,7 @@ define([ if (childObj) { var index = telemetryObjects.indexOf(childObj); telemetryObjects.splice(index, 1); - $scope.$broadcast('plot:tickWidth', Math.max(...Object.values(tickWidthMap))); + $scope.$broadcast('plot:tickWidth', _.max(tickWidthMap)); } } @@ -131,7 +131,6 @@ define([ } tickWidthMap[plotId] = Math.max(width, tickWidthMap[plotId]); var newTickWidth = _.max(tickWidthMap); - if (newTickWidth !== tickWidth || width !== tickWidth) { tickWidth = newTickWidth; $scope.$broadcast('plot:tickWidth', tickWidth); diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js index ceb03f26c6..7ae94d3e42 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js @@ -154,7 +154,7 @@ define([ return _(this.baseState) .values() .map(_.clone) - .keyBy('id') + .indexBy('id') .value(); }.bind(this)); }; diff --git a/src/plugins/telemetryTable/TelemetryTableConfiguration.js b/src/plugins/telemetryTable/TelemetryTableConfiguration.js index a423b51910..5946779c4d 100644 --- a/src/plugins/telemetryTable/TelemetryTableConfiguration.js +++ b/src/plugins/telemetryTable/TelemetryTableConfiguration.js @@ -100,7 +100,7 @@ define([ hasColumnWithKey(columnKey) { return _.flatten(Object.values(this.columns)) - .some(column => column.getKey() === columnKey); + .findIndex(column => column.getKey() === columnKey) !== -1; } getColumns() { diff --git a/src/plugins/telemetryTable/collections/SortedTableRowCollection.js b/src/plugins/telemetryTable/collections/SortedTableRowCollection.js index 3cf99c20b5..043ac29032 100644 --- a/src/plugins/telemetryTable/collections/SortedTableRowCollection.js +++ b/src/plugins/telemetryTable/collections/SortedTableRowCollection.js @@ -93,7 +93,7 @@ define( // same time stamp let potentialDupes = this.rows.slice(startIx, endIx + 1); // Search potential dupes for exact dupe - isDuplicate = potentialDupes.some(_.isEqual.bind(undefined, row)); + isDuplicate = _.findIndex(potentialDupes, _.isEqual.bind(undefined, row)) > -1; } if (!isDuplicate) { @@ -201,7 +201,7 @@ define( sortBy(sortOptions) { if (arguments.length > 0) { this.sortOptions = sortOptions; - this.rows = _.orderBy(this.rows, (row) => row.getParsedValue(sortOptions.key) , sortOptions.direction); + this.rows = _.sortByOrder(this.rows, (row) => row.getParsedValue(sortOptions.key) , sortOptions.direction); this.emit('sort'); } // Return duplicate to avoid direct modification of underlying object