admin管理员组

文章数量:1309939

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

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

Share Improve this question asked Jul 4, 2013 at 20:36 Jeanluca ScaljeriJeanluca Scaljeri 29.2k66 gold badges233 silver badges380 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

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

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

You can use jshint reporter from nodejs

This generates output in HTML

https://www.npmjs./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']);

本文标签: javascriptgrunt how to generate jshint output as HTMLStack Overflow