• Stars
    star
    3,077
  • Rank 14,629 (Top 0.3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Check the browser compatibility of your code

eslint-plugin-compat

Test Financial Contributors on Open Collective NPM version 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 eslint-plugin-compat

2. Update ESLint Config

.eslintrc.json

{
  "plugins": ["compat"],
  "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"
    ]
  }
}

Linting ES APIs (Experimental)

This plugin also supports linting the compatibility of ES APIs in addition to Web APIs. This is an experimental feature and is disabled by default. To enable this feature, add the following to your eslint config:

{
  // ...
  "settings": {
    "lintAllEsApis": true
  }
}

Demo

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

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]

More Repositories

1

reading

A list of computer-science readings I recommend
2,628
star
2

project-checklist

✅ A checklist of things to do before releasing your project
748
star
3

popcorn-time-desktop

🍿 🕐 🎞 A Modern Popcorn Time Client
TypeScript
458
star
4

eslint-plugin-flowtype-errors

Run Flow as an ESLint plugin
JavaScript
402
star
5

js-algorithms

A collection of algorithms written in javascript
JavaScript
226
star
6

awesome-web-audio

A list of resources and projects to help learn about audio
121
star
7

front-end-system-design

A checklist for front end system design
91
star
8

compat-db

A browser API compatibility database
JavaScript
63
star
9

drum-machine

A drum machine. Made with Vue and the WebAudio API.
Vue
51
star
10

alfred

A Modular Toolchain for JavaScript
TypeScript
42
star
11

erb-sqlite-example

An example of erb with native dependencies (sqlite3 in this case)
TypeScript
40
star
12

node-disk-utility

Quickly calculate the size of a folder or disk on macOS and Linux
Rust
30
star
13

erb-tailwind-example

TypeScript
21
star
14

erb-ant-design-example

JavaScript
19
star
15

clipboard

A better command line clipboard
Rust
17
star
16

xwing

An xwing WebGL game powered by three.js
JavaScript
16
star
17

erb-serialport-example

An example of using electron-react-boilerplate with serialport
TypeScript
15
star
18

freesound-client

A node and browser client freesound.org API v2
TypeScript
15
star
19

react-wavesurfer.js

React bindings for wavesurfer.js
TypeScript
11
star
20

erb-typescript-example

A fork of electron-react-boilerplate that adds Typescript integration
JavaScript
11
star
21

startups-101

Everything you need to know to start a startup
11
star
22

erb-second-renderer-window-example

JavaScript
10
star
23

erb-express-example

JavaScript
10
star
24

eslint-plugin-dom

Lint DOM API performance
JavaScript
9
star
25

ast-metadata-inferer

Given a list of API's, return their AST node type
TypeScript
8
star
26

babel-plugin-fail-explicit

A babel plugin that prevents coercion and silent failure in JavaScript
JavaScript
7
star
27

eslint-plugin-compat-demo

A minimal demo of eslint-plugin-compat
JavaScript
7
star
28

database_exporter

Export any database to any format
Rust
6
star
29

erb-bootstrap-example

An example of electron-react-boilerplate using sass and bootstrap.
JavaScript
6
star
30

joker

A modern and intuitive testing library for command-line apps
TypeScript
5
star
31

erb-local-fs-read-example

An exmaple of reading local files with node in production with erb.
JavaScript
5
star
32

oxide

Parallelisim and concurrency primatives for JS by leveraging immutability data structures
Rust
5
star
33

themoviedb

🎥🎬🍿 themoviedb API node client
JavaScript
4
star
34

awesome-node-cli-libraries

A list of libraries and infrastructure for building CLI's with node
4
star
35

eslint-config-bliss

An opinionated ESLint config general node development 🎉
JavaScript
4
star
36

erb-monorepo-example

JavaScript
4
star
37

contrast

A cross-platform diff tool
JavaScript
4
star
38

awesome-js-perf-readings

Awesome JS performance readings
3
star
39

awesome-javascript-tooling

A list of JavaScript tooling
3
star
40

os-type

Node bindings to the os_type Rust library
Rust
3
star
41

threejs-game

A toy game that I'm trying to make so that I can familiarize myself with threejs
JavaScript
3
star
42

css-compat

Check the compatibility of a given css rule
JavaScript
2
star
43

erb-better-sqlite3-example

TypeScript
2
star
44

webgl-specs

Detect the graphics specs of a device using web APIs
JavaScript
2
star
45

esm-dep-check

Check if your dependencies are using ES6 modules
JavaScript
2
star
46

svg-zoom

A micro library that lets you zoom in on svg elements
HTML
2
star
47

openvpn-client

JavaScript
2
star
48

erb-video-example

JavaScript
2
star
49

kat-shows

DEPRECATED: A repo for scraping kat shows
JavaScript
2
star
50

erb-audio-example

A runnable example of electron-react-boilerplate importing audio files
JavaScript
2
star
51

popcorn-time-desktop-design

The design of UI components for popcorn-time-desktop
2
star
52

neon-benchmarks

A collection of benchmarks comparing performance differences between native node modules and Neon implementations
JavaScript
2
star
53

gridsound.github.io

This is the landing page of the GridSound project
CSS
2
star
54

react-skia-fiber

A React renderer for Skia
TypeScript
2
star
55

amilajack

my personal w̶e̶b̶s̶i̶t̶e̶ npm module
JavaScript
2
star
56

compat-db-rewrite

A scalable database of browser api compatibility
Rust
2
star
57

cra-palette-example

JavaScript
1
star
58

parallel-scripts

JavaScript
1
star
59

sir-simulation

A disease spread simulation based on the SIR model
JavaScript
1
star
60

cs-data-structures-and-algorithms

Data Structures and Algorithms Homework and Problems
Java
1
star
61

sqlite

1
star
62

react-tabs

Created with CodeSandbox
TypeScript
1
star
63

erb-pdf-example

An example of using a pdf viewer with electron-react-boilerplate
JavaScript
1
star
64

erb-electron-remote-example

JavaScript
1
star
65

erb-electrino-example

JavaScript
1
star
66

babel-plugin-fail-explicit-demo

A simple demo of babel-plugin-fail-explicit
JavaScript
1
star
67

safe-access-check

A micro library that prevents unsafe coercion and property access in javascript
JavaScript
1
star
68

erb-cli

A CLI tool for electron-react-boilerplate
1
star
69

my-website

JavaScript
1
star
70

erb-redux-persist-example

JavaScript
1
star
71

vite-project

1
star
72

rust-algos

An ongoing collection of algorithms written in rust
Rust
1
star
73

erb-node-opencv-example

JavaScript
1
star
74

debugging-the-gender-gap

My presentation on addressing low percentages of women in the software industry
JavaScript
1
star
75

renovate-config-bliss

A renovate config optimized for minimal maintainer intervention
1
star
76

node-eztv-example

A clonable and runnable example repo for the eztv npm package
JavaScript
1
star
77

esbuild-as-a-service

TypeScript
1
star
78

awesome-webgl

1
star
79

xwing-rewrite

A rewrite of amilajack/wing
JavaScript
1
star
80

state-of-nature-syntax

A simple and subtle syntax theme inspired by the beauty of nature
CSS
1
star
81

learning-webgl

A list of links for learning WebGL
1
star
82

threejs-playground

A playground for getting started with three-js
JavaScript
1
star
83

openframeworks-emscripten-wasm-example

A set of setup steps and tooling for running openframeworks with emscripten
1
star
84

serde_postgres

Easily Deserialize Postgres rows.
Rust
1
star
85

gaussify

Fast and intuitive library for creating efficient blurred UI's
JavaScript
1
star
86

naming-things

A guide for naming things
1
star
87

fuzzy-phrase

Fast fuzzy phrase matching, designed for use with https://github.com/mapbox/carmen
Rust
1
star
88

resume

My resume
1
star
89

spectrogram

A spectrogram implementation in js
JavaScript
1
star
90

webgl-sdf-demo

The source for Will Dobbie's Warn and Peace WebGL demo
HTML
1
star
91

quill-browserify-example

JavaScript
1
star
92

rust-bindgen-example

A working example of the rust-bindgen walkthrough
Rust
1
star
93

compat-test-runner

Given a compat record, return if the API is supported or not
JavaScript
1
star
94

dark-demo

A minimal runnable demo of Dark, a modern fork of commander.js
JavaScript
1
star
95

erb-testcafe-example

A fork of electron-react-boilerplate that uses testcafe for e2e tests
JavaScript
1
star
96

linear-programming-with-julia

A simple linear programming example with julia and JuMP
Julia
1
star