From 8bc8ae2053d686c726ce06a6b3465e1305514b6c Mon Sep 17 00:00:00 2001 From: "Devin W. Hurley" Date: Fri, 13 Sep 2019 09:15:42 -0400 Subject: [PATCH] [SIEM] Enable eslint rule for duplicate import statements (#45552) * enable eslint rule for duplicate import statements * updates lint warn to an error --- .eslintrc.js | 3 +-- .../siem/public/components/charts/barchart.tsx | 12 ++++++++++-- .../public/components/embeddables/embedded_map.tsx | 3 +-- .../components/fields_browser/category_columns.tsx | 3 +-- .../public/components/fields_browser/field_name.tsx | 3 +-- .../siem/public/components/netflow/index.test.tsx | 3 +-- .../siem/public/components/open_timeline/index.tsx | 6 ++---- .../public/components/page/hosts/kpi_hosts/index.tsx | 4 +--- .../components/page/network/kpi_network/index.tsx | 4 +--- .../components/source_destination/geo_fields.tsx | 3 +-- .../components/source_destination/index.test.tsx | 3 +-- .../body/renderers/auditd/generic_details.tsx | 3 +-- .../body/renderers/auditd/generic_file_details.tsx | 4 +--- .../components/timeline/search_or_filter/index.tsx | 3 +-- .../public/components/timeline/timeline.test.tsx | 3 +-- .../server/lib/hosts/elasticsearch_adapter.test.ts | 2 +- 16 files changed, 26 insertions(+), 36 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 63f30b427e16..bd5d31596669 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -537,8 +537,7 @@ module.exports = { 'no-continue': 'error', 'no-dupe-keys': 'error', 'no-duplicate-case': 'error', - // This will be turned on after bug fixes are mostly completed - // 'no-duplicate-imports': 'warn', + 'no-duplicate-imports': 'error', 'no-empty-character-class': 'error', 'no-empty-pattern': 'error', 'no-ex-assign': 'error', diff --git a/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx b/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx index 547699d49fb0..b90ff6d7a6cc 100644 --- a/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx +++ b/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx @@ -6,8 +6,16 @@ import React from 'react'; -import { Chart, BarSeries, Axis, Position, getSpecId, ScaleType, Settings } from '@elastic/charts'; -import { getAxisId } from '@elastic/charts'; +import { + Chart, + BarSeries, + Axis, + Position, + getAxisId, + getSpecId, + ScaleType, + Settings, +} from '@elastic/charts'; import { getOr, get } from 'lodash/fp'; import { ChartConfigsData, diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx index 62a1bb15c90e..dafaaad01cdb 100644 --- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx +++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx @@ -5,8 +5,7 @@ */ import { EuiFlexGroup, EuiSpacer } from '@elastic/eui'; -import * as React from 'react'; -import { useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { npStart } from 'ui/new_platform'; import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/category_columns.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/category_columns.tsx index 381a95875f02..8fab6ec14688 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/category_columns.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/category_columns.tsx @@ -13,10 +13,9 @@ import { EuiText, EuiToolTip, } from '@elastic/eui'; -import * as React from 'react'; +import React, { useContext } from 'react'; import styled from 'styled-components'; -import { useContext } from 'react'; import { BrowserFields } from '../../containers/source'; import { getColumnsWithTimestamp } from '../event_details/helpers'; import { OnUpdateColumns } from '../timeline/events'; diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx index 3bb9e24a36c0..a998c057661e 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx @@ -15,10 +15,9 @@ import { EuiText, EuiToolTip, } from '@elastic/eui'; -import * as React from 'react'; +import React, { useContext } from 'react'; import styled, { css } from 'styled-components'; -import { useContext } from 'react'; import { WithCopyToClipboard } from '../../lib/clipboard/with_copy_to_clipboard'; import { ColumnHeader } from '../timeline/body/column_headers/column_header'; import { OnUpdateColumns } from '../timeline/events'; diff --git a/x-pack/legacy/plugins/siem/public/components/netflow/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/netflow/index.test.tsx index c2635db6d702..f6827e3516c6 100644 --- a/x-pack/legacy/plugins/siem/public/components/netflow/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/netflow/index.test.tsx @@ -18,8 +18,7 @@ import { } from '../certificate_fingerprint'; import { EVENT_DURATION_FIELD_NAME } from '../duration'; import { ID_FIELD_NAME } from '../event_details/event_id'; -import { DESTINATION_IP_FIELD_NAME } from '../ip'; -import { SOURCE_IP_FIELD_NAME } from '../ip'; +import { DESTINATION_IP_FIELD_NAME, SOURCE_IP_FIELD_NAME } from '../ip'; import { JA3_HASH_FIELD_NAME } from '../ja3_fingerprint'; import { DESTINATION_PORT_FIELD_NAME, SOURCE_PORT_FIELD_NAME } from '../port'; import { diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/index.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/index.tsx index 248d1bfd563c..c1954da03c36 100644 --- a/x-pack/legacy/plugins/siem/public/components/open_timeline/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/index.tsx @@ -11,10 +11,10 @@ import { connect } from 'react-redux'; import { Dispatch } from 'redux'; import { defaultHeaders } from '../../components/timeline/body/column_headers/default_headers'; import { deleteTimelineMutation } from '../../containers/timeline/delete/persist.gql_query'; -import { AllTimelinesVariables } from '../../containers/timeline/all'; +import { AllTimelinesVariables, AllTimelinesQuery } from '../../containers/timeline/all'; import { allTimelinesQuery } from '../../containers/timeline/all/index.gql_query'; -import { DeleteTimelineMutation, SortFieldTimeline } from '../../graphql/types'; +import { DeleteTimelineMutation, SortFieldTimeline, Direction } from '../../graphql/types'; import { State, timelineSelectors } from '../../store'; import { createTimeline as dispatchCreateNewTimeline, @@ -40,8 +40,6 @@ import { OpenTimelineDispatchProps, OpenTimelineReduxProps, } from './types'; -import { AllTimelinesQuery } from '../../containers/timeline/all'; -import { Direction } from '../../graphql/types'; import { DEFAULT_SORT_FIELD, DEFAULT_SORT_DIRECTION } from './constants'; export interface OpenTimelineState { diff --git a/x-pack/legacy/plugins/siem/public/components/page/hosts/kpi_hosts/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/hosts/kpi_hosts/index.tsx index 592ca4429130..99b0c266bd78 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/hosts/kpi_hosts/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/hosts/kpi_hosts/index.tsx @@ -4,10 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiFlexGroup } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner } from '@elastic/eui'; import React from 'react'; -import { EuiLoadingSpinner } from '@elastic/eui'; -import { EuiFlexItem } from '@elastic/eui'; import styled from 'styled-components'; import { KpiHostsData, KpiHostDetailsData } from '../../../../graphql/types'; import { StatItemsComponent, StatItemsProps, useKpiMatrixStatus } from '../../../stat_items'; diff --git a/x-pack/legacy/plugins/siem/public/components/page/network/kpi_network/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/network/kpi_network/index.tsx index 0cab1640c0f5..898990c4497f 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/network/kpi_network/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/network/kpi_network/index.tsx @@ -4,12 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiFlexGroup } from '@elastic/eui'; import React from 'react'; -import { EuiFlexItem, EuiLoadingSpinner } from '@elastic/eui'; +import { EuiFlexItem, EuiLoadingSpinner, EuiFlexGroup, EuiSpacer } from '@elastic/eui'; import styled from 'styled-components'; -import { EuiSpacer } from '@elastic/eui'; import { chunk as _chunk } from 'lodash/fp'; import { StatItemsComponent, diff --git a/x-pack/legacy/plugins/siem/public/components/source_destination/geo_fields.tsx b/x-pack/legacy/plugins/siem/public/components/source_destination/geo_fields.tsx index 1a7184b4dc9a..9f28ea98e3cb 100644 --- a/x-pack/legacy/plugins/siem/public/components/source_destination/geo_fields.tsx +++ b/x-pack/legacy/plugins/siem/public/components/source_destination/geo_fields.tsx @@ -5,8 +5,7 @@ */ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { get } from 'lodash/fp'; -import { uniq } from 'lodash/fp'; +import { get, uniq } from 'lodash/fp'; import * as React from 'react'; import { pure } from 'recompose'; import styled from 'styled-components'; diff --git a/x-pack/legacy/plugins/siem/public/components/source_destination/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/source_destination/index.test.tsx index 48daee4182f3..edce246aa61b 100644 --- a/x-pack/legacy/plugins/siem/public/components/source_destination/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/source_destination/index.test.tsx @@ -14,8 +14,7 @@ import { asArrayIfExists } from '../../lib/helpers'; import { getMockNetflowData } from '../../mock'; import { TestProviders } from '../../mock/test_providers'; import { ID_FIELD_NAME } from '../event_details/event_id'; -import { DESTINATION_IP_FIELD_NAME } from '../ip'; -import { SOURCE_IP_FIELD_NAME } from '../ip'; +import { DESTINATION_IP_FIELD_NAME, SOURCE_IP_FIELD_NAME } from '../ip'; import { DESTINATION_PORT_FIELD_NAME, SOURCE_PORT_FIELD_NAME } from '../port'; import { DESTINATION_BYTES_FIELD_NAME, diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_details.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_details.tsx index 580fcae8830c..f6fa3ea63de0 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_details.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_details.tsx @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiFlexGroup } from '@elastic/eui'; -import { EuiSpacer } from '@elastic/eui'; +import { EuiFlexGroup, EuiSpacer } from '@elastic/eui'; import { get } from 'lodash/fp'; import * as React from 'react'; import { pure } from 'recompose'; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_file_details.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_file_details.tsx index 3eaf5240ca1f..318a3abe9c00 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_file_details.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_file_details.tsx @@ -4,9 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiFlexGroup } from '@elastic/eui'; -import { EuiSpacer } from '@elastic/eui'; -import { IconType } from '@elastic/eui'; +import { EuiFlexGroup, EuiSpacer, IconType } from '@elastic/eui'; import { get } from 'lodash/fp'; import * as React from 'react'; import { pure } from 'recompose'; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx index d9287e5a7553..9213ff79ccc5 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx @@ -11,8 +11,7 @@ import { ActionCreator } from 'typescript-fsa'; import { StaticIndexPattern } from 'ui/index_patterns'; import { convertKueryToElasticSearchQuery } from '../../../lib/keury'; -import { KueryFilterQuery, SerializedFilterQuery, timelineSelectors } from '../../../store'; -import { State } from '../../../store'; +import { KueryFilterQuery, SerializedFilterQuery, State, timelineSelectors } from '../../../store'; import { SearchOrFilter } from './search_or_filter'; import { timelineActions } from '../../../store/actions'; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/timeline.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/timeline.test.tsx index c760ab7ab418..2617f9a957dd 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/timeline.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/timeline.test.tsx @@ -12,8 +12,7 @@ import { MockedProvider } from 'react-apollo/test-utils'; import { timelineQuery } from '../../containers/timeline/index.gql_query'; import { mockBrowserFields } from '../../containers/source/mock'; import { Direction } from '../../graphql/types'; -import { defaultHeaders, mockTimelineData } from '../../mock'; -import { mockIndexPattern } from '../../mock'; +import { defaultHeaders, mockTimelineData, mockIndexPattern } from '../../mock'; import { TestProviders } from '../../mock/test_providers'; import { flyoutHeaderHeight } from '../flyout'; diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/elasticsearch_adapter.test.ts b/x-pack/legacy/plugins/siem/server/lib/hosts/elasticsearch_adapter.test.ts index 98b07f600064..979f3a832919 100644 --- a/x-pack/legacy/plugins/siem/server/lib/hosts/elasticsearch_adapter.test.ts +++ b/x-pack/legacy/plugins/siem/server/lib/hosts/elasticsearch_adapter.test.ts @@ -23,9 +23,9 @@ import { mockGetHostLastFirstSeenResponse, mockGetHostOverviewRequestDsl, mockGetHostLastFirstSeenDsl, + mockGetHostsQueryDsl, } from './mock'; import { HostAggEsItem } from './types'; -import { mockGetHostsQueryDsl } from './mock'; jest.mock('./query.hosts.dsl', () => { return {