grunt: how to generate jshint output as HTML

蓝咒 提交于 2019-12-23 16:33:53

问题


I'm trying to run jshint using grunt. This works, but now I would like the output to be HTML. Here is my grunt file

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');
};

Running this grunt taks, the output is in XML. Any suggestion how to turn this into something that outputs HTML ?

Thanks a lot


回答1:


You would need to write a custom reporter. Check the jshint docs on writing custom reporters: http://jshint.com/docs/reporters/ Then you can specify the path to the reporter with:

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



回答2:


You can use jshint reporter from nodejs

This generates output in HTML

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

Include this in your 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']);


来源:https://stackoverflow.com/questions/17477788/grunt-how-to-generate-jshint-output-as-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!