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

access-sniff-ext

v4.2.2

Published

A node/iojs library & CLI for HTML_Codesniffer

Downloads

7

Readme

AccessSniff Extended

Build Status codecov

A CLI, JsDom and PhantomJs library for HTML_CodeSniffer

This fork writes the report, even if errors are detected in input files.

Example Image

Getting Started

Install this plugin with npm install access-sniff-ext --save

ES5

var AccessSniff = require('access-sniff-ext');

AccessSniff
  .default(['**/*.html'], options)
  .then(function(report) {
    AccessSniff.report(report, reportOptions);
  });

ES6

import AccessSniff, { reports as AccessReports } from 'access-sniff-ext';

AccessSniff(['**/*.html'], options)
  .then(report => AccessReports(report, reportOptions));

CLI

npm install access-sniff-ext -g
sniff test/**/*.html -r json -l reports

AccessSniff can test both locally hosted files and websites.

sniff http://statamic.com/ -r json -l reports

Options

You can pass the following options

Accessibility Level

accessibilityLevel is a string

options: {
  accessibilityLevel: 'WCAG2A'
}

Levels are WCAG2A, WCAG2AA, WCAG2AAA, and Section508

Accessibilityrc

You can create an .accessibilityrc file in your project to set options:

{
  "ignore": [
    "WCAG2A.Principle2.Guideline2_4.2_4_2.H25.1.NoTitleEl",
    "WCAG2A.Principle3.Guideline3_1.3_1_1.H57.2"
  ]
}

Ignore By Rule Identifier

ignore is an array

You can ignore rules by placing them in an array outlined below.

options: {
  ignore: [
    'WCAG2A.Principle2.Guideline2_4.2_4_2.H25.1.NoTitleEl'
    'WCAG2A.Principle3.Guideline3_1.3_1_1.H57.2'
  ]
}

Rules will also match to remove and entire set.

WCAG2A.Principle2.Guideline2_4.2_4_2.H25.1 will ignore WCAG2A.Principle2.Guideline2_4.2_4_2.H25.1.NoTitleEl

Ignore By Other Information

ignoreByDescription, ignoreByElement, ignoreByClass and ignoreById are arrays

You can ignore rules by including their description, element content, CSS class or HTML ID in their full as string, or by including regular expression matching their textual value. This can be useful to ignore only some problem occurrences, which are "false positives", while retaining the other checks done by the same rule.

options: {
  ignoreByDescription: [
    'This form field should be labelled in some way. Use the label element ' +
    '(either with a "for" attribute or wrapped around the form field), or ' +
    '"title", "aria-label" or "aria-labelledby" attributes as appropriate.',
    /^This element has a role of "\w+" but does not have a name available to an accessibility API\. Valid names are: [^.]+\.$/
  ],
  ignoreByElement: [
    /^<a id="herpDerp" class="[^"]*" href="test">Test<\/a>$/
  ],
  ignoreByClass: [
    /\bcustom-checkbox\b/
  ],
  ignoreById: [
    'select-all'
  ]
}

Error levels

errorLevels is an object

  options: {
    errorLevels: {
      notice: false,
      warning: false,
      error: true
    }
  }

If an issue of a certain level is found and this level is flagged by true in errorLevels, validation will fail

Verbose output

verbose is a boolean

options: {
  verbose: false
}

Output messages to console, set to true by default

Force

force is a boolean, defaults to false

options: {
  force: true
}

Continue running in the event of failures. You can catch failures from the promise as below:

AccessSniff(['**/*.html'], options)
.then(report => AccessReports(report, reportOptions));
.catch(error => console.error(error))

Browser

browser is a boolean, defaults to false

options: {
  browser: false
}

AccessSniff uses jsDom as the default, setting this to true will use PhantomJs instead

maxBuffer

maxBuffer is a number, defaults to 500*1024

In certain situations you might have to increase the memory allocated to render a page.

options: {
  maxBuffer: 500*1024
}

Reports

You can pass the following options to the report generator

Notes

  • Reports are now generated from the returned json to the report module
  • Report location is required to write a report
  • Reports return the content from the report

Modular Reporting

You can use the inbuilt system or create your own

AccessSniff.report(report, reportOptions)

Report Type

reportType is a string

options: {
  reportType: 'json'
}

Text, CSV or JSON format output

  • txt will output text files
  • json will output .json files
  • csv will output csv

Report Location

reportLocation is a string

  options: {
    reportLocation: 'reports'
  }

Set the value to where you want reports created

Report Levels

reportLevels is an object

  options: {
    reportLevels: {
      notice: true,
      warning: true,
      error: true
    }
  }

Set a value to false to limit output

CLI

You can use the CLI component by installing it globally with npm install -g access-sniff-ext

sniff test/**/*.html -r json -l reports
sniff test/**/*.html -r csv -l reports
sniff test/**/*.html -r txt -l reports

Options

Error Levels

-e or -errorLevels

Combination of comma-delimited error, warning and notice.

Report Type

-r or -reportType

txt, csv, json.

Report Location

-r or -reportLocation

Force

-f or -force

Quiet

-q or -quiet