如何强制 jshint 在提示适用的地方打印源文件?

How to force jshint to print source file where the the hint applies?

我是来自 grunt 的 运行 jshint。
这是我的配置:

jshint: {
    files: ['Gruntfile.js', 'app/htmlplayer/js/directives/**/*.js'],
    options: {
        globals: {
            jQuery: true
        }
    }
},

但是在 运行 grunt test 之后在控制台中触发 jshint 打印提示,最后打印:
“30 个文件中有 118 个错误”

这是一个example

如何找到出现此问题的文件?
有没有办法配置 jshint 来指定对每个错误负责的源文件?

您需要更改 reporter 选项,以修改插件的输出。

默认情况下(当 reporter 值为 null 时),输出类似于 -

切换到 checkstyle 记者,将给出类似 -

的输出

切换到 jslint 记者,将给出类似 -

的输出

除此之外,您还可以使用自定义报告器,例如 jshint-stylish -

grunt 任务配置为 -

jshint: {
            all: ['entry.js'],
            options: {
                reporter: require('jshint-stylish')
            }
        }

您可以在 - https://www.npmjs.com/search?q=jshint%20reporter

找到其他自定义记者