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

Rule no-unwanted-polyfillio wrongly reports error on es2019 rule #33072

Open
jdeniau opened this issue Jan 6, 2022 · 3 comments
Open

Rule no-unwanted-polyfillio wrongly reports error on es2019 rule #33072

jdeniau opened this issue Jan 6, 2022 · 3 comments

Comments

@jdeniau
Copy link

@jdeniau jdeniau commented Jan 6, 2022

Run next info (available from version 12.0.8 and up)

No response

What version of Next.js are you using?

11.1.0 or 12.0.0

What version of Node.js are you using?

14.18.0

What browser are you using?

Chrome 67

What operating system are you using?

Windows

How are you deploying your application?

other platform

Describe the Bug

The eslint rule no-unwanted-polyfillio wrongly report es2019 as duplicate.

All esXXX rule are marked as Should be covered by babel-preset-env instead..

My babel configuration is the following:

module.exports = {
  presets: ['next/babel'],
  plugins: ['styled-components'], // See https://github.com/brandonchinn178/next.js/blob/master/examples/with-styled-components/.babelrc
};

So I think this is pretty much the default config. I did not customize anything about babel-preset-env

I tried with a boostraped nextjs 12 and swc (without babel configuration) and the issue is the same.

Expected Behavior

Either do not report as an error, or possibly fix the babel configuration if needed ?

If we only need to fix the eslint rule, I can open a PR. If the fix is on the babel side, I will need some help there.

To Reproduce

Reproductible repository : https://github.com/jdeniau/nextjs-object-fromentries

Open a chrome <= 71 (or any browser that does not support Object.fromEntries) and try to run a nextjs app with the following code.

Object.fromEntries([]);

It will crash with an error:

Object.fromEntries is not a function
@balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Jan 7, 2022

Hi. We decided not to add a polyfill to not penalize most users with the increased size.

See the discussion here: #15772 (comment)

@jdeniau
Copy link
Author

@jdeniau jdeniau commented Jan 7, 2022

@balazsorban44 OK, so I think that we should remove it from the polyfillio rule then.

If I'm correct, all next-js polyfill are loaded in https://github.com/kripod/next.js/blob/076c0275d0133db2f8e7e8dc68f6cb2f2bd1a159/packages/next-polyfill-nomodule/src/index.js so the NEXT_POLYFILLED_FEATURES should contain a copy of those polyfill, no ? (and in my case should not contain es2019)

If so, I can open a PR fixing this.

@balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Jan 7, 2022

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

Successfully merging a pull request may close this issue.

None yet
2 participants