Justin Chmura

Generate JSHint Markdown Reports

By on

I wanted to quickly talk about a new NPM module I published not to long ago, jshint-md-reporter. As you could figure out from the name, it will give you JSHint markdown reports.

After a quick search, I saw that there wasn’t a reporter already made. I found one that would generate an HTML page in Bootstrap so I stole that same concept, and modified it to generate markdown.

Using the Reporter

If you’re familiar with using JSHint at all, using this reporter should be straightforward. To do it from the command line, just have to specify the reporter file:

jshint --reporter node_modules/jshint-md-reporter/lib/reporter.js file.js

This will write out the markdown result to the console, so you’ll have to pipe that output to a file or some other command to use it.

Using it with Grunt is simple. All that is required is to install the package via npm, then specify it as the reporter for JSHint.

  jshint: {
    options: {
      reporter: require('jshint-md-reporter'),
      reporterOutput: 'jshint-report.md'
    target: ['file.js']

grunt.registerTask('default', ['jshint']);

Just remember to indicate what file to put the output into and add .md as the file extension.

Gulp will require a wrapper in order to have it fit with streams. This wrapper is currently under development and will be released soon. I know Gulp is becoming the popular choice for task runners so I won’t make you wait too long.

Hack Away

If there’s any bugs or if you have an idea for a new feature, let me know on Github. It’s simple, but hopefully you can get some use out of it when linting your JS code.