Skip to content
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

Upgrade to react-scripts 5 #249

Merged
merged 12 commits into from
Feb 2, 2022
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
},
extends: [
"react-app",
"react-app/jest",
Copy link
Contributor Author

@dylnclrk dylnclrk Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ CRA includes this extend now. I wonder if that includes plugin:jest/recommended, which makes the below extend a dupe.

"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
Expand Down
1 change: 1 addition & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ module.exports = {
"selector-no-qualifying-type": true,
"string-quotes": "double",
"value-list-comma-newline-after": null,
"scss/comment-no-empty": null,
},
};
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM node:16.13.2-alpine
WORKDIR /app-prototype
COPY package.json yarn.lock ./
RUN npx yarn@1.12.1 install --production
RUN npx yarn@1.22.17 install
COPY . .
RUN DISABLE_ESLINT_PLUGIN=true npm run build
RUN npm run build
EXPOSE 3000
ENV NODE_ENV=production
CMD npx --no-install serve -s
38 changes: 18 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,16 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/node": "^16.11.21",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"classnames": "^2.3.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"sass": "^1.45.1",
"serve": "^13.0.2",
"typescript": "^4.5.4"
},
"devDependencies": {
"@testing-library/dom": "^8.11.1",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.4.0",
"eslint": "^7.32.0",
"@types/node": "^16.11.21",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"classnames": "^2.3.1",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-jest": "^25.3.4",
"eslint-plugin-prettier": "^4.0.0",
Expand All @@ -30,16 +22,23 @@
"lint-staged": "^12.1.4",
"npm-run-all": "^4.1.3",
"prettier": "2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"sass": "^1.48.0",
"serve": "^13.0.2",
"shelljs": "^0.8.5",
"stylelint": "^13.12.0",
"stylelint-config-recommended-scss": "^4.3.0",
"stylelint-config-standard": "^22.0.0",
"stylelint": "^14.2.0",
"stylelint-config-recommended-scss": "^5.0.2",
"stylelint-config-standard": "^24.0.0",
"stylelint-declaration-strict-value": "^1.8.0",
"stylelint-scss": "^3.21.0"
"stylelint-scss": "^4.1.0",
"typescript": "^4.5.4",
"web-vitals": "^2.1.3"
},
"resolutions": {
"@typescript-eslint/typescript-estree": "^5.6.0",
Copy link
Contributor Author

@dylnclrk dylnclrk Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ I dropped this resolution @typescript-eslint/typescript-estree because I wasn't sure why it was in there, and getting rid of it didn't seem to have an effect.

"caniuse-lite": "^1.0.30001272"
"caniuse-lite": "^1.0.30001299",
Copy link
Contributor Author

@dylnclrk dylnclrk Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ Updated the caniuse-lite def to match what was installed from scratch

"mini-css-extract-plugin": "2.4.7"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦 This is a temporary workaround for this issue: facebook/create-react-app#11930

},
"scripts": {
"prepare": "husky install",
Expand Down Expand Up @@ -71,7 +70,6 @@
"production": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"development": [
Expand Down
3 changes: 3 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Not sure if this was intentionally omitted before, but it was generated by create-react-app

User-agent: *
Disallow:
4 changes: 2 additions & 2 deletions src/App.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
pointer-events: none;

@media (prefers-reduced-motion: no-preference) {
animation: App-logo-spin infinite 20s linear;
animation: app-logo-spin infinite 20s linear;
}
}

Expand All @@ -34,7 +34,7 @@
color: colors.$blue;
}

@keyframes App-logo-spin {
@keyframes app-logo-spin {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ New stylelint rule wants keyframes to be lower-kebab-case.

from {
transform: rotate(0deg);
}
Expand Down
6 changes: 6 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import React from "react";
import ReactDOM from "react-dom";
import "./index.scss";
import App from "./App";
import reportWebVitals from "./reportWebVitals";

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root")
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
Comment on lines +13 to +17
Copy link
Contributor Author

@dylnclrk dylnclrk Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ Here's the boilerplate for web-vitals. More info on the linked page.

15 changes: 15 additions & 0 deletions src/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ReportHandler } from "web-vitals";

const reportWebVitals = (onPerfEntry?: ReportHandler) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣 Would be funny if this code affected these metrics.

if (onPerfEntry && onPerfEntry instanceof Function) {
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};

export default reportWebVitals;
2 changes: 1 addition & 1 deletion src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom/extend-expect";
import "@testing-library/jest-dom";
Copy link
Contributor Author

@dylnclrk dylnclrk Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ CRA generates this file with the shorter import (which matches the docs)

5 changes: 3 additions & 2 deletions src/theme/colors.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@use "sass:color";
$blue: #61dafb;
$blue-darker: darken($blue, 30%);
$blue-lighter: lighten($blue, 5%);
$blue-darker: color.adjust($blue, $lightness: -30%);
$blue-lighter: color.adjust($blue, $lightness: 5%);
Comment on lines +1 to +4
Copy link
Contributor Author

@dylnclrk dylnclrk Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ stylelint doesn't want you to use darken/lighten any more.


$white: #fff;
$gray-28: #282c34;
Expand Down
Loading