Add eslint-plugin-compat.

Some new features are obvious, like Promises and fetch, but for some
smaller features we don't always know if they're supported everywhere.
eslint-plugin-compat, however, does :)

It will log an error if we use anything that is not supported in IE 10
or recent versions of Chrome/Edge/Firefox/Safari. Features can be
whitelisted by adding them to the `polyfills` setting in the eslint
config; this is nice, because it gives us an easy list of features that
users may have to polyfill without having to comb through all of the
code!
This commit is contained in:
Renée Kooi 2018-06-07 13:14:24 +02:00
parent 4132fccb8a
commit 7a53b72893
No known key found for this signature in database
GPG key ID: 8CDD5F0BC448F040
5 changed files with 95 additions and 2 deletions

8
.browserslistrc Normal file
View file

@ -0,0 +1,8 @@
IE 10
last 2 Safari versions
last 2 Chrome versions
last 2 ChromeAndroid versions
last 2 Firefox versions
last 2 FirefoxAndroid versions
last 2 Edge versions
iOS 11.2

View file

@ -9,8 +9,12 @@
"window": true,
"hexo": true
},
"plugins": ["jest"],
"plugins": ["jest", "compat"],
"rules": {
"jsx-quotes": ["error", "prefer-double"]
"jsx-quotes": ["error", "prefer-double"],
"compat/compat": ["error"]
},
"settings": {
"polyfills": ["fetch", "promises"]
}
}

74
package-lock.json generated
View file

@ -5602,6 +5602,65 @@
}
}
},
"eslint-plugin-compat": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-compat/-/eslint-plugin-compat-2.3.0.tgz",
"integrity": "sha1-GNMVzGgymES9VNzBhL5T04pvkcg=",
"dev": true,
"requires": {
"babel-runtime": "^6.26.0",
"browserslist": "^3.2.7",
"caniuse-db": "^1.0.30000843",
"mdn-browser-compat-data": "^0.0.20",
"requireindex": "^1.1.0"
},
"dependencies": {
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
"dev": true,
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
}
},
"browserslist": {
"version": "3.2.8",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.2.8.tgz",
"integrity": "sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==",
"dev": true,
"requires": {
"caniuse-lite": "^1.0.30000844",
"electron-to-chromium": "^1.3.47"
}
},
"caniuse-db": {
"version": "1.0.30000850",
"resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000850.tgz",
"integrity": "sha1-llyBZkFXbQhwm+4SJWoFUBZLldU=",
"dev": true
},
"caniuse-lite": {
"version": "1.0.30000850",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000850.tgz",
"integrity": "sha512-iHK48UR/InydhpPAzgSmsJXRAR925T0kwJhZ1wk0xRatpGMvi2f06LABg6HXfV4WW4P2wChzlcFa/TEmbTyXQA==",
"dev": true
},
"electron-to-chromium": {
"version": "1.3.48",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.48.tgz",
"integrity": "sha1-07DYWTgUBE4JLs4hCPw6ya6kuQA=",
"dev": true
},
"regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==",
"dev": true
}
}
},
"eslint-plugin-import": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz",
@ -11852,6 +11911,15 @@
"resolved": "https://registry.npmjs.org/max-safe-integer/-/max-safe-integer-1.0.1.tgz",
"integrity": "sha1-84BgvixWPYwC5tSK85Ei/YO29BA="
},
"mdn-browser-compat-data": {
"version": "0.0.20",
"resolved": "https://registry.npmjs.org/mdn-browser-compat-data/-/mdn-browser-compat-data-0.0.20.tgz",
"integrity": "sha512-DImQhKtc7umi/LI0licM3GVnKTxYoYmFUKnMjomfIvW8dO4B6UeQLWYQhf1jDTfEV9WZGjFTz3DOfcsnZO6WdA==",
"dev": true,
"requires": {
"extend": "3.0.1"
}
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@ -15483,6 +15551,12 @@
"resolve-from": "^1.0.0"
}
},
"requireindex": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz",
"integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==",
"dev": true
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",

View file

@ -69,6 +69,7 @@
"eslint": "^3.19.0",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-preact": "^1.1.6",
"eslint-plugin-compat": "^2.3.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jest": "^21.6.2",
"eslint-plugin-node": "^4.2.3",

View file

@ -0,0 +1,6 @@
{
"extends": "../../../.eslintrc",
"settings": {
"polyfills": ["serviceworkers"]
}
}