Skip to content

Commit

Permalink
[Security Solutions] Removes tech debt of exporting all from linter r…
Browse files Browse the repository at this point in the history
…ule for security_solution plugin (#120188) (#120270)

## Summary

See: #110903

This removes the top level API `export *` spots from:
* `security_solution` plugin

by removing _all_ the exports from `security_solution/common/index.ts` since non of those were shared outside this plugin. Look at the metrics from the build below and you will see _huge_ drops off numbers across the board for required API documentation to the page load size.

In the file `security_solution/common/index.ts` I now put the advice of:

 ```
// Careful of exporting anything from this file as any file(s) you export here will cause your page bundle size to increase.
// If you're using functions/types/etc... internally it's best to import directly from their paths than expose the functions/types/etc... here.
// You should _only_ expose functions/types/etc... that need to be shared with other plugins here.
```

But really I doubt we will have to share anything from `security_solutions` plugin to another plugin or expose it for anyone else. So I think this is 👍 the way forward to not expose anything directly from `security_solution/common/index.ts` anymore.
  • Loading branch information
FrankHassanabad authored Dec 2, 2021
1 parent ba7f9b9 commit 3a289aa
Show file tree
Hide file tree
Showing 90 changed files with 126 additions and 108 deletions.
4 changes: 4 additions & 0 deletions x-pack/plugins/lists/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// Careful of exporting anything from this file as any file(s) you export here will cause your page bundle size to increase.
// If you're using functions/types/etc... internally it's best to import directly from their paths than expose the functions/types/etc... here.
// You should _only_ expose functions/types/etc... that need to be shared with other plugins here.
9 changes: 3 additions & 6 deletions x-pack/plugins/security_solution/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
* 2.0.
*/

// TODO: https://github.com/elastic/kibana/issues/110904
/* eslint-disable @kbn/eslint/no_export_all */

export * from './types';
export * from './search_strategy';
export * from './utility_types';
// Careful of exporting anything from this file as any file(s) you export here will cause your page bundle size to increase.
// If you're using functions/types/etc... internally it's best to import directly from their paths than expose the functions/types/etc... here.
// You should _only_ expose functions/types/etc... that need to be shared with other plugins here.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { TimelineEventsDetailsItem } from '../../../../common/search_strategy';
import { useRuleWithFallback } from '../../../detections/containers/detection_engine/rules/use_rule_with_fallback';

import { TestProviders, TestProvidersComponent } from '../../mock';
import { TimelineId } from '../../../../common';
import { TimelineId } from '../../../../common/types';
import { mockBrowserFields } from '../../containers/source/mock';

jest.mock('../../lib/kibana');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { AlertSummaryRow, getSummaryColumns, SummaryRow } from './helpers';

import { ActionCell } from './table/action_cell';
import { FieldValueCell } from './table/field_value_cell';
import { TimelineEventsDetailsItem, TimelineId } from '../../../../common';
import { TimelineId } from '../../../../common/types';
import { TimelineEventsDetailsItem } from '../../../../common/search_strategy';

import { getSummaryRows } from './get_alert_summary_rows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { BrowserFields } from '../../containers/source';
import { OnUpdateColumns } from '../../../timelines/components/timeline/events';
import * as i18n from './translations';
import { EventFieldsData } from './types';
import { BrowserField, ColumnHeaderOptions } from '../../../../common';
import { ColumnHeaderOptions } from '../../../../common/types';
import { BrowserField } from '../../../../common/search_strategy';
import { FieldValueCell } from './table/field_value_cell';
import { FieldNameCell } from './table/field_name_cell';
import { ActionCell } from './table/action_cell';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { getEnrichmentIdentifiers, isInvestigationTimeEnrichment } from './helpe

import { FieldsData } from '../types';
import { ActionCell } from '../table/action_cell';
import { BrowserField, BrowserFields, TimelineEventsDetailsItem } from '../../../../../common';
import {
BrowserField,
BrowserFields,
TimelineEventsDetailsItem,
} from '../../../../../common/search_strategy';
import { FormattedFieldValue } from '../../../../timelines/components/timeline/body/renderers/formatted_field';
import { EnrichedDataRow, ThreatSummaryPanelHeader } from './threat_summary_view';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import { CtiEnrichment } from '../../../../../common/search_strategy/security_so

import { FieldsData } from '../types';

import { BrowserField, BrowserFields, TimelineEventsDetailsItem } from '../../../../../common';
import {
BrowserField,
BrowserFields,
TimelineEventsDetailsItem,
} from '../../../../../common/search_strategy';
import { HostRisk } from '../../../../overview/containers/overview_risky_host_links/use_hosts_risk_score';
import { HostRiskSummary } from './host_risk_summary';
import { EnrichmentSummary } from './enrichment_summary';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { FieldsData } from './types';

import * as i18n from './translations';
import { ColumnHeaderOptions } from '../../../../common';
import { ColumnHeaderOptions } from '../../../../common/types';

/**
* Defines the behavior of the search input that appears above the table of data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as i18n from './translations';
import { useRuleWithFallback } from '../../../detections/containers/detection_engine/rules/use_rule_with_fallback';
import { MarkdownRenderer } from '../markdown_editor';
import { LineClamp } from '../line_clamp';
import { TimelineEventsDetailsItem } from '../../../../common';
import { TimelineEventsDetailsItem } from '../../../../common/search_strategy';

export const Indent = styled.div`
padding: 0 8px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import React, { useMemo } from 'react';
import styled from 'styled-components';
import { getRuleDetailsUrl, useFormatUrl } from '../link_to';
import * as i18n from './translations';
import { TimelineEventsDetailsItem } from '../../../../common';
import { TimelineEventsDetailsItem } from '../../../../common/search_strategy';
import { LinkAnchor } from '../links';
import { useKibana } from '../../lib/kibana';
import { APP_UI_ID, SecurityPageName } from '../../../../common/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ColumnHeaderOptions } from '../../../../common';
import { ColumnHeaderOptions } from '../../../../common/types';
import { defaultColumnHeaderType } from '../../../timelines/components/timeline/body/column_headers/default_headers';
import { DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../../../timelines/components/timeline/body/constants';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
RULES_PATH,
UEBA_PATH,
} from '../../../../common/constants';
import { TimelineId } from '../../../../common';
import { TimelineId } from '../../../../common/types';
import { useDeepEqualSelector } from '../../hooks/use_selector';
import { checkIfIndicesExist, getScopePatternListSelection } from '../../store/sourcerer/helpers';
import { useAppToasts } from '../../hooks/use_app_toasts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ColumnHeaderOptions } from '../../../common';
import { ColumnHeaderOptions } from '../../../common/types';
import { defaultColumnHeaderType } from '../../timelines/components/timeline/body/column_headers/default_headers';
import {
DEFAULT_COLUMN_MIN_WIDTH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useUiSetting$ } from '../../../../common/lib/kibana';
import { DEFAULT_NUMBER_FORMAT } from '../../../../../common/constants';
import * as i18n from './translations';
import { DefaultDraggable } from '../../../../common/components/draggables';
import type { GenericBuckets } from '../../../../../common';
import type { GenericBuckets } from '../../../../../common/search_strategy';
import type { AlertSearchResponse } from '../../../containers/detection_engine/alerts/types';
import type { AlertsCountAggregation } from './types';

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

import type { GenericBuckets } from '../../../../../common';
import type { GenericBuckets } from '../../../../../common/search_strategy';

export interface AlertsCountAggregation {
alertsByGroupingCount: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { mount } from 'enzyme';
import { AlertContextMenu } from './alert_context_menu';
import { TimelineId } from '../../../../../common';
import { TimelineId } from '../../../../../common/types';
import { TestProviders } from '../../../../common/mock';
import React from 'react';
import { Ecs } from '../../../../../common/ecs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from '../../../../common/components/exceptions/add_exception_modal';
import * as i18n from '../translations';
import { inputsModel, inputsSelectors, State } from '../../../../common/store';
import { TimelineId } from '../../../../../common';
import { TimelineId } from '../../../../../common/types';
import { AlertData, EcsHit } from '../../../../common/components/exceptions/types';
import { useQueryAlerts } from '../../../containers/detection_engine/alerts/use_query';
import { useSignalIndex } from '../../../containers/detection_engine/alerts/use_signal_index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
useGlobalFullScreen,
useTimelineFullScreen,
} from '../../../../common/containers/use_full_screen';
import { TimelineId, TimelineTabs } from '../../../../../common';
import { TimelineId, TimelineTabs } from '../../../../../common/types';
import { ACTION_INVESTIGATE_IN_RESOLVER } from '../../../../timelines/components/timeline/body/translations';
import { Ecs } from '../../../../../common/ecs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import { useMemo } from 'react';
import { useGetUserCasesPermissions, useKibana } from '../../../../common/lib/kibana';
import { TimelineId, TimelineNonEcsData } from '../../../../../common';
import type { TimelineNonEcsData } from '../../../../../common/search_strategy';
import { TimelineId } from '../../../../../common/types';
import { APP_ID, APP_UI_ID } from '../../../../../common/constants';
import { useInsertTimeline } from '../../../../cases/components/use_insert_timeline';
import { Ecs } from '../../../../../common/ecs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { find } from 'lodash/fp';

import type { TimelineEventsDetailsItem } from '../../../../common';
import type { TimelineEventsDetailsItem } from '../../../../common/search_strategy';

export const getFieldValues = (
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import React, { useCallback, useMemo } from 'react';
import { EuiContextMenuItem } from '@elastic/eui';
import type { TimelineEventsDetailsItem } from '../../../../common';
import type { TimelineEventsDetailsItem } from '../../../../common/search_strategy';
import { isIsolationSupported } from '../../../../common/endpoint/service/host_isolation/utils';
import { HostStatus } from '../../../../common/endpoint/types';
import { useIsolationPrivileges } from '../../../common/hooks/endpoint/use_isolate_privileges';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { debounce } from 'lodash/fp';
import { Type } from '@kbn/securitysolution-io-ts-alerting-types';
import * as i18n from '../rule_preview/translations';
import { useMatrixHistogram } from '../../../../common/containers/matrix_histogram';
import { MatrixHistogramType } from '../../../../../common';
import { MatrixHistogramType } from '../../../../../common/search_strategy';
import { FieldValueQueryBar } from '../query_bar';
import { PreviewEqlQueryHistogram } from './eql_histogram';
import { useEqlPreview } from '../../../../common/hooks/eql/';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { useMemo } from 'react';
import { useMatrixHistogram } from '../../../../common/containers/matrix_histogram';
import { MatrixHistogramType } from '../../../../../common';
import { MatrixHistogramType } from '../../../../../common/search_strategy';
import { convertToBuildEsQuery } from '../../../../common/lib/keury';
import { getEsQueryConfig } from '../../../../../../../../src/plugins/data/common';
import { useKibana } from '../../../../common/lib/kibana';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { waitFor } from '@testing-library/react';
import { TakeActionDropdown, TakeActionDropdownProps } from '.';
import { mockAlertDetailsData } from '../../../common/components/event_details/__mocks__';
import { mockEcsDataWithAlert } from '../../../common/mock/mock_detection_alerts';
import { TimelineEventsDetailsItem, TimelineId } from '../../../../common';
import type { TimelineEventsDetailsItem } from '../../../../common/search_strategy';
import { TimelineId } from '../../../../common/types';
import { TestProviders } from '../../../common/mock';
import { mockTimelines } from '../../../common/mock/mock_timelines_plugin';
import { createStartServicesMock } from '../../../common/lib/kibana/kibana_react.mock';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useState, useCallback, useMemo } from 'react';
import { EuiContextMenuPanel, EuiButton, EuiPopover } from '@elastic/eui';
import type { ExceptionListType } from '@kbn/securitysolution-io-ts-list-types';
import { isEmpty } from 'lodash/fp';
import { TimelineEventsDetailsItem } from '../../../../common';
import { TimelineEventsDetailsItem } from '../../../../common/search_strategy';
import { TAKE_ACTION } from '../alerts_table/alerts_utility_bar/translations';
import { useExceptionActions } from '../alerts_table/timeline_actions/use_add_exception_actions';
import { useAlertsActions } from '../alerts_table/timeline_actions/use_alerts_actions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ALERT_STATUS,
} from '@kbn/rule-data-utils/technical_field_names';

import { ColumnHeaderOptions } from '../../../../../common';
import { ColumnHeaderOptions } from '../../../../../common/types';
import { defaultColumnHeaderType } from '../../../../timelines/components/timeline/body/column_headers/default_headers';
import { DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../../../../timelines/components/timeline/body/constants';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { defaultHeaders, mockTimelineData, TestProviders } from '../../../../com
import { TimelineNonEcsData } from '../../../../../common/search_strategy/timeline';
import { CellValueElementProps } from '../../../../timelines/components/timeline/cell_rendering';
import { DefaultCellRenderer } from '../../../../timelines/components/timeline/cell_rendering/default_cell_renderer';
import { ColumnHeaderOptions } from '../../../../../common';
import { ColumnHeaderOptions } from '../../../../../common/types';

import { RenderCellValue } from '.';

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

import { EuiDataGridColumn } from '@elastic/eui';
import { ColumnHeaderOptions } from '../../../../../common';
import { ColumnHeaderOptions } from '../../../../../common/types';
import { defaultColumnHeaderType } from '../../../../timelines/components/timeline/body/column_headers/default_headers';
import { DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../../../../timelines/components/timeline/body/constants';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CellValueElementProps } from '../../../../timelines/components/timeline
import { DefaultCellRenderer } from '../../../../timelines/components/timeline/cell_rendering/default_cell_renderer';

import { RenderCellValue } from '.';
import { ColumnHeaderOptions } from '../../../../../common';
import { ColumnHeaderOptions } from '../../../../../common/types';

jest.mock('../../../../common/lib/kibana/');

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

import { EuiDataGridColumn } from '@elastic/eui';
import { ColumnHeaderOptions } from '../../../../common';
import { ColumnHeaderOptions } from '../../../../common/types';

import { defaultColumnHeaderType } from '../../../timelines/components/timeline/body/column_headers/default_headers';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { mount } from 'enzyme';
import { cloneDeep } from 'lodash/fp';
import React from 'react';

import { ColumnHeaderOptions } from '../../../../common';
import { ColumnHeaderOptions } from '../../../../common/types';
import { mockBrowserFields } from '../../../common/containers/source/mock';
import { DragDropContextWrapper } from '../../../common/components/drag_and_drop/drag_drop_context_wrapper';
import { defaultHeaders, mockTimelineData, TestProviders } from '../../../common/mock';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { LinkPanelListItem } from '../link_panel';
import { useRiskyHostsDashboardButtonHref } from '../../containers/overview_risky_host_links/use_risky_hosts_dashboard_button_href';
import { useRiskyHostsDashboardLinks } from '../../containers/overview_risky_host_links/use_risky_hosts_dashboard_links';
import { HostRisk } from '../../containers/overview_risky_host_links/use_hosts_risk_score';
import { HostsRiskScore } from '../../../../common';
import { HostsRiskScore } from '../../../../common/search_strategy';

const getListItemsFromHits = (items: HostsRiskScore[]): LinkPanelListItem[] => {
return items.map(({ host, risk_score: count, risk: copy }) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useAppToasts } from '../../../common/hooks/use_app_toasts';
import { useKibana } from '../../../common/lib/kibana';
import { inputsActions } from '../../../common/store/actions';
import { isIndexNotFoundError } from '../../../common/utils/exceptions';
import { HostsRiskScore } from '../../../../common';
import { HostsRiskScore } from '../../../../common/search_strategy';
import { useHostsRiskScoreComplete } from './use_hosts_risk_score_complete';
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features';
import { getHostRiskIndex } from '../../../helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
HostsQueries,
HostsRiskScoreRequestOptions,
HostsRiskScoreStrategyResponse,
} from '../../../../common';
} from '../../../../common/search_strategy';

type GetHostsRiskScoreProps = HostsRiskScoreRequestOptions & {
data: DataPublicPluginStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { TestProviders } from '../../../common/mock';
import { useKibana } from '../../../common/lib/kibana';
import type { DataView } from '../../../../../../../src/plugins/data/common';
import { TimelineId } from '../../../../common';
import { TimelineId } from '../../../../common/types';

const useKibanaMock = useKibana as jest.Mocked<typeof useKibana>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { BrowserFields } from '../../../common/containers/source';
import { getColumnsWithTimestamp } from '../../../common/components/event_details/helpers';
import type { OnUpdateColumns } from '../timeline/events';
import { FieldName } from './field_name';
import type { ColumnHeaderOptions } from '../../../../common';
import type { ColumnHeaderOptions } from '../../../../common/types';
import { useKibana } from '../../../common/lib/kibana';

const DraggableFieldsBrowserFieldComponent = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import styled from 'styled-components';

import { OnUpdateColumns } from '../timeline/events';
import { WithHoverActions } from '../../../common/components/with_hover_actions';
import { ColumnHeaderOptions } from '../../../../common';
import { ColumnHeaderOptions } from '../../../../common/types';
import { HoverActions } from '../../../common/components/hover_actions';
import { TimelineContext } from '../../../../../timelines/public';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { waitFor } from '@testing-library/react';

import { FormattedIp } from './index';
import { TestProviders } from '../../../common/mock';
import { TimelineId, TimelineTabs } from '../../../../common';
import { TimelineId, TimelineTabs } from '../../../../common/types';
import { StatefulEventContext } from '../../../../../timelines/public';
import { timelineActions } from '../../store/timeline';
import { activeTimeline } from '../../containers/active_timeline_context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { EuiFlyoutFooter, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { find, get, isEmpty } from 'lodash/fp';
import { connect, ConnectedProps } from 'react-redux';
import { TakeActionDropdown } from '../../../../detections/components/take_action_dropdown';
import { TimelineEventsDetailsItem, TimelineId } from '../../../../../common';
import type { TimelineEventsDetailsItem } from '../../../../../common/search_strategy';
import { TimelineId } from '../../../../../common/types';
import { useExceptionModal } from '../../../../detections/components/alerts_table/timeline_actions/use_add_exception_modal';
import { AddExceptionModalWrapper } from '../../../../detections/components/alerts_table/timeline_actions/alert_context_menu';
import { EventFiltersModal } from '../../../../management/pages/event_filters/view/components/modal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import { getFieldValue } from '../../../../detections/components/host_isolation/helpers';
import { ALERT_DETAILS } from './translations';
import { useWithCaseDetailsRefresh } from '../../../../common/components/endpoint/host_isolation/endpoint_host_isolation_cases_context';
import { TimelineNonEcsData } from '../../../../../common';
import { TimelineNonEcsData } from '../../../../../common/search_strategy';
import { Ecs } from '../../../../../common/ecs';
import { EventDetailsFooter } from './footer';
import { EntityType } from '../../../../../../timelines/common';
Expand Down
Loading

0 comments on commit 3a289aa

Please sign in to comment.