Skip to content

Commit

Permalink
[ML] Transforms: Removes temporary x-pack/legacy/plugins/transform
Browse files Browse the repository at this point in the history
…eslint overrides.

Re-enables linting rules related to React hooks and adapts inline code.
  • Loading branch information
walterra authored Oct 30, 2019
1 parent 0efe6a2 commit b368c6a
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 7 deletions.
6 changes: 0 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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,
Expand All @@ -178,6 +182,7 @@ export const StepDetailsForm: SFC<Props> = React.memo(({ overrides = {}, onChang
transformDescription,
destinationIndex,
valid,
/* eslint-enable react-hooks/exhaustive-deps */
]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

0 comments on commit b368c6a

Please sign in to comment.