17

I'm writing a Javascript library, and I'd like to be able to run it through some tool that will

  1. detect any methods that are incompatible with certain browsers, and/or
  2. tell me which browsers do support my code.

So far I can't find anything like this. Does it really not exist?


Prior Research:

  • I've found http://caniuse.com for checking specific methods, but it doesn't help me identify problems I don't know about.
  • I've read question after question about browser compatibility, but found nothing that fits.
  • I've found a bunch of tools for running my unit tests in different browsers (e.g., Sauce Labs), but that's not really what I'm trying to do.
Community
  • 1
  • 1
Carolyn Conway
  • 1,356
  • 1
  • 15
  • 21

2 Answers2

6

I'd recommend you to use this website http://jscc.info/ (wayback machine) or https://seedmanc.github.io/jscc/

Its done the job for me in the past.

Jan
  • 2,178
  • 3
  • 14
  • 26
Dragg
  • 336
  • 1
  • 9
3

You can use eslint-plugin-compat, a plugin for the ESlint linting utility. You can even use Browserlist to configure the browsers you want to support.

Nice animation about eslint-plugin-compat

Installation is very easy. You'll have to install eslint and this plugin:

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

or

yarn add --dev eslint eslint-plugin-compat

And add a ESlint configuration file:

// .eslintrc
{
  "extends": ["plugin:compat/recommended"]
}

Add the supported browsers to your package.json file:

// sample configuration (package.json)
{
  // ...
  "browserslist": ["last 2 Chrome versions", "IE 11"],
}

And then run the linter:

eslint yourfile.js

In my case this was the output:

92:9   error  Promise.all() is not supported in IE 11  compat/compat
94:9   error  Promise.all() is not supported in IE 11  compat/compat
Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97