npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@riverglide/jshint-junit-reporter

v0.3.0

Published

A JSHint reporter for jUnit.

Downloads

2

Readme

JSHint JUnit Reporter

A JSHint output report that returns results compatible with JUnit XML. This makes it possible to integrate the results into any reporting framework that accepts that format. I have found this particularly useful in continuous integration scenarios (Bamboo, Jenkins, etc.)

The entire JSHint run is considered a test suite and each file with failures is a test case. A failure node is added to each test case indicating the number of linting errors for that test case. The body of that node enumerates the messages.

<?xml version="1.0" encoding="utf-8"?>
<testsuite name="jshint" tests="1" failures="3" errors="0" >
	<testcase name="test.js">
		<failure message="3 JSHint Failures" >
1. line 3, char 5: Missing &quot;use strict&quot; statement.
2. line 4, char 2: Missing semicolon.
3. line 1, char 1: &apos;x&apos; is not defined.
		</failure>
	</testcase>
</testsuite>

Installation

Download the file directly on install using NPM:

npm install jshint-junit-reporter

Usage

Pass the path to reporter.js to the JSHint --reporter option like this:

jshint --reporter=reporter.js reporter.js

You can also use this plugin with the grunt-contrib-jshint plugin that support the reporter option using something like this in your options object:

options: {
	reporter: require("jshint-junit-reporter"),
	reporterOutput: "junit-output.xml"
}

Note: To use this option you should be on grunt-contrib-jshint >0.5.3.

Bamboo Integration

In order to hook this into Bamboo I have a 3 step test-plan:

  1. Checkout Code
  2. Build Script
  3. Read JUnit XML Files

Build Script

grunt jshint

I also fill in the Working Sub-directory field with the path to my repo, which my case is grunt.

Bamboo Build Script

JUnit Parser Configuration

grunt/junit-output.xml

Again, change this to whatever works for your naming convention. With the newer verison of grunt you can just reference the single file and it should work fine!

JUnit Parser Configuration

Results

Bamboo JSHint

Limitations

The reporter API provided by JSHint provides access only to failure information. Therefore, the resulting XML will only list test cases for files that contained failures.

The number of tests containing linting failures will be reflected in the "tests" attribute of the testsuite element. The total number of failures in those files will be reflected in the "failures" attribute.

In the happy case that there are no failures an empty test case will be created for you.