Skip to content

Commit bde8c42

Browse files
[7.x] [SIEM] Fix eslint errors (#49713) (#51875)
* [SIEM] Fix eslint errors (#49713) * Update use_kibana_ui_setting.ts
1 parent af9f20d commit bde8c42

File tree

16 files changed

+49
-54
lines changed

16 files changed

+49
-54
lines changed

.eslintrc.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,6 @@ module.exports = {
202202
'jsx-a11y/click-events-have-key-events': 'off',
203203
},
204204
},
205-
{
206-
files: ['x-pack/legacy/plugins/siem/**/*.{js,ts,tsx}'],
207-
rules: {
208-
'react-hooks/exhaustive-deps': 'off',
209-
'react-hooks/rules-of-hooks': 'off',
210-
},
211-
},
212205
{
213206
files: ['x-pack/legacy/plugins/snapshot_restore/**/*.{js,ts,tsx}'],
214207
rules: {
@@ -827,6 +820,8 @@ module.exports = {
827820
// might be introduced after the other warns are fixed
828821
// 'react/jsx-sort-props': 'error',
829822
'react/jsx-tag-spacing': 'error',
823+
// might be introduced after the other warns are fixed
824+
'react-hooks/exhaustive-deps': 'off',
830825
'require-atomic-updates': 'error',
831826
'rest-spread-spacing': ['error', 'never'],
832827
'symbol-description': 'error',

x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ import * as React from 'react';
1010
import { EmbeddedMapComponent } from './embedded_map';
1111
import { SetQuery } from './types';
1212
import { useKibanaCore } from '../../lib/compose/kibana_core';
13+
import { useIndexPatterns } from '../../hooks/use_index_patterns';
1314

1415
jest.mock('../search_bar', () => ({
1516
siemFilterManager: {
1617
addFilters: jest.fn(),
1718
},
1819
}));
1920

21+
const mockUseIndexPatterns = useIndexPatterns as jest.Mock;
22+
jest.mock('../../hooks/use_index_patterns');
23+
mockUseIndexPatterns.mockImplementation(() => [true, []]);
24+
2025
const mockUseKibanaCore = useKibanaCore as jest.Mock;
2126
jest.mock('../../lib/compose/kibana_core');
2227
mockUseKibanaCore.mockImplementation(() => ({

x-pack/legacy/plugins/siem/public/components/flyout/pane/index.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ mockUseKibanaCore.mockImplementation(() => ({
2424
uiSettings: mockUiSettings,
2525
}));
2626

27+
jest.mock('ui/vis/lib/timezone', () => ({
28+
timezoneProvider: () => () => 'America/New_York',
29+
}));
30+
2731
describe('Pane', () => {
2832
test('renders correctly against snapshot', () => {
2933
const EmptyComponent = shallow(

x-pack/legacy/plugins/siem/public/components/link_to/redirect_wrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
import React from 'react';
88
import { Redirect } from 'react-router-dom';
9-
import { scrollToTop } from '../scroll_to_top';
9+
import { useScrollToTop } from '../scroll_to_top';
1010

1111
export interface RedirectWrapperProps {
1212
to: string;
1313
}
1414

1515
export const RedirectWrapper = ({ to }: RedirectWrapperProps) => {
16-
scrollToTop();
16+
useScrollToTop();
1717
return <Redirect to={to} />;
1818
};

x-pack/legacy/plugins/siem/public/components/resize_handle/is_resizing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { useState } from 'react';
88

9-
export const isContainerResizing = () => {
9+
export const useIsContainerResizing = () => {
1010
const [isResizing, setIsResizing] = useState(false);
1111

1212
return {

x-pack/legacy/plugins/siem/public/components/scroll_to_top/index.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { mount } from 'enzyme';
88
import * as React from 'react';
99

1010
import { globalNode, HookWrapper } from '../../mock';
11-
import { scrollToTop } from '.';
11+
import { useScrollToTop } from '.';
1212

1313
const spyScroll = jest.fn();
1414
const spyScrollTo = jest.fn();
@@ -21,15 +21,15 @@ describe('Scroll to top', () => {
2121

2222
test('scroll have been called', () => {
2323
Object.defineProperty(globalNode.window, 'scroll', { value: spyScroll });
24-
mount(<HookWrapper hook={() => scrollToTop()} />);
24+
mount(<HookWrapper hook={() => useScrollToTop()} />);
2525

2626
expect(spyScroll).toHaveBeenCalledWith(0, 0);
2727
});
2828

2929
test('scrollTo have been called', () => {
3030
Object.defineProperty(globalNode.window, 'scroll', { value: null });
3131
Object.defineProperty(globalNode.window, 'scrollTo', { value: spyScrollTo });
32-
mount(<HookWrapper hook={() => scrollToTop()} />);
32+
mount(<HookWrapper hook={() => useScrollToTop()} />);
3333
expect(spyScrollTo).toHaveBeenCalled();
3434
});
3535
});

x-pack/legacy/plugins/siem/public/components/scroll_to_top/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { useEffect } from 'react';
88

9-
export const scrollToTop = () => {
9+
export const useScrollToTop = () => {
1010
useEffect(() => {
1111
// trying to use new API - https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo
1212
if (window.scroll) {

x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { ColumnHeadersComponent } from '.';
1919

2020
jest.mock('../../../resize_handle/is_resizing', () => ({
2121
...jest.requireActual('../../../resize_handle/is_resizing'),
22-
isContainerResizing: () => ({
22+
useIsContainerResizing: () => ({
2323
isResizing: true,
2424
setIsResizing: jest.fn(),
2525
}),

x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { DraggableFieldBadge } from '../../../draggables/field_badge';
1919
import { StatefulFieldsBrowser } from '../../../fields_browser';
2020
import { FIELD_BROWSER_HEIGHT, FIELD_BROWSER_WIDTH } from '../../../fields_browser/helpers';
21-
import { isContainerResizing } from '../../../resize_handle/is_resizing';
21+
import { useIsContainerResizing } from '../../../resize_handle/is_resizing';
2222
import {
2323
OnColumnRemoved,
2424
OnColumnResized,
@@ -71,7 +71,7 @@ export const ColumnHeadersComponent = ({
7171
timelineId,
7272
toggleColumn,
7373
}: Props) => {
74-
const { isResizing, setIsResizing } = isContainerResizing();
74+
const { isResizing, setIsResizing } = useIsContainerResizing();
7575

7676
return (
7777
<EventsThead data-test-subj="column-headers">

x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/endgame/endgame_security_event_details_line.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
getHumanReadableLogonType,
1919
getUserDomainField,
2020
getUserNameField,
21-
useTargetUserAndTargetDomain,
21+
getTargetUserAndTargetDomain,
2222
} from './helpers';
2323

2424
import * as i18n from './translations';
@@ -65,10 +65,10 @@ export const EndgameSecurityEventDetailsLine = React.memo<Props>(
6565
userName,
6666
winlogEventId,
6767
}) => {
68-
const domain = useTargetUserAndTargetDomain(eventAction) ? endgameTargetDomainName : userDomain;
68+
const domain = getTargetUserAndTargetDomain(eventAction) ? endgameTargetDomainName : userDomain;
6969
const eventDetails = getEventDetails(eventAction);
7070
const hostNameSeparator = getHostNameSeparator(eventAction);
71-
const user = useTargetUserAndTargetDomain(eventAction) ? endgameTargetUserName : userName;
71+
const user = getTargetUserAndTargetDomain(eventAction) ? endgameTargetUserName : userName;
7272
const userDomainField = getUserDomainField(eventAction);
7373
const userNameField = getUserNameField(eventAction);
7474

0 commit comments

Comments
 (0)