fix: linting errors

This commit is contained in:
Adolfo R. Brandes
2025-12-12 13:54:18 -03:00
committed by Adolfo R. Brandes
parent 4f79099eca
commit dad2887eed
10 changed files with 18 additions and 24 deletions

View File

@@ -16,8 +16,8 @@ export async function getThirdPartyAuthContext(urlParams) {
throw (e);
});
return {
fieldDescriptions: data.registrationFields || {},
optionalFields: data.optionalFields || {},
thirdPartyAuthContext: data.contextData || {},
fieldDescriptions: data.registrationFields ?? {},
optionalFields: data.optionalFields ?? {},
thirdPartyAuthContext: data.contextData ?? {},
};
}

View File

@@ -10,7 +10,7 @@ import { breakpoints } from '@openedx/paragon';
const useMobileResponsive = (breakpoint) => {
const [isMobileWindow, setIsMobileWindow] = useState();
const checkForMobile = () => {
setIsMobileWindow(window.matchMedia(`(max-width: ${breakpoint || breakpoints.small.maxWidth}px)`).matches);
setIsMobileWindow(window.matchMedia(`(max-width: ${breakpoint ?? breakpoints.small.maxWidth}px)`).matches);
};
useEffect(() => {
checkForMobile();

View File

@@ -20,7 +20,7 @@ export function* handleForgotPassword(action) {
yield put(forgotPasswordSuccess(action.payload.email));
} catch (e) {
if (e.response && e.response.status === 403) {
if (e.response?.status === 403) {
yield put(forgotPasswordForbidden());
logInfo(e);
} else {

View File

@@ -63,8 +63,8 @@ export const validateEmailAddress = (value, username, domainName) => {
const tldSuggestion = !DEFAULT_TOP_LEVEL_DOMAINS.includes(topLevelDomain);
const serviceSuggestion = getLevenshteinSuggestion(serviceLevelDomain, DEFAULT_SERVICE_PROVIDER_DOMAINS, 2);
if (DEFAULT_SERVICE_PROVIDER_DOMAINS.includes(serviceSuggestion || serviceLevelDomain)) {
suggestion = `${username}@${serviceSuggestion || serviceLevelDomain}.com`;
if (DEFAULT_SERVICE_PROVIDER_DOMAINS.includes(serviceSuggestion ?? serviceLevelDomain)) {
suggestion = `${username}@${serviceSuggestion ?? serviceLevelDomain}.com`;
}
if (!hasMultipleSubdomains && tldSuggestion) {

View File

@@ -74,7 +74,7 @@ const reducer = (state = defaultState, action = {}) => {
registrationError: { ...action.payload },
submitState: DEFAULT_STATE,
validations: null,
usernameSuggestions: usernameSuggestions || state.usernameSuggestions,
usernameSuggestions: usernameSuggestions ?? state.usernameSuggestions,
};
}
case REGISTRATION_CLEAR_BACKEND_ERROR: {
@@ -90,7 +90,7 @@ const reducer = (state = defaultState, action = {}) => {
return {
...state,
validations: validationWithoutUsernameSuggestions,
usernameSuggestions: usernameSuggestions || state.usernameSuggestions,
usernameSuggestions: usernameSuggestions ?? state.usernameSuggestions,
};
}
case REGISTER_FORM_VALIDATIONS.FAILURE:

View File

@@ -44,7 +44,7 @@ export function* fetchRealtimeValidations(action) {
yield put(fetchRealtimeValidationsSuccess(camelCaseObject(fieldValidations)));
} catch (e) {
if (e.response && e.response.status === 403) {
if (e.response?.status === 403) {
yield put(fetchRealtimeValidationsFailure());
logInfo(e);
} else {

View File

@@ -22,7 +22,7 @@ const getBackendValidations = createSelector(
const validationDecisions = {};
fields.forEach(field => {
validationDecisions[field] = registrationError[field][0].userMessage || '';
validationDecisions[field] = registrationError[field][0].userMessage ?? '';
});
return validationDecisions;
}

View File

@@ -18,8 +18,8 @@ export async function registerRequest(registrationInformation) {
});
return {
redirectUrl: data.redirect_url || `${getSiteConfig().lmsBaseUrl}/dashboard`,
success: data.success || false,
redirectUrl: data.redirect_url ?? `${getSiteConfig().lmsBaseUrl}/dashboard`,
success: data.success ?? false,
authenticatedUser: data.authenticated_user,
};
}

View File

@@ -43,9 +43,7 @@ export const isFormValid = (
Object.keys(payload).forEach(key => {
switch (key) {
case 'name':
if (!fieldErrors.name) {
fieldErrors.name = validateName(payload.name, formatMessage);
}
fieldErrors.name ||= validateName(payload.name, formatMessage);
if (fieldErrors.name) {
isValid = false;
}
@@ -71,17 +69,13 @@ export const isFormValid = (
break;
}
case 'username':
if (!fieldErrors.username) {
fieldErrors.username = validateUsername(payload.username, formatMessage);
}
fieldErrors.username ||= validateUsername(payload.username, formatMessage);
if (fieldErrors.username) {
isValid = false;
}
break;
case 'password':
if (!fieldErrors.password) {
fieldErrors.password = validatePasswordField(payload.password, formatMessage);
}
fieldErrors.password ||= validatePasswordField(payload.password, formatMessage);
if (fieldErrors.password) {
isValid = false;
}

View File

@@ -26,7 +26,7 @@ export function* handleValidateToken(action) {
yield put(passwordResetFailure(PASSWORD_RESET.INVALID_TOKEN));
}
} catch (err) {
if (err.response && err.response.status === 429) {
if (err.response?.status === 429) {
yield put(passwordResetFailure(PASSWORD_RESET.FORBIDDEN_REQUEST));
logInfo(err);
} else {
@@ -51,7 +51,7 @@ export function* handleResetPassword(action) {
yield put(resetPasswordFailure(PASSWORD_VALIDATION_ERROR, resetErrors));
}
} catch (err) {
if (err.response && err.response.status === 429) {
if (err.response?.status === 429) {
yield put(resetPasswordFailure(PASSWORD_RESET.FORBIDDEN_REQUEST));
logInfo(err);
} else {