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

[HOLD for payment 2023-05-05] [$1000] Enable no-invalid-this ESLint rule #17971

Closed
pecanoro opened this issue Apr 25, 2023 · 28 comments
Closed
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@pecanoro
Copy link
Contributor

pecanoro commented Apr 25, 2023

Context: https://expensify.slack.com/archives/C049HHMV9SM/p1682089468352009

Problem

Using this outside of classes or class-like objects might work because it could refer to the module (for example, ReportUtils), but after building it, it might not be the case. This will cause crashes that cannot be caught while testing PRs and will only be seen once the app is deployed on staging or production.

Solution

Enable this ESLint rule (no-invalid-this) in our eslint-config-expensify repo.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0138e39a2b0f958b39
  • Upwork Job ID: 1650895714648719360
  • Last Price Increase: 2023-04-25
@pecanoro pecanoro added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 25, 2023
@MelvinBot
Copy link

Triggered auto assignment to @NicMendonca (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@MelvinBot
Copy link

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@pecanoro pecanoro added the External Added to denote the issue can be worked on by a contributor label Apr 25, 2023
@melvin-bot melvin-bot bot changed the title Enable no-invalid-this ESLint rule [$1000] Enable no-invalid-this ESLint rule Apr 25, 2023
@MelvinBot
Copy link

Job added to Upwork: https://www.upwork.com/jobs/~0138e39a2b0f958b39

@MelvinBot
Copy link

Current assignee @NicMendonca is eligible for the External assigner, not assigning anyone new.

@MelvinBot
Copy link

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 25, 2023
@MelvinBot
Copy link

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

@Prince-Mendiratta
Copy link
Contributor

Prince-Mendiratta commented Apr 25, 2023

Proposal

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

Using this outside of classes or class-like objects might work because it could refer to the module (for example, ReportUtils), but after building it, it might not be the case. This can lead to runtime exceptions.

What is the root cause of that problem?

As can be seen in the thread in the OP, the use of a non required this. call outside a class, leading to a crash.

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

We nee to enable the no-invalid-this rule in the eslint-config-expensify repo. This can be done by adding the following statement in the rules/es6.js file. 'no-invalid-this': 'error'. In addition to this, we need to resolve the active offenders of this rule in the PR after enabling it to ensure that the current errors are resolved so that this coding style can be enforced in the future.

As of now, there is only 1 occurrence of this rule offender in the repo:

I've worked with eslint-config-expensify before on this issue so I'll be a good fit for this issue.

@alitoshmatov
Copy link
Contributor

Proposal

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

Enable no-invalid-this ESLint rule

What is the root cause of that problem?

Enable no-invalid-this rule in eslint

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

We should create new file in https://github.com/Expensify/eslint-config-expensify/tree/main/rules with the name of general or common since there is no suitable file for this rule. And add no-invalid-this rule into this file.

Also add newly created file here:
https://github.com/Expensify/eslint-config-expensify/blob/459e6c434dde4054a5c53290d9abed3e1a1c849f/index.js#L10-L13

What alternative solutions did you explore? (Optional)

@s77rt
Copy link
Contributor

s77rt commented Apr 25, 2023

@Prince-Mendiratta Thanks for the proposal. Let's get this going!

🎀 👀 🎀 C+ reviewed

cc @pecanoro

@s77rt
Copy link
Contributor

s77rt commented Apr 25, 2023

@alitoshmatov Thanks for the proposal. Given this is a feature request there is not much to base proposal selection on. So we are going with the first proposal that we get. I hope this makes sense and looks fair for all. The location of the rule is not a significant difference and I think es6 is just fine.

@riffly
Copy link

riffly commented Apr 25, 2023

Hello dev team,
I am trying to contribute ,
I was reading the instructions for opening the app in android, and there was an "SO Post" guideline maybe linked in the instructions.
There I am required a "@expensify.com" mail to join,
I mailed to "contributors@expensify.com" yesterday, and waiting for the response.
My upwork profile is active.
I want to participate in the contribution.
my upwork profile link- https://www.upwork.com/freelancers/~0148d2c4c39cb141bc

@MelvinBot
Copy link

📣 @riffly! 📣

Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.

Screen Shot 2022-11-16 at 4 42 54 PM

Format:

Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@s77rt
Copy link
Contributor

s77rt commented Apr 25, 2023

@riffly Hi 👋! Do you have access to Slack? If yes, then please post such problems on Slack, but by the way you don't need access to SO. Run npm install followed by npm run android and that's all.

@tgolen
Copy link
Contributor

tgolen commented Apr 25, 2023

🟢 to hire @Prince-Mendiratta for this. I can help you with publishing the config to NPM when the time comes.

@gulfam110
Copy link

To enable the no-invalid-this ESLint rule in your project, you can add it to your ESLint configuration file.

@s77rt
Copy link
Contributor

s77rt commented Apr 25, 2023

@gulfam110 Hi! Thanks for your input. I assume you are new here so Welcome! I would really insist that your read the contributing guide. If you have any questions outside the GH issue, please ask on Slack.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 26, 2023
@MelvinBot
Copy link

📣 @Prince-Mendiratta You have been assigned to this job by @pecanoro!
Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@pecanoro
Copy link
Contributor Author

Assigning @Prince-Mendiratta since I think @tgolen forgot hehe

@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label Apr 26, 2023
@Prince-Mendiratta
Copy link
Contributor

PR enabling the rule is ready.

PR bumping the version on E/A is ready for review as well but awaiting merge on the aforementioned PR.

Applied in Upwork.

cc @tgolen @s77rt @NicMendonca

@NicMendonca
Copy link
Contributor

@Prince-Mendiratta hired ✅

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Apr 28, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Enable no-invalid-this ESLint rule [HOLD for payment 2023-05-05] [$1000] Enable no-invalid-this ESLint rule Apr 28, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 28, 2023
@MelvinBot
Copy link

Reviewing label has been removed, please complete the "BugZero Checklist".

@MelvinBot
Copy link

MelvinBot commented Apr 28, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.7-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-05-05. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@MelvinBot
Copy link

MelvinBot commented Apr 28, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@s77rt] The PR that introduced the bug has been identified. Link to the PR:
  • [@s77rt] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@s77rt] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@s77rt] Determine if we should create a regression test for this bug.
  • [@s77rt] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@NicMendonca] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@s77rt
Copy link
Contributor

s77rt commented Apr 28, 2023

  • The PR that introduced the bug has been identified: Not a bug, this is a feature request.
  • The offending PR has been commented on: n/a
  • A discussion in #expensify-bugs has been started: n/a
  • Determine if we should create a regression test for this bug: n/a

What a friendly non time-consuming checklist 😍

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 4, 2023
@NicMendonca
Copy link
Contributor

@s77rt can you please apply to the job: https://www.upwork.com/jobs/~0138e39a2b0f958b39

@NicMendonca
Copy link
Contributor

@Prince-Mendiratta you've been paid, thank you!

@s77rt
Copy link
Contributor

s77rt commented May 5, 2023

@NicMendonca Applied.

@NicMendonca
Copy link
Contributor

@s77rt paid! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants