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

no-unnecessary-polyfills: always triggered on core-js/{actual,full}/<feature> #2506

Open
andreww2012 opened this issue Dec 6, 2024 · 2 comments
Labels

Comments

@andreww2012
Copy link

andreww2012 commented Dec 6, 2024

Hello! If the environment doesn't support <feature>, when I import from core-js/actual/<feature> or core-js/full/<feature>, no-unnecessary-polyfills rule is incorrectly triggered, but if I import it from es or stable, it is not.

Example:

// Reported - but the environment doesn't support `Array.prototype.toSpliced`:
import 'core-js/actual/array/to-spliced';
import 'core-js/full/array/to-spliced';

// Not reported as expected:
import 'core-js/es/array/to-spliced';
import 'core-js/stable/array/to-spliced';

Full reproduction: https://stackblitz.com/edit/vitejs-vite-zrgjkh?file=src%2Fmain.js

pnpm test
@andreww2012 andreww2012 added the bug label Dec 6, 2024
@fregante
Copy link
Collaborator

no-unnecessary-polyfills rule is incorrectly triggered

Why would that be incorrect?

// Reported:
import 'core-js/actual/array/to-spliced';

If you include this in an environment that has Array#toSpliced, then it is unnecessary.

if I import it from es or stable, it is not

This part sounds like the bug.

@andreww2012
Copy link
Author

andreww2012 commented Dec 12, 2024

Sorry, I think I meant to say "correctly".

Upd: actually it was implied that the environment doesn't support the feature. Made my initial message more clear. Either way the rule should not report any or report all the 4 imports 🙂

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

No branches or pull requests

2 participants