yargalot / grunt-accessibility Goto Github PK
View Code? Open in Web Editor NEWUse HTML codesniffer to grade accessibility
License: MIT License
Use HTML codesniffer to grade accessibility
License: MIT License
Example:
Running "bootlint:files" (bootlint) task
>> 52 file(s) lint free.
Passing --verbose
should show all the info, but by default, that info is just extra bloat.
I can have a look when I have some time, unless someone else beats me to it.
It would also be great if the report would tell me what Line the error occured on.
Right now it is really hard to find the element sometimes when it only tells me that element "a" is the source of the error
when testing the html and a warning occurs it aborts the grunt task and thus no report is created to see how to deal with the problem. So I can't really solve the problem without --force
Thanks again :)
How to do this:
You can link to the files you wish to lint using the grunt api. The result will be the results file.
When using the ** glob operator in my files / src array, the task hangs indefinitely when processing the first file in that directory.
Config:
files: [{
expand: true,
flatten: false,
cwd: '<%= project.paths.forms %>',
src: [ 'modules/**/*.html' ],
dest: '<%= project.paths.reportData %>/WCAG'
}]
It works for directories if I leave out the globbing pattern, so I think it is related to that.
v1.2.1 is the last version that didn't hang, but it also only processes the first file matched in the globbing pattern for some reason.
maybe it is useful to have an option that let users decide what they want to be in their report. In short: I would like only warnings to show up
thanks again :)
Set force in options to true to not fail the grunt task
force: true
Is there a way to have the task create a report without setting the force
option to true?
I am trying to achieve a grunt build
task that will fail if the accessibility task fails due to accessibility notices, warnings, or errors being discovered, but being able to view the report in this case would be very beneficial. It seems that the only way to have the task create a report after notices, warnings, or errors are discovered is to set force
to true, right?
Could you please move the ignored rules to a file?
Maybe like other linters do into a .accessibilityrc file?
thanks again
After processing is done, there are a bunch of PhantomJS processes still running in background, per each file. This can easily drive system out of memory by running task on a large set of files or multiple times on a smaller one.
It seems to me, the problem is within fs.write
in bridge.js
. According to Node.js API reference, it's unsafe to use fs.write
multiple times on the same file without waiting for the callback.
Looking into it, but still not sure.
I'm on Ubuntu 13.10 32-bit
I'd expect errors to fail the grunt task and halt execution, but even setting force (as documented by AccessSniff) to false doesn't stop the task.
Could you please add a reference to the element in the console output as well?
awesome package!
thanks :)
Steven,
I've just added your plugin to my project and I can't run any test as every time I get an error:
$ grunt accessibility
Running "accessibility:test" (accessibility) task
Running accessibility tests
Page Loaded. Starting Tests
Fatal error: Maximum call stack size exceeded
My configuration:
accessibility: {
options : {
accessibilityLevel: 'WCAG2AA'
},
test : {
files: [{
expand : true,
force: true,
src : ['build/no-template.html'],
dest : '',
ext : '-report.txt'
}]
}
},
I'm getting "Fatal Error: Maximum call stack size exceeded" every time when running.
Here's my Gruntfile.js configuration
module.exports = function(grunt) {
grunt.initConfig(
{
accessibility: {
options : {
force: false,
accessibilityLevel: 'WCAG2AA',
verbose: true
},
test : {
files: [{
expand : true,
cwd : 'source/',
src : ['index.html'],
dest : 'reports/',
ext : '-report.txt'
}]
}
}
}
);
grunt.loadNpmTasks('grunt-accessibility');
grunt.registerTask('access', 'accessibility');
}
The terminal output is...
Running "accessibility:test" (accessibility) task
Verifying property accessibility.test exists in config...OK
Files: source/index.html -> reports/index-report.txt
Options: phantomScript="myprojectpath/node_modules/grunt-accessibility/phantomjs/bridge.js", urls=[], domElement, verbose, force=false, accessibilityLevel="WCAG2AA"
Running accessibility tests
Page Loaded. Starting Tests
Fatal error: Maximum call stack size exceeded
I have 'WCAG2A.Principle2.Guideline2_4.2_4_2.H25.1.NoTitleEl' ignored but the build still breaks. This is caused by lines 43-45 in the grunt-accessibility.js.
if (msgSplit[0] === 'ERROR' && !options.force) {
grunt.fail.warn(msgSplit[1] + ': ' + msgSplit[2]);
}
The problem is the ignore logic never gets a chance to run before the build stops. If this block is moved down to line 56 after the following block, it works properly:
if (ignore) {
return;
}
Thanks!
Example SVG:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
<a xlink:href="#anchor">
<text>Link</text>
</a>
</g>
</svg>
Links cause the following error
I would expect this to understand the namespace and find the href behind xlink.
Thank you :)
Gonna start pulling this task out and putting it into a CLI/Node Library
The Task is becoming too big.
As per feedback in #18
options: {
verboseTypes: [
"notice": false,
"warning": true,
"error": true
]
}
It would be nice to support html partials, so the missing title error isn't always thrown
After hooking up grunt-accessibility and configuring a task, when I run my "test" task, it just hangs and never completes.
Here is the html it's testing and my full gruntfile
http://codepen.io/anon/pen/KyAfr
Terminal hangs at this:
Running "accessibility:test" (accessibility) task
Running accessibility tests
Page Loaded. Starting Tests
Node, npm and grunt are all up to date. I only run this after the making a build, so it's not being passed partials or anything like that.
I have a build directory with multiple .html files in it. I am trying to audit each one and output the results of the audit to a file located in wcag2-reports/. After each run there are not any errors and the dest. directory only has one file in it. That file is always the last one audited from the src. directory. My grunt-accessibility config is below.
module.exports = {
options : {
accessibilityLevel: 'WCAG2A',
force: true,
outputFormat: 'json',
verbose: false
},
test : {
files: [{
expand : true,
cwd : 'build/',
src : ['*.html'],
dest : 'wcag2-reports/',
ext : '-report'
}]
}
};
I get this error when using a certain styling: Fatal error: Unexpected end of input
I have narrowed down the SCSS that causes the problem:
.contentbox-head {
.startnext & {
display: table;
}
}
.contentbox-heading {
.startnext & {
display: table-cell;
}
}
and HTML:
<div class="contentbox white">
<div class="contentbox-head">
<h2 class="contentbox-heading">Beschriftung</h2>
</div>
<div class="contentbox-image">
<img src="http://imagefoo.dev.webit.de/300x181/bbb/222.png" width="300" height="181" alt="">
</div>
<div class="contentbox-content">
<h3>Tourist Information</h3>
<p>
Weit hinten, hinter den Wortbergen, fern der Länder Vokalien und Konsonantien leben die Blindtexte.
</p>
<a href="#" class="userlike">Lassen Sie sich beraten</a>
</div>
</div>
It seems the display: table-cell
is causing the accessibility task to exit. The whole setup is here: https://github.com/markusfalk/css-vs-accessibility
Any idea what could cause this error?
Usual Drill
The Grunt command-line option --force
can suppress the failure in any task. However, sometimes it is needed to suppress the failure in just one task and check the result of the other as usual. Tasks usually support their own boolean option force
for this.
For example, one instance f the accessibility
task could be forced to generate a full report including problems, which have not been fixed yet, while another one could perform the hard check. For example, like this configuration:
accessibility: {
'full-report': {
options: {
force: true, // ignores the error and lets Grunt continue
reportType: 'json',
reportLocation: 'pending'
},
src: ['**/*.html']
},
'check-fixed': {
src: ['**/*.html']
}
}
used in this task:
grunt.registerTask('test', [
'continue:on', 'accessibility:report-all', 'continue:off',
'accessibility:check-fixed'
]);
If the Grunt task should not fail, it must not call grunt.fail.warn
, but grunt.log.warn
instead. What do you think about supporting the force
option like that?
Hey guys,
I've been trying most of the day to get the a grunt script to run to no avail.
grunt.initConfig({
accessibility: {
options : {
accessibilityLevel: 'WCAG2A',
domElement: false,
force: true
},
test : {
files: [{
expand : true,
cwd : 'templates',
src : ['*.html'],
dest : 'reports/',
ext : '-report.txt'
}]
}
}
});
grunt.loadNpmTasks('grunt-accessibility');
grunt.registerTask('accessibility', ['accessibility']);
The script just hangs, no feedback from grunt, no error. Just hangs...
grunt accessibility
I have installed the plugin using: npm install grunt-accessibility --save-dev
Ae their other dependancies? All my other grunt tasks run fine.
Using pa11y/a11y runs fine, just this plugin doesn't.
It just sit's there doing nothing. Even if I hit ^C it ignores.
What am I missing?
OSX El capitan
node - v7.0.0
npm - v3.10.8
grunt-cli - v1.2.0
grunt - v0.4.5
Help :)
accessibility: {
options : {
accessibilityLevel: 'WCAG2<%= WCAG2 %>',
accessibilityrc: true,
domElement: true
},
development : {
files: [{
expand : true,
cwd : 'build/',
src : ['*.html'],
// dest : 'WCAG2-reports/',
// ext : '-report.txt'
}]
}
},
when no 'dest:' option is given the report will be written into the tested html file deleting all HTML in it
Is there a way to stop exiting the grunt task on WCAG errors. I have a cleanup script that I'd like to run after validation.
It would be great if I could chose wether to generate a report or not. For those cases where console output is enough.
thanks
Like jsHint
Issue with installing plugin when using grunt >=1.0.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.