Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jacobjuul opened this issue Mar 24, 2025 · 2 comments

Comments

@jacobjuul
Copy link

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.

@FStefanni
Copy link

Hi,

same issue here. Any solution?

Regards

@ljharb
Copy link
Collaborator

ljharb commented Mar 25, 2025

(It was Array.prototype.groupToMap, not Object.groupToMap)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants