Skip to content

no-async-foreach-callback: computed-property calls and named async-function references bypass detection (false negative) #69217

Closed

Description

@github-actions

Summary

no-async-foreach-callback (eslint-factory/src/rules/no-async-foreach-callback.ts) exists specifically to catch the classic forEach()-with-async-callback bug (discarded promise, unawaited work, unhandled rejections). The test fixture lists two forms as explicitly valid (unflagged) that belong to the same bug class the rule targets:

  1. Computed-property access: items["forEach"](async x => {}) is valid today purely because the rule bails out at callee.computed with no further check -- no scope analysis needed, this is a pure AST-shape gap. This codebase already treats bracket-notation access as an equivalent form worth covering in several sibling rules (for example JSON["parse"], err["message"]).
  2. Named function reference: items.forEach(handler) is valid today because the rule only inspects the callback argument node itself for .async === true; it never resolves handler back to its declaration. If handler is declared as async function handler(x) { await f(x); } (or const handler = async x => {...}) and passed by reference, the same discarded-promise bug occurs and goes undetected.

Where

eslint-factory/src/rules/no-async-foreach-callback.ts, the CallExpression visitor: the callee.computed early return, and the callback-shape check that only accepts an inline ArrowFunctionExpression/FunctionExpression with .async === true.

Confirmed via the valid-test fixtures in no-async-foreach-callback.test.ts: items["forEach"](async x => {}); and items.forEach(handler); are both listed under valid.

Reproduction (constructed)

Case 1 (computed access):
items["forEach"](async (x) => { await process(x); }); // NOT flagged today

Case 2 (named reference):
async function handleItem(x) { await process(x); }
items.forEach(handleItem); // NOT flagged today

Acceptance criteria

  • Drop the callee.computed early return in favor of also accepting a computed, string-literal forEach property name (mirroring the non-computed case), consistent with how other rules in this factory already handle bracket-notation access.
  • When the callback argument is a plain Identifier, resolve it to its binding (function declaration, or a write-once const bound to a function/arrow expression) using a write-once scope walk consistent with this factory conventions (for example try-catch-rule-utils.ts), and flag it when the resolved function is async. Leave genuinely unresolvable references (parameters, reassigned bindings, imports) out of scope, matching this factory established convention.
  • Add invalid tests for both forms above, and keep (or add) a valid test for a non-async named function reference (e.g. items.forEach(syncHandler)) and an unresolvable reference (e.g. a function parameter) to confirm no new false positives.

Scope

eslint-factory/** only.

Filed by ESLint Refiner (daily run 2026-10-16).

Generated by 🤖 ESLint Refiner · claude · agent · 161.5 AIC · ⌖ 0.878 AIC · ⊞ 5.3K · ◷

  • expires on Oct 22, 2026, 7:43 PM UTC-08:00

Activity

  1. github-actions commented on Oct 16, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 15.2 AIC · ⌖ 9.89 AIC · ⊞ 12.3K · ◷

  2. github-actions commented on Oct 16, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 12 AIC · ⌖ 9.74 AIC · ⊞ 12.3K · ◷

  3. github-actions commented on Oct 16, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 15.4 AIC · ⌖ 7.8 AIC · ⊞ 12.4K · ◷

  4. github-actions commented on Oct 17, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 9.93 AIC · ⌖ 7.85 AIC · ⊞ 12.4K · ◷

  5. github-actions commented on Oct 17, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 9.59 AIC · ⌖ 8.21 AIC · ⊞ 12.4K · ◷

  6. github-actions commented on Oct 17, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 19.6 AIC · ⌖ 9.05 AIC · ⊞ 12.4K · ◷

  7. github-actions commented on Oct 17, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 13 AIC · ⌖ 8.88 AIC · ⊞ 12.4K · ◷

  8. github-actions commented on Oct 17, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 16.7 AIC · ⌖ 9 AIC · ⊞ 12.4K · ◷

  9. github-actions commented on Oct 17, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 17.1 AIC · ⌖ 10.1 AIC · ⊞ 12.3K · ◷

  10. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    This issue is a good candidate for automated resolution and has been requested for the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 15.8 AIC · ⌖ 9.46 AIC · ⊞ 12.2K · ◷

  11. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 12.2 AIC · ⌖ 10.4 AIC · ⊞ 12.7K · ◷

  12. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 10.1 AIC · ⌖ 8.17 AIC · ⊞ 12.7K · ◷

  13. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 13.5 AIC · ⌖ 11.9 AIC · ⊞ 12.7K · ◷

  14. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 10.3 AIC · ⌖ 8.7 AIC · ⊞ 12.7K · ◷

  15. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 14.7 AIC · ⌖ 10.3 AIC · ⊞ 12.7K · ◷

  16. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 11.6 AIC · ⌖ 8.4 AIC · ⊞ 12.7K · ◷

  17. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 11.4 AIC · ⌖ 10.4 AIC · ⊞ 12.7K · ◷

  18. github-actions commented on Oct 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 20.4 AIC · ⌖ 8.39 AIC · ⊞ 12.7K · ◷

  19. github-actions commented on Oct 19, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 11.5 AIC · ⌖ 9.39 AIC · ⊞ 12.7K · ◷

  20. github-actions commented on Oct 19, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 10.6 AIC · ⌖ 9.61 AIC · ⊞ 12.7K · ◷

  21. github-actions commented on Oct 19, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 12.1 AIC · ⌖ 8.51 AIC · ⊞ 12.8K · ◷

  22. github-actions commented on Oct 19, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 14.6 AIC · ⌖ 8.26 AIC · ⊞ 12.8K · ◷

  23. github-actions commented on Oct 19, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt54 · 11.7 AIC · ⌖ 10.7 AIC · ⊞ 12.9K · ◷

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cookieIssue Monster Loves Cookies!eslint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions