Adding comment about importing lodash library (#78156)

* added comment about importing lodash library

* fixed space with prefer

* cleaned up extra space and removed comments for lodash/fp

* took out the comment in server files

* Remove newlines

Co-authored-by: Nathan L Smith <smith@nlsmith.com>
This commit is contained in:
Brittany Joiner 2020-09-24 11:38:11 -05:00 committed by GitHub
parent 83c44dbb0d
commit 63ce752dc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 179 additions and 0 deletions

View file

@ -1229,5 +1229,20 @@ 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',
{
patterns: ['lodash/*', '!lodash/fp'],
},
],
},
},
],
};

View file

@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isPlainObject from 'lodash/isPlainObject';
/**
* Deeply merges two objects, omitting undefined values, and not deeply merging Arrays.

View file

@ -6,6 +6,8 @@
import cytoscape from 'cytoscape';
import dagre from 'cytoscape-dagre';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isEqual from 'lodash/isEqual';
import React, {
createContext,

View file

@ -5,6 +5,8 @@
*/
import cytoscape from 'cytoscape';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import debounce from 'lodash/debounce';
import { useEffect } from 'react';
import { EuiTheme, useUiTracker } from '../../../../../observability/public';

View file

@ -6,6 +6,8 @@
import React from 'react';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import _camelCase from 'lodash/camelCase';
import { images } from '../assets';

View file

@ -7,6 +7,8 @@
import React from 'react';
import classNames from 'classnames';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import _kebabCase from 'lodash/kebabCase';
import { Link } from 'react-router-dom';

View file

@ -5,6 +5,8 @@
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isEmpty from 'lodash/isEmpty';
import './brace_imports';

View file

