[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',
},
},
{
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: {

View file

@ -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 {

View file

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

View file

@ -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 };
};

View file

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

View file

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

View file

@ -487,6 +487,8 @@ export const StepDefineForm: SFC<Props> = 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<Props> = 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`

View file

@ -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 };

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]);
if (!isKibanaContextInitialized(kibanaContext)) {
@ -169,6 +171,8 @@ export const StepDetailsForm: SFC<Props> = 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<Props> = React.memo(({ overrides = {}, onChang
transformDescription,
destinationIndex,
valid,
/* eslint-enable react-hooks/exhaustive-deps */
]);
return (

View file

@ -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
};