Skip to content

Commit f29c872

Browse files
Fix lint issues
1 parent 5fc42f5 commit f29c872

File tree

14 files changed

+52
-60
lines changed

14 files changed

+52
-60
lines changed

.eslintrc.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,6 @@ module.exports = {
214214
'jsx-a11y/click-events-have-key-events': 'off',
215215
},
216216
},
217-
{
218-
files: ['x-pack/legacy/plugins/siem/**/*.{js,ts,tsx}'],
219-
rules: {
220-
'react-hooks/exhaustive-deps': 'off',
221-
'react-hooks/rules-of-hooks': 'off',
222-
},
223-
},
224217
{
225218
files: ['x-pack/legacy/plugins/snapshot_restore/**/*.{js,ts,tsx}'],
226219
rules: {
@@ -838,6 +831,8 @@ module.exports = {
838831
// might be introduced after the other warns are fixed
839832
// 'react/jsx-sort-props': 'error',
840833
'react/jsx-tag-spacing': 'error',
834+
// might be introduced after the other warns are fixed
835+
'react-hooks/exhaustive-deps': 'off',
841836
'require-atomic-updates': 'error',
842837
'rest-spread-spacing': ['error', 'never'],
843838
'symbol-description': 'error',

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ import * as React from 'react';
1010
import { EmbeddedMap } 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(() => ({
@@ -30,6 +35,10 @@ mockUseKibanaCore.mockImplementation(() => ({
3035

3136
jest.mock('../../lib/compose/kibana_plugins');
3237

38+
jest.mock('ui/vis/lib/timezone', () => ({
39+
timezoneProvider: () => () => 'America/New_York',
40+
}));
41+
3342
describe('EmbeddedMap', () => {
3443
let setQuery: SetQuery;
3544

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,7 +21,7 @@ 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({
2727
top: 0,
@@ -32,7 +32,7 @@ describe('Scroll to top', () => {
3232
test('scrollTo have been called', () => {
3333
Object.defineProperty(globalNode.window, 'scroll', { value: null });
3434
Object.defineProperty(globalNode.window, 'scrollTo', { value: spyScrollTo });
35-
mount(<HookWrapper hook={() => scrollToTop()} />);
35+
mount(<HookWrapper hook={() => useScrollToTop()} />);
3636
expect(spyScrollTo).toHaveBeenCalled();
3737
});
3838
});

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 { ColumnHeaders } 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,
@@ -72,7 +72,7 @@ export const ColumnHeaders = React.memo<Props>(
7272
timelineId,
7373
toggleColumn,
7474
}) => {
75-
const { isResizing, setIsResizing } = isContainerResizing();
75+
const { isResizing, setIsResizing } = useIsContainerResizing();
7676

7777
return (
7878
<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

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import {
88
getHostNameSeparator,
99
getHumanReadableLogonType,
10-
useTargetUserAndTargetDomain,
10+
getTargetUserAndTargetDomain,
1111
getUserDomainField,
1212
getUserNameField,
1313
getEventDetails,
@@ -102,29 +102,29 @@ describe('helpers', () => {
102102
});
103103
});
104104

105-
describe('#useTargetUserAndTargetDomain', () => {
105+
describe('#getTargetUserAndTargetDomain', () => {
106106
test('it returns false when eventAction is undefined', () => {
107-
expect(useTargetUserAndTargetDomain(undefined)).toEqual(false);
107+
expect(getTargetUserAndTargetDomain(undefined)).toEqual(false);
108108
});
109109

110110
test('it returns false when eventAction is null', () => {
111-
expect(useTargetUserAndTargetDomain(null)).toEqual(false);
111+
expect(getTargetUserAndTargetDomain(null)).toEqual(false);
112112
});
113113

114114
test('it returns false when eventAction is an empty string', () => {
115-
expect(useTargetUserAndTargetDomain('')).toEqual(false);
115+
expect(getTargetUserAndTargetDomain('')).toEqual(false);
116116
});
117117

118118
test('it returns false when eventAction is a random value', () => {
119-
expect(useTargetUserAndTargetDomain('a random value')).toEqual(false);
119+
expect(getTargetUserAndTargetDomain('a random value')).toEqual(false);
120120
});
121121

122122
test('it returns true when eventAction is "explicit_user_logon"', () => {
123-
expect(useTargetUserAndTargetDomain('explicit_user_logon')).toEqual(true);
123+
expect(getTargetUserAndTargetDomain('explicit_user_logon')).toEqual(true);
124124
});
125125

126126
test('it returns true when eventAction is "user_logoff"', () => {
127-
expect(useTargetUserAndTargetDomain('user_logoff')).toEqual(true);
127+
expect(getTargetUserAndTargetDomain('user_logoff')).toEqual(true);
128128
});
129129
});
130130

0 commit comments

Comments
 (0)