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 · 3 comments
Open

Ignore usages that are part of feature test expressions #72

robatwilliams opened this issue May 11, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@robatwilliams
Copy link
Owner

robatwilliams commented May 11, 2023

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.

The current workaround is to configure the options to say you have a polyfill for that feature, even if you don't. This is dangerous as it will ignore all usages of that feature, including those without a feature test guard. This workaround isn't an option for non-polyfillable features namely BigInt and Atomics, as raised in #70.

It's the responsibility of https://github.com/eslint-community/eslint-plugin-es-x to do the detection. es-compat simply passes through all reports raised by it.

It might be possible to implement something here to guess if an expression looks like a feature test. We have the AST node there. But really eslint-plugin-es-x would be the ideal place for this, as this problem is not unique to es-compat, and it's the root of where the problem arises.

@robatwilliams
Copy link
Owner Author

This is a partly a subset of #29

@robatwilliams
Copy link
Owner Author

@robatwilliams
Copy link
Owner Author

A smaller scope solution could allow users to specify code strings to ignore as a rule option. We might be able to think of many possible ways of doing feature tests, but not all.

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

No branches or pull requests

1 participant