简体   繁体   English

如何放松Gulp-JSHint的掉毛规则?

[英]How do I relax Gulp-JSHint linting rules?

I'm trying to adjust the gulp-jshint 'fail' reporter to only fail based on situations that would break javascript code when minifying. 我正在尝试将gulp-jshint'fail'报告程序调整为仅基于缩小时会破坏javascript代码的情况而失败。

For example the two situations I find cause the most problems are 例如,我发现导致最多问题的两种情况是

  • Missing Semicolons 缺少分号

  • Implicitly declared variables 隐式声明的变量

Is there any way I can create a gulp-jshint task that only looks for the above conditions? 有什么办法可以创建查找上述条件的gulp-jshint任务?

So far I have: 到目前为止,我有:

gulp.task('lint', function() {
    return gulp.src('src/main/webapp/static/js/**/**/**/*')
            .pipe(jshint())
            .pipe(jshint.reporter('fail'));
});

But this picks up many issues that aren't important for minification 但这带来了许多对缩小并不重要的问题


EDIT 编辑

I have tried using: 我试过使用:

.pipe(jshint.reporter('default', {undef: true, asi: false}))

but this doesn't seem to change anything 但这似乎并没有改变任何东西

From looking at the docs , the conditions you want to enforce are the following: 通过查看文档 ,您要执行的条件如下:

undef : This option prohibits the use of explicitly undeclared variables. undef :此选项禁止使用显式未声明的变量。 This option is very useful for spotting leaking and mistyped variables. 此选项对于发现泄漏和错误键入的变量非常有用。

and

asi : This option suppresses warnings about missing semicolons. asi :此选项禁止显示有关分号丢失的警告。 There is a lot of FUD about semicolon spread by quite a few people in the community. 关于社区中很多人传播的分号有很多FUD。 The common myths are that semicolons are required all the time (they are not) and that they are unreliable. 常见的误解是分号始终是必需的(不是),并且分号不可靠。 JavaScript has rules about semicolons which are followed by all browsers so it is up to you to decide whether you should or should not use semicolons in your code. JavaScript的分号规则由所有浏览器都遵循,因此您可以自行决定是否在代码中使用分号。

So you should have 所以你应该有

  1. undef = true undef = true

and

  1. asi = false asi = false

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

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