Compare commits

...

8 Commits

24 changed files with 62 additions and 54 deletions

View File

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

View File

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

View File

@ -24,6 +24,7 @@
"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 +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",

View File

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

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.
*****************************************************************************/
import _ from 'lodash';
import eq from 'lodash/eq';
const INSIDE_EDIT_PATH_BLACKLIST = ["copy", "follow", "link", "locate", "move", "link"];
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?
*/
function isInsideEditPath() {
return objectPath.some((object) => _.eq(object.identifier, navigatedObject.identifier));
return objectPath.some((object) => eq(object.identifier, navigatedObject.identifier));
}
if (isEditing) {

View File

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

View File

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

View File

@ -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);
};
/**

View File

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

View File

@ -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)));
@ -253,7 +251,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;
},
@ -270,7 +268,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;

View File

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

View File

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

View File

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

View File

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

View File

@ -76,7 +76,7 @@ define([
if (childObj) {
var index = telemetryObjects.indexOf(childObj);
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)
.values()
.map(_.clone)
.indexBy('id')
.keyBy('id')
.value();
}.bind(this));
};

View File

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

View File

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

View File

@ -93,7 +93,7 @@ define(
// same time stamp
let potentialDupes = this.rows.slice(startIx, endIx + 1);
// Search potential dupes for exact dupe
isDuplicate = _.findIndex(potentialDupes, _.isEqual.bind(undefined, row)) > -1;
isDuplicate = potentialDupes.some(_.isEqual.bind(undefined, row));
}
if (!isDuplicate) {
@ -201,7 +201,7 @@ define(
sortBy(sortOptions) {
if (arguments.length > 0) {
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');
}
// 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 TelemetryFilterIndicator from './TelemetryFilterIndicator.vue';
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';
const VISIBLE_ROW_COUNT = 100;
@ -378,13 +379,13 @@ export default {
}
},
created() {
this.filterChanged = _.debounce(this.filterChanged, 500);
this.filterChanged = debounce(this.filterChanged, 500);
},
mounted() {
this.csvExporter = new CSVExporter();
this.rowsAdded = _.throttle(this.rowsAdded, 200);
this.rowsRemoved = _.throttle(this.rowsRemoved, 200);
this.scroll = _.throttle(this.scroll, 100);
this.rowsAdded = throttle(this.rowsAdded, 200);
this.rowsRemoved = throttle(this.rowsRemoved, 200);
this.scroll = throttle(this.scroll, 100);
this.table.on('object-added', this.addObject);
this.table.on('object-removed', this.removeObject);

View File

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

View File

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

View File

@ -47,14 +47,13 @@ import Location from './Location.vue';
import Properties from './Properties.vue';
import ObjectName from './ObjectName.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 {
inject: ['openmct'],
components: {
StylesInspectorView,
// StylesInspectorView,
multipane,
pane,
Elements,
@ -120,7 +119,7 @@ export default {
this.currentTabbedView = 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 toolbarSeparator from './components/toolbar-separator.vue';
import toolbarToggleButton from './components/toolbar-toggle-button.vue';
import _ from 'lodash';
import isEqual from 'lodash/isEqual';
import get from 'lodash/get';
export default {
inject: ['openmct'],
@ -161,7 +161,7 @@ export default {
property = property + "." + formKey;
}
return _.get(domainObject, property);
return get(domainObject, property);
},
getFormValue(domainObject, toolbarItem) {
let value = {};
@ -209,7 +209,7 @@ export default {
if (toolbarItem.domainObject) {
let id = this.openmct.objects.makeKeyString(toolbarItem.domainObject.identifier);
if (changedItemId === id && _.isEqual(toolbarItem, item)) {
if (changedItemId === id && isEqual(toolbarItem, item)) {
toolbarItem.value = value;
}
}