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

chore(mono): Enforce notification hooks in the app #15010

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

mjhuff
Copy link
Contributor

@mjhuff mjhuff commented Apr 25, 2024

Closes EXEC-419

Overview

Enforces the usage of the notification wrapper for the equivalent HTTP hook if the wrapper exists. We need this, so we don't accidentally poll in the app/ODD when we can use notifications instead.

I went with the lint approach over the "global mock and fail test" approach for a couple reasons:

  1. We don't have 100% test coverage, and making sure we find a way to enforce this across the codebase is important.
  2. It's nice having the immediate IDE feedback that the import is wrong instead of running into the error with the CI suite.

Also, I've intentionally excluded test files from the lint rule for a few reasons:

  1. Test files are for devs, not the end user.
  2. A lot of times, we import all of react-api-client in a test file, and the lint rule will catch these spots even when the rule doesn't apply.
  3. The reason hooks are imported in the test file is to mock them out from the respective file they are test. Enforcing lint on the test files is redundant.

Test Plan

  • In any file within the app, try importing any vanilla HTTP that has a useNotify equivalent, such as useCurrentMaintenanceRun. Verify that lint fails.
  • Alternatively, look at the first commit CI failure errors.

Risk assessment

low

Enforce the usage of the "useNotifyX" wrapper around the equivalent HTTP hook if the wrapper exists.
@mjhuff mjhuff requested a review from a team April 25, 2024 17:37
@mjhuff mjhuff requested a review from a team as a code owner April 25, 2024 17:37
@mjhuff mjhuff requested review from ncdiehl11 and removed request for a team April 25, 2024 17:37
@mjhuff mjhuff changed the title Mono notification lint rule chore(mono): Add a notification lint rule Apr 25, 2024
@mjhuff mjhuff removed the request for review from ncdiehl11 April 25, 2024 17:38
@mjhuff mjhuff changed the title chore(mono): Add a notification lint rule chore(mono): Add a notification lint rule for app dir Apr 25, 2024
@mjhuff mjhuff changed the title chore(mono): Add a notification lint rule for app dir chore(mono): Enforce notification hooks in the app Apr 25, 2024
Copy link
Contributor

@koji koji left a comment

Choose a reason for hiding this comment

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

This is awesome!
eslint shows the error with the message.

@mjhuff mjhuff merged commit faff667 into edge Apr 25, 2024
25 checks passed
@mjhuff mjhuff deleted the mono_notification-lint-rule branch April 25, 2024 19:37
Carlos-fernandez pushed a commit that referenced this pull request May 20, 2024
Closes EXEC-419

Enforces the usage of the notification wrapper for the equivalent HTTP hook if the wrapper exists. We need this, so we don't accidentally poll in the app/ODD when we can use notifications instead.
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.

None yet

2 participants