Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add browserslist depending js validation #7

Open
alexander-schranz opened this issue Jun 19, 2019 · 0 comments
Open

Add browserslist depending js validation #7

alexander-schranz opened this issue Jun 19, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@alexander-schranz
Copy link
Member

alexander-schranz commented Jun 19, 2019

To avoid the usage of JS functions which are not supported by some browsers we should introduce eslinter for this.

There exist a plugin for this type of linting:

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

Based on the browserslist which can be dumped by running:

npx browserslist

and configured the following way in the project package.json:

    "browserslist": [
        "> 0.25% in my stats",
        "> 0.5% in CH",
        "last 3 version and not dead"
    ]

if a polyfill is added it can be configured the following way:

{
    "root": true,
    "extends": [
        // ...
        "plugin:compat/recommended"
    ],
    "settings": {
        "polyfills": [
            "fetch",
            "Object.values",
            "Object.assign",
            "Promise",
            "URL",
            "URLSearchParams",
            "Symbol",
            "Array.keys",
            "Array.from"
        ]
    },
    // ...
}

polyfills can mostly be included over the exist core-js or whatwg-fetch from github:

import 'whatwg-fetch';
import 'core-js/features/url';
import 'core-js/features/url-search-params';
import 'core-js/features/object/assign';
import 'core-js/features/object/values';
import 'core-js/features/promise';
import 'core-js/features/symbol';
import 'core-js/features/array/keys';
import 'core-js/features/array/from';
@alexander-schranz alexander-schranz added the enhancement New feature or request label Jun 19, 2019
alexander-schranz added a commit to alexander-schranz/eslint-config-ma that referenced this issue Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant