Skip to content

Check JavaScript code compatibility with target runtime environments

License

Notifications You must be signed in to change notification settings

sobstel/es-compat

 
 

Repository files navigation

npm version npm downloads

es-compat

Check JavaScript code compatibility with target browsers and Node.js versions

Checks that the language features used in your code/bundles are supported by your browserslist targets.

Tools

Rationale

You might not need a transpiler or polyfills.

Or, you may be transpiling your own code but not prebuilt 3rd-party libraries - leaving you open to breakages when they use new language features.

ESLint supports targeting a specific ECMAScript version, and eslint-plugin-es allows forbidding individual language features. However when building applications, what we target are particular browser/runtime versions. This project lets you check compatibility by specifying those targets directly via a browserslist. It will figure out which individual features you can use, by looking up those targets in the MDN compatibility dataset.

Scope

ECMAScript language features only; this includes syntax, built-ins, and methods.

It doesn't check browser/runtime-specific APIs (see eslint-plugin-compat), or CSS (see doiuse).

ECMAScript version coverage

n Expand for footnotes...

1 Excluding features not statically detectable: revised Function.prototype.toString, stable Array.prototype.sort, well-formed JSON.stringify.

2 Excluding Symbol.prototype.description; as a debug feature, it's not worth the false positives that arise due to its name and not being a method.

3 ES2015 (ES6) is out of scope; it's been supported by evergreen browsers for many years. Assisting you to continue supporting IE11 is not a goal of this tool.

4 ES5 is out of scope; it's over 10 years old and supported even in IE10.

Limitations

Because JavaScript is untyped, detection of some features' usage (namely prototype methods) through static analysis requires some assumptions to be made. This shouldn't be a problem as long as you avoid creating your own methods having the same names, or write code in an unusual way to deliberately evade detection.

The MDN compatibility dataset has very good coverage of the top ~6 desktop and mobile browsers, and Node.js (much more than kangax/compat-table). In case of missing data (support unknown, or unknown in which version support was added), we currently assume support.

Contributing

Contributions and feedback welcome. Please see the GitHub issues or create one, as appropriate.

Related

* Thanks to these projects in particular (and many others) for making this project possible.

About

Check JavaScript code compatibility with target runtime environments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%