【问题标题】:grunt: how to generate jshint output as HTMLgrunt:如何将 jshint 输出生成为 HTML
【发布时间】:2013-07-04 20:36:04
【问题描述】:

我正在尝试使用 grunt 运行 jshint。这可行,但现在我希望输出为 HTML。这是我的 grunt 文件

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        jshint: {
            all: ['Gruntfile.js', 'src/*.js']
            , options: {
                //reporter: 'jslint'
                reporter:'checkstyle'
                , reporterOutput: 'jshint.html'
            }
         }
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
};

运行这个 grunt taks,输出是 XML。有什么建议可以把它变成输出 HTML 的东西吗?

非常感谢

【问题讨论】:

    标签: javascript html gruntjs jshint


    【解决方案1】:

    您需要编写一个自定义报告器。查看关于编写自定义报告器的 jshint 文档:http://jshint.com/docs/reporters/ 然后您可以指定报告器的路径:

    options: {
      reporter: '/path/to/custom/html/reporter',
      reporterOutput: 'jshint.html'
    }
    

    【讨论】:

    • 那么,有人写过这样的记者吗?这样做应该很简单,所以我宁愿使用现有的,而不是尝试重新实现它。
    • 我还没有见过现有的 HTML 记者。主要是 XML 和 JSON。
    • 你可以查看这个:jshint-html-reporter。我曾经在 CI 构建中显示报告,它就像一个魅力。
    【解决方案2】:

    您可以使用 nodejs 中的 jshint 报告器

    这会生成 HTML 格式的输出

    https://www.npmjs.com/package/jshint-html-reporter

    在你的 GruntFile.js 中包含这个

    grunt.initConfig({
        jshint: {
            options: {
                reporter: require('jshint-html-reporter'),
                reporterOutput: 'jshint-report.html'
            },
            target: ['file.js']
        }
    });
    
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.registerTask('default', ['jshint']);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 1970-01-01
      • 1970-01-01
      • 2014-09-24
      • 1970-01-01
      相关资源
      最近更新 更多