-
Notifications
You must be signed in to change notification settings - Fork 3
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 v5 #695
Conversation
babel cannot find the File import from react-filepond, but it can be imported from filepond. i don't understand :/
@@ -1,4 +1,3 @@ | |||
{ | |||
"extends": ["plugin:prettier/recommended"], | |||
"parser": "babel-eslint" | |||
"extends": ["react-app"] |
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.
see my comment in the PR description
"eslint-plugin-react": "^7.20.3", | ||
"eslint-plugin-react-hooks": "^2.5.1", | ||
"prettier": "^1.19.1" | ||
}, |
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.
see my comment in the PR description about eslint
@@ -7,23 +7,27 @@ | |||
* | |||
* @return {string} - Formatted string. | |||
*/ | |||
export default (bytes, si=false, dp=1) => { | |||
const thresh = si ? 1000 : 1024; | |||
const humanReadableFileSize = (bytes, si = false, dp = 1) => { |
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.
Here is the change that fixed the ESLint warning - the rest is prettification
background-image: url(/moped/static/images/mapAerial.jpg) !important; | ||
color: white; | ||
} | ||
|
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.
it's now impossible to reference files in /public
directory in CSS that lives in /src
. The workaround here was to use our existing styles that we build in ProjectComponentsBaseMap.js
@@ -5,38 +5,38 @@ | |||
* @default | |||
*/ | |||
export const StaffListViewExportConf = { |
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.
linting
@@ -24,9 +24,6 @@ | |||
"test": "react-scripts test", | |||
"eject": "react-scripts eject" | |||
}, | |||
"eslintConfig": { | |||
"extends": "react-app" | |||
}, |
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.
The react-app
ESLint config is Create React App's base lint configuration. As far as I can tell, this config was previously being ignored, because we're using an .eslintrc
file which overrode the package.json
config.
Docs:
If there are multiple configuration files in the same directory, ESLint will only use one. The priority order is as follows:
.eslintrc.js
.eslintrc.cjs
.eslintrc.yaml
.eslintrc.yml
.eslintrc.json
package.json
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.
Thank you for this very detailed documentation via your opening PR comment. It's been exceptionally helpful both in terms of understanding the PR's contents itself, but also will serve as a useful reference for me going forward. 🙏
I've tested this both locally and on test, and I've found that everything you enumerated in your PR description works as expected:
- Local
- Deployment spins up
- Live-refresh on code-change
- Jest tests 💯
- Test
- File upload
- Static images referenced via CSS
Thanks for the chance to review this. I've gone through the code changes, and everything makes sense to me, but take me with a grain of salt 🧂 - I'm eager to learn from our more seasoned JS devs' reviews too.
thanks @frankhereford! btw, here's a diff of |
@johnclary wrote:
Wow - It's a sisyphean task 🪨 and this is a huge step forward. You got a lot of libraries (~40!!) updated or removed! You know that makes my day -- I realize this is a complex process to say the least, and I really am thankful for this PR!! |
@@ -87,24 +84,15 @@ | |||
"react-quill": "^2.0.0-beta.4", | |||
"react-router": "^6.3.0", | |||
"react-router-dom": "^6.3.0", | |||
"react-scripts": "^3.4.1", | |||
"react-scripts": "^5.0.0", |
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.
🎊
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.
Tested locally, runs as expected. I'm leaning towards suppressing the build warning, unless theres a different fix on the horizon for the DoubleScrollbar.js.map package. I can be convinced otherwise though.
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.
I tested this locally and in the deploy preview, and it works great. Thanks for pushing us forward here - the hot reload is so great! Such a nice DX enhancement.
Happy to see someone getting into the lint config and cut out some of the unneeded stuff too. It will make it easier to see how to move forward there. ✨
import { FilePond, registerPlugin } from "react-filepond"; | ||
// `File` imported from filepond to workaround react-scripts 5 import error | ||
import { File } from "filepond" |
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.
File uploads still work great in the deploy preview 👍
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.
Project files and static images are looking good on Netlify! 👍 🚢
thanks, y'all—here we go! |
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.
👍
Associated issues
cityofaustin/atd-data-tech#9561
Steps I took (for reference):
$ nvm use
😉/node_modules
andpackage-lock.json
package.json
to removereact-map-gl-draw
package.json
to remove alldevDependencies
react-scripts
inpackage.json
to^5.0.0
package-lock.json
:$ npm install
react-map-gl-draw
again, forcibly:$ npm install react-map-gl-draw@^0.22.3 --force
peerDependencies
ofreact-map-gl-draw
to^17.x
inpackage-lock.json
$ npm install --save-dev babel-plugin-import
eslintConfig
inpackage.json
and update.eslintrc.json
$ npm run test
⚙️$ npm run start
✨About our ESLint config
It's been hard for me to untangle the effects of this upgrade on linting. We're migrating from ESLint v6 to v8, as well as upgrading a number of related parsers and configs.
Also, as far as I can tell, the
react-app
ESLint config was previously being ignored, because it was defined inpackage.json
, and it was being overwritten by our.eslintrc
file (docs).One issue I immediately encountered were errors with anonymous default exports. That rule has been in place for years, but was maybe only enabled by
react-app
? 🤔. Anyway, I addressed those errors in this PR.The
react-app
ESLint config is Create React App's base lint configuration, and they recommend that we do not ignore it. It's now enabled. Besides a few anonymous default export problems, the app is (surprisingly?) compiling without errors.Additionally, we had a number of ESLint plugins through
eslint-config-airbnb
. However, none of these configs were enabled in our.eslintrc
file. I removed them:And, lastly, i removed the
prettier
linting configs as well. I don't fully understand, but the latest version threw a lot of errors and clearly had different opinions than our previous setup.In summary, we need to revisit all of our linting soon.
Other notes
npm install
will fail without our package-lock.json. we are stuck dealing with force installingreact-map-gl-draw
for the near future.DoubleScrollbar.js
:Seems harmless, and it's possible to suppress the warning. Discussed here.
Testing
URL to test: deploy preview and local
If testing locally
$ nvm use
node_modules/
and then$ npm install
, but who knows$ npm run test
Things to test
Ship list
Added to QA test script if applicable