Skip to content

feat(eslint-plugin): prefer workflow events#16150

Open
leobenzol wants to merge 4 commits into
medusajs:developfrom
leobenzol:feat/eslint-module-events
Open

feat(eslint-plugin): prefer workflow events#16150
leobenzol wants to merge 4 commits into
medusajs:developfrom
leobenzol:feat/eslint-module-events

Conversation

@leobenzol

Copy link
Copy Markdown
Contributor

Summary

What — What changes are introduced in this PR?

Adds a new eslint rule to warn users if they use a module-level event that has a corresponding workflow-level event, and logic to fix it automatically.
Added a new "core" preset that doesn't include this kind of end-user-only rule

Why — Why are these changes relevant or necessary?

I got bit by this personally a while ago and it seems to be a frequent issue.

How — How have these changes been implemented?

  • Rename the current "recommended" preset to "core", and add this new rule to "recommended"
  • As the rule gets loaded we compute a map of all module-workflow event pairs with the same values, this allows for autofix without a manually maintained mapping and avoids warning if the module-level event has no workflow equivalent, which means it was probably imported on purpose.
  • Use the map to check if any module-level events should be replaced and issue warnings if so.

Testing — How have these changes been tested, or how can the reviewer test the feature?

New tests + manual verification


Examples

Screenshot 2026-07-21 alle 20 20 28

Checklist

Please ensure the following before requesting a review:

  • I have added a changeset for this PR
    • Every non-breaking change should be marked as a patch
    • To add a changeset, run yarn changeset and follow the prompts
  • The changes are covered by relevant tests
  • I have verified the code works as intended locally
  • I have linked the related issue(s) if applicable

@leobenzol
leobenzol requested review from a team as code owners July 21, 2026 18:25
@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bc35642

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

This PR includes changesets to release 79 packages
Name Type
@medusajs/eslint-plugin Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/draft-order Patch
@medusajs/loyalty-plugin Patch
@medusajs/core-flows Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/query Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/http-types-generator Patch
@medusajs/cli Patch
@medusajs/medusa-oas-cli Patch
@medusajs/oas-github-ci Patch
@medusajs/deps Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
integration-tests-http Patch
@medusajs/ui Patch

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

@medusa-os-bot

medusa-os-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

Thanks for the contribution! A few items need to be addressed before this can move forward:

Community contribution adding a new ESLint rule ('prefer-workflow-events') to warn when module-level events have workflow-level equivalents, plus a new 'core' preset. PR totals 828 changed lines across 11 files with no linked GitHub issue, which is above the 500-line threshold requiring pre-approval per CONTRIBUTING.md. Additionally, adding new rules to the 'recommended' preset changes its behaviour for existing users and should be versioned as a minor bump in the changeset, not a patch.

  • PR exceeds 500 changed lines (828 total) without a linked issue carrying a help-wanted label. Per CONTRIBUTING.md, large contributions must be pre-approved via an issue discussion with CODEOWNERS before submitting.
  • Adding new lint rules to the recommended preset changes behaviour for existing users (new warnings appear). The changeset bump type should be minor, not patch, per the contribution guidelines for altered-behaviour changes.

Triggered by: new PR opened

@shahednasser shahednasser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your contribution @leobenzol ! I think this is a good addition, but would approach it differently:

  1. If the goal of core is to disable the rule for this repo, then I think we should modify the eslint config at the root. Would avoid causing confusion for end-users on when to use it.
  2. The rule is too broad, and from an end user perspective I would focus on the subscription part as that is the part where users often get confused. Would change the rule to work only on subscriber files and detect the event name to be either the enum, or in the format {domain}.{action}. Internal services on the other hand are {module}.{data-model}.{action}. For the enum, we show the warning if we know it's an internal service event enum, with an auto-fix action if possible. For the literal string, we show a warning that the event doesn't match workflow event enums and to confirm that the event is correct.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants