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

ES2016 method 'Array.prototype.includes' is forbidden _eslint(ecmascript-compat/compat)_ #47

Closed
dossy opened this issue Mar 6, 2022 · 4 comments

Comments

@dossy
Copy link

dossy commented Mar 6, 2022

I'm using plugin:ecmascript-compat/recommended and my browserslist is set to last 5 Chrome versions which absolutely supports ES2016 and Array.prototype.includes, yet ecma-compat/compat says this is forbidden?

In mdn/browser-compat-data, it lists Array.prototype.includes as being added in Chrome 47, which is certainly older than the last 5 Chrome versions.

If I'm reading things correctly, this is actually being picked up by eslint's no-restricted-syntax rule, as configured by eslint-plugin-ecmascript-compat's es2016.js.

Am I misunderstanding what this eslint plugin is supposed to do? Or is this a bug somewhere, because Array.prototype.inclues is definitely available in modern Chrome.

I'm silencing the error with eslint-disable-next-line ecmascript-compat/compat for now, but is less than ideal.

@dossy
Copy link
Author

dossy commented Mar 6, 2022

Is this another instance of #30 ?

@robatwilliams
Copy link
Owner

Yes, I expect so - because chrome 100 is now probably in "last 5 versions"

@dossy
Copy link
Author

dossy commented Mar 7, 2022

Interesting, now when I run eslint it seems to work as expected? I blew away my node_modules and did a fresh yarn install and it now magically works? I'm confused.

$ echo 'Array.prototype.includes' > test.js

$ BROWSERSLIST="last 5 Chrome versions" eslint test.js
es-compat: checking compatibility for targets { chrome: '95' }

$ BROWSERSLIST="Chrome < 47" eslint test.js
es-compat: checking compatibility for targets { chrome: '10' }

/Volumes/Alt-ExternalHD/Users/dossy/Work/Upwork/dev/better-upwork/test.js
  1:1  error  ES2016 method 'Array.prototype.includes' is forbidden  ecmascript-compat/compat

✖ 1 problem (1 error, 0 warnings)

But, then I'm guessing this is what issue #30 is fixing:

$ BROWSERSLIST="Safari >= 15" eslint test.js
es-compat: checking compatibility for targets { safari: '15' }

/Volumes/Alt-ExternalHD/Users/dossy/Work/Upwork/dev/better-upwork/test.js
  1:1  error  ES2016 method 'Array.prototype.includes' is forbidden  ecmascript-compat/compat

✖ 1 problem (1 error, 0 warnings)

BROWSERSLIST="Safari >= 9" eslint test.js
es-compat: checking compatibility for targets { safari: '10' }

/Volumes/Alt-ExternalHD/Users/dossy/Work/Upwork/dev/better-upwork/test.js
  1:1  error  ES2016 method 'Array.prototype.includes' is forbidden  ecmascript-compat/compat

✖ 1 problem (1 error, 0 warnings)

I'll close this issue as I cannot reproduce the original issue specifically with Chrome, but I can definitely reproduce issue #30, and @lamansky's fix in #46 fixes the Safari cases for me, at least.

@dossy dossy closed this as completed Mar 7, 2022
@robatwilliams
Copy link
Owner

Released https://github.com/robatwilliams/es-compat/releases/tag/v3.0.0

including fix for #30

FYI @dossy

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