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

Standardize imports #6279

Merged
merged 23 commits into from
Nov 24, 2021
Merged

Standardize imports #6279

merged 23 commits into from
Nov 24, 2021

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented Nov 11, 2021

Details

Fixed Issues

$ #6072

Tests

  • Make sure the app builds OK and there are no obvious issues

QA Steps

  • None other than regression testing. This touches a lot of code so it is not realistic to test specific areas of the app. However, there are no changes in behavior so we should just be on the look out for unexpected changes.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Mobile Web

Desktop

iOS

Android

@marcaaron marcaaron self-assigned this Nov 11, 2021
@marcaaron marcaaron changed the title [WIP] Standardize imports [HOLD 11/19] Standardize imports Nov 12, 2021
@marcaaron marcaaron changed the title [HOLD 11/19] Standardize imports [HOLD eslint-config-expensify] Standardize imports Nov 22, 2021
@marcaaron marcaaron marked this pull request as ready for review November 22, 2021 23:28
@marcaaron marcaaron requested a review from a team as a code owner November 22, 2021 23:28
@MelvinBot MelvinBot requested review from jasperhuangg and removed request for a team November 22, 2021 23:29
@marcaaron marcaaron requested review from a team and removed request for jasperhuangg November 23, 2021 18:23
@MelvinBot MelvinBot requested review from jasperhuangg and removed request for a team November 23, 2021 18:23
@marcaaron marcaaron requested a review from a team November 23, 2021 18:28
@MelvinBot MelvinBot removed the request for review from a team November 23, 2021 18:29
@aldo-expensify
Copy link
Contributor

Should we add exceptions for very specific cases? Or perhaps we should just update the usages even if the linter is not complaining? The goal is to get people to mostly do something consistently - my feeling is that even if it's not yet perfect it is better than it was 😄

Yep, had the same doubt, I leave it totally up to you. If I was working on it, I would add it because it is just one, but if we had many (hopefully won't happen) it could become a pain to maintain and I wouldn't do it.

@aldo-expensify
Copy link
Contributor

I think no, but maybe it could be improved on. All our styles live in styles/styles.js with one big default export of all styles and then named exports for the "style helpers". Probably a better way to do this would be to move all the helper methods into something like StyleUtils.js and then import * as StyleUtils from './style/StyleUtils or something like that.

Moving the methods to a new StyleUtils.js sounds like a good way to organize these functions.

I asked this question because I saw some cases where we are still destructuring imports from styles and I don't know if they were intentionally left like that, i.e.:

import styles, {getAutoGrowTextInputStyle} from '../styles/styles';

import styles, {getWidthAndHeightStyle} from '../styles/styles';

@marcaaron
Copy link
Contributor Author

I asked this question because I saw some cases where we are still destructuring imports from styles and I don't know if they were intentionally left like that, i.e.:

Yeah maybe this is a bit confusing, but the new guidance is to only warn if we are not mixing default and named together in one import so those examples you shared are actually OK but something like this would not be OK...

 import {getAutoGrowTextInputStyle} from '../styles/styles'; 

@marcaaron
Copy link
Contributor Author

It gets confusing when you are not mixing these together e.g. how should we fix that previous example?

import * as StyleUtils from '../styles/styles'; 

Doesn't seem quite right if there's still a default export. Gonna take some time to fix these up since @jasperhuangg had a similar question and this will probably remain confusing. I think the long term mission is to stop mixing these together and just use one or the other.

@marcaaron marcaaron changed the title [HOLD eslint-config-expensify] Standardize imports Standardize imports Nov 24, 2021
@marcaaron
Copy link
Contributor Author

Ok, I think we are good now once e2e finishes 🤞

@aldo-expensify
Copy link
Contributor

I asked this question because I saw some cases where we are still destructuring imports from styles and I don't know if they were intentionally left like that, i.e.:

Yeah maybe this is a bit confusing, but the new guidance is to only warn if we are not mixing default and named together in one import so those examples you shared are actually OK but something like this would not be OK...

 import {getAutoGrowTextInputStyle} from '../styles/styles'; 

I see, thanks for explaining

Copy link
Contributor

@aldo-expensify aldo-expensify left a comment

Choose a reason for hiding this comment

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

I think your have to update the package-lock.json

"resolved": "https://registry.npmjs.org/eslint-config-expensify/-/eslint-config-expensify-2.0.18.tgz",
"integrity": "sha512-jEBAcXWm89NptiprvlBrRoDsK8zJbbkt8yVZOgzo/Vadp86gL0oc7blgyLfJHA2cjecs1kgfPYGByXb6V8v8cw==",
"version": "2.0.19",
"resolved": "git+https://github.com/Expensify/eslint-config-expensify.git#afc71e84361cc68af4a85b425b3a599c4ac1861d",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be updated. If I try to do npm install with the committed package-lock.json, I get this error:

npm ERR! code 128
npm ERR! Command failed: git checkout afc71e84361cc68af4a85b425b3a599c4ac1861d
npm ERR! fatal: reference is not a tree: afc71e84361cc68af4a85b425b3a599c4ac1861d
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/aldocanepa/.npm/_logs/2021-11-24T18_57_59_383Z-debug.log

Deleting the package-lock.json and running npm install changes to:

"eslint-config-expensify": {
    "version": "2.0.19",
    "resolved": "git+https://github.com/Expensify/eslint-config-expensify.git#e1edb2cfe7fd91b9b131187cb19481ba9d29705b",
    ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh hmm weird..

@marcaaron
Copy link
Contributor Author

@aldo-expensify let me know if that solved it for ya!

@aldo-expensify
Copy link
Contributor

@aldo-expensify let me know if that solved it for ya!

It did 👍

Copy link
Contributor

@aldo-expensify aldo-expensify left a comment

Choose a reason for hiding this comment

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

Looks good to me! feel free to merge once the e2e tests pass!

@marcaaron marcaaron merged commit 2b7d6d0 into main Nov 24, 2021
@marcaaron marcaaron deleted the marcaaron-standardizeImports branch November 24, 2021 20:58
@botify
Copy link

botify commented Nov 24, 2021

@marcaaron looks like this was merged without passing tests. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@marcaaron
Copy link
Contributor Author

Tbh I don't know why the Emergency label was added - it looks like the tests passed to me. If there was a test still going it must have been the E2E and I missed that it was running. But there's no Emergency here.

@marcaaron
Copy link
Contributor Author

2021-11-24_11-09-46

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @marcaaron in version: 1.1.16-11 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Dec 6, 2021

🚀 Deployed to production by @roryabraham in version: 1.1.17-7 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants