简体   繁体   中英

How to specifiy ES version within js comment when using ESLint

We are using using ESLint project wide, and there is grunt, clouser-complier, typescript etc to do all hard work to make all js file es5 compliant.

but there is one file which we don't process via these tools, because that is small file we've to serve to browser directly.

How can i specify version of that file to es5 to eslint, so it don't show errors and warnings for that particular file, i saw there are options we can set via comment on top, but how js version could be set.

Eslint supports an overrides property inside its config file:

overrides: [
    {
        files: [
            "path/to/file.js"
        ],
        parserOptions: {
            ecmaVersion: 5
        },
    },
],

As per https://github.com/xojs/eslint-config-xo/issues/16#issuecomment-190302577

its not possible to do, so only thing we can do is completely turn it off by this comment.

/* eslint-disable */

thanks @felipekm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM