-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgraded frontend-build version to v12 #836
Conversation
Codecov ReportBase: 82.43% // Head: 83.17% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #836 +/- ##
==========================================
+ Coverage 82.43% 83.17% +0.73%
==========================================
Files 398 386 -12
Lines 8989 8510 -479
Branches 1895 1828 -67
==========================================
- Hits 7410 7078 -332
+ Misses 1546 1400 -146
+ Partials 33 32 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
…n-portal into bilalqamar95/frontend-build-upgrade
.eslintrc
Outdated
"react/no-unstable-nested-components": [ | ||
2, { "allowAsProps": true } | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't think we should change this rule as it tries to prevent creating potentially unstable components, when React components are defined inline with another component, which indeed does feel like an anti-pattern.
Could we abstract these inline components as a completely standalone component instead?
.eslintrc
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"extends": "@edx/eslint-config", | |||
"parser": "babel-eslint", | |||
"parser": "@babel/eslint-parser", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, ideally this repo (or most MFE repos) wouldn't need a custom .eslintrc file. Most of the stuff in this file is legacy from when this repo was first created in 2018, before @edx/frontend-build
existed.
OK to keep for now, but I'd love to see this repo move away from a custom .eslintrc file in favor of using the default .eslintrc config from @edx/frontend-build
.
subscription: [{}, () => {}], | ||
}; | ||
}), [selectedCourses]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things here:
- Technically,
selectedCourses
will have a new array reference on each re-render ofStepperWrapper
, essentially getting re-created each time. This could causevalue
to change indefinitely instead of being memoized as intended. EitherselectedCourses
should be computed inside theuseMemo
or theselectedCourses
itself should be memoized. - Why was
selectedEmails
replaced with an empty array here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was covered in one of the previous commits, made in light of changes suggested by you on this PR.
); | ||
function BulkEnrollmentSubmitWrapper({ bulkEnrollInfo = defaultBulkEnrollInfo, ...props }) { | ||
return ( | ||
<ToastsContext.Provider value={useMemo(() => ({ addToast }), [])}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: abstract the useMemo
into a variable contextValue
instead of defining it inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was covered in one of the previous commits, made in light of changes suggested by you on this PR.
return ( | ||
<Provider store={mockStore({ portalConfiguration: { enterpriseId: '1234' } })}> | ||
<Router history={history}> | ||
<ToastsContext.Provider value={useMemo(() => ({ addToast: mockAddToast }), [])}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: abstract the useMemo
out of the return statement into its own variable contextValue
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was covered in one of the previous commits, made in light of changes suggested by you on this PR.
@@ -26,11 +26,12 @@ const ToastsProvider = ({ children }) => { | |||
}; | |||
|
|||
return ( | |||
// eslint-disable-next-line react/jsx-no-constructed-context-values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this context value be computed with a useMemo
to avoid ignoring this ESLint rule?
<div className="justify-content-center"> | ||
{config.display_name} | ||
</div> | ||
<span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: unrelated to your change, but we're using block elements (p
) inside of inline elements (span
) which is typically an anti-pattern / not best practice. Any reason not to change the span
to be div
here?
@@ -18,6 +18,7 @@ import { features } from '../../config'; | |||
import NotFoundPage from '../../components/NotFoundPage'; | |||
import { EnterpriseSubsidiesContext } from '../../components/EnterpriseSubsidiesContext'; | |||
|
|||
// eslint-disable-next-line react/function-component-definition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Why is this rule disabled here but in other test files, you've replaced arrow function components with function
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing it here results in following error,
The module factory of jest.mock() is not allowed to reference any out-of-scope variables.
@@ -69,6 +69,7 @@ export const useSubscriptions = ({ enterpriseId, errors, setErrors }) => { | |||
loadCustomerAgreementData(); | |||
}, [loadCustomerAgreementData]); | |||
|
|||
// eslint-disable-next-line react-hooks/exhaustive-deps | |||
useEffect(loadCustomerAgreementData, [enterpriseId]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid ignoring ESLint rules about react-hooks/exhaustive-deps
. Is there a fix here to avoid getting the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be to replace enterpriseId
with loadCustomerAgreementData
in dependency array. When it comes to useEffect
, I generally avoid making these changes just to satisfy the linter
@@ -47,6 +47,7 @@ export const useLinkManagement = (enterpriseUUID) => { | |||
}; | |||
}, [enterpriseUUID]); | |||
|
|||
// eslint-disable-next-line react-hooks/exhaustive-deps | |||
useEffect(loadLinks, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should generally avoid ignoring ESLint rules about react-hooks/exhaustive-deps
. Is there a solution here to avoid needing to disable this rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be to either add loadLinks to the dependency array or remove the array entirely. I have seen these being ignored for useEffect in other areas/repos as well. One such example would be in SSOConfigConfiguredCard.jsx
…portal into bilalqamar95/frontend-build-upgrade
…portal into bilalqamar95/frontend-build-upgrade
PR upgrading frontend-build to v12 was already merged, therefore I'm closing this on |
Git Ticket: 42: Upgrade eslint to v8.x
What changed?
frontend-build
to v12 (Eslint was updated infrontend-build
version resulting in it's version being bumped to v12. This PR updatesfrontend-build
to reciprocate eslint version update)eslint
issuesFor all changes
Only if submitting a visual change