-
Notifications
You must be signed in to change notification settings - Fork 16
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
chore: upgrade React; use new JSX transform; sort imports #1129
Conversation
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.
Lgtm, just need to shift the modules import order
import cx from 'classnames' | ||
|
||
import styles from './ActionButton.module.scss' | ||
|
||
import type { MouseEvent as ReactMouseEvent } from 'react' |
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.
Let's move this up top together with the react import, combine them if possible?
import cx from 'classnames' | ||
|
||
import styles from './BodyWrapper.module.scss' | ||
|
||
import type { FunctionComponent } from 'react' | ||
|
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.
To follow the import order convention, external module imports should be at the top. We could also look into if we want to use this plugin to sort import order
https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md#importorder-enforce-a-convention-in-module-import-order
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.
Thanks! I agree about sorting the import order with a plugin. I've looked into both eslint-plugin-import
and eslint-plugin-simple-import-sort
and settled on the eslint-plugin-import
since it better supports module aliasing.
I've just rebased the branch atop Just to clarify, eslint-plugin-import sorts imports into the following groups, with newlines between each group:
|
@lamkeewei I had suggested using an eslint plugin to auto sort import order for our frontend, wanted to get your go ahead too |
Sure! Will make our imports neater. Might also be useful to think about what is a good sort order for our imports, beyond the default rules (e.g. assets should be first/last, etc). Can refer to what vaccine ops did for their sorting. |
We don't need this in the root directory.
This release introduces support for the new JSX transform. Changelog: https://github.com/facebook/react/blob/master/CHANGELOG.md#16140-october-14-2020
Also, use `import type` where it makes sense. Note: React's ``MouseEvent` type conflicts with the global `MouseEvent` type, so rename it to `ReactMouseEvent` as well.
The group order is: 1. builtin modules (e.g. Node) 2. external modules (e.g. react) 3. parent relative models (e.g. ../xyz) 4. sibling modules (e.g. ./abc) 5. index file (e.g. ./index.ts) 6. import-mapped modules (e.g. classes, components)
Rebased the branch. Todo: However, I don't feel like this is a big deal. The existing import order seems good to me. |
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 sorted import order is sufficient for now, improvising it has been delegated to a separate issue
* develop: fix: fix error when updating Telegram ID for an existing phone number (#1178) chore: upgrade React; use new JSX transform; sort imports (#1129) fix(backend): docker build and tsc output directory structure (#1177) feat: refactor msg template components; add telegram character limit (#1148) refactor: use shared function to initialize models (#1172) chore: setup scaffolding for backend tests (#940) 1.23.0 fix(frontend): fix frontend test flakiness (#1162) fix: update successful delivery status only if error does not exist (#1150) chore: upgrade dependencies (#1153)
Problem
Let's upgrade to the new JSX transform to stay modern.
React has introduced the new JSX transform to enable improvements in future React releases. Although it does nothing significant as of now, it might be a good idea to upgrade anyway to stay up-to-date.
Reference on transitioning to the new JSX transform: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
Solution
Improvements:
frontend
directoryimport React from 'react'
->import { ... } from 'react'
)Before & After Screenshots
No visual changes.
Tests
These tests have been verified locally but not on Amplify staging yet.
Deploy Notes
Upgraded dependencies:
react
,react-dom
: 16.31.1 -> 16.14.0@types/react
: 16.9.29 -> 16.14.5@types/react-dom
: 16.9.5 -> 16.9.12