我如何强制JSHint在咕噜声中运行以始终使用--verbose标志 [英] How can I force JSHint running in grunt to always use the --verbose flag

查看:95
本文介绍了我如何强制JSHint在咕噜声中运行以始终使用--verbose标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个特殊的JSHint / Grunt设置,我想完成以下任务:


  1. 从单个.jshintrc文件加载允许我的IDE linter拿起我的设置
  2. 能够在其他grunt任务中覆盖.jshintrc中的单个选项

  3. 让JSHint始终运行在详细模式下,这样我就可以随时查看警告号码,而无需使用--verbose

运行所有的咕噜声。我从.jshintrc加载,并始终运行在详细,但不允许选项覆盖。文档提到这应该是这种情况,但不要说详细的选项,这是可行的:

  jshint: {
选项:{
jshintrc:'.jshintrc',
详细信息:true,
},
来源:{
选项:{
忽略:['src / ** / *。test.js'],
},
文件:{
src:['src / ** / *。js']
}
},
测试:{
选项:{
未使用:false
},
文件:{
src: ['src / ** / *。test.js']
}
}
}

为了避开覆盖限制,只需将grunt将.jshintrc文件的内容注入到配置中就相当容易,但无论出于何种原因,这会导致linter现在将line 0 col 0错误选项:'verbose'。(E001)错误(如果我删除了options.verbose = true;这行就会正确运行,但是w没有详细的标志):

  jshint:{
options:(function(){
var options = grunt.file.readJSON('。jshintrc');
options.verbose = true;
返回选项;
}()),
source:{
options:{
ignores:['src / ** / *。test.js'],
},
档案:{
src:['src / ** / *。js']
}
},
测试:{
选项:(函数(){
var options = grunt.file.readJSON('。jshintrc');
options.unused = false;
返回选项;
}()),
档案:{
src:['src / ** / *。test.js']
}
}
}

所以,根据我的三个标准,有没有办法配置grunt以这种方式运行?



 <$ c  $ c> ./ node_modules / grunt-contrib-jshint / node_modules / jshint / bin / jshint --verbose app / sources / modules / dashboard / views / dashboard-performance / dashboard-performance-ctrl.js 
code>

在选项中没有办法为grunt jshint定义详细模式。并且它将不会被解决,直到grunt更新。
(感谢MaxPRafferty)


I have a particular JSHint/Grunt setup in which I would like to accomplish the following:

  1. Load from a single .jshintrc file to allow my IDE linter to pick up my settings
  2. Be able to override single options from the .jshintrc in other grunt tasks
  3. Have JSHint always run in verbose mode so that I can always see the warning numbers, without needing to run all of grunt with --verbose

The following allows me to load from the .jshintrc and always run in verbose, but does not allow option overrides. The docs mention that this should be the case, but don't say anything about the verbose option, which works:

jshint: {
    options:{
        jshintrc: '.jshintrc',
        verbose: true,
    },
    source: {
        options: {
            ignores: ['src/**/*.test.js'],
        },
        files:{
            src:['src/**/*.js']
        }
    },
    tests: {
        options: {
            unused: false
        },
        files: {
             src: ['src/**/*.test.js']
        }
    }
}

To get around the override limitations, it is fairly easy to just have grunt inject the contents of the .jshintrc file into the config, but for whatever reason this causes the linter to now throw "line 0 col 0 Bad option: 'verbose'. (E001)" errors (this runs correctly if i remove the options.verbose = true; line, but without the verbose flag):

jshint: {
    options:(function () {
        var options = grunt.file.readJSON('.jshintrc');
        options.verbose = true;
        return options;
    }()),
    source: {
        options: {
            ignores: ['src/**/*.test.js'],
        },
        files:{
            src:['src/**/*.js']
        }
    },
    tests: {
        options: (function () {
            var options = grunt.file.readJSON('.jshintrc');
            options.unused = false;
            return options;
        }()),
        files: {
            src: ['src/**/*.test.js']
        }
    }
}

So, given my three criteria, is there a way to configure grunt to run in this way?

解决方案

How to run jshint on specific file using grunt-contrib-jshint:

./node_modules/grunt-contrib-jshint/node_modules/jshint/bin/jshint --verbose app/sources/modules/dashboard/views/dashboard-performance/dashboard-performance-ctrl.js

there is no way to define verbose mode for grunt jshint in options. And it will not be solved until grunt updates. (thanks to MaxPRafferty)

这篇关于我如何强制JSHint在咕噜声中运行以始终使用--verbose标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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