#21113·eslint

Rule Change: support `Object.groupBy` and `Map.groupBy` in `array-callback-return`

Author: synthex-byteCreated Jul 19, 2026Updated Sep 11, 2026
Labelsenhancementrule

What rule do you want to change?

array-callback-return

What change do you want to make?

Generate more warnings

How do you think the change should be implemented?

A new default behavior

Example code

javascript
/* eslint array-callback-return: "error" */
const grouped = Object.groupBy(inventory, ({ type }) => {
    if (type === "fruit") {
        return "fruit";
    }
    // forgot to return
});

What does the rule currently do for this code?

No problem is currently reported. At runtime, elements whose callback returns undefined are silently grouped under the key "undefined"

What will the rule do after it's changed?

Report a problem when the callback passed to Object.groupBy or Map.groupBy doesn't return a value on some code path, consistent with the existing behavior for Array.from . The callback is the second argument, same as Array.from / Array.fromAsync

Participation

  • I am willing to submit a pull request to implement this change.

AI acknowledgment

  • I did not use AI to generate this issue report.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

Additional comments

Object.groupBy and Map.groupBy have reached TC39 stage 4 and are part of ES2024, so I think it makes sense for this rule to cover them as well. Similar to what was done for Array.fromAsync (#20438)