[ML] Transforms: Removes temporary x-pack/legacy/plugins/transform eslint overrides.

Re-enables linting rules related to React hooks and adapts inline code.
This commit is contained in:
Walter Rafelsberger 2019-10-30 08:07:09 -07:00 committed by GitHub
parent 0efe6a2f16
commit b368c6acba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 22 additions and 7 deletions

View file

@ -229,12 +229,6 @@ module.exports = {
'react-hooks/exhaustive-deps': 'off', '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}'], files: ['x-pack/legacy/plugins/uptime/**/*.{js,ts,tsx}'],
rules: { rules: {

View file

@ -95,6 +95,8 @@ export const useRefreshTransformList = (
return () => { return () => {
subscriptions.map(sub => sub.unsubscribe()); subscriptions.map(sub => sub.unsubscribe());
}; };
// The effect should only be called once.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
return { return {

View file

@ -75,6 +75,8 @@ export const KibanaProvider: FC<Props> = ({ savedObjectId, children }) => {
useEffect(() => { useEffect(() => {
fetchSavedObject(savedObjectId); fetchSavedObject(savedObjectId);
// fetchSavedObject should not be tracked.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [savedObjectId]); }, [savedObjectId]);
return <KibanaContext.Provider value={contextValue}>{children}</KibanaContext.Provider>; return <KibanaContext.Provider value={contextValue}>{children}</KibanaContext.Provider>;

View file

@ -131,6 +131,8 @@ export const useSourceIndexData = (
useEffect(() => { useEffect(() => {
getSourceIndexData(); getSourceIndexData();
// custom comparison
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [indexPattern.title, JSON.stringify(query)]); }, [indexPattern.title, JSON.stringify(query)]);
return { errorMessage, status, tableItems }; return { errorMessage, status, tableItems };
}; };

View file

@ -76,6 +76,8 @@ export const StepCreateForm: SFC<Props> = React.memo(
useEffect(() => { useEffect(() => {
onChange({ created, started, indexPatternId }); onChange({ created, started, indexPatternId });
// custom comparison
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [created, started, indexPatternId]); }, [created, started, indexPatternId]);
const api = useApi(); const api = useApi();

View file

@ -150,7 +150,7 @@ export const PivotPreview: SFC<PivotPreviewProps> = React.memo(({ aggs, groupBy,
if (clearTable) { if (clearTable) {
setTimeout(() => setClearTable(false), 0); setTimeout(() => setClearTable(false), 0);
} }
}); }, [firstColumnNameChanged, clearTable]);
if (firstColumnNameChanged) { if (firstColumnNameChanged) {
return null; return null;

View file

@ -487,6 +487,8 @@ export const StepDefineForm: SFC<Props> = React.memo(({ overrides = {}, onChange
sourceConfigUpdated, sourceConfigUpdated,
valid, valid,
}); });
// custom comparison
/* eslint-disable react-hooks/exhaustive-deps */
}, [ }, [
JSON.stringify(pivotAggsArr), JSON.stringify(pivotAggsArr),
JSON.stringify(pivotGroupByArr), JSON.stringify(pivotGroupByArr),
@ -495,6 +497,7 @@ export const StepDefineForm: SFC<Props> = React.memo(({ overrides = {}, onChange
searchString, searchString,
searchQuery, searchQuery,
valid, valid,
/* eslint-enable react-hooks/exhaustive-deps */
]); ]);
// TODO This should use the actual value of `indices.query.bool.max_clause_count` // TODO This should use the actual value of `indices.query.bool.max_clause_count`

View file

@ -91,11 +91,14 @@ export const usePivotPreviewData = (
useEffect(() => { useEffect(() => {
getPreviewData(); getPreviewData();
// custom comparison
/* eslint-disable react-hooks/exhaustive-deps */
}, [ }, [
indexPattern.title, indexPattern.title,
JSON.stringify(aggsArr), JSON.stringify(aggsArr),
JSON.stringify(groupByArr), JSON.stringify(groupByArr),
JSON.stringify(query), JSON.stringify(query),
/* eslint-enable react-hooks/exhaustive-deps */
]); ]);
return { errorMessage, status, previewData, previewMappings, previewRequest }; return { errorMessage, status, previewData, previewMappings, previewRequest };

View file

@ -121,6 +121,8 @@ export const StepDetailsForm: SFC<Props> = React.memo(({ overrides = {}, onChang
} }
} }
})(); })();
// custom comparison
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [kibanaContext.initialized]); }, [kibanaContext.initialized]);
if (!isKibanaContextInitialized(kibanaContext)) { if (!isKibanaContextInitialized(kibanaContext)) {
@ -169,6 +171,8 @@ export const StepDetailsForm: SFC<Props> = React.memo(({ overrides = {}, onChang
touched: true, touched: true,
valid, valid,
}); });
// custom comparison
/* eslint-disable react-hooks/exhaustive-deps */
}, [ }, [
continuousModeDateField, continuousModeDateField,
continuousModeDelay, continuousModeDelay,
@ -178,6 +182,7 @@ export const StepDetailsForm: SFC<Props> = React.memo(({ overrides = {}, onChang
transformDescription, transformDescription,
destinationIndex, destinationIndex,
valid, valid,
/* eslint-enable react-hooks/exhaustive-deps */
]); ]);
return ( return (

View file

@ -77,5 +77,7 @@ export const useRefreshInterval = (
refreshIntervalSubscription.unsubscribe(); refreshIntervalSubscription.unsubscribe();
clearRefreshInterval(); clearRefreshInterval();
}; };
// custom comparison
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); // [] as comparator makes sure this only runs once }, []); // [] as comparator makes sure this only runs once
}; };