-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allow specifying provided polyfills (#2) #50
Allow specifying provided polyfills (#2) #50
Conversation
Hi, thanks for taking a look at this. In principle I don't agree with doing string inclusion checks to achieve this. How about something like this?
Once past draft state, also:
|
Thanks a lot for quick and very detailed feedback. I found checking inclusions very tempting (mostly due to easy implementation) but no doubt, your suggestion is much more solid and bullet-proof. I actually had similar idea with expanding rules, but ruled it out at the beginning. I thought it might be a little too complex, but wrongly so. I'll let you know when I have it improved. |
4f4022d
to
5191f7c
Compare
Both done. @robatwilliams Could you please have a look if we're on the same page regarding implementation details? Usage: {
"
ecmascript-compat/compat": [
"
error",
{
"
polyfills":[
"Array.prototype.flat",
"Array.prototype.flatMap",
"Array.prototype.includes",
"Promise.prototype.finally",
"Object.entries",
"Object.fromEntries",
"Object.getOwnPropertyDescriptors",
"Object.values",
"String.prototype.padStart",
"
String.prototype.replaceAll",
"
String.prototype.trimEnd",
"
String.prototype.trimStart",
],
I'll add unit tests and update schema once we agree on above. |
Looks good, thanks. I looked to see if I could allow the workflow to run without my approval, without changing the setting for all potential contributors - but there isn't anything. You can run it locally via |
It should pass now (at least it passes locally after most recent fixes). |
Thanks for updating docs @robatwilliams. I'll update the schema and unit tests. |
@robatwilliams I have added unit tests for all polyfills and updated json schema. It's ready for final review now.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks. Just two straightfoward things.
As a final thing, could you try it out in the example subproject, with and without options given, just for one polyfill, to make sure it works outside of unit tests? Just run npm run lint
there. No need to commit this.
packages/eslint-plugin-ecmascript-compat/lib/features/es2016.spec.js
Outdated
Show resolved
Hide resolved
I looked at how eslint-plugin-compat (similar plugin for browser and language features, but not syntax) allows polyfills to be specified - https://github.com/amilajack/eslint-plugin-compat#adding-polyfills That way allows sharing between different rules - https://eslint.org/docs/latest/user-guide/configuring/configuration-files#adding-shared-settings. But like us, they only have one rule. I don't think we need to accept polyfills from this location instead of or in addition to the rule options. It's a global location and "polyfills" is a very generic key which different plugins might interpret differently. If a user wants both plugins to share config, they can define an array in their config file and use/spread it in both locations. |
Checked with random polyfills setup and it works ✅ |
Great, that big codebase is the best test. |
Thanks for approval. I cannot merge it on my own though. When do you think we can get it merged and released? |
Now released v2.2.0. Thanks for your work, and please pass my thanks on to your team for continued contribution back to the plugin that you're making use of. |
Allow to whitelist particular non-syntax features as polyfills, so they aren't reported as problems.