Skip to content

[$500] Create an ESLint rule to detect multiple uses of withOnyx #27463

Closed

Description

@tgolen

Problem

When withOnyx is used multiple times while composing components, it adds overhead to what Onyx has to keep track of and also prevents optimizations like batched render updates from working to their full potential.

Solution

Create a custom ESLint in https://github.com/Expensify/eslint-config-expensify/tree/main/eslint-plugin-expensify which detects when withOnyx() is used multiple times in the same file, and throws an error. The error should give instructions on the best practices which is something like:

Only use withOnyx() once. If there are dependent Onyx keys, they can all be handled in a single instance of withOnyx through the use of selectors.

That should also link to the Onyx readme, and I'm going to write a specific section in there about the best practice that we can link to.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f185d4f92edd4f6c
  • Upwork Job ID: 1702383017796775936
  • Last Price Increase: 2023-09-14
  • Automatic offers:
    • mollfpr | Reviewer | 26743007
    • studentofcoding | Contributor | 26743012

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    NewFeatureSomething to build that is a new item.
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 14, 2023
  2. changed the title [-]Create an ESLint rule to detect multiple uses of withOnyx[/-] [+][$500] Create an ESLint rule to detect multiple uses of withOnyx[/+] on Sep 14, 2023
  3. melvin-bot commented on Sep 14, 2023

    @melvin-bot
  4. melvin-bot commented on Sep 14, 2023

    @melvin-bot
  5. melvin-bot commented on Sep 14, 2023

    @melvin-bot

    Triggered auto assignment to @puneetlath (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

  6. melvin-bot commented on Sep 14, 2023

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @mollfpr (External)

  7. needpower commented on Sep 14, 2023

    @needpower

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    withOnyx() can be called multiple times while composing components.

    What is the root cause of that problem?

    Sometimes developers do not notice that withOnyx() is already called, and create a new call instead of extending the existing one.

    What changes do you think we should make in order to solve the problem?

    Create a new eslint rule in https://github.com/Expensify/eslint-config-expensify/blob/main/eslint-plugin-expensify/ called no-multiple-onyx-calls which will display an error message in case of multiple calls, e.g.

    export default compose(
        withOnyx({
            isCheckingPublicRoom: {
                key: ONYXKEYS.IS_CHECKING_PUBLIC_ROOM,
                initWithStoredValues: false,
            }
        }),
        withOnyx({
            isSidebarLoaded: {
                key: ONYXKEYS.IS_SIDEBAR_LOADED,
            },
        })
    )(Component)

    What alternative solutions did you explore? (Optional)

    N/A

  8. 23 remaining items

  9. studentofcoding commented on Sep 19, 2023

    @studentofcoding
    Contributor

    Thanks, @neil-marcellini

    Upon Reading the Readme on https://github.com/Expensify/eslint-config-expensify it's said that the PR should be there, therefore it's ready to review on Expensify/eslint-config-expensify#73 @mollfpr @tgolen

  10. studentofcoding commented on Sep 21, 2023

    @studentofcoding
    Contributor

    The follow up PR is ready for review @tgolen @mollfpr #27840, thanks!

  11. studentofcoding commented on Sep 22, 2023

    @studentofcoding
    Contributor

    Hey @MelvinBot the PR is merged yesterday (takes 2 days)

  12. studentofcoding commented on Sep 27, 2023

    @studentofcoding
    Contributor

    Hey @tgolen, as the PR is merged 6 days ago, and @MelvinBot didn't automatically report it. I believe the waiting time for payment is only 1 day left and tomorrow it should be released right?

  13. tgolen commented on Sep 27, 2023

    @tgolen
    ContributorAuthor

    I believe so, but I am not involved in that part of the process too much. @mallenexpensify might know better since he is handling the payment side for this issue.

  14. studentofcoding commented on Sep 27, 2023

    @studentofcoding
    Contributor

    Thanks for it @tgolen, This is also happening on another PR, in which we have to change the Title of the Issue. If I need to do anything, do let me know @mallenexpensify, thanks!

  15. studentofcoding commented on Sep 27, 2023

    @studentofcoding
    Contributor

    Hey @tgolen, as the PR is merged 6 days ago, and @MelvinBot didn't automatically report it. I believe the waiting time for payment is only 1 day left and tomorrow it should be released right?

    Can we have a guide on this condition @mallenexpensify ? Thanks!

  16. mallenexpensify commented on Sep 29, 2023

    @mallenexpensify
    Contributor

    Contributor: @studentofcoding paid $750 via Upwork, includes 50% urgency bonus
    Contributor+: @mollfpr is due $750. Unsure if paying via Upwork or NewDot yet, will know next week.

  17. mallenexpensify commented on Oct 2, 2023

    @mallenexpensify
    Contributor
  18. mollfpr commented on Oct 19, 2023

    @mollfpr
    Contributor

    @mallenexpensify I should be paid via Upwork since I already have the contract for this issue.

  19. mallenexpensify commented on Oct 20, 2023

    @mallenexpensify
    Contributor

    Thanks @mollfpr , I agree, updated the above to reflect you've been paid via Upwork!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ExternalAdded to denote the issue can be worked on by a contributorNewFeatureSomething to build that is a new item.ReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions