Compare commits

...

8 Commits

24 changed files with 62 additions and 54 deletions

View File

@ -8,9 +8,11 @@ module.exports = {
"globals": { "globals": {
"_": "readonly" "_": "readonly"
}, },
"plugins": ["lodash"],
"extends": [ "extends": [
"eslint:recommended", "eslint:recommended",
"plugin:vue/recommended" "plugin:vue/recommended",
"plugin:lodash/recommended"
], ],
"parser": "vue-eslint-parser", "parser": "vue-eslint-parser",
"parserOptions": { "parserOptions": {
@ -22,6 +24,14 @@ module.exports = {
} }
}, },
"rules": { "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",
"no-bitwise": "error", "no-bitwise": "error",
"curly": "error", "curly": "error",
"eqeqeq": "error", "eqeqeq": "error",

View File

@ -1,14 +1,14 @@
<template> <template>
<div class="example">{{ msg }}</div> <div class="example">{{ msg }}</div>
</template> </template>
<script> <script>
export default { export default {
data () { data() {
return { return {
msg: 'Hello world!' msg: 'Hello world!'
}
} }
}
} }
</script> </script>

View File

@ -24,6 +24,7 @@
"d3-time": "1.0.x", "d3-time": "1.0.x",
"d3-time-format": "2.1.x", "d3-time-format": "2.1.x",
"eslint": "5.2.0", "eslint": "5.2.0",
"eslint-plugin-lodash": "^6.0.0",
"eslint-plugin-vue": "^6.0.0", "eslint-plugin-vue": "^6.0.0",
"eventemitter3": "^1.2.0", "eventemitter3": "^1.2.0",
"exports-loader": "^0.7.0", "exports-loader": "^0.7.0",
@ -48,7 +49,7 @@
"karma-sourcemap-loader": "^0.3.7", "karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.0", "karma-webpack": "^3.0.0",
"location-bar": "^3.0.1", "location-bar": "^3.0.1",
"lodash": "^3.10.1", "lodash": "^4.17.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",

View File

@ -235,7 +235,7 @@ define(
var defaultRange = metadata.valuesForHints(['range'])[0]; var defaultRange = metadata.valuesForHints(['range'])[0];
defaultRange = defaultRange ? defaultRange.key : undefined; defaultRange = defaultRange ? defaultRange.key : undefined;
var sourceMap = _.indexBy(metadata.values(), 'key'); var sourceMap = _.keyBy(metadata.values(), 'key');
var isLegacyProvider = telemetryAPI.findRequestProvider(domainObject) === var isLegacyProvider = telemetryAPI.findRequestProvider(domainObject) ===
telemetryAPI.legacyProvider; telemetryAPI.legacyProvider;
@ -300,7 +300,7 @@ define(
var defaultRange = metadata.valuesForHints(['range'])[0]; var defaultRange = metadata.valuesForHints(['range'])[0];
defaultRange = defaultRange ? defaultRange.key : undefined; defaultRange = defaultRange ? defaultRange.key : undefined;
var sourceMap = _.indexBy(metadata.values(), 'key'); var sourceMap = _.keyBy(metadata.values(), 'key');
var isLegacyProvider = telemetryAPI.findSubscriptionProvider(domainObject) === var isLegacyProvider = telemetryAPI.findSubscriptionProvider(domainObject) ===
telemetryAPI.legacyProvider; telemetryAPI.legacyProvider;

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.
*****************************************************************************/ *****************************************************************************/
import _ from 'lodash'; import eq from 'lodash/eq';
const INSIDE_EDIT_PATH_BLACKLIST = ["copy", "follow", "link", "locate", "move", "link"]; const INSIDE_EDIT_PATH_BLACKLIST = ["copy", "follow", "link", "locate", "move", "link"];
const OUTSIDE_EDIT_PATH_BLACKLIST = ["copy", "follow", "properties", "move", "link", "remove", "locate"]; const OUTSIDE_EDIT_PATH_BLACKLIST = ["copy", "follow", "properties", "move", "link", "remove", "locate"];
@ -74,7 +74,7 @@ export default class LegacyContextMenuAction {
* Is the object being edited, or a child of the object being edited? * Is the object being edited, or a child of the object being edited?
*/ */
function isInsideEditPath() { function isInsideEditPath() {
return objectPath.some((object) => _.eq(object.identifier, navigatedObject.identifier)); return objectPath.some((object) => eq(object.identifier, navigatedObject.identifier));
} }
if (isEditing) { if (isEditing) {

View File

@ -196,8 +196,8 @@ define([
* @private * @private
*/ */
DefaultCompositionProvider.prototype.includes = function (parent, childId) { DefaultCompositionProvider.prototype.includes = function (parent, childId) {
return parent.composition.findIndex(composee => return parent.composition.some(composee =>
this.publicAPI.objects.areIdsEqual(composee, childId)) !== -1; this.publicAPI.objects.areIdsEqual(composee, childId));
}; };
DefaultCompositionProvider.prototype.reorder = function (domainObject, oldIndex, newIndex) { DefaultCompositionProvider.prototype.reorder = function (domainObject, oldIndex, newIndex) {

View File

@ -85,7 +85,7 @@ define([
value: +e.value value: +e.value
}; };
}), 'e.value'); }), 'e.value');
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value'); valueMetadata.values = _.map(valueMetadata.enumerations, 'value');
valueMetadata.max = _.max(valueMetadata.values); valueMetadata.max = _.max(valueMetadata.values);
valueMetadata.min = _.min(valueMetadata.values); valueMetadata.min = _.min(valueMetadata.values);
} }

View File

@ -370,7 +370,7 @@ define([
TelemetryAPI.prototype.commonValuesForHints = function (metadatas, hints) { TelemetryAPI.prototype.commonValuesForHints = function (metadatas, hints) {
var options = metadatas.map(function (metadata) { var options = metadatas.map(function (metadata) {
var values = metadata.valuesForHints(hints); var values = metadata.valuesForHints(hints);
return _.indexBy(values, 'key'); return _.keyBy(values, 'key');
}).reduce(function (a, b) { }).reduce(function (a, b) {
var results = {}; var results = {};
Object.keys(a).forEach(function (key) { Object.keys(a).forEach(function (key) {
@ -383,7 +383,7 @@ define([
var sortKeys = hints.map(function (h) { var sortKeys = hints.map(function (h) {
return 'hints.' + h; return 'hints.' + h;
}); });
return _.sortByAll(options, sortKeys); return _.sortBy(options, sortKeys);
}; };
/** /**

View File

@ -57,7 +57,7 @@ define([
if (valueMetadata.format === 'enum') { if (valueMetadata.format === 'enum') {
if (!valueMetadata.values) { if (!valueMetadata.values) {
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value'); valueMetadata.values = _.map(valueMetadata.enumerations, 'value');
} }
if (!valueMetadata.hasOwnProperty('max')) { if (!valueMetadata.hasOwnProperty('max')) {
valueMetadata.max = _.max(valueMetadata.values) + 1; valueMetadata.max = _.max(valueMetadata.values) + 1;
@ -121,7 +121,7 @@ define([
return metadata.hints[hint]; return metadata.hints[hint];
} }
}); });
return _.sortByAll(matchingMetadata, ...iteratees); return _.sortBy(matchingMetadata, ...iteratees);
}; };
TelemetryMetadataManager.prototype.getFilterableValues = function () { TelemetryMetadataManager.prototype.getFilterableValues = function () {

View File

@ -20,8 +20,6 @@
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
import _ from 'lodash';
const convertToNumbers = (input) => { const convertToNumbers = (input) => {
let numberInputs = []; let numberInputs = [];
input.forEach(inputValue => numberInputs.push(Number(inputValue))); input.forEach(inputValue => numberInputs.push(Number(inputValue)));
@ -253,7 +251,7 @@ export const OPERATIONS = [
const lhsValue = input[0] !== undefined ? input[0].toString() : ''; const lhsValue = input[0] !== undefined ? input[0].toString() : '';
if (input[1]) { if (input[1]) {
const values = input[1].split(','); const values = input[1].split(',');
return values.find((value) => lhsValue === _.trim(value.toString())); return values.find((value) => lhsValue === value.toString().trim());
} }
return false; return false;
}, },
@ -270,7 +268,7 @@ export const OPERATIONS = [
const lhsValue = input[0] !== undefined ? input[0].toString() : ''; const lhsValue = input[0] !== undefined ? input[0].toString() : '';
if (input[1]) { if (input[1]) {
const values = input[1].split(','); 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 !found;
} }
return false; return false;

View File

@ -59,7 +59,7 @@
</template> </template>
<script> <script>
import _ from 'lodash'; import sortedIndexBy from 'lodash/sortedIndexBy';
export default { export default {
inject: ['openmct', 'domainObject'], inject: ['openmct', 'domainObject'],
@ -219,8 +219,7 @@ export default {
if (this.datumMatchesMostRecent(datum)) { if (this.datumMatchesMostRecent(datum)) {
return; 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); this.imageHistory.splice(index, 0, datum);
}, },
updateValues(datum) { updateValues(datum) {

View File

@ -111,7 +111,7 @@ import SearchResults from './search-results.vue';
import Sidebar from './sidebar.vue'; import Sidebar from './sidebar.vue';
import { clearDefaultNotebook, getDefaultNotebook, setDefaultNotebook, setDefaultNotebookSection, setDefaultNotebookPage } from '../utils/notebook-storage'; import { clearDefaultNotebook, getDefaultNotebook, setDefaultNotebook, setDefaultNotebookSection, setDefaultNotebookPage } from '../utils/notebook-storage';
import { addNotebookEntry, createNewEmbed, getNotebookEntries } from '../utils/notebook-entries'; import { addNotebookEntry, createNewEmbed, getNotebookEntries } from '../utils/notebook-entries';
import { throttle } from 'lodash'; import throttle from 'lodash/throttle';
const DEFAULT_CLASS = 'is-notebook-default'; const DEFAULT_CLASS = 'is-notebook-default';

View File

@ -150,7 +150,7 @@ function (
MCTChartController.prototype.destroy = function () { MCTChartController.prototype.destroy = function () {
this.isDestroyed = true; this.isDestroyed = true;
this.stopListening(); this.stopListening();
_.invoke(this.lines, 'destroy'); _.invokeMap(this.lines, 'destroy');
DrawLoader.releaseDrawAPI(this.drawAPI); DrawLoader.releaseDrawAPI(this.drawAPI);
}; };

View File

@ -55,10 +55,10 @@ define([
}; };
} }
var newRange = {}; var newRange = {};
if (typeof range.min !== 'undefined' && range.min !== null) { if (!_.isNil(range.min)) {
newRange.min = Number(range.min); newRange.min = Number(range.min);
} }
if (typeof range.max !== 'undefined' && range.max !== null) { if (!_.isNil(range.max)) {
newRange.max = Number(range.max); newRange.max = Number(range.max);
} }
return newRange; return newRange;

View File

@ -76,7 +76,7 @@ define([
if (childObj) { if (childObj) {
var index = telemetryObjects.indexOf(childObj); var index = telemetryObjects.indexOf(childObj);
telemetryObjects.splice(index, 1); telemetryObjects.splice(index, 1);
$scope.$broadcast('plot:tickWidth', _.max(tickWidthMap)); $scope.$broadcast('plot:tickWidth', _.max(Object.values(tickWidthMap)));
} }
} }

View File

@ -154,7 +154,7 @@ define([
return _(this.baseState) return _(this.baseState)
.values() .values()
.map(_.clone) .map(_.clone)
.indexBy('id') .keyBy('id')
.value(); .value();
}.bind(this)); }.bind(this));
}; };

View File

@ -57,7 +57,7 @@
<script> <script>
import ObjectView from '../../../ui/components/ObjectView.vue'; import ObjectView from '../../../ui/components/ObjectView.vue';
import _ from 'lodash'; import isEqual from 'lodash/isEqual';
var unknownObjectType = { var unknownObjectType = {
definition: { definition: {
@ -155,7 +155,7 @@ export default {
this.allowDrop = false; this.allowDrop = false;
}, },
isCurrent(tab) { isCurrent(tab) {
return _.isEqual(this.currentTab, tab) return isEqual(this.currentTab, tab)
} }
} }
} }

View File

@ -100,7 +100,7 @@ define([
hasColumnWithKey(columnKey) { hasColumnWithKey(columnKey) {
return _.flatten(Object.values(this.columns)) return _.flatten(Object.values(this.columns))
.findIndex(column => column.getKey() === columnKey) !== -1; .some(column => column.getKey() === columnKey);
} }
getColumns() { getColumns() {

View File

@ -93,7 +93,7 @@ define(
// same time stamp // same time stamp
let potentialDupes = this.rows.slice(startIx, endIx + 1); let potentialDupes = this.rows.slice(startIx, endIx + 1);
// Search potential dupes for exact dupe // Search potential dupes for exact dupe
isDuplicate = _.findIndex(potentialDupes, _.isEqual.bind(undefined, row)) > -1; isDuplicate = potentialDupes.some(_.isEqual.bind(undefined, row));
} }
if (!isDuplicate) { if (!isDuplicate) {
@ -201,7 +201,7 @@ define(
sortBy(sortOptions) { sortBy(sortOptions) {
if (arguments.length > 0) { if (arguments.length > 0) {
this.sortOptions = sortOptions; this.sortOptions = sortOptions;
this.rows = _.sortByOrder(this.rows, (row) => row.getParsedValue(sortOptions.key) , sortOptions.direction); this.rows = _.orderBy(this.rows, (row) => row.getParsedValue(sortOptions.key) , sortOptions.direction);
this.emit('sort'); this.emit('sort');
} }
// Return duplicate to avoid direct modification of underlying object // Return duplicate to avoid direct modification of underlying object

View File

@ -260,7 +260,8 @@ import search from '../../../ui/components/search.vue';
import TableColumnHeader from './table-column-header.vue'; import TableColumnHeader from './table-column-header.vue';
import TelemetryFilterIndicator from './TelemetryFilterIndicator.vue'; import TelemetryFilterIndicator from './TelemetryFilterIndicator.vue';
import CSVExporter from '../../../exporters/CSVExporter.js'; import CSVExporter from '../../../exporters/CSVExporter.js';
import _ from 'lodash'; import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
import ToggleSwitch from '../../../ui/components/ToggleSwitch.vue'; import ToggleSwitch from '../../../ui/components/ToggleSwitch.vue';
const VISIBLE_ROW_COUNT = 100; const VISIBLE_ROW_COUNT = 100;
@ -378,13 +379,13 @@ export default {
} }
}, },
created() { created() {
this.filterChanged = _.debounce(this.filterChanged, 500); this.filterChanged = debounce(this.filterChanged, 500);
}, },
mounted() { mounted() {
this.csvExporter = new CSVExporter(); this.csvExporter = new CSVExporter();
this.rowsAdded = _.throttle(this.rowsAdded, 200); this.rowsAdded = throttle(this.rowsAdded, 200);
this.rowsRemoved = _.throttle(this.rowsRemoved, 200); this.rowsRemoved = throttle(this.rowsRemoved, 200);
this.scroll = _.throttle(this.scroll, 100); this.scroll = throttle(this.scroll, 100);
this.table.on('object-added', this.addObject); this.table.on('object-added', this.addObject);
this.table.on('object-removed', this.removeObject); this.table.on('object-removed', this.removeObject);

View File

@ -3,9 +3,9 @@
</template> </template>
<script> <script>
import _ from "lodash" import debounce from "lodash/debounce"
import StyleRuleManager from "@/plugins/condition/StyleRuleManager"; import StyleRuleManager from "@/plugins/condition/StyleRuleManager";
import {STYLE_CONSTANTS} from "@/plugins/condition/utils/constants"; import { STYLE_CONSTANTS } from "@/plugins/condition/utils/constants";
export default { export default {
inject: ["openmct"], inject: ["openmct"],
@ -48,7 +48,7 @@ export default {
} }
}, },
created() { created() {
this.debounceUpdateView = _.debounce(this.updateView, 10); this.debounceUpdateView = debounce(this.updateView, 10);
}, },
mounted() { mounted() {
this.currentObject = this.object; this.currentObject = this.object;

View File

@ -49,9 +49,9 @@
</template> </template>
<script> <script>
import _ from 'lodash';
import Search from '../components/search.vue'; import Search from '../components/search.vue';
import ObjectLabel from '../components/ObjectLabel.vue'; import ObjectLabel from '../components/ObjectLabel.vue';
import isEqual from 'lodash/isEqual';
export default { export default {
inject: ['openmct'], inject: ['openmct'],
@ -94,7 +94,7 @@ export default {
this.showSelection(this.openmct.selection.get()); this.showSelection(this.openmct.selection.get());
}, },
showSelection(selection) { showSelection(selection) {
if (_.isEqual(this.selection, selection)) { if (isEqual(this.selection, selection)) {
return; return;
} }
this.selection = selection; this.selection = selection;

View File

@ -47,14 +47,13 @@ import Location from './Location.vue';
import Properties from './Properties.vue'; import Properties from './Properties.vue';
import ObjectName from './ObjectName.vue'; import ObjectName from './ObjectName.vue';
import InspectorViews from './InspectorViews.vue'; import InspectorViews from './InspectorViews.vue';
import _ from "lodash"; import StylesInspectorView from './StylesInspectorView.vue';
import StylesInspectorView from "./StylesInspectorView.vue"; import isEqual from 'lodash/isEqual';
export default { export default {
inject: ['openmct'], inject: ['openmct'],
components: { components: {
StylesInspectorView, StylesInspectorView,
// StylesInspectorView,
multipane, multipane,
pane, pane,
Elements, Elements,
@ -120,7 +119,7 @@ export default {
this.currentTabbedView = view; this.currentTabbedView = view;
}, },
isCurrent(view) { isCurrent(view) {
return _.isEqual(this.currentTabbedView, view) return isEqual(this.currentTabbedView, view)
} }
} }
} }

View File

@ -20,8 +20,8 @@ import toolbarMenu from './components/toolbar-menu.vue';
import toolbarSelectMenu from './components/toolbar-select-menu.vue'; import toolbarSelectMenu from './components/toolbar-select-menu.vue';
import toolbarSeparator from './components/toolbar-separator.vue'; import toolbarSeparator from './components/toolbar-separator.vue';
import toolbarToggleButton from './components/toolbar-toggle-button.vue'; import toolbarToggleButton from './components/toolbar-toggle-button.vue';
import isEqual from 'lodash/isEqual';
import _ from 'lodash'; import get from 'lodash/get';
export default { export default {
inject: ['openmct'], inject: ['openmct'],
@ -161,7 +161,7 @@ export default {
property = property + "." + formKey; property = property + "." + formKey;
} }
return _.get(domainObject, property); return get(domainObject, property);
}, },
getFormValue(domainObject, toolbarItem) { getFormValue(domainObject, toolbarItem) {
let value = {}; let value = {};
@ -209,7 +209,7 @@ export default {
if (toolbarItem.domainObject) { if (toolbarItem.domainObject) {
let id = this.openmct.objects.makeKeyString(toolbarItem.domainObject.identifier); let id = this.openmct.objects.makeKeyString(toolbarItem.domainObject.identifier);
if (changedItemId === id && _.isEqual(toolbarItem, item)) { if (changedItemId === id && isEqual(toolbarItem, item)) {
toolbarItem.value = value; toolbarItem.value = value;
} }
} }