mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Security Solution][Tech Debt] cleans up ts-ignore issues and some smaller linter issues (#74268)
## Summary * Removes ts-ignore where it is not being used * Replaces ts-ignore with the better alternative which is the ts-expect-error
This commit is contained in:
parent
54e13ad6f6
commit
f506279a55
26 changed files with 25 additions and 41 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { resolve } from 'path';
|
||||
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
import madge from 'madge';
|
||||
import { createFailError, run } from '@kbn/dev-utils';
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
Cypress.Commands.add('stubSecurityApi', function (dataFileName) {
|
||||
cy.on('window:before:load', (win) => {
|
||||
// @ts-ignore no null, this is a temp hack see issue above
|
||||
win.fetch = null;
|
||||
});
|
||||
cy.server();
|
||||
|
|
|
@ -38,7 +38,6 @@ export const setTimelineEndDate = (date: string) => {
|
|||
|
||||
cy.get(DATE_PICKER_ABSOLUTE_INPUT).click({ force: true });
|
||||
cy.get(DATE_PICKER_ABSOLUTE_INPUT).then(($el) => {
|
||||
// @ts-ignore
|
||||
if (Cypress.dom.isAttached($el)) {
|
||||
cy.wrap($el).click({ force: true });
|
||||
}
|
||||
|
@ -55,7 +54,6 @@ export const setTimelineStartDate = (date: string) => {
|
|||
|
||||
cy.get(DATE_PICKER_ABSOLUTE_INPUT).click({ force: true });
|
||||
cy.get(DATE_PICKER_ABSOLUTE_INPUT).then(($el) => {
|
||||
// @ts-ignore
|
||||
if (Cypress.dom.isAttached($el)) {
|
||||
cy.wrap($el).click({ force: true });
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ export const EventFieldsBrowser = React.memo<Props>(
|
|||
return (
|
||||
<div className="euiTable--compressed">
|
||||
<EuiInMemoryTable
|
||||
// @ts-ignore items going in match Partial<BrowserField>, column `render` callbacks expect complete BrowserField
|
||||
// @ts-expect-error items going in match Partial<BrowserField>, column `render` callbacks expect complete BrowserField
|
||||
items={items}
|
||||
columns={columns}
|
||||
pagination={false}
|
||||
|
|
|
@ -220,7 +220,6 @@ type PropsFromRedux = ConnectedProps<typeof connector>;
|
|||
export const StatefulEventsViewer = connector(
|
||||
React.memo(
|
||||
StatefulEventsViewerComponent,
|
||||
// eslint-disable-next-line complexity
|
||||
(prevProps, nextProps) =>
|
||||
prevProps.id === nextProps.id &&
|
||||
deepEqual(prevProps.columns, nextProps.columns) &&
|
||||
|
|
|
@ -8,7 +8,6 @@ import {
|
|||
EuiButton,
|
||||
EuiButtonEmpty,
|
||||
EuiCheckbox,
|
||||
// @ts-ignore no-exported-member
|
||||
EuiFilePicker,
|
||||
EuiModal,
|
||||
EuiModalBody,
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
EuiFlexGroup,
|
||||
EuiFlexItem,
|
||||
EuiLoadingSpinner,
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
EuiLoadingSpinnerSize,
|
||||
EuiText,
|
||||
} from '@elastic/eui';
|
||||
|
|
|
@ -64,7 +64,6 @@ const HeaderChildrenFlexItem = styled(EuiFlexItem)`
|
|||
margin-left: 24px;
|
||||
`;
|
||||
|
||||
// @ts-ignore - the EUI type definitions for Panel do no play nice with styled-components
|
||||
const HistogramPanel = styled(Panel)<{ height?: number }>`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
@ -77,9 +77,9 @@ const AnomaliesHostTableComponent: React.FC<AnomaliesHostTableProps> = ({
|
|||
/>
|
||||
|
||||
<BasicTable
|
||||
// @ts-ignore the Columns<T, U> type is not as specific as EUI's...
|
||||
// @ts-expect-error the Columns<T, U> type is not as specific as EUI's...
|
||||
columns={columns}
|
||||
// @ts-ignore ...which leads to `networks` not "matching" the columns
|
||||
// @ts-expect-error ...which leads to `networks` not "matching" the columns
|
||||
items={hosts}
|
||||
pagination={pagination}
|
||||
sorting={sorting}
|
||||
|
|
|
@ -67,9 +67,9 @@ const AnomaliesNetworkTableComponent: React.FC<AnomaliesNetworkTableProps> = ({
|
|||
/>
|
||||
|
||||
<BasicTable
|
||||
// @ts-ignore the Columns<T, U> type is not as specific as EUI's...
|
||||
// @ts-expect-error the Columns<T, U> type is not as specific as EUI's...
|
||||
columns={columns}
|
||||
// @ts-ignore ...which leads to `networks` not "matching" the columns
|
||||
// @ts-expect-error ...which leads to `networks` not "matching" the columns
|
||||
items={networks}
|
||||
pagination={pagination}
|
||||
sorting={sorting}
|
||||
|
|
|
@ -11,7 +11,6 @@ import {
|
|||
EuiFilterGroup,
|
||||
EuiFlexGroup,
|
||||
EuiFlexItem,
|
||||
// @ts-ignore no-exported-member
|
||||
EuiSearchBar,
|
||||
} from '@elastic/eui';
|
||||
import { EuiSearchBarQuery } from '../../../../../timelines/components/open_timeline/types';
|
||||
|
|
|
@ -14,8 +14,7 @@ import { onError } from 'apollo-link-error';
|
|||
const mockDispatch = jest.fn();
|
||||
jest.mock('apollo-link-error');
|
||||
jest.mock('../../store');
|
||||
// @ts-ignore
|
||||
store.getStore.mockReturnValue({ dispatch: mockDispatch });
|
||||
(store.getStore as jest.Mock).mockReturnValue({ dispatch: mockDispatch });
|
||||
|
||||
describe('errorLinkHandler', () => {
|
||||
const mockGraphQLErrors: GraphQLError = {
|
||||
|
|
|
@ -18,10 +18,8 @@ jest.mock('../../containers/errors');
|
|||
const mockWithClientState = 'mockWithClientState';
|
||||
const mockHttpLink = { mockHttpLink: 'mockHttpLink' };
|
||||
|
||||
// @ts-ignore
|
||||
withClientState.mockReturnValue(mockWithClientState);
|
||||
// @ts-ignore
|
||||
apolloLinkHttp.createHttpLink.mockImplementation(() => mockHttpLink);
|
||||
(withClientState as jest.Mock).mockReturnValue(mockWithClientState);
|
||||
(apolloLinkHttp.createHttpLink as jest.Mock).mockImplementation(() => mockHttpLink);
|
||||
|
||||
describe('getLinks helper', () => {
|
||||
test('It should return links in correct order', () => {
|
||||
|
|
|
@ -255,8 +255,7 @@ describe('alert actions', () => {
|
|||
nonEcsData: [],
|
||||
updateTimelineIsLoading,
|
||||
});
|
||||
// @ts-ignore
|
||||
const createTimelineArg = createTimeline.mock.calls[0][0];
|
||||
const createTimelineArg = (createTimeline as jest.Mock).mock.calls[0][0];
|
||||
|
||||
expect(createTimeline).toHaveBeenCalledTimes(1);
|
||||
expect(createTimelineArg.timeline.kqlQuery.filterQuery.kuery.kind).toEqual('kuery');
|
||||
|
@ -285,8 +284,7 @@ describe('alert actions', () => {
|
|||
nonEcsData: [],
|
||||
updateTimelineIsLoading,
|
||||
});
|
||||
// @ts-ignore
|
||||
const createTimelineArg = createTimeline.mock.calls[0][0];
|
||||
const createTimelineArg = (createTimeline as jest.Mock).mock.calls[0][0];
|
||||
|
||||
expect(createTimeline).toHaveBeenCalledTimes(1);
|
||||
expect(createTimelineArg.timeline.kqlQuery.filterQueryDraft.kind).toEqual('kuery');
|
||||
|
|
|
@ -95,7 +95,7 @@ export const buildShowBuildingBlockFilter = (showBuildingBlockAlerts: boolean):
|
|||
key: 'signal.rule.building_block_type',
|
||||
value: 'exists',
|
||||
},
|
||||
// @ts-ignore TODO: Rework parent typings to support ExistsFilter[]
|
||||
// @ts-expect-error TODO: Rework parent typings to support ExistsFilter[]
|
||||
exists: { field: 'signal.rule.building_block_type' },
|
||||
},
|
||||
]),
|
||||
|
|
|
@ -140,7 +140,7 @@ const hostListApiPathHandlerMocks = ({
|
|||
// Build a GET route handler for each host details based on the list of Hosts passed on input
|
||||
if (hostsResults) {
|
||||
hostsResults.forEach((host) => {
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
apiHandlers[`/api/endpoint/metadata/${host.metadata.host.id}`] = () => host;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -109,14 +109,14 @@ export const policyDetailsReducer: ImmutableReducer<PolicyDetailsState, AppActio
|
|||
/**
|
||||
* This is directly changing redux state because `policyItem.inputs` was copied over and not cloned.
|
||||
*/
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
newState.policyItem.inputs[0].config.policy.value = newPolicy;
|
||||
|
||||
Object.entries(action.payload.policyConfig).forEach(([section, newSettings]) => {
|
||||
/**
|
||||
* this is not safe because `action.payload.policyConfig` may have excess keys
|
||||
*/
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
newPolicy[section as keyof UIPolicyConfig] = {
|
||||
...newPolicy[section as keyof UIPolicyConfig],
|
||||
...newSettings,
|
||||
|
|
|
@ -114,7 +114,7 @@ export const createEmbeddable = async (
|
|||
|
||||
if (!isErrorEmbeddable(embeddableObject)) {
|
||||
embeddableObject.setRenderTooltipContent(renderTooltipContent);
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
await embeddableObject.setLayerList(getLayerList(indexPatterns));
|
||||
}
|
||||
|
||||
|
|
|
@ -238,7 +238,6 @@ export const getTimelineStatus = (
|
|||
return duplicate ? TimelineStatus.active : timeline.status;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
export const defaultTimelineToTimelineModel = (
|
||||
timeline: TimelineResult,
|
||||
duplicate: boolean,
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
EuiFilterButton,
|
||||
EuiFlexGroup,
|
||||
EuiFlexItem,
|
||||
// @ts-ignore
|
||||
EuiSearchBar,
|
||||
} from '@elastic/eui';
|
||||
import React, { useMemo } from 'react';
|
||||
|
|
|
@ -87,7 +87,7 @@ const RowRenderersBrowserComponent = React.forwardRef(
|
|||
const handleNameClick = useCallback(
|
||||
(item: RowRendererOption) => () => {
|
||||
const newSelection = xor([item], notExcludedRowRenderers);
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
ref?.current?.setSelection(newSelection); // eslint-disable-line no-unused-expressions
|
||||
},
|
||||
[notExcludedRowRenderers, ref]
|
||||
|
|
|
@ -126,7 +126,7 @@ describe('filterEventsAgainstList', () => {
|
|||
);
|
||||
expect(res.hits.hits.length).toEqual(2);
|
||||
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
const ipVals = res.hits.hits.map((item) => item._source.source.ip);
|
||||
expect(['3.3.3.3', '7.7.7.7']).toEqual(ipVals);
|
||||
});
|
||||
|
@ -188,7 +188,7 @@ describe('filterEventsAgainstList', () => {
|
|||
expect(listClient.getListItemByValues as jest.Mock).toHaveBeenCalledTimes(2);
|
||||
expect(res.hits.hits.length).toEqual(6);
|
||||
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
const ipVals = res.hits.hits.map((item) => item._source.source.ip);
|
||||
expect(['1.1.1.1', '3.3.3.3', '5.5.5.5', '7.7.7.7', '8.8.8.8', '9.9.9.9']).toEqual(ipVals);
|
||||
});
|
||||
|
@ -247,7 +247,7 @@ describe('filterEventsAgainstList', () => {
|
|||
buildRuleMessage,
|
||||
});
|
||||
expect(listClient.getListItemByValues as jest.Mock).toHaveBeenCalledTimes(2);
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
const ipVals = res.hits.hits.map((item) => item._source.source.ip);
|
||||
expect(res.hits.hits.length).toEqual(7);
|
||||
|
||||
|
@ -324,7 +324,7 @@ describe('filterEventsAgainstList', () => {
|
|||
expect(listClient.getListItemByValues as jest.Mock).toHaveBeenCalledTimes(2);
|
||||
expect(res.hits.hits.length).toEqual(8);
|
||||
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
const ipVals = res.hits.hits.map((item) => item._source.source.ip);
|
||||
expect([
|
||||
'1.1.1.1',
|
||||
|
@ -386,7 +386,7 @@ describe('filterEventsAgainstList', () => {
|
|||
expect(listClient.getListItemByValues as jest.Mock).toHaveBeenCalledTimes(2);
|
||||
expect(res.hits.hits.length).toEqual(9);
|
||||
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
const ipVals = res.hits.hits.map((item) => item._source.source.ip);
|
||||
expect([
|
||||
'1.1.1.1',
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('elasticsearch_adapter', () => {
|
|||
|
||||
describe('#getUsers', () => {
|
||||
test('will format edges correctly', () => {
|
||||
// @ts-ignore Re-work `DatabaseSearchResponse` types as mock ES Response won't match
|
||||
// @ts-expect-error Re-work `DatabaseSearchResponse` types as mock ES Response won't match
|
||||
const edges = getUsersEdges(mockUsersData);
|
||||
expect(edges).toEqual(mockFormattedUsersEdges);
|
||||
});
|
||||
|
|
|
@ -37,7 +37,6 @@ const getTimelineTypeAndStatus = (
|
|||
status: TimelineStatus | null = TimelineStatus.active
|
||||
) => {
|
||||
// TODO: Added to support legacy TimelineType.draft, can be removed in 7.10
|
||||
// @ts-ignore
|
||||
if (timelineType === 'draft') {
|
||||
return {
|
||||
timelineType: TimelineType.default,
|
||||
|
|
|
@ -34,7 +34,6 @@ export const updateTimelinesRoute = (
|
|||
tags: ['access:securitySolution'],
|
||||
},
|
||||
},
|
||||
// eslint-disable-next-line complexity
|
||||
async (context, request, response) => {
|
||||
const siemResponse = buildSiemResponse(response);
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ describe('elasticsearch_adapter', () => {
|
|||
_id: 'id-9',
|
||||
_score: 0,
|
||||
_source: {
|
||||
// @ts-ignore ts doesn't like seeing the object written this way, but sometimes this is the data we get!
|
||||
// @ts-expect-error ts doesn't like seeing the object written this way, but sometimes this is the data we get!
|
||||
'host.id': ['host-id-9'],
|
||||
'host.name': ['host-9'],
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue