Skip to content

Commit

Permalink
[ML] Improve lodash imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Sep 28, 2020
1 parent 4aab13c commit 9313f87
Show file tree
Hide file tree
Showing 92 changed files with 92 additions and 265 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/common/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import once from 'lodash/once';
import { once } from 'lodash';
import { i18n } from '@kbn/i18n';
import { JOB_ID_MAX_LENGTH, VALIDATION_STATUS } from './validation';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash';
import { Datafeed } from './datafeed';
import { DatafeedStats } from './datafeed_stats';
import { Job } from './job';
Expand Down
13 changes: 1 addition & 12 deletions x-pack/plugins/ml/common/util/job_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isEmpty from 'lodash/isEmpty';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isEqual from 'lodash/isEqual';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import each from 'lodash/each';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import pick from 'lodash/pick';
import { isEmpty, isEqual, each, pick } from 'lodash';

import semver from 'semver';
import moment, { Duration } from 'moment';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { Component, FC, ReactNode, useCallback } from 'react';
import useObservable from 'react-use/lib/useObservable';
import * as Rx from 'rxjs';
import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash';

import {
EuiButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
* getting the annotations via props (used in Anomaly Explorer and Single Series Viewer).
*/

// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import uniq from 'lodash/uniq';
import { uniq } from 'lodash';

import PropTypes from 'prop-types';
import React, { Component, Fragment } from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
*/

import PropTypes from 'prop-types';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import get from 'lodash/get';
import { get } from 'lodash';

import React, { Component } from 'react';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import { EuiButtonIcon, EuiLink, EuiScreenReaderOnly } from '@elastic/eui';

import React from 'react';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import get from 'lodash/get';
import { get } from 'lodash';

import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@

import PropTypes from 'prop-types';
import React, { Component, Fragment } from 'react';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import get from 'lodash/get';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import pick from 'lodash/pick';
import { get, pick } from 'lodash';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import each from 'lodash/each';
import { each } from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash';
import moment from 'moment';
import rison from 'rison-node';
import PropTypes from 'prop-types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { BehaviorSubject, Observable } from 'rxjs';
import isEqual from 'lodash/isEqual';
import { isEqual } from 'lodash';
import { TooltipValue, TooltipValueFormatter } from '@elastic/charts';
import { distinctUntilChanged } from 'rxjs/operators';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import isEqual from 'lodash/isEqual';
import { isEqual } from 'lodash';
import React, { memo, useEffect, FC, useMemo } from 'react';
import { i18n } from '@kbn/i18n';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import difference from 'lodash/difference';
import { difference } from 'lodash';
import { useEffect, useMemo } from 'react';

import { i18n } from '@kbn/i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import React, { Component } from 'react';

import { EuiDescriptionList, EuiLink, EuiPanel } from '@elastic/eui';

import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash';

import { AddToFilterListLink } from './add_to_filter_list_link';
import { DeleteRuleModal } from './delete_rule_modal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
OPERATOR,
} from '../../../../common/constants/detector_rule';

import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash';
import { ml } from '../../services/ml_api_service';
import { mlJobService } from '../../services/job_service';
import { i18n } from '@kbn/i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { useEffect } from 'react';
import { BehaviorSubject, Subscription } from 'rxjs';
import { distinctUntilChanged, filter } from 'rxjs/operators';
import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash';
import { ml } from '../../services/ml_api_service';
import { Dictionary } from '../../../../common/types/common';
import { extractErrorMessage } from '../../../../common/util/errors';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import debounce from 'lodash/debounce';
import { debounce } from 'lodash';

