🌜
🌞
eslint-plugin-compat

eslint-plugin-compat

v4.0.2

Lint browser compatibility of API used

npm install eslint-plugin-compat

README

eslint-plugin-compat

Build Status 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 --save-dev eslint-plugin-compat

2. Update ESLint Config

.eslintrc.json

   {
+    "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"
    ]
  }
}

Demo

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

Advanced

Road Map

See the Road Map for the details.

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.

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute]. code contributor

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

individual

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

organization organization organization organization organization organization organization organization organization organization

Release Notes

4.0.2
By Amila Welihinda • Published on January 31, 2022
  • fix: bump caniuse-lite a702236
  • chore: bump @mdn/browser-compat-data 153cfe7
  • fix: drop yarn (#510) 023d0c5

https://github.com/amilajack/eslint-plugin-compat/compare/v4.0.1...v4.0.2

4.0.1
By Amila Welihinda • Published on January 6, 2022
  • hoist memoized fn for getting rules (#505) b2b922f
  • infra: npm caching in ci 8f4cf06
  • Add new CommonJS babel config files (#497) 856d476

https://github.com/amilajack/eslint-plugin-compat/compare/v4.0.0...v4.0.1

4.0.0
By Amila Welihinda • Published on November 16, 2021
  • Add version 8 to the peer dependencies for ESLint (#495) 0bf4751
  • chore: migrate to npm (#494) 286b9b6

https://github.com/amilajack/eslint-plugin-compat/compare/v4.0.0-0...v4.0.0

4.0.0-0
By Amila Welihinda • Published on November 15, 2021
  • feat: [email protected] support (#489) b1b9306
  • chore(dev-deps): add eslint-plugin-eslint-plugin (#491) 372fd9b

https://github.com/amilajack/eslint-plugin-compat/compare/v3.13.0...v4.0.0-0

3.13.0
By Amila Welihinda • Published on August 19, 2021
  • feat: bump to latest ast-metadata-inferer 42a782e

https://github.com/amilajack/eslint-plugin-compat/compare/v3.12.0...v3.13.0

3.12.0
By Amila Welihinda • Published on August 9, 2021
3.11.1
By Amila Welihinda • Published on July 18, 2021
3.11.0
By Amila Welihinda • Published on July 16, 2021
3.9.1-0
By Amila Welihinda • Published on July 16, 2021
  • chore: bump deps (#478) 4368c65
  • chore(deps): update dependency electron to v9.4.0 [security] 7c5bd34
  • chore(deps): update dependency semantic-release to ^17.4.2 db0958d
  • chore(deps): update dependency @types/jest to ^26.0.22 62dd90f
  • chore(deps): update dependency @types/eslint to ^7.2.8 815af0c
  • chore(deps): update babel monorepo c508527
  • chore(deps): update dependency semantic-release to ^17.4.0 34fcb60
  • chore(deps): update babel monorepo 5b2e4c6
  • chore(deps): update octokit/request-action action to v2.0.26 86ee795
  • chore(deps): update dependency semantic-release to ^17.3.7 f33e05a
  • chore(deps): update dependency eslint-plugin-prettier to ^3.3.1 dd7c193
  • chore(deps): update dependency @types/jest to ^26.0.20 f415b21
  • chore(deps): update dependency simple-git to ^2.31.0 89b7dc7
  • chore(deps): update dependency semantic-release to ^17.3.1 3459e29
  • chore(deps): update dependency @types/jest to ^26.0.19 c4e7417
  • chore(deps): update dependency eslint-plugin-prettier to ^3.3.0 446e1b3
  • chore(deps): update dependency @types/eslint to ^7.2.6 5e04701
  • chore(deps): update babel monorepo ecb152a
  • chore(deps): updates in order to fix IE undetected compat infringements (#436) df1c913

https://github.com/amilajack/eslint-plugin-compat/compare/v3.9.0...v3.9.1-0

3.9.0
By Amila Welihinda • Published on December 14, 2020
  • Migrate from caniuse-db to caniuse-lite (#431) 673f1f0
  • chore: add actions tests (#432) 3c5f1ef
  • Create codeql-analysis.yml c429fa2
  • chore(deps): replace mdn-browser-compat-data with @mdn/browser-compat-data (#427) 90dd999
  • ci: semantic release fix (#429) 4c0f71b
  • chore(deps): update octokit/request-action action to v2.0.17 b1bfb37
  • chore(deps): update dependency simple-git to ^2.24.0 acb92db
  • chore(deps): update dependency typescript to ^3.9.7 9caeb5e
  • chore(deps): update dependency prettier to ^2.2.1 88a4670
  • chore(deps): update dependency @types/eslint to ^7.2.5 dede711
  • chore(deps): update babel monorepo 4ea567d
  • ci: automated semantic-release workflow (#420) 59f5b37
  • ci: semantic-pr title check (#418) 37a6b0b
  • Update dependency eslint-plugin-import to ^2.22.1 9e35ab8
  • Update dependency @types/jest to ^26.0.15 c5c1621
  • Update dependency caniuse-db to ^1.0.30001154 8fd0609
  • Update dependency @types/eslint to ^7.2.4 f24ee7d
  • Update babel monorepo 6d6ae21
  • Update dependency @types/jest to ^26.0.14 8f2bf82
  • Update dependency @types/semver to ^7.3.4 aff0701
  • Update dependency @types/eslint to ^7.2.3 3e23f4b
  • Update babel monorepo to ^7.11.6 53db092
  • Update dependency caniuse-db to ^1.0.30001122 5fd5640
  • Update dependency @types/jest to ^26.0.12 be9d7fb
  • Update dependency @types/semver to ^7.3.3 a0b45c9
  • Update dependency @types/eslint to ^7.2.2 414c87a
  • Update babel monorepo to ^7.11.5 c4c4dc6
  • Update README.md (#389) 3008280
  • Update dependency caniuse-db to ^1.0.30001109 b069d4b
  • Update dependency @types/jest to ^26.0.8 d34b5cd
  • Update babel monorepo 2c63c76
  • Move fatal error check to e2e-repo spec (#379) b18bd6f
  • Add contributors to package.json (#378) ede76bc
  • Azure yml fix (#377) 3c8b866
  • update yml styling 5a303e3
  • comment out libkrb5-dev 8b02938
  • Simple git migration (#375) 7878bf3
  • fix(deps): update dependency caniuse-db to ^1.0.30001091 6fc1475
  • chore(deps): update typescript-eslint monorepo to ^3.5.0 503ee95
  • chore(deps): update babel monorepo to ^7.10.4 c9f3e38
  • Repoinfo tags to commit (#371) d910130
  • test: null propagation (#369) 3d7197c

https://github.com/amilajack/eslint-plugin-compat/compare/v3.8.0...v3.9.0

General

License
MIT
Typescript Types
None found
Tree-shakeable
No

Popularity

GitHub Stargazers
2,857
Community Interest
2,913
Number of Forks
113

Maintenance

Commits
11/2110/2206
Last Commit
Open Issues
51
Closed Issues
149
Open Pull Requests
2
Closed Pull Requests
81

Versions

Versions Released
11/2110/2202
Latest Version Released
Jan 31, 2022
Current Tags
latest4.0.2
next4.0.0-0

Contributors

amilajack
amilajack
Commits: 245
renovate-bot
renovate-bot
Commits: 94
jooohhn
jooohhn
Commits: 25
renovate[bot]
renovate[bot]
Commits: 9
kenju
kenju
Commits: 4
greenkeeper[bot]
greenkeeper[bot]
Commits: 4
andrewjong
andrewjong
Commits: 2
yavorsky
yavorsky
Commits: 1
andrewiggins
andrewiggins
Commits: 1
sapegin
sapegin
Commits: 1
touzoku
touzoku
Commits: 1
terenc3
terenc3
Commits: 1
FND
FND
Commits: 1
eligao
eligao
Commits: 1
exarus
exarus
Commits: 1