Skip to content

feat(lint): add avoid_async_emit rule with tests and documentation#4585

Open
Katekko wants to merge 5 commits intofelangel:masterfrom
Katekko:feature/avoid_async_context
Open

feat(lint): add avoid_async_emit rule with tests and documentation#4585
Katekko wants to merge 5 commits intofelangel:masterfrom
Katekko:feature/avoid_async_context

Conversation

@Katekko
Copy link

@Katekko Katekko commented Aug 1, 2025

Status

READY

Breaking Changes

NO

Description

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@Katekko Katekko requested a review from felangel as a code owner August 1, 2025 00:01
@Katekko
Copy link
Author

Katekko commented Aug 1, 2025

Hello @felangel

I've implemented the avoid_async_emit lint rule based on the open issue regarding unguarded emit calls inside async methods. This rule helps ensure emit is properly guarded with isClosed checks to prevent potential runtime issues. Please review and let me know if any adjustments are needed!

ps. This is my first time contributing a lint rule. Please let me know if there are any improvements I can make or if there's a better approach I should follow.

Copy link
Owner

@felangel felangel left a comment

Choose a reason for hiding this comment

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

Thanks so much for the PR! I haven't thoroughly reviewed the code yet but at first glance I think changes are needed since this lint rule should apply to both Bloc and Cubit instances. Currently it looks like this is implemented to ignore Bloc instances entirely.

@felangel felangel added enhancement New feature or request pkg:bloc_lint This issue is related to the bloc_lint package labels Aug 1, 2025
@Katekko
Copy link
Author

Katekko commented Aug 1, 2025

You were right—I needed to include Bloc as well. I updated the condition in handleIdentifier to check for both Cubit and Bloc tokens. Thanks for pointing it out!

@codecov
Copy link

codecov bot commented Aug 1, 2025

Codecov Report

❌ Patch coverage is 98.64865% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ages/bloc_lint/lib/src/rules/avoid_async_emit.dart 98.64% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@euclidesgc
Copy link

You were right—I needed to include Bloc as well. I updated the condition in handleIdentifier to check for both Cubit and Bloc tokens. Thanks for pointing it out!

Great job, bro, you were amazing.
This will help us get the benefits much sooner than we expected. I'm proud of you, and thanks so much for your contribution to this process. I can't wait to use it.

@felangel
Copy link
Owner

felangel commented Aug 4, 2025

Just wanted to say this is still very much on my radar -- I need to get #4562 merged first and then this is next on my list to review and get merged. Thanks so much for taking the time to contribution! 💙

@felangel
Copy link
Owner

felangel commented Sep 22, 2025

Sorry for the delay! This is next on my todo list and I'm hoping to get this reviewed and merged in the next few days.

@euclidesgc
Copy link

Sorry for the delay! This is next on my todo list and I'm hoping to get this reviewed and merged in the next few days.

Hey man, how's it going? Do you have any idea when this awesome feature will be merged?

@felangel
Copy link
Owner

Sorry for the delay! This is next on my todo list and I'm hoping to get this reviewed and merged in the next few days.

Hey man, how's it going? Do you have any idea when this awesome feature will be merged?

Sorry for the delay! Hoping to have some time this week to clean this up and get it landed but at first glance I don't think it's ready to land as-is.

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

Labels

enhancement New feature or request pkg:bloc_lint This issue is related to the bloc_lint package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(bloc_lint): avoid_async_emit

4 participants