Grunt task to hint html code.
LOOKING FOR CONTRIBUTOR TO MAINTAIN THIS REPO!
This plugin requires Grunt >=0.4.0
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 i -D grunt-htmlhint-plus
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-htmlhint-plus');
Run this task with the grunt htmlhintplus
command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Source path. Support file path, glob and globs.
Htmlhint rules. Default is:
- "tagname-lowercase": true,
- "attr-lowercase": true,
- "attr-value-double-quotes": true,
- "attr-value-not-empty": true,
- "attr-no-duplication": true,
- "doctype-first": true,
- "tag-pair": true,
- "tag-self-close": false,
- "spec-char-escape": true,
- "id-unique": true,
- "src-not-empty": true,
- "head-script-disabled": false,
- "img-alt-require": true,
- "doctype-html5": true,
- "id-class-value": "dash",
- "style-disabled": false,
- "space-tab-mixed-disabled": true,
- "id-class-ad-disabled": true,
- "href-abs-or-rel": true,
- "attr-unsafe-chars": true
For the whole rules list, please see Rules page.
Htmlhintrc file path. Has higher priority than rules
option.
Throw fatal fail or not at the end of this task, when there is hint error. Default false
.
Only hint changed file and new file. Default true
.
Ignore strings between key and value from this object. Default {}
.
An array of paths to custom rule files to load and use in your HTMLHinting. See issue #47 on the HTMLHint project. For examples of how to write a custom rule.
Extend the default rules instead of only running the rules specified. Default false
.
A string or array of output file types for reporting. Multiple types can also be selected separating them with a pipe character (ex: console|checkstyle|json
). Available output types include console
, default
(alias for console), text
, json
, and checkstyle
. Default console
.
// Project configuration
htmlhintplus: {
build: {
options: {
rules: {
'tag-pair': true,
'custom-rule': true
},
customRules: [
'rules/custom-rule.js'
],
extendRules: true,
output: [ 'console', 'text', 'json', 'checkstyle' ]
}
src: 'path/to/file'
}
}
// Project configuration
htmlhintplus: {
html: {
options: {
htmlhintrc: 'path/to/file'
}
src: [
'path/to/file',
'path/to/file2'
]
}
}
// Project configuration
htmlhintplus: {
options: {
htmlhintrc: 'path/to/file',
newer: true
},
build: {
options: {
force: false
},
src: [
'path/1/*.html',
'path/2/**/*.html'
]
}
}
Run the test demo:
grunt test