eslint-plugin-compat
This plugin is a fork of eslint-plugin-compat with support to track usage of unsupported features on instance methods and objects.
Demo:
Setup
1. Install
npm install --save-dev eslint-plugin-agoda-compat
2. Update ESLint Config
// .eslintrc.json{ "extends": ["plugin:agoda-compat/recommended"], "env": { "browser": true }, // ...}
3. Configure Target Browsers
Browser targets are configured using browserslist. You can configure browser targets in your package.json
:
package.json
{ // ... "browserslist": ["chrome 70", "last 1 versions", "not ie <= 8"]}
If no configuration is found, browserslist defaults to "> 0.5%, last 2 versions, Firefox ESR, not dead"
.
See browserslist/browserslist for more details.
Adding Polyfills
v3
Add polyfills to the settings section of your eslint config. Append the name of the object and the property if one exists. Here are some examples:
{ // ... "settings": { "polyfills": [ // Example of marking entire API and all methods and properties as polyfilled "Promise", // Example of marking specific method of an API as polyfilled "WebAssembly.compile", // Example of API with no property (i.e. a function) "fetch", // Example of instance method, must add `.prototype.` "Array.prototype.push" ] }}
v2
Demo
For a minimal demo, see amilajack/eslint-plugin-compat-demo