Giter Club home page Giter Club logo

eslint-plugin-compat's Introduction

eslint-plugin-compat

Build Status Financial Contributors on Open Collective NPM version Dependency Status npm Backers on Open Collective Sponsors on Open Collective

Lint the browser compatibility of your code

demo of plugin usage

Setup

1. Install

npm install --save-dev eslint-plugin-compat

2. Update ESLint Config

.eslintrc.json

   {
+    "extends": ["plugin: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": [
+      "defaults"
+    ]
  }

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

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"
    ]
  }
}

Demo

For a minimal demo, see amilajack/eslint-plugin-compat-demo

Advanced

Road Map

See the Road Map for the details.

Inspiration

Toolchains for native platforms, like iOS and Android, have had API linting from the start. It's about time that the web had similar tooling.

This project was inspired by a two hour conversation I had with someone on the experience of web development and if it is terrible or not. The premise they argued was that x browser doesn't support y feature while z browser does. Eventually, I agreed with him on this and made this plugin to save web developers from having to memorize the browser compatibility of WebAPIs.

Related

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

eslint-plugin-compat's People

Contributors

amilajack avatar andrewjong avatar bagage avatar bfred-it avatar brettz9 avatar dkrnl avatar eligao avatar exarus avatar fnd avatar greenkeeper[bot] avatar hamirmahal avatar jaylinski avatar joeybaker avatar jooohhn avatar julien-f avatar kenju avatar msakamaki avatar pwfcurry avatar renovate-bot avatar renovate[bot] avatar sapegin avatar tbroyer avatar terenc3 avatar touzoku avatar trevorburnham avatar yavorsky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.