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

Ignore usages that are part of feature test expressions #72

Open
robatwilliams opened this issue May 11, 2023 · 1 comment
Open

Ignore usages that are part of feature test expressions #72

robatwilliams opened this issue May 11, 2023 · 1 comment

Comments

@robatwilliams
Copy link

If your code (or library code) is using a feature support test conditional statement before using a feature, then you still get an error reported by this plugin. It doesn't know your intent when doing such checks.

Could this plugin make guesses of reasonable confidence that statements like the following should not cause an error?

if (String.prototype.replaceAll) {
   // use it
}

This issues arises from robatwilliams/es-compat#72

@ota-meshi
Copy link
Member

I think in order to reliably determine the method existence check, we need to analyze the code path and identify where the code is placed. I think it's very difficult to do, but if you have ideas please comment here or open a PR to add changes.

if (String.prototype.replaceAll) {
   // use replaceAll
}
if (!String.prototype.replaceAll) {
   // use polyfill
} else {
   // use replaceAll
}
if (typeof String.prototype.replaceAll !== 'undefined') {
   // use replaceAll
}
if (typeof String.prototype.replaceAll === 'undefined') {
   // use polyfill
} else {
   // use replaceAll
}
a = String.prototype.replaceAll ? /* use replaceAll */ : /* use polyfill */;

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

2 participants