限制最大错误数 [英] Limit maximum number of errors

查看:91
本文介绍了限制最大错误数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过.eslintrc限制eslint中的最大错误数.我目前的.eslintrc

How to limit maximum number of error in eslint through .eslintrc. My current .eslintrc

module.exports = {
    "extends": "airbnb",
    "parserOptions": {
        "ecmaVersion": 6
    },
    "max-warnings" : 2
};

推荐答案

当前, max-warnings 是仅命令行选项.您不能在 .eslintrc 文件中定义它.参见 eslint#2769 .

Currently, max-warnings is a command-line only option. You can't define it in a .eslintrc file. See eslint#2769.

有两种方法可以使用,具体取决于您如何运行eslint.您可以使用 eslint-nibble 之类的方法一次解决一部分错误,然后看到那个子集.

There are a couple of alternatives you can use, depending on how you are runnning eslint. You can use something like eslint-nibble to address a subset of the errors one at a time, and see that subset.

如果您正在使用任务运行程序,则另一个选择是使用其内置选项.例如,如果您使用的是 gulp-eslint ,则在使用 failOnError/failAfterError :

Another option if you're using a task runner is to use its built in options. For example, if you're using gulp-eslint you can fail on/after the first error using failOnError/failAfterError:

var eslint = require('gulp-eslint'),
    gulp   = require('gulp');

gulp.src('**/*.js')
    .pipe(eslint())
    .pipe(eslint.failAfterError());

这篇关于限制最大错误数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