为了在环境中使用ES6,我必须将.eslintrc文件指定为:

"env": {
    "node": false,
    "browser": true,
    "amd": true,
    "mocha": true,
    "jasmine": false,
    "es6": true
}

但是,当我想使用ES7时,我可以:
"env": {
    "node": false,
    "browser": true,
    "amd": true,
    "mocha": true,
    "jasmine": false,
    "es7": true
}



有关信息,我查看了https://eslint.org/docs/user-guide/configuring,但没有得到答案。

更新

我当前的文件eslint文件如下所示:
{
    "globals": {
        "com": true,
        "oData": false,
        "sakp": false,
        "fin": true,
        "cloud": true,
        "bsuite": false,
        "cordova": false,
        "ui": true,
        "webide": false,
        "asyncTest": false,
        "i2d": true,
        "gltrade": false,
        "drilldown": true,
        "opaTest": false,
        "ux": true,
        "test": false,
        "$": false,
        "module": false,
        "ai": false,
        "notEqual": false,
        "notDeepEqual": false,
        "throws": false,
        "ssuite": false,
        "deepEqual": false,
        "s2p": false,
        "Promise": false,
        "ehs": false,
        "sinon": false,
        "stop": false,
        "util": true,
        "slo": false,
        "mdm": false,
        "mytravelandexpense": false,
        "strictEqual": false,
        "cec": false,
        "cus": false,
        "notStrictEqual": false,
        "fscm": false,
        "fm": true,
        "nw": true,
        "shcm": false,
        "fcg": true,
        "URI": false,
        "fs": true,
        "retail": false,
        "d3": false,
        "hcm": false,
        "oil": true,
        "assert": false,
        "hpa": false,
        "ok": false,
        "sap": true,
        "QUnit": false,
        "cross": true,
        "srm": false,
        "equal": false,
        "expect": false,
        "jQuery": false,
        "publicservices": true,
        "uxcc": false,
        "equals": false,
        "tl": false,
        "travel": true
    },
    "env": {
        "node": false,
        "browser": true,
        "amd": true,
        "mocha": true,
        "jasmine": false,
        "es6": true
    }
}

在哪里指定es7?

最佳答案

要控制允许的语法版本,您需要设置 ecmaVersion under parserOptions :

{
    "env": {
        "node": false,
        "browser": true,
        "amd": true,
        "mocha": true,
        "jasmine": false,
        "es6": true
    },
    "parserOptions": {
        "ecmaVersion": 2016
    }
}

该值可以是规范的年份或版本号(例如ECMAScript 20189版本具有相同的效果)。

关于javascript - 为ES7指定env选项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50561054/

10-09 16:36