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

fix: #2138 linter issues with fail function #2171

Merged

Conversation

JuanJo4
Copy link
Contributor

@JuanJo4 JuanJo4 commented Mar 31, 2024

What does this PR do and why?

It solves #2138, this has happened before (#2137 & #1989) and was solved only for those specific cases, this PR aims to fix once and for all.

This is what I did:

  • removed fail function and created a new MstError class that extends from Error.
  • adjusted the calls of the fail function accordingly.
  • removed unused imports

Steps to validate locally

I've added some basic unit tests, not sure if that's enough.

JuanJo4 added 2 commits March 30, 2024 18:57
- refactoring fail function to be a custom Error class
- adjusting throw class given the above changes
- adding missing imports
- removing unused imports
@coolsoftwaretyler
Copy link
Collaborator

Thanks @JuanJo4! I'll take a look today or tomorrow.

Copy link
Collaborator

@coolsoftwaretyler coolsoftwaretyler left a comment

Choose a reason for hiding this comment

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

Hey @JuanJo4 - I love it. I came around to really liking the new class rather than the function-based approach. Initially, I thought fail was throwing, but I had misremenbered. Since we were throwing whatever gets returned from fail, I think a new class that extends Error is perfect.

I found a typo in one of your file names. Would you mind fixing that? Once you do, we can merge this.

Thanks for doing this! Really appreciate it.

@@ -0,0 +1,20 @@
import { MstError } from "../src/utils"
Copy link
Collaborator

Choose a reason for hiding this comment

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

issue: @JuanJo4 - would you mind renaming this file to __tests__/utils.test.ts? I think the file name is a typo currently.

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! my bad... fixed.

@@ -0,0 +1,20 @@
import { MstError } from "../src/utils"

describe("MstError custom error class", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

praise: @JuanJo4 - thank you for these test! Make sense to me!

@coolsoftwaretyler
Copy link
Collaborator

Perfect! Merging.

I'll get a new 6.0.0 release out soon. We're in a preview mode for the next major and this should land there once we ship it.

Thanks for the help, and please let us know if there's anything else you'd like to work on.

@coolsoftwaretyler coolsoftwaretyler merged commit f87f96d into mobxjs:master Apr 1, 2024
1 check passed
@JuanJo4 JuanJo4 deleted the fix-linters-dont-recognize-fail branch April 1, 2024 05:20
coolsoftwaretyler pushed a commit that referenced this pull request Apr 17, 2024
* fix: #2138 linter issues with fail function

- refactoring fail function to be a custom Error class
- adjusting throw class given the above changes
- adding missing imports
- removing unused imports

* adding tests

* typo
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.

2 participants