Skip to content

Commit 70870e2

Browse files
authored
[7.x] [Uptime] Delete uptime eslint rule skip (#50912) (#53916)
* [Uptime] Delete uptime eslint rule skip (#50912) * Delete uptime eslint rules. * Update hooks usage to adhere to new eslint rules. * Delete code accidentally added during rebase. * WIP trying things. * Clean up types and hook usage to comply with kibana eslint rules. * Clean up code. * Update new useEffect hooks that are missing dependencies. * Fix edits that broke a page. * Update handler type to match interface.
1 parent a1d811c commit 70870e2

File tree

16 files changed

+63
-69
lines changed

16 files changed

+63
-69
lines changed

.eslintrc.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,6 @@ module.exports = {
189189
'react-hooks/exhaustive-deps': 'off',
190190
},
191191
},
192-
{
193-
files: ['x-pack/legacy/plugins/uptime/**/*.{js,ts,tsx}'],
194-
rules: {
195-
'react-hooks/exhaustive-deps': 'off',
196-
'react-hooks/rules-of-hooks': 'off',
197-
},
198-
},
199192

200193
/**
201194
* Files that require Apache 2.0 headers, settings

x-pack/legacy/plugins/uptime/public/components/functional/charts/donut_chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const DonutChart = ({ height, down, up, width }: DonutChartProps) => {
6868
)
6969
.attr('fill', (d: any) => color(d.data.key));
7070
}
71-
}, [chartElement.current, upCount, down]);
71+
}, [danger, down, gray, height, upCount, width]);
7272
return (
7373
<EuiFlexGroup alignItems="center" responsive={false}>
7474
<EuiFlexItem grow={false}>

x-pack/legacy/plugins/uptime/public/components/functional/charts/snapshot_histogram.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ export const SnapshotHistogramComponent: React.FC<Props> = ({
5151
loading = false,
5252
height,
5353
}: Props) => {
54+
const {
55+
colors: { danger, gray },
56+
} = useContext(UptimeSettingsContext);
5457
if (!data || !data.queryResult)
5558
/**
5659
* TODO: the Fragment, EuiTitle, and EuiPanel should be extracted to a dumb component
@@ -94,10 +97,6 @@ export const SnapshotHistogramComponent: React.FC<Props> = ({
9497
queryResult: { histogram, interval },
9598
} = data;
9699

97-
const {
98-
colors: { danger, gray },
99-
} = useContext(UptimeSettingsContext);
100-
101100
const downMonitorsId = i18n.translate('xpack.uptime.snapshotHistogram.downMonitorsId', {
102101
defaultMessage: 'Down Monitors',
103102
});

x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function KueryBar({ autocomplete }: Props) {
8080
useEffect(() => {
8181
getIndexPattern(basePath, (result: any) => setIndexPattern(toStaticIndexPattern(result)));
8282
setIsLoadingIndexPattern(false);
83-
}, []);
83+
}, [basePath]);
8484
const [getUrlParams, updateUrlParams] = useUrlParams();
8585
const { search: kuery } = getUrlParams();
8686

x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/embedded_map.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ const EmbeddedPanel = styled.div`
4646

4747
export const EmbeddedMap = ({ upPoints, downPoints }: EmbeddedMapProps) => {
4848
const [embeddable, setEmbeddable] = useState<MapEmbeddable>();
49+
const embeddableRoot: React.RefObject<HTMLDivElement> = React.createRef();
50+
const factory = start.getEmbeddableFactory(MAP_SAVED_OBJECT_TYPE);
51+
52+
const input = {
53+
id: uuid.v4(),
54+
filters: [],
55+
hidePanelTitles: true,
56+
query: { query: '', language: 'kuery' },
57+
refreshConfig: { value: 0, pause: false },
58+
viewMode: 'view',
59+
isLayerTOCOpen: false,
60+
hideFilterActions: true,
61+
mapCenter: { lon: 11, lat: 47, zoom: 0 },
62+
disableInteractive: true,
63+
disableTooltipControl: true,
64+
hideToolbarOverlay: true,
65+
};
4966

5067
useEffect(() => {
5168
async function setupEmbeddable() {
@@ -59,38 +76,21 @@ export const EmbeddedMap = ({ upPoints, downPoints }: EmbeddedMapProps) => {
5976
setEmbeddable(embeddableObject);
6077
}
6178
setupEmbeddable();
79+
// we want this effect to execute exactly once after the component mounts
80+
// eslint-disable-next-line react-hooks/exhaustive-deps
6281
}, []);
6382

6483
useEffect(() => {
6584
if (embeddable) {
6685
embeddable.setLayerList(getLayerList(upPoints, downPoints));
6786
}
68-
}, [upPoints, downPoints]);
87+
}, [upPoints, downPoints, embeddable]);
6988

7089
useEffect(() => {
7190
if (embeddableRoot.current && embeddable) {
7291
embeddable.render(embeddableRoot.current);
7392
}
74-
}, [embeddable]);
75-
76-
const factory = start.getEmbeddableFactory(MAP_SAVED_OBJECT_TYPE);
77-
78-
const input = {
79-
id: uuid.v4(),
80-
filters: [],
81-
hidePanelTitles: true,
82-
query: { query: '', language: 'kuery' },
83-
refreshConfig: { value: 0, pause: false },
84-
viewMode: 'view',
85-
isLayerTOCOpen: false,
86-
hideFilterActions: true,
87-
mapCenter: { lon: 11, lat: 47, zoom: 0 },
88-
disableInteractive: true,
89-
disableTooltipControl: true,
90-
hideToolbarOverlay: true,
91-
};
92-
93-
const embeddableRoot: React.RefObject<HTMLDivElement> = React.createRef();
93+
}, [embeddable, embeddableRoot]);
9494

9595
return (
9696
<EmbeddedPanel>

x-pack/legacy/plugins/uptime/public/components/functional/monitor_charts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export const MonitorChartsComponent = ({
3939
dateRangeEnd,
4040
loading,
4141
}: Props) => {
42+
const [getUrlParams] = useUrlParams();
4243
if (data && data.monitorChartsData) {
4344
const {
4445
monitorChartsData: { locationDurationLines },
4546
} = data;
4647

47-
const [getUrlParams] = useUrlParams();
4848
const { absoluteDateRangeStart, absoluteDateRangeEnd } = getUrlParams();
4949

5050
return (

x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_list_drawer.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ export function MonitorListDrawerComponent({
4949
loadMonitorDetails,
5050
monitorDetails,
5151
}: MonitorListDrawerProps) {
52+
const monitorId = summary?.monitor_id;
53+
useEffect(() => {
54+
if (monitorId) {
55+
loadMonitorDetails(monitorId);
56+
}
57+
}, [loadMonitorDetails, monitorId]);
58+
5259
if (!summary || !summary.state.checks) {
5360
return null;
5461
}
55-
useEffect(() => {
56-
loadMonitorDetails(summary.monitor_id);
57-
}, []);
5862

5963
const monitorUrl: string | undefined = get(summary.state.url, 'full', undefined);
6064

x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_details.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const MonitorStatusDetailsComponent = ({
2828
}: MonitorStatusBarProps) => {
2929
useEffect(() => {
3030
loadMonitorLocations(monitorId);
31-
}, [monitorId, dateStart, dateEnd]);
31+
}, [loadMonitorLocations, monitorId, dateStart, dateEnd]);
3232

3333
return (
3434
<EuiPanel>

x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/ping_list.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/ping_list.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ describe('PingList component', () => {
207207
onPageCountChange={jest.fn()}
208208
onSelectedLocationChange={(loc: EuiComboBoxOptionProps[]) => {}}
209209
onSelectedStatusChange={jest.fn()}
210-
onUpdateApp={jest.fn()}
211210
pageSize={30}
212211
selectedOption="down"
213212
selectedLocation={BaseLocationOptions}

0 commit comments

Comments
 (0)