简体   繁体   English

使用ESLint时如何在js注释中指定ES版本

[英]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. 我们在整个项目范围内都使用ESLint,并且有大量的工作,clouser-complier,打字稿等可以使所有js文件与es5兼容的所有工作。

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. 我如何才能将该文件的版本指定为es5到eslint,所以它不会显示该特定文件的错误和警告,我看到可以在顶部通过注释设置一些选项,但是可以如何设置js版本。

Eslint supports an overrides property inside its config file: Eslint在其配置文件中支持overrides属性:

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

As per https://github.com/xojs/eslint-config-xo/issues/16#issuecomment-190302577 根据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 谢谢@felipekm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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