Closed dossy closed 2 years ago
Is this another instance of #30 ?
Yes, I expect so - because chrome 100 is now probably in "last 5 versions"
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.
Released https://github.com/robatwilliams/es-compat/releases/tag/v3.0.0
including fix for #30
FYI @dossy
I'm using
plugin:ecmascript-compat/recommended
and mybrowserslist
is set tolast 5 Chrome versions
which absolutely supports ES2016 andArray.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 byeslint-plugin-ecmascript-compat
'ses2016.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.