import { newJobCapsService } from '../../../../../services/new_job_capabilities_service';
import { useMlContext } from '../../../../../contexts/ml';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React, { FC, Fragment, useRef, useEffect, useState } from 'react';
import debounce from 'lodash/debounce';
import { debounce } from 'lodash';
import {
EuiFieldText,
EuiFormRow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

import { EuiToolTip } from '@elastic/eui';
import React, { FC } from 'react';
import cloneDeep from 'lodash/cloneDeep';
import isEqual from 'lodash/isEqual';
import { cloneDeep, isEqual } from 'lodash';
import { i18n } from '@kbn/i18n';
import { IIndexPattern } from 'src/plugins/data/common';
import { DeepReadonly } from '../../../../../../../common/types/common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

import { useState } from 'react';
import { Direction, EuiBasicTableProps, EuiTableSortingType } from '@elastic/eui';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import sortBy from 'lodash/sortBy';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import get from 'lodash/get';
import { sortBy, get } from 'lodash';

const PAGE_SIZE = 10;
const PAGE_SIZE_OPTIONS = [10, 25, 50];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import merge from 'lodash/merge';
import { merge } from 'lodash';

import { ANALYSIS_CONFIG_TYPE, DataFrameAnalyticsConfig } from '../../../../common';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import memoize from 'lodash/memoize';
import { memoize } from 'lodash';
// @ts-ignore
import numeral from '@elastic/numeral';
import { isValidIndexName } from '../../../../../../../common/util/es_utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import debounce from 'lodash/debounce';
import { debounce } from 'lodash';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { ChangeEvent, Component, Fragment } from 'react';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash';
import uuid from 'uuid/v4';
import { CombinedField } from './types';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import difference from 'lodash/difference';
import { difference } from 'lodash';

export function getFieldNames(results) {
const { mappings, field_stats: fieldStats, column_names: columnNames } = results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { Component } from 'react';

import { EuiSpacer } from '@elastic/eui';

import isEqual from 'lodash/isEqual';
import { isEqual } from 'lodash';

import { ml } from '../../../../services/ml_api_service';
import { AboutPanel, LoadingPanel } from '../about_panel';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@elastic/eui';

import { i18n } from '@kbn/i18n';
import debounce from 'lodash/debounce';
import { debounce } from 'lodash';
import { importerFactory } from './importer';
import { ResultsLinks } from '../results_links';
import { FilebeatConfigFlyout } from '../filebeat_config_flyout';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import chunk from 'lodash/chunk';
import { chunk } from 'lodash';
import moment from 'moment';
import { i18n } from '@kbn/i18n';
import { ml } from '../../../../../services/ml_api_service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import isEqual from 'lodash/isEqual';
import { isEqual } from 'lodash';
// @ts-ignore
import numeral from '@elastic/numeral';
import { ml } from '../../../../services/ml_api_service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import memoizeOne from 'memoize-one';
import isEqual from 'lodash/isEqual';
import { isEqual } from 'lodash';
import useObservable from 'react-use/lib/useObservable';

import { forkJoin, of, Observable, Subject } from 'rxjs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React, { FC, useCallback, useMemo, useState, useEffect } from 'react';
import debounce from 'lodash/debounce';
import { debounce } from 'lodash';
import {
EuiFormRow,
EuiCheckboxGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React, { FC, useMemo, useState } from 'react';
import isEqual from 'lodash/isEqual';
import { isEqual } from 'lodash';
import {
EuiPanel,
EuiPopover,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,7 @@
* and manages the layout of the charts in the containing div.
*/

// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import get from 'lodash/get';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import each from 'lodash/each';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import find from 'lodash/find';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import sortBy from 'lodash/sortBy';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import map from 'lodash/map';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import reduce from 'lodash/reduce';
import { get, each, find, sortBy, map, reduce } from 'lodash';

import { buildConfig } from './explorer_chart_config_builder';
import { chartLimits, getChartType } from '../../util/chart_utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash';

import mockAnomalyChartRecords from './__mocks__/mock_anomaly_chart_records.json';
import mockDetectorsByJob from './__mocks__/mock_detectors_by_job.json';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* components in the Explorer dashboard.
*/

import isEqual from 'lodash/isEqual';
import { isEqual } from 'lodash';

import { from, isObservable, Observable, Subject } from 'rxjs';
import { distinctUntilChanged, flatMap, map, scan, shareReplay } from 'rxjs/operators';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@

import React from 'react';
import './_explorer.scss';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isEqual from 'lodash/isEqual';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import uniq from 'lodash/uniq';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import get from 'lodash/get';
import { isEqual, uniq, get } from 'lodash';
import d3 from 'd3';
import moment from 'moment';
import DragSelect from 'dragselect';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
* utils for Anomaly Explorer.
*/

import get from 'lodash/get';
import union from 'lodash/union';
import sortBy from 'lodash/sortBy';
import uniq from 'lodash/uniq';
import { get, union, sortBy, uniq } from 'lodash';
import moment from 'moment-timezone';

import {
Expand Down
Loading

0 comments on commit 9313f87

Please sign in to comment.