Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing lodash #74539

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1295,5 +1295,46 @@ module.exports = {
'@typescript-eslint/prefer-ts-expect-error': 'error',
},
},
{
files: [
'**/public/**/*.{js,mjs,ts,tsx}',
'**/common/**/*.{js,mjs,ts,tsx}',
'packages/**/*.{js,mjs,ts,tsx}',
],
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'lodash',
message: 'Please import specific method as a file instead, e.g. "lodash/get"',
},
],
},
],
},
},
{
files: [
'**/public/**/*.{js,mjs,ts,tsx}',
'**/common/**/*.{js,mjs,ts,tsx}',
'packages/**/*.{js,mjs,ts,tsx}',
],
rules: {
'no-restricted-imports': [
'warn',
{
paths: [
{
name: 'lodash',
importNames: ['_'],
message: 'Prefer importing individual modules, e.g. import get from "lodash/get"',
},
],
},
],
},
},
],
};
2 changes: 1 addition & 1 deletion examples/alerting_example/public/alert_types/astros.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
EuiTextColor,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { flatten } from 'lodash';
import flatten from 'lodash/flatten';
import { ALERTING_EXAMPLE_APP_ID, Craft, Operator } from '../../common/constants';
import { SanitizedAlert } from '../../../../x-pack/plugins/alerts/common';
import { PluginSetupContract as AlertingSetup } from '../../../../x-pack/plugins/alerts/public';
Expand Down
2 changes: 1 addition & 1 deletion examples/alerting_example/public/components/view_alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from '@elastic/eui';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { CoreStart } from 'kibana/public';
import { isEmpty } from 'lodash';
import isEmpty from 'lodash/isEmpty';
import {
Alert,
AlertTaskState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
} from '@elastic/eui';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { CoreStart } from 'kibana/public';
import { isEmpty } from 'lodash';
import isEmpty from 'lodash/isEmpty';
import {
Alert,
AlertTaskState,
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
ValidationErrorItem,
ValidationOptions,
} from 'joi';
import { isPlainObject } from 'lodash';
import isPlainObject from 'lodash/isPlainObject';
import { isDuration } from 'moment';
import { Stream } from 'stream';
import { ByteSizeValue, ensureByteSizeValue } from '../byte_size_value';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/lib/__tests__/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { uniq } from 'lodash';
import uniq from 'lodash/uniq';
import sinon from 'sinon';
import expect from '@kbn/expect';
import { ToolingLog } from '@kbn/dev-utils';
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-es-archiver/src/lib/docs/__tests__/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import { Client } from 'elasticsearch';
import sinon from 'sinon';
import Chance from 'chance';
import { times } from 'lodash';

import times from 'lodash/times';
import { Stats } from '../../stats';

const chance = new Chance();
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/lib/indices/delete_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { get } from 'lodash';
import get from 'lodash/get';
import { Client } from 'elasticsearch';
import { ToolingLog } from '@kbn/dev-utils';
import { Stats } from '../stats';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/lib/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { ToolingLog } from '@kbn/dev-utils';
import { cloneDeep } from 'lodash';
import cloneDeep from 'lodash/cloneDeep';

