A node/iojs library & CLI for HTML_Codesniffer
npm install access-sniff
A CLI, JsDom and PhantomJs library for HTML_CodeSniffer
npm install access-sniff --savejs
var AccessSniff = require('access-sniff');AccessSniff
.default(['*/.html'], options)
.then(function(report) {
AccessSniff.report(report, reportOptions);
});
`$3
`js
import AccessSniff, { reports as AccessReports } from 'access-sniff';AccessSniff(['*/.html'], options)
.then(report => AccessReports(report, reportOptions));
`
$3
`
npm install access-sniff -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$3
accessibilityLevel is a string`js
options: {
accessibilityLevel: 'WCAG2A'
}
`Levels are
WCAG2A, WCAG2AA, WCAG2AAA, and Section508$3
You can create an .accessibilityrc file in your project to set options:
`json
{
"ignore": [
"WCAG2A.Principle2.Guideline2_4.2_4_2.H25.1.NoTitleEl",
"WCAG2A.Principle3.Guideline3_1.3_1_1.H57.2"
]
}
`$3
ignore is an arrayYou can ignore rules by placing them in an array outlined below.
`js
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$3
verbose is a boolean`js
options: {
verbose: false
}
`Output messages to console, set to true by default
$3
force is a boolean, defaults to false`js
options: {
force: true
}
`Continue running in the event of failures.
You can catch failures from the promise as below:
`js
AccessSniff(['*/.html'], options)
.then(report => AccessReports(report, reportOptions));
.catch(error => console.error(error))
`$3
browser is a boolean, defaults to false`js
options: {
browser: false
}
`AccessSniff uses jsDom as the default, setting this to true will use PhantomJs instead
$3
maxBuffer is a number, defaults to 500*1024In certain situations you might have to increase the memory allocated to render a page.
`js
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
$3
You can use the inbuilt system or create your own
`js
AccessSniff.report(report, reportOptions)
`$3
reportType is a string
`js
options: {
reportType: 'json'
}
`Text, CSV or JSON format output
-
txt will output text files
- json will output .json files
- csv will output csv$3
reportLocation is a string`js
options: {
reportLocation: 'reports'
}
`Set the value to where you want reports created
$3
reportLevels is an object`js
options: {
reportLevels: {
notice: true,
warning: true,
error: true
}
}
`Set a value to
false to limit outputCLI
You can use the CLI component by installing it globally with npm install -g access-sniff`cmd
sniff test/*/.html -r json -l reports
sniff test/*/.html -r csv -l reports
sniff test/*/.html -r txt -l reports
`$3
#### Report Type
-r or -reportTypetxt, csv, json.
#### Report Location
-r or -reportLocation#### Force
-f or -force#### Quiet
-q or -quiet`