Giter Club home page Giter Club logo

eslint-plugin-compat's Introduction

eslint-plugin-compat

Build Status Build status NPM version Dependency Status npm

demo of plugin usage

Goals

  • Allow configuration of target browser/s
  • Use caniuse and @kangax's compat table for determining coverage
  • Enable config using .eslintrc
  • browserslist integration (using package.json)

See the Road Map for more details

Installation

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

Add "compat" to .eslintrc "plugins" section, add "browser": true to "env"

If you use typescript, see typescript-eslint-parser.

// .eslintrc
{
  // ...
  "env": {
    "browser": true
  },
  "plugins": ["compat"],
  "rules": {
    // ...
    "compat/compat": 2
  }
}

Idea

Default

 22:  navigator.serviceWorker
                ^^^^^^^^^^^^^ `ServiceWorker` is not supported in IE 11, Edge 15
                               and Safari 8 ๐Ÿ˜ข

Targeting Browsers

eslint-plugin-compat uses the browserslist configuration in package.json

See ai/browserslist for configuration. Here's some examples:

// Simple configuration (package.json)
{
  // ...
  "browserslist": ["last 1 versions", "not ie <= 8"],
}
// Use development and production configurations (package.json)
{
  // ...
  "browserslist": {
    "development": ["last 2 versions"],
    "production": ["last 4 versions"]
  }
}

๐Ÿ’ก You can also define browsers in a separate browserslist file

Adding Polyfills

See wiki polyfills section

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 checked made this plugin to save web developers from having to memorize browser compatibility of specs.

Demo

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

eslint-plugin-compat's People

Contributors

amilajack avatar andrewjong avatar bfred-it avatar greenkeeper[bot] avatar joeybaker avatar sapegin avatar yavorsky avatar

Watchers

 avatar  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.