Giter VIP home page Giter VIP 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
  • Babel integration (using babel-preset-env config)

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

// .eslintrc
{
  // ...
  settings: {
    targets: ['chrome >= 50', 'firefox', 'edge', 'safari >= 9'], // Determine target env's
    polyfills: ['simd', 'fetch'], // Indicate features to be ignored
    coverage: false, // Show the global coverage of the feature
    compiler: 'babel' // Warn against usage of API's unsupported by compiler
  }
}

Adding Polyfills

See wiki

Explicit Error Messages

 91:  const some = () => true
                   ^^^^^^^^^^ Arrow Functions are not supported by your babel preset
                              (using .babelrc)

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.

eslint-plugin-compat's People

Contributors

amilajack avatar andrewjong avatar bfred-it avatar joeybaker avatar sapegin avatar

Watchers

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