[Tooling] Expand browsers target while keeping Polyfills under control (#709)
* expand browsers target * add eslint-plugin-compat * sort polyfils * adjust readme * add polyfills sync check action * only build js * trim * add Element.prototype.closest * add closest to demo links * fix ignorepull/719/head
parent
e3cc6eaf1b
commit
172366d6fa
12 changed files with 172 additions and 24 deletions
@ -1,2 +1 @@ |
||||
> 5% |
||||
IE 11 |
||||
> 1% |
||||
|
@ -0,0 +1,14 @@ |
||||
const { readFileSync } = require('fs'); |
||||
const path = require('path'); |
||||
const assert = require('assert'); |
||||
|
||||
const readme = readFileSync(path.resolve(__dirname, '../../README.md'), 'utf8'); |
||||
|
||||
const polyfillsFromDocs = /^```polyfills\s*\n([^`]+)\n^```/m |
||||
.exec(readme)[1] |
||||
.split('\n') |
||||
.map(v => v.trim()) |
||||
.sort(); |
||||
// @ts-ignore
|
||||
const polyfillsFromSettings = require('../../.eslintrc.json').settings.polyfills.sort(); |
||||
assert.deepStrictEqual(polyfillsFromDocs, polyfillsFromSettings); |
@ -0,0 +1,23 @@ |
||||
name: Polyfills documentation |
||||
|
||||
on: |
||||
pull_request: |
||||
paths: |
||||
- 'README.md' |
||||
- '.browserslistrc' |
||||
- '.eslintrc.json' |
||||
|
||||
jobs: |
||||
sync: |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- uses: actions/checkout@v1 |
||||
with: |
||||
fetch-depth: 1 |
||||
|
||||
- uses: actions/setup-node@v1 |
||||
with: |
||||
node-version: 12 |
||||
|
||||
- name: Check Polyfills documentation and settings sync |
||||
run: node .github/actions-scripts/polyfills-sync.js |
@ -0,0 +1,24 @@ |
||||
|
||||
// get polyfill settings from top level config
|
||||
// @ts-ignore
|
||||
const { settings } = require('../../../.eslintrc.json'); |
||||
|
||||
// Adding non-polyfilable Symbol-related functions as they are most probably
|
||||
// behind the flag
|
||||
|
||||
settings.polyfills.push('Symbol.toStringTag', 'Symbol.for', 'Object.getOwnPropertySymbols', 'Object.getOwnPropertyDescriptors') |
||||
|
||||
module.exports = /** @type {import('eslint').Linter.Config} */({ |
||||
root: true, |
||||
extends: [ |
||||
"plugin:compat/recommended" |
||||
], |
||||
parserOptions: { |
||||
// ensure that it's compatible with ES5 browsers, so, no `const`, etc
|
||||
ecmaVersion: 5 |
||||
}, |
||||
env: { |
||||
browser: true |
||||
}, |
||||
settings |
||||
}) |
Loading…
Reference in new issue