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

New only-hardhat-error rule #5461

Merged
merged 2 commits into from
Jul 1, 2024
Merged

New only-hardhat-error rule #5461

merged 2 commits into from
Jul 1, 2024

Conversation

alcuadrado
Copy link
Member

@alcuadrado alcuadrado commented Jun 29, 2024

This PR introduces a no-restricted-syntax rule that forbids throwing any error except for:

  • throw new HardhatError(...)
  • throw variableName within catch clauses. — The rationale here is to allow re-throwing of the error that was caught.

We could later improve this with a custom rule to:

  • Allow subclasses of HardhatError
  • Only allow throw variable when the variable is the one in the catch (variable).

I believe that no-restricted-syntax isn't expressive enough for these things, as they are semantic conditions and not entirely syntactic. Still, I think this is a good trade-off.

PS: This depends on #5460 just for convenience and to avoid merge conflicts.

@alcuadrado alcuadrado added the v-next A Hardhat v3 development task label Jun 29, 2024
@alcuadrado alcuadrado requested a review from schaable June 29, 2024 23:01
Copy link

changeset-bot bot commented Jun 29, 2024

🦋 Changeset detected

Latest commit: b142e0d

The changes in this PR will be included in the next version bump.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jun 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 29, 2024 11:01pm

@alcuadrado alcuadrado changed the base branch from main to v-next June 29, 2024 23:01
@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Jun 29, 2024
@alcuadrado alcuadrado changed the base branch from v-next to isolate-build-system June 29, 2024 23:04
Copy link
Member

@schaable schaable left a comment

Choose a reason for hiding this comment

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

LGTMT

Base automatically changed from isolate-build-system to v-next July 1, 2024 16:03
@alcuadrado alcuadrado merged commit fb7357e into v-next Jul 1, 2024
9 checks passed
@alcuadrado alcuadrado deleted the only-hardhat-error branch July 1, 2024 16:04
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:ready This issue is ready to be worked on v-next A Hardhat v3 development task
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants