Skip to content

Refactor Store namespace pattern to enable noFloatingPromises lint detection #252

@PaulRBerg

Description

@PaulRBerg

Problem

Biome's noFloatingPromises lint rule cannot detect floating promises when async functions are accessed through namespace re-exports using the export import pattern.

Root cause: The current Store pattern uses:

export namespace Store {
  export import Campaign = EntityCampaign;
}

This prevents Biome's type inference from resolving that Store.Campaign.updateAdmin() returns a Promise<void>, even though the function has an explicit return type annotation and the rule is properly configured.

Real-world impact: Bug in envio/airdrops/mappings/common/campaign/transfer-admin.ts:37 where Store.Campaign.updateAdmin() was called without await, causing the error: "Impossible to access context.Campaign after the handler is resolved."

Warning

Any async Store methods called without await will NOT be caught by the linter, creating a silent reliability issue.

Solution

Refactor 4 Store index files to use plain object exports (Analytics pattern):

// Before (problematic)
export namespace Store {
  export import Campaign = EntityCampaign;
}

// After (Biome-compatible)
export const Store = {
  Campaign: EntityCampaign,
};

This maintains the same public API (Store.Entity.method()) while enabling proper type inference for lint rules.

Note

The Analytics indexer already uses this correct pattern and does NOT need changes.

Testing

Undo the fix for #251 to test.

Tip

After refactoring, run na biome lint to verify the rule now works. Test by temporarily removing await from an async Store call - Biome should flag it.

Files Affected

Toggle to see affected files

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort: lowEasy or tiny task that takes less than a day.priority: 2We will do our best to deal with this.type: refactorChange that neither fixes a bug nor adds a feature.work: clearSense-categorize-respond. The relationship between cause and effect is clear.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions