Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1737986

Browse files
update to htmlhint v0.9.8
1 parent ee3713b commit 1737986

File tree

6 files changed

+125
-113
lines changed

6 files changed

+125
-113
lines changed

‎.editorconfig‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
# Apply for all files
8+
[*]
9+
10+
charset = utf-8
11+
12+
indent_style = space
13+
indent_size = 4
14+
15+
end_of_line = lf
16+
insert_final_newline = true
17+
trim_trailing_whitespace = true

‎package.json‎

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
{
2-
"name": "grunt-htmlhint",
3-
"description": "Validate html files with htmlhint.",
4-
"version": "0.4.1",
5-
"homepage": "https://github.com/yaniswang/grunt-htmlhint",
6-
"author": {
7-
"name": "Yanis Wang",
8-
"email": "yanis.wang@gmail.com",
9-
"url": "http://yaniswang.com/"
10-
},
11-
"repository": {
12-
"type": "git",
13-
"url": "git@github.com:yaniswang/grunt-htmlhint.git"
14-
},
15-
"bugs": {
16-
"url": "https://github.com/yaniswang/grunt-htmlhint/issues"
17-
},
18-
"licenses": [
19-
{
20-
"type": "MIT",
21-
"url": "https://github.com/yaniswang/grunt-htmlhint/blob/master/LICENSE-MIT"
22-
}
23-
],
24-
"main": "Gruntfile.js",
25-
"engines": {
26-
"node": ">= 0.8.0"
27-
},
28-
"scripts": {
29-
"test": "grunt --force"
30-
},
31-
"devDependencies": {
32-
"grunt-contrib-jshint": "~0.1.1",
33-
"grunt": "~0.4.1"
34-
},
35-
"peerDependencies": {
36-
"grunt": "~0.4.1"
37-
},
38-
"keywords": [
39-
"gruntplugin"
40-
],
41-
"dependencies": {
42-
"htmlhint": "0.9.6"
43-
}
44-
}
1+
{
2+
"name": "grunt-htmlhint",
3+
"description": "Validate html files with htmlhint.",
4+
"version": "0.9.8",
5+
"homepage": "https://github.com/yaniswang/grunt-htmlhint",
6+
"author": {
7+
"name": "Yanis Wang",
8+
"email": "yanis.wang@gmail.com",
9+
"url": "http://yaniswang.com/"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git@github.com:yaniswang/grunt-htmlhint.git"
14+
},
15+
"bugs": {
16+
"url": "https://github.com/yaniswang/grunt-htmlhint/issues"
17+
},
18+
"licenses": [
19+
{
20+
"type": "MIT",
21+
"url": "https://github.com/yaniswang/grunt-htmlhint/blob/master/LICENSE-MIT"
22+
}
23+
],
24+
"main": "Gruntfile.js",
25+
"engines": {
26+
"node": ">= 0.8.0"
27+
},
28+
"scripts": {
29+
"test": "grunt --force"
30+
},
31+
"devDependencies": {
32+
"grunt-contrib-jshint": "~0.1.1",
33+
"grunt": "~0.4.1"
34+
},
35+
"peerDependencies": {
36+
"grunt": "~0.4.1"
37+
},
38+
"keywords": [
39+
"gruntplugin"
40+
],
41+
"dependencies": {
42+
"htmlhint": "0.9.8"
43+
}
44+
}

‎tasks/htmlhint.js‎

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,64 +10,59 @@
1010

1111
module.exports = function(grunt) {
1212

13-
grunt.registerMultiTask('htmlhint', 'Validate html files with htmlhint.', function() {
13+
grunt.registerMultiTask('htmlhint', 'Validate html files with htmlhint.', function() {
1414

15-
var HTMLHint = require("htmlhint").HTMLHint;
16-
var options = this.options({
17-
force: false
18-
}),
19-
arrFilesSrc = this.filesSrc,
20-
verbose = grunt.verbose;
15+
var HTMLHint = require("htmlhint").HTMLHint;
16+
var options = this.options({
17+
force: false
18+
}),
19+
arrFilesSrc = this.filesSrc,
20+
verbose = grunt.verbose;
2121

22-
if (options.htmlhintrc) {
23-
var rc = grunt.file.readJSON(options.htmlhintrc);
24-
grunt.util._.defaults(options, rc);
25-
delete options.htmlhintrc;
26-
}
22+
if (options.htmlhintrc) {
23+
var rc = grunt.file.readJSON(options.htmlhintrc);
24+
grunt.util._.defaults(options, rc);
25+
delete options.htmlhintrc;
26+
}
2727

28-
var force = options.force;
29-
delete options.force;
28+
var force = options.force;
29+
delete options.force;
3030

31-
var hintCount = 0;
32-
arrFilesSrc.forEach(function( filepath ) {
33-
var file = grunt.file.read( filepath ),
34-
msg = "Linting " + filepath + "...",
35-
messages;
36-
if (file.length) {
37-
messages = HTMLHint.verify(file, options);
38-
verbose.write( msg );
39-
if (messages.length > 0) {
40-
verbose.or.write( msg );
41-
grunt.log.error();
42-
} else {
43-
verbose.ok();
44-
}
45-
messages.forEach(function( message ) {
46-
grunt.log.writeln( "[".red + ( "L" + message.line ).yellow + ":".red + ( "C" + message.col ).yellow + "]".red + ' ' + message.message.yellow );
47-
var evidence = message.evidence,
48-
col = message.col;
49-
if (col === 0) {
50-
evidence = '?'.inverse.red + evidence;
51-
} else if (col > evidence.length) {
52-
evidence = evidence + ' '.inverse.red;
53-
} else {
54-
evidence = evidence.slice(0, col - 1) + evidence[col - 1].inverse.red + evidence.slice(col);
55-
}
56-
grunt.log.writeln(evidence);
57-
hintCount ++;
31+
var hintCount = 0;
32+
var fileCount = 0;
33+
arrFilesSrc.forEach(function(filepath) {
34+
var file = grunt.file.read(filepath),
35+
msg = " " + filepath,
36+
messages;
37+
if (file.length) {
38+
messages = HTMLHint.verify(file, options);
39+
if (messages.length > 0) {
40+
grunt.log.writeln(msg);
41+
messages.forEach(function(hint) {
42+
grunt.log.writeln(' L%d |%s', hint.line, hint.evidence.replace(/\t/g, ' ').grey);
43+
grunt.log.writeln(' %s^ %s', repeatStr(String(hint.line).length + 3 + hint.col - 1), (hint.message + ' (' + hint.rule.id + ')')[hint.type === 'error' ? 'red' : 'yellow']);
44+
hintCount++;
45+
});
46+
grunt.log.writeln('');
47+
fileCount ++;
48+
}
49+
}
5850
});
59-
}
60-
else{
61-
grunt.log.writeln( "Skipping empty file " + filepath);
62-
}
63-
});
6451

65-
if ( hintCount > 0 ) {
66-
return force;
67-
}
52+
if (hintCount > 0) {
53+
grunt.log.error('%d errors in %d files'.red, hintCount, fileCount);
54+
return force;
55+
}
56+
else{
57+
verbose.ok();
58+
}
6859

69-
grunt.log.ok(arrFilesSrc.length + ' file' + (arrFilesSrc.length === 1 ? '' : 's') + ' lint free.');
60+
grunt.log.ok(arrFilesSrc.length + ' file' + (arrFilesSrc.length === 1 ? '' : 's') + ' lint free.');
7061

71-
});
62+
});
7263

64+
65+
function repeatStr(n, str){
66+
return new Array(n + 1).join(str || ' ');
67+
}
7368
};

‎test/fixtures/empty.html‎

Whitespace-only changes.

‎test/fixtures/invalid.html‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<html>
2-
<head>
3-
<meta charset="UTF-8">
4-
<title></title>
5-
</head>
6-
<body>
7-
<ul><li></ul>
8-
<div>
9-
</body>
1+
<html>
2+
<head>
3+
<meta charset="UTF-8">
4+
<title></title>
5+
</head>
6+
<body>
7+
<ul><li></ul>
8+
<div>
9+
</body>
1010
</html>

‎test/fixtures/valid.html‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<!DOCTYPE HTML>
2-
<html>
3-
<head>
4-
<meta charset="UTF-8">
5-
<title></title>
6-
</head>
7-
<body>
8-
<div>test</div>
9-
</body>
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
<div>test</div>
9+
</body>
1010
</html>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /