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

gulp-pa11y

v0.0.4

Published

Accessibility audit of your site using Gulp based on pa11y

Downloads

46

Readme

gulp-pa11y

Accessibility Audit of your site using pa11y

gulp-pa11y is a gulp.js task to do accessibility audit of your site for standards: Section508, WCAG2A, WCAG2AA (default), WCAG2AAA using pa11y

It runs [HTML CodeSniffer][http://squizlabs.github.com/HTML_CodeSniffer/] from the command line for programmatic accessibility reporting.

Check out the documentation to get a full overview of what you can do and test using pally.org.

Getting Started

If you haven't used gulp before, be sure to check out the Getting Started guide, as it explains how to create a gulpfile.js as well as install and use gulp plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install gulp-pa11y --save-dev

Once the plugin has been installed, it may be enabled inside your gulpfile with this line of JavaScript:

var pa11y = require('gulp-pa11y');

The pa11y task

Required configuration properties

To start auditing pages, you must configure a start URL:

Crawl the site with deepth 1.

{
	url: 'http://localhost/'
}

With these configuration properties set, you can add sitespeedio to your default tasks list. That'll look something like this:

gulp.task('default', ['jshint', 'pa11y']);

With this in place, gulp-pa11y will now audit the performance of your pages.

Available Options

url

(string) The URL to sniff. Required.

reporter

(string) The reporter to use. (see custom reporters). Default console.

standard

(string) The standard to use. One of Section508, WCAG2A, WCAG2AA, WCAG2AAA. Default WCAG2AA.

failOnError

(boolean) Fail your build if there is any accessibility error. Default: true

showFailedOnly

(boolean) Only display the errors in report, Set to false to display errros, warnings and notice. Default: true

htmlcs

(string) The URL to source HTML_CodeSniffer from. Default http://squizlabs.github.io/HTML_CodeSniffer/build/HTMLCS.js.

config

(string,object) The path to a JSON config file or a config object (see configuration). Default null.

timeout

(number) The number of milliseconds before a timeout error occurs. Default 30000.

useragent

(string) The user-agent to send with the request. Default pa11y/<version>.

port

(number) The port the PhantomJS server should run on. Default 12300.

viewport.width

(number) The viewport width to load the page at.

viewport.height

(number) The viewport height to load the page at.

debug

(boolean) Whether to report debug-level messages. Default: false.

Callback

The callback function should accept two arguments. The first is an error object or null, the second is an object containing the results of the sniff.

Examples


// Sniff a URL, specifying some options
{
    url: 'nature.com',
    standard: 'WCAG2AAA',
    timeout: 20000
}

Configuration

gulp-pa11y can be configured via a JSON file or JavaScript object.

{
    config: __dirname + '/config/pa11y.json'
}

The config file or object should be formatted like the example below, where

  • The cookies key is an array of maps containing only the required keys for [PhantomJS cookie objects][https://github.com/ariya/phantomjs/wiki/API-Reference#cookie-object].
  • The ignore key holds an array of rule names you'd like to ignore. You can find the codes for each rule in the console output, so you can simply copy/paste these into your config. We also maintain a [list of all available rules][https://github.com/nature/pa11y/wiki/HTML-CodeSniffer-Rules].
{
	"cookies": [
		{
			"name": "cookie-name",
			"value": "cookie-value",
			"domain": "localhost"
		}
	],
	"ignore": [
		"WCAG2AA.Principle2.Guideline2_4.2_4_2.H25.2",
		"WCAG2AA.Principle3.Guideline3_1.3_1_1.H57.2"
	]
}

All configuration options are optional.

Caveats

gulp-pa11y can't catch all accessibility errors. It'll catch many of them, but you should do manual checking as well.