robatwilliams / es-compat

Check JavaScript code compatibility with target runtime environments
MIT License
64 stars 13 forks source link

Object rest/spread can be transpiled using Babel #84

Closed lgdevlop closed 8 months ago

lgdevlop commented 9 months ago

Can we add the Object rest/spread option to the polyfill options of this library since we can use Babel to transpile the unsupported syntax? Below is a link to the Babel plugin that performs the transformation.

https://babeljs.io/docs/babel-plugin-transform-object-rest-spread

robatwilliams commented 9 months ago

That's an ES6/ES2015 feature, so isn't checked by this plugin to begin with (see list of ES versions in the readme).

robatwilliams commented 9 months ago

Please close the issue unless you'r experiencing a problem

lgdevlop commented 9 months ago

Thank you for the quick response.

According to the link to the Babel plugin I provided above and the links I include below, including an image of the ecmascript-compat/compat plugin, the feature in question is ES2018, as we are referring to Object rest/spread. You are correct in stating that rest and spread are ES2015, but Object rest/spread is ES2018. I want to turn off linting for Object rest/spread using the polyfill option of the ecmascript-compat plugin.

Thank you for the excellent work!

https://css-tricks.com/new-es2018-features-every-javascript-developer-should-know/#aa-the-rest-spread-properties

https://2ality.com/2017/02/ecmascript-2018.html

Captura de tela 2023-10-22 193324

robatwilliams commented 9 months ago

Ah thanks, I didn't remember that spread didn't all arrive in the same version.

Given you're using a transpiler, what's your need for using es-compat on the source code? The envisaged scenarios are described under Rationale in the readme. If you have a new scenario, do let me know.

lgdevlop commented 9 months ago

I'm using it so that ESLint can alert me when using features not supported by the environments configured in Browserlist.

With this, I check the tooling to see if it supports the functionality by transpiling or polyfilling it or if I need to adjust it using a Babel plugin.

These issues typically arise with older tooling, so I configure ESLint with this plugin, Browserlist, and look for notifications from the plugin. This way, I prioritize updating the tooling if necessary

robatwilliams commented 8 months ago

In that case, I suggest you run es-compat against the output of Babel rather than the input.

lgdevlop commented 8 months ago

I see. OK, I will close this issue.

robatwilliams commented 8 months ago

I think the readme should provide an better explanation of this, so I've created #85