Skip to content
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

Might Miss Compatibility Issues Based on Assumed Polyfills from Babel Config #602

Open
ChrisSargent opened this issue Oct 4, 2023 · 0 comments

Comments

@ChrisSargent
Copy link

ChrisSargent commented Oct 4, 2023

## Description

We use eslint-plugin-compat to check browser compatibility in our projects. However, we recently noticed some compatibility issues in our code related to Babel configurations and core-js.

For us, this happened specifically, when using the feature Object.hasOwn, which isn't supported in Safari < 15.3, we expected eslint-plugin-compat to flag this as an error. However, it seems the plugin checks for the presence of a Babel config and assumes that all possible polyfills for the browsers (defined in the browserslist file) are being used. This assumption can lead to false negatives, especially if there's a mismatch with the core-js version or if specific polyfills aren't explicitly imported.

This happened because we are using Gatsby and in the babel-preset-gatsby, it only use the major version for the corejs option, like corejs: 3 and recommendations from corejs repo says to use the minor version. I have created a PR against Gatsby to address this issue: https://github.com/gatsbyjs/gatsby/pull/38589/files

Potential Solutions

Honestly I'm not sure what could be done to address this in the logic / code - maybe detecting that @babel/preset-env is being used and checking the corejs version being passed in. Or maybe just something adding to the docs

Minimal Repo

https://github.com/ChrisSargent/eslint-compat-example

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

1 participant