@ -3,6 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* 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 { serializePolicy } from './policy_serialization';
import {

View file

@ -4,6 +4,8 @@
* 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 {

View file

@ -5,6 +5,8 @@
*/
import { i18n } from '@kbn/i18n';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import flowRight from 'lodash/flowRight';
import React from 'react';
import { Redirect, RouteComponentProps } from 'react-router-dom';

View file

@ -4,6 +4,8 @@
* 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 isDate from 'lodash/isDate';
import type { HttpSetup, HttpStart } from 'src/core/public';
import { LicenseType } from '../../common/types';

View file

@ -4,9 +4,17 @@
* 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 semver from 'semver';

View file

@ -10,6 +10,8 @@
* 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 PropTypes from 'prop-types';

View file

@ -9,6 +9,8 @@
*/
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 React, { Component } from 'react';

View file

@ -7,6 +7,8 @@
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 { i18n } from '@kbn/i18n';

View file

@ -11,7 +11,11 @@
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 { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

View file

@ -4,6 +4,8 @@
* 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 PropTypes from 'prop-types';
import React, { Component } from 'react';

View file

@ -4,6 +4,8 @@
* 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 moment from 'moment';
import rison from 'rison-node';

View file

@ -6,7 +6,11 @@
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';
const PAGE_SIZE = 10;

View file

@ -5,6 +5,8 @@
*/
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 { FormattedMessage } from '@kbn/i18n/react';
import React, { ChangeEvent, Component, Fragment } from 'react';

View file

@ -11,11 +11,23 @@
* 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 { buildConfig } from './explorer_chart_config_builder';

View file

@ -4,6 +4,8 @@
* 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 mockAnomalyChartRecords from './__mocks__/mock_anomaly_chart_records.json';

View file

@ -10,8 +10,14 @@
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 d3 from 'd3';
import moment from 'moment';

View file

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

View file

@ -6,8 +6,14 @@
// Service for carrying out requests to run ML forecasts and to obtain
// data on forecasts that have been performed.
// 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 find from 'lodash/find';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import each from 'lodash/each';
import { map } from 'rxjs/operators';

View file

@ -4,10 +4,20 @@
* 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';
// 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 get from 'lodash/get';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isNumber from 'lodash/isNumber';
import moment from 'moment';
import { i18n } from '@kbn/i18n';

View file

@ -4,6 +4,8 @@
* 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 { ml } from './ml_api_service';

View file

@ -13,7 +13,11 @@
// Returned response contains a results property containing the requested aggregation.
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
// 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 get from 'lodash/get';
import { Dictionary } from '../../../../common/types/common';
import { ML_MEDIAN_PERCENTS } from '../../../../common/util/job_utils';

View file

@ -4,7 +4,11 @@
* 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';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import get from 'lodash/get';
import { ML_MEDIAN_PERCENTS } from '../../../../common/util/job_utils';

View file

@ -9,6 +9,8 @@
*/
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 React, { Component } from 'react';

View file

@ -12,9 +12,17 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import useObservable from 'react-use/lib/useObservable';
// 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 reduce from 'lodash/reduce';
// 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 get from 'lodash/get';
import d3 from 'd3';
import moment from 'moment';

View file

@ -4,9 +4,17 @@
* 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';
// 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 get from 'lodash/get';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import filter from 'lodash/filter';
import { Observable } from 'rxjs';

View file

@ -10,8 +10,14 @@
* Viewer dashboard.
*/
// 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 get from 'lodash/get';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import find from 'lodash/find';
import moment from 'moment-timezone';

View file

@ -9,6 +9,8 @@
* in the source metric data.
*/
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import get from 'lodash/get';
import { mlFunctionToESAggregation } from '../../../common/util/job_utils';

View file

@ -4,10 +4,20 @@
* 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 isPlainObject from 'lodash/isPlainObject';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isString from 'lodash/isString';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import ary from 'lodash/ary';
// 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 assign from 'lodash/assign';
import moment from 'moment';
import dateMath from '@elastic/datemath';

View file

@ -4,6 +4,8 @@
* 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';
import {
AnomalyDetectionQueryState,

View file

@ -4,6 +4,8 @@
* 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';
import { MlGenericUrlState } from '../../common/types/ml_url_generator';
import { setStateToKbnUrl } from '../../../../../src/plugins/kibana_utils/public';

View file

@ -5,6 +5,8 @@
*/
import deepEqual from 'fast-deep-equal';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isEqual from 'lodash/isEqual';
import { useEffect, useMemo } from 'react';
import { useDispatch, useSelector } from 'react-redux';

View file

@ -4,6 +4,8 @@
* 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';
import { reducerWithInitialState } from 'typescript-fsa-reducers';

View file

@ -7,6 +7,8 @@
import { EuiButtonEmpty, EuiFormRow } from '@elastic/eui';
import React, { FC, memo, useCallback, useState, useEffect } from 'react';
import styled from 'styled-components';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isEqual from 'lodash/isEqual';
import { DEFAULT_INDEX_KEY } from '../../../../../common/constants';

View file

@ -6,6 +6,8 @@
import { fold } from 'fp-ts/lib/Either';
import { identity } from 'fp-ts/lib/function';
import { pipe } from 'fp-ts/lib/pipeable';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import isEmpty from 'lodash/isEmpty';
import { throwErrors } from '../../../../case/common/api';

View file

@ -4,6 +4,8 @@
* 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 isEqual from 'lodash/isEqual';
import React, { memo, FC } from 'react';

View file

@ -18,6 +18,8 @@ import {
EuiSelectOption,
} from '@elastic/eui';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import cloneDeep from 'lodash/cloneDeep';
import { useUpdateEffect } from 'react-use';
import { AggName } from '../../../../../../common/types/aggregations';

View file

@ -4,6 +4,8 @@
* 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 isEqual from 'lodash/isEqual';
import { Dictionary } from '../../../../../../../common/types/common';

View file

@ -7,6 +7,8 @@
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { EuiComboBox, EuiFormRow } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import debounce from 'lodash/debounce';
import { useUpdateEffect } from 'react-use';
import { i18n } from '@kbn/i18n';

View file

@ -4,7 +4,11 @@
* 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 isEqual from 'lodash/isEqual';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import merge from 'lodash/merge';
import { useReducer } from 'react';

View file

@ -6,7 +6,11 @@
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';
const PAGE_SIZE = 10;

View file

@ -7,6 +7,8 @@
import React, { useEffect, useState, useMemo } from 'react';
import { ToastsStart } from 'kibana/public';
import useMountedState from 'react-use/lib/useMountedState';
// Prefer importing entire lodash library, e.g. import { get } from "lodash"
// eslint-disable-next-line no-restricted-imports
import intersection from 'lodash/intersection';
import { DrilldownWizardConfig, FlyoutDrilldownWizard } from '../flyout_drilldown_wizard';
import { FlyoutListManageDrilldowns } from '../flyout_list_manage_drilldowns';

View file

@ -4,6 +4,8 @@
* 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 partition from 'lodash/partition';
import { getFlattenedObject } from '@kbn/std';
import { UrlDrilldownGlobalScope, UrlDrilldownScope } from './types';