Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Update create-react-app, craco, & eslint #2042

Draft
wants to merge 2 commits into
base: ogr/develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions src/app/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,35 @@
"react-hooks"
],
"rules": {
"max-statements": [0, 10],
"func-names": "off",
"implicit-arrow-linebreak": "off",
"import/no-cycle": "off",
"import/extensions": "off",
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"import/no-unresolved": "off",
"import/no-useless-path-segments": "off",
"jsx-a11y/label-has-associated-control": "off",
"jsx-a11y/label-has-for": [2, {
"required": {
"every": ["id"]
}
}],
"implicit-arrow-linebreak": "off",
"max-statements": [0, 10],
"object-curly-newline": "off",
"operator-linebreak": "off",
"import/extensions": "off",
"import/no-unresolved": "off",
"import/no-useless-path-segments": "off",
"jsx-a11y/label-has-associated-control": "off",
"prefer-object-spread": "off",
"react/destructuring-assignment": "off",
"react/forbid-prop-types": "off",
"react/function-component-definition": "off",
"react/jsx-fragments": "off",
"react/jsx-props-no-spreading": "off",
"react/jsx-one-expression-per-line": "off",
"react/jsx-wrap-multilines": "off",
"react/prop-types": "off",
"react/sort-comp": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"prefer-object-spread": "off",
"react/jsx-props-no-spreading": "off",
"react/state-in-constructor": "off",
"react/jsx-fragments": "off",
"import/no-cycle": "off",
"react/forbid-prop-types": "off",
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"func-names": "off"
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}
9 changes: 8 additions & 1 deletion src/app/craco.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
module.exports = {
babel: {
plugins: [['@babel/plugin-proposal-class-properties', { loose: true }]],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }],
[
'@babel/plugin-proposal-private-property-in-object',
{ loose: true },
],
['@babel/plugin-proposal-private-methods', { loose: true }],
],
},
webpack: {
configure: (webpackConfig, { env }) => {
Expand Down
22 changes: 13 additions & 9 deletions src/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"license": "MIT",
"private": true,
"dependencies": {
"@craco/craco": "6.1.1",
"@material-ui/core": "3.1.0",
"@material-ui/icons": "3.0.1",
"@turf/distance": "6.0.1",
Expand Down Expand Up @@ -35,7 +34,6 @@
"react-redux": "^7.2.3",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.2",
"react-select": "^4.3.0",
"react-toastify": "4.1.0",
"redux": "^4.0.5",
Expand All @@ -56,20 +54,26 @@
"devDependencies": {
"@babel/core": "^7.18.9",
"@babel/eslint-parser": "^7.18.9",
"@babel/helper-builder-react-jsx": "^7.12.13",
"@babel/plugin-transform-react-jsx": "^7.12.17",
"@babel/plugin-transform-react-jsx-self": "^7.12.13",
"@babel/helper-builder-react-jsx": "^7.18.6",
"@babel/plugin-syntax-flow": "^7.18.6",
"@babel/plugin-transform-react-jsx": "^7.18.10",
"@babel/plugin-transform-react-jsx-self": "^7.18.6",
"@babel/preset-react": "^7.18.6",
"@craco/craco": "alpha",
"babel-jest": "^26.6.0",
"eslint": "^7.11.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.1.0",
"eslint": "^8.21.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"querystring": "npm:[email protected]",
"postcss": "^8.1.0",
"prettier": "2.0.2",
"prettier-loader": "3.3.0"
"prettier-loader": "3.3.0",
"react-scripts": "5.0.1",
"typescript": "^3.8.0"
},
"browserslist": [
">0.2%",
Expand Down
6 changes: 1 addition & 5 deletions src/app/src/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,7 @@ class Routes extends Component {
<Route
exact
path={profileRoute}
component={({
match: {
params: { id },
},
}) => <UserProfile id={id} />}
component={UserProfile}
/>
<Route
exact
Expand Down
2 changes: 1 addition & 1 deletion src/app/src/actions/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const completeUploadFile = createAction('COMPLETE_UPLOAD_FILE');

export const resetUploadState = createAction('RESET_UPLOAD_STATE');

export function uploadFile(file = null, redirectToListDetail) {
export function uploadFile(file, redirectToListDetail) {
return (dispatch, getState) => {
dispatch(startUploadFile());

Expand Down
121 changes: 57 additions & 64 deletions src/app/src/components/ClaimFacilityStepper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,74 +153,67 @@ function ClaimFacilityStepper({

const controlsSection =
activeStepName !== lastStepName ? (
<>
<div style={claimFacilityStepperStyles.formContainerStyles}>
<Typography variant="title">
{nextButtonAction !== SUBMIT_FORM
? `Step ${activeStep + 2}: ${nextStepName}`
: nextStepName}
</Typography>
{error || !stepInputIsValid(formData) ? (
<Typography
variant="body2"
style={
claimFacilityStepperStyles.validationMessageStyles
}
color="error"
>
{error
? 'An error prevented submitting the form'
: 'Some required fields are missing or invalid.'}
</Typography>
) : null}
<div
<div style={claimFacilityStepperStyles.formContainerStyles}>
<Typography variant="title">
{nextButtonAction !== SUBMIT_FORM
? `Step ${activeStep + 2}: ${nextStepName}`
: nextStepName}
</Typography>
{error || !stepInputIsValid(formData) ? (
<Typography
variant="body2"
style={
claimFacilityStepperStyles.buttonsContainerStyles
claimFacilityStepperStyles.validationMessageStyles
}
color="error"
>
{hasBackButton && (
<Button
color="default"
variant="outlined"
onClick={decrementActiveStep}
style={claimFacilityStepperStyles.buttonStyles}
disabled={activeStep === 0}
>
Back
</Button>
)}
{hasNextButton && nextButtonAction !== SUBMIT_FORM && (
<Button
color="primary"
variant="contained"
onClick={incrementActiveStep}
style={claimFacilityStepperStyles.buttonStyles}
disabled={!stepInputIsValid(formData)}
>
Next
</Button>
)}
{hasNextButton && nextButtonAction === SUBMIT_FORM && (
<Button
color="primary"
variant="contained"
onClick={submitClaimForm}
style={claimFacilityStepperStyles.buttonStyles}
disabled={
fetching ||
!claimAFacilityFormIsValid(formData)
}
>
{fetching ? (
<CircularProgress size={5} />
) : (
'Submit'
)}
</Button>
)}
</div>
{error
? 'An error prevented submitting the form'
: 'Some required fields are missing or invalid.'}
</Typography>
) : null}
<div style={claimFacilityStepperStyles.buttonsContainerStyles}>
{hasBackButton && (
<Button
color="default"
variant="outlined"
onClick={decrementActiveStep}
style={claimFacilityStepperStyles.buttonStyles}
disabled={activeStep === 0}
>
Back
</Button>
)}
{hasNextButton && nextButtonAction !== SUBMIT_FORM && (
<Button
color="primary"
variant="contained"
onClick={incrementActiveStep}
style={claimFacilityStepperStyles.buttonStyles}
disabled={!stepInputIsValid(formData)}
>
Next
</Button>
)}
{hasNextButton && nextButtonAction === SUBMIT_FORM && (
<Button
color="primary"
variant="contained"
onClick={submitClaimForm}
style={claimFacilityStepperStyles.buttonStyles}
disabled={
fetching || !claimAFacilityFormIsValid(formData)
}
>
{fetching ? (
<CircularProgress size={5} />
) : (
'Submit'
)}
</Button>
)}
</div>
</>
</div>
) : null;

return (
Expand Down
32 changes: 15 additions & 17 deletions src/app/src/components/ControlledCheckboxInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,21 @@ function ControlledCheckboxInput({
);

return (
<Fragment>
<FormControlLabel
control={
<MaterialCheckbox
id={id}
color="primary"
onChange={onChange}
className={classes.checkbox}
checked={checked}
/>
}
label={labelElement}
classes={{
label: classes.p,
}}
/>
</Fragment>
<FormControlLabel
control={
<MaterialCheckbox
id={id}
color="primary"
onChange={onChange}
className={classes.checkbox}
checked={checked}
/>
}
label={labelElement}
classes={{
label: classes.p,
}}
/>
);
}

Expand Down
40 changes: 19 additions & 21 deletions src/app/src/components/DashboardClaimsDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ InfoSection.propTypes = {
value: node.isRequired,
};

const ParentCompanyLink = ({ data }) => {
const parentCompanyName = get(data, 'facility_parent_company.name', null);

if (!parentCompanyName) {
return '';
}

const profileLink = makeProfileRouteLink(
get(data, 'facility_parent_company.id', null),
);

return (
<Link to={profileLink} href={profileLink}>
{parentCompanyName}
</Link>
);
};

function DashboardClaimsDetails({
getFacilityClaim,
clearFacilityClaim,
Expand Down Expand Up @@ -150,27 +168,7 @@ function DashboardClaimsDetails({
/>
<InfoSection
label="Facility Parent Company / Supplier Group"
value={(() => {
const parentCompanyName = get(
data,
'facility_parent_company.name',
null,
);

if (!parentCompanyName) {
return '';
}

const profileLink = makeProfileRouteLink(
get(data, 'facility_parent_company.id', null),
);

return (
<Link to={profileLink} href={profileLink}>
{parentCompanyName}
</Link>
);
})()}
value={<ParentCompanyLink data={data} />}
/>
<InfoSection
label="Preferred Contact Method"
Expand Down
Loading