W3C html validaton grunt plugin. Validate all files in a directory automatically.
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-html-validation --save-dev
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-html-validation');
In your project's Gruntfile, add a section named html_validation
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
html_validation: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
Type: Boolean
Default value: 'false'
Resets all the validated files status. When want to revalidate all the validated files - eg: sudo grunt validate --reset=true
Type: String
Default value: 'validation-staus.json'
Default file for storing validation information.
Type: String
Default value: validation-report.json
Consolidated report in JSON format.
Type: Boolean
Default value: false
When hit by a validation error, html-validator continue validating next file by default and this process continues until all files in the list completes validation. If 'toponerror' set to true
, validator will stop validating next file.
validation: {
options: {
reset: grunt.option('reset') || false,
toponerror: false
},
files: {
src: ['<%= yeoman.app %>/*.html',
'!<%= yeoman.app %>/index.html',
'!<%= yeoman.app %>/modules.html',
'!<%= yeoman.app %>/404.html']
}
}
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
- 2013-08-19 v0.1.4 Fixed issues. Added 'stoponerror' option, validation report added.
- 2013-08-05 v0.1.2 Fixed issues.
- 2013-04-20 v0.1.0 Initial release.