diff --git a/superset-frontend/src/views/CRUD/hooks.ts b/superset-frontend/src/views/CRUD/hooks.ts index ae4b041f6687..ae58aef0d9e0 100644 --- a/superset-frontend/src/views/CRUD/hooks.ts +++ b/superset-frontend/src/views/CRUD/hooks.ts @@ -649,7 +649,7 @@ export function useDatabaseValidation() { null, ); const getValidation = useCallback( - (database: Partial | null, onCreate = false) => { + (database: Partial | null, onCreate = false) => SupersetClient.post({ endpoint: '/api/v1/database/validate_parameters', body: JSON.stringify(database), @@ -658,9 +658,10 @@ export function useDatabaseValidation() { .then(() => { setValidationErrors(null); }) + // eslint-disable-next-line consistent-return .catch(e => { if (typeof e.json === 'function') { - e.json().then(({ errors = [] }: JsonObject) => { + return e.json().then(({ errors = [] }: JsonObject) => { const parsedErrors = errors .filter((error: { error_type: string }) => { const skipValidationError = ![ @@ -748,12 +749,10 @@ export function useDatabaseValidation() { ); setValidationErrors(parsedErrors); }); - } else { - // eslint-disable-next-line no-console - console.error(e); } - }); - }, + // eslint-disable-next-line no-console + console.error(e); + }), [setValidationErrors], );