Skip to content

ESLint-plugin-compat doesn’t flag Object.groupBy when only groupToMap is available in Safari #650

@jacobjuul

Description

@jacobjuul

I'm targeting browsers using a browserslist configuration (e.g. "last 2 years, not dead") which includes Safari 16.4. As you might know, Safari implemented the grouping functionality under the alias Object.groupToMap until version 17, so Object.groupBy isn’t actually supported until Safari 17.

I expected eslint-plugin-compat to warn me when using Object.groupBy on environments where the standard API isn’t available (i.e. Safari 16.4), but it doesn’t flag it. It seems that the underlying compatibility data (likely coming from compat‑db or a similar dependency) uses the alternative_name field in its normalization process treating the existence of groupToMap as sufficient support for groupBy.

Would it be possible to have an option (or a change in logic) to flag cases where the standardized API (Object.groupBy) is used even if the browser exposes an alternative name (like groupToMap)? This would help prevent potential runtime issues in Safari 16.4 where the standardized method is missing.

Additional details:

  • My browserslist includes Safari 16.4.
  • The MDN compatibility data shows that Safari supports the feature as groupToMap until version 17 (where full support of groupBy was added).
  • I suspect the normalization code in the compatibility conversion (in compat‑db) appends an “x” to the support status when an alternative name is in use, which then results in eslint-plugin-compat treating it as “supported.”

I believe this behavior causes a false negative warning, since using Object.groupBy would not work as expected in Safari 16.4.

Any guidance on how to address this or a potential PR to change this behavior would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions