mysticatea / eslint-plugin-es

ESLint plugin about ECMAScript syntactic features.
https://eslint-plugin-es.mysticatea.dev/
MIT License
108 stars 21 forks source link

Incorporate browser compatibility data #22

Open robatwilliams opened 5 years ago

robatwilliams commented 5 years ago

Rather than banning particular ES versions or individual features, I'd like to be able to declare the browser features that are to be supported. This might be for this plugin, or some companion plugin/config that works with it.

As a starting idea...

// .eslinrc.json
{
  "plugins": ["es"],
  "extends": "plugin:es/browserslist"
}
// .browserslistrc
last 3 versions

The es/no-foo rules included in the output config would be dynamic, based on the browsers matching the browserslist spec, looked up against a compatibility database.

Leading on from:

robatwilliams commented 5 years ago

I ended up making this myself, as a plugin which delegates to this plugin. It uses browserslist and the MDN browser compatibility data. Also made a companion CLI tool.

https://github.com/robatwilliams/es-compat

I've just released a beta version which covers ES2018 and 2019. It shouldn't be much more work to add the other ES20xx versions for a MVP. Let me know if you have any feedback.

If it turns out well, it may be worth linking to as a related tool.

Thanks for your work on this plugin - it does all the hard work so all I had to do was join everything up.