export interface IndexStats {
skipped: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-interpreter/src/common/lib/arg.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

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

export function Arg(config) {
if (config.name === '_') throw Error('Arg names must not be _. Use it in aliases instead.');
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-interpreter/src/common/lib/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
* under the License.
*/

import { mapValues, includes } from 'lodash';
import mapValues from 'lodash/mapValues';
import includes from 'lodash/includes';
import { Arg } from './arg';

export function Fn(config) {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-interpreter/src/common/lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

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

export class Registry {
constructor(prop = 'name') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { cloneDeepWith } from 'lodash';
import cloneDeepWith from 'lodash/cloneDeepWith';
import { resolve, sep as pathSep } from 'path';

const repoRoot = resolve(__dirname, '../../../../');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { cloneDeep } from 'lodash';
import cloneDeep from 'lodash/cloneDeep';
import * as ts from 'typescript';
import { parsedWorkingCollector } from './__fixture__/parsed_working_collector';
import { checkCompatibleTypeDescriptor, checkMatchingMapping } from './check_collector_integrity';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { reduce } from 'lodash';
import reduce from 'lodash/reduce';
import { difference, flattenKeys, pickDeep } from './utils';
import { ParsedUsageCollection } from './ts_parser';
import { generateMapping, compatibleSchemaTypes } from './manage_schema';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-telemetry-tools/src/tools/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import * as ts from 'typescript';
import { uniq } from 'lodash';
import uniq from 'lodash/uniq';
import {
getResolvedModuleSourceFile,
getIdentifierDeclarationFromSource,
Expand Down
10 changes: 9 additions & 1 deletion packages/kbn-telemetry-tools/src/tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@
*/

import * as ts from 'typescript';
import { pick, isObject, each, isArray, reduce, isEmpty, merge, transform, isEqual } from 'lodash';
import pick from 'lodash/pick';
import isObject from 'lodash/isObject';
import each from 'lodash/each';
import isArray from 'lodash/isArray';
import reduce from 'lodash/reduce';
import isEmpty from 'lodash/isEmpty';
import merge from 'lodash/merge';
import transform from 'lodash/transform';
import isEqual from 'lodash/isEqual';
import * as path from 'path';
import glob from 'glob';
import { readFile, writeFile } from 'fs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
*/

import { Schema } from 'joi';
import { cloneDeepWith, get, has, toPath } from 'lodash';

import cloneDeepWith from 'lodash/cloneDeepWith';
import get from 'lodash/get';
import has from 'lodash/has';
import toPath from 'lodash/toPath';
import { schema } from './schema';

const $values = Symbol('values');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/

import { ToolingLog } from '@kbn/dev-utils';
import { defaultsDeep } from 'lodash';

import defaultsDeep from 'lodash/defaultsDeep';
import { Config } from './config';
import { transformDeprecations } from './transform_deprecations';

Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-test/src/legacy_es/legacy_es_test_cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

import { resolve } from 'path';
import { format } from 'url';
import { get, toPath } from 'lodash';
import get from 'lodash/get';
import toPath from 'lodash/toPath';
import { Cluster } from '@kbn/es';
import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix';
import { esTestConfig } from './es_test_config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import React from 'react';
import PropTypes from 'prop-types';

import _ from 'lodash';

import { KuiListingTableToolBar } from './listing_table_tool_bar';
import { KuiListingTableToolBarFooter } from './listing_table_tool_bar_footer';
import { KuiListingTableRow } from './listing_table_row';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import React from 'react';
import PropTypes from 'prop-types';

import _ from 'lodash';

import { KuiTableRow, KuiTableRowCell, KuiTableRowCheckBoxCell } from '../';

import { LEFT_ALIGNMENT, RIGHT_ALIGNMENT } from '../../../services';
Expand Down
1 change: 0 additions & 1 deletion src/cli/cluster/cluster_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jest.mock('readline', () => ({
const mockConfig: any = {};

import { sample } from 'lodash';

import { ClusterManager, SomeCliArgs } from './cluster_manager';
import { Worker } from './worker';

Expand Down
1 change: 0 additions & 1 deletion src/cli/serve/read_keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import { set } from '@elastic/safer-lodash-set';

import { Keystore } from '../../legacy/server/keystore';
import { getKeystore } from '../../cli_keystore/get_keystore';

Expand Down
1 change: 0 additions & 1 deletion src/cli_keystore/cli_keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import _ from 'lodash';

import { pkg } from '../core/server/utils';
import Command from '../cli/command';
import { Keystore } from '../legacy/server/keystore';
Expand Down
4 changes: 3 additions & 1 deletion src/core/public/chrome/doc_title/doc_title_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* under the License.
*/

import { compact, flattenDeep, isString } from 'lodash';
import compact from 'lodash/compact';
import flattenDeep from 'lodash/flattenDeep';
import isString from 'lodash/isString';

interface StartDeps {
document: { title: string };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { sortBy } from 'lodash';
import sortBy from 'lodash/sortBy';
import { BehaviorSubject, ReplaySubject, Observable } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { MountPoint } from '../../types';
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/nav_links/nav_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { sortBy } from 'lodash';
import sortBy from 'lodash/sortBy';
import { BehaviorSubject, combineLatest, Observable, ReplaySubject } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';

Expand Down
4 changes: 3 additions & 1 deletion src/core/public/chrome/recently_accessed/persisted_log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* under the License.
*/

import { cloneDeep, isEqual, take } from 'lodash';
import cloneDeep from 'lodash/cloneDeep';
import isEqual from 'lodash/isEqual';
import take from 'lodash/take';
import * as Rx from 'rxjs';
import { map } from 'rxjs/operators';

Expand Down
3 changes: 2 additions & 1 deletion src/core/public/chrome/ui/header/collapsible_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import {
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { groupBy, sortBy } from 'lodash';
import groupBy from 'lodash/groupBy';
import sortBy from 'lodash/sortBy';
import React, { Fragment, useRef } from 'react';
import { useObservable } from 'react-use';
import * as Rx from 'rxjs';
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/http/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { omitBy } from 'lodash';
import omitBy from 'lodash/omitBy';
import { format } from 'url';
import { BehaviorSubject } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { get } from 'lodash';
import get from 'lodash/get';
import { DiscoveredPlugin, PluginName } from '../../server';
import {
EnvironmentMode,
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/overlays/banners/priority_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

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

interface PriorityValue {
readonly priority: number;
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/plugins/plugin_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { omit } from 'lodash';
import omit from 'lodash/omit';
import { DiscoveredPlugin } from '../../server';
import { PluginOpaqueId, PackageInfo, EnvironmentMode } from '../../server/types';
import { CoreContext } from '../core_system';
Expand Down
3 changes: 2 additions & 1 deletion src/core/public/plugins/plugins_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
* under the License.
*/

import { omit, pick } from 'lodash';
import omit from 'lodash/omit';
import pick from 'lodash/pick';

import {
MockedPluginInitializer,
Expand Down
4 changes: 3 additions & 1 deletion src/core/public/saved_objects/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* under the License.
*/

import { cloneDeep, pick, throttle } from 'lodash';
import cloneDeep from 'lodash/cloneDeep';
import pick from 'lodash/pick';
import throttle from 'lodash/throttle';
import { resolve as resolveUrl } from 'url';

import {
Expand Down
3 changes: 2 additions & 1 deletion src/core/public/saved_objects/simple_saved_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/

import { set } from '@elastic/safer-lodash-set';
import { get, has } from 'lodash';
import get from 'lodash/get';
import has from 'lodash/has';
import { SavedObject as SavedObjectType } from '../../server';
import { SavedObjectsClientContract } from './saved_objects_client';

Expand Down
Loading