diff --git a/.eslintrc.js b/.eslintrc.js index a7b712dabb6c2..e21beee819932 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -229,12 +229,6 @@ module.exports = { 'react-hooks/exhaustive-deps': 'off', }, }, - { - files: ['x-pack/legacy/plugins/transform/**/*.{js,ts,tsx}'], - rules: { - 'react-hooks/exhaustive-deps': 'off', - }, - }, { files: ['x-pack/legacy/plugins/uptime/**/*.{js,ts,tsx}'], rules: { diff --git a/x-pack/legacy/plugins/transform/public/app/common/transform.ts b/x-pack/legacy/plugins/transform/public/app/common/transform.ts index 7670ab1f1cca1..481ad3c6d74ff 100644 --- a/x-pack/legacy/plugins/transform/public/app/common/transform.ts +++ b/x-pack/legacy/plugins/transform/public/app/common/transform.ts @@ -95,6 +95,8 @@ export const useRefreshTransformList = ( return () => { subscriptions.map(sub => sub.unsubscribe()); }; + // The effect should only be called once. + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return { diff --git a/x-pack/legacy/plugins/transform/public/app/lib/kibana/kibana_provider.tsx b/x-pack/legacy/plugins/transform/public/app/lib/kibana/kibana_provider.tsx index b64260b92d473..7d615bfa521f0 100644 --- a/x-pack/legacy/plugins/transform/public/app/lib/kibana/kibana_provider.tsx +++ b/x-pack/legacy/plugins/transform/public/app/lib/kibana/kibana_provider.tsx @@ -75,6 +75,8 @@ export const KibanaProvider: FC = ({ savedObjectId, children }) => { useEffect(() => { fetchSavedObject(savedObjectId); + // fetchSavedObject should not be tracked. + // eslint-disable-next-line react-hooks/exhaustive-deps }, [savedObjectId]); return {children}; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.ts b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.ts index 1f8f25d33e807..9205d03e6401b 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.ts +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/source_index_preview/use_source_index_data.ts @@ -131,6 +131,8 @@ export const useSourceIndexData = ( useEffect(() => { getSourceIndexData(); + // custom comparison + // eslint-disable-next-line react-hooks/exhaustive-deps }, [indexPattern.title, JSON.stringify(query)]); return { errorMessage, status, tableItems }; }; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx index 9623ff6abeced..6e9505898ced4 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx @@ -76,6 +76,8 @@ export const StepCreateForm: SFC = React.memo( useEffect(() => { onChange({ created, started, indexPatternId }); + // custom comparison + // eslint-disable-next-line react-hooks/exhaustive-deps }, [created, started, indexPatternId]); const api = useApi(); diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.tsx b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.tsx index bbfc6b11d3619..b53e0fca0fee1 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.tsx +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/pivot_preview.tsx @@ -150,7 +150,7 @@ export const PivotPreview: SFC = React.memo(({ aggs, groupBy, if (clearTable) { setTimeout(() => setClearTable(false), 0); } - }); + }, [firstColumnNameChanged, clearTable]); if (firstColumnNameChanged) { return null; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx index 6cde57fc2316d..442ce2011f77e 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx @@ -487,6 +487,8 @@ export const StepDefineForm: SFC = React.memo(({ overrides = {}, onChange sourceConfigUpdated, valid, }); + // custom comparison + /* eslint-disable react-hooks/exhaustive-deps */ }, [ JSON.stringify(pivotAggsArr), JSON.stringify(pivotGroupByArr), @@ -495,6 +497,7 @@ export const StepDefineForm: SFC = React.memo(({ overrides = {}, onChange searchString, searchQuery, valid, + /* eslint-enable react-hooks/exhaustive-deps */ ]); // TODO This should use the actual value of `indices.query.bool.max_clause_count` diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts index 17deb4db31990..92e3bdded4f6a 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_define/use_pivot_preview_data.ts @@ -91,11 +91,14 @@ export const usePivotPreviewData = ( useEffect(() => { getPreviewData(); + // custom comparison + /* eslint-disable react-hooks/exhaustive-deps */ }, [ indexPattern.title, JSON.stringify(aggsArr), JSON.stringify(groupByArr), JSON.stringify(query), + /* eslint-enable react-hooks/exhaustive-deps */ ]); return { errorMessage, status, previewData, previewMappings, previewRequest }; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx index ba43e020674ac..962a8905056b6 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx +++ b/x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx @@ -121,6 +121,8 @@ export const StepDetailsForm: SFC = React.memo(({ overrides = {}, onChang } } })(); + // custom comparison + // eslint-disable-next-line react-hooks/exhaustive-deps }, [kibanaContext.initialized]); if (!isKibanaContextInitialized(kibanaContext)) { @@ -169,6 +171,8 @@ export const StepDetailsForm: SFC = React.memo(({ overrides = {}, onChang touched: true, valid, }); + // custom comparison + /* eslint-disable react-hooks/exhaustive-deps */ }, [ continuousModeDateField, continuousModeDelay, @@ -178,6 +182,7 @@ export const StepDetailsForm: SFC = React.memo(({ overrides = {}, onChang transformDescription, destinationIndex, valid, + /* eslint-enable react-hooks/exhaustive-deps */ ]); return ( diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/use_refresh_interval.ts b/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/use_refresh_interval.ts index 7a2e6b9e623fb..8e505c7cccc02 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/use_refresh_interval.ts +++ b/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/use_refresh_interval.ts @@ -77,5 +77,7 @@ export const useRefreshInterval = ( refreshIntervalSubscription.unsubscribe(); clearRefreshInterval(); }; + // custom comparison + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); // [] as comparator makes sure this only runs once };