-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Rename and clean up custom Text
and Button
components.
#3133
Comments
Really like the idea to clean these up. I recently went through and did something similar with all the I like the idea to try to prevent incorrect usages, but maybe you're right that the name change is enough for now. Probably once there are no more usages of |
Removing N6 hold, might work on this from the plane later today |
Going to send this back into the pool. |
I've renamed the components in #6538. I'll announce it in #expensify-open-source once it's merged so people know as well. There are still some cases of the react-native I'll look into the bonus solutions a bit as well.
I don't think this will work because our custom components and some other ones do use the react-native |
Nice! A little while back, @marcaaron wrote up this handy-dandy SO on writing custom ESLint plugins. So we could make a lint rule prohibiting the use of the RN default components, and just disable the rule in the locations where we're intentionally making exceptions. Still a bonus solution, but it's doable if it interests you 😄 |
Nice, thanks for that! I looked into this a bit and I think there's actually an easier way we can do it rather than creating a custom rule. ESLint has a default rule called
It seems that you can't have RuleTester test their built-in rules, but it seems to work well: What do you think @roryabraham @marcaaron? |
Ooh nice find @puneetlath! Seems perfect for this use case. |
Sweet, I'll get that added. Tracking the todos for it here: https://github.com/Expensify/Expensify/issues/187203 |
@anthony-hull suggested we also add an ESLint rule for I think it makes sense. What do y'all think? |
Sure, sounds good to me @puneetlath |
Problem
I have observed in my own work and in PR reviews that a common pitfall in Expensify.cash is to do this:
Which will result in text that does not have the correct font, line height, etc...
Why this is important?
Especially for new contributors, or when working with fancy IDE's such as WebStorm that auto-import things for you, it's an easy mistake to make. It's also an easy mistake to miss, because it's not always easy to tell the difference between GT America and the default font (on Android, in particular).
Solution
Rename our custom
Text
component and our customButton
component toExpensifyText
andExpensifyButton
, respectively. That should help make it clear to newcomers and reviewers that we should generally always be using our custom component. Some potential bonus solutions:Put something like this in
index.js
:Implement a new ESLint rule that complains if you create a custom component that shadows the name of a standard RN library component.
Platform:
Where is this issue occurring?
Web
iOS
Android
Desktop App
Mobile Web
Version Number: 1.0.53-0
The text was updated successfully, but these errors were encountered: