Skip to content

Commit

Permalink
1. cli: support hint for url
Browse files Browse the repository at this point in the history
2. attr-lowercase: add test case
  • Loading branch information
yaniswang committed May 2, 2016
1 parent b860810 commit 7a54e14
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
HTMLHint change log
====================

## ver 0.9.14 (2016-5-2)

add:

1. cli: support hint for url
2. attr-lowercase: add test case

## ver 0.9.13 (2016-5-1)

add:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Quick start
htmlhint www/test.html
htmlhint www/**/*.xhtml
htmlhint www/**/*.{htm,html}
htmlhint http://www.alibaba.com/
cat test.html | htmlhint stdin

2. results
Expand Down
24 changes: 23 additions & 1 deletion bin/htmlhint
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var stripJsonComments = require('strip-json-comments');
var async = require('async');
var glob = require("glob");
var parseGlob = require('parse-glob');
var request = require('request');

var HTMLHint = require("../index").HTMLHint;
var formatter = require('./formatter');
Expand All @@ -31,6 +32,7 @@ program.on('--help', function(){
console.log(' htmlhint www/test.html');
console.log(' htmlhint www/**/*.xhtml');
console.log(' htmlhint www/**/*.{htm,html}');
console.log(' htmlhint http://www.alibaba.com/');
console.log(' cat test.html | htmlhint stdin');
console.log(' htmlhint --list');
console.log(' htmlhint --rules tag-pair,id-class-value=underline test.html');
Expand All @@ -44,7 +46,7 @@ var arrSupportedFormatters = formatter.getSupported();

program
.version(pkg.version)
.usage('<file|folder|pattern ...> [options]')
.usage('<file|folder|pattern|stdin|url ...> [options]')
.option('-l, --list', 'show all of the rules available')
.option('-c, --config <file>', 'custom configuration file')
.option('-r, --rules <ruleid, ruleid=value ...>', 'set all of the rules available', map)
Expand Down Expand Up @@ -194,6 +196,9 @@ function hintAllFiles(target, options, onFinised){
if(filepath === 'stdin'){
hintStdin(ruleset, hintNext);
}
else if(/^https?:\/\//.test(filepath)){
hintUrl(filepath, ruleset, hintNext);
}
else{
var messages = hintFile(filepath, ruleset);
hintNext(messages);
Expand Down Expand Up @@ -240,6 +245,10 @@ function hintAllFiles(target, options, onFinised){
isWalkDone = true;
hintQueue.push(target);
}
else if(/^https?:\/\//.test(target)){
isWalkDone = true;
hintQueue.push(target);
}
else{
walkPath(globInfo, function(filepath){
isHintDone = false;
Expand Down Expand Up @@ -367,3 +376,16 @@ function hintStdin(ruleset, callback){
callback(messages);
});
}

// hint url
function hintUrl(url, ruleset, callback){
request.get(url, function(error, response, body){
if(!error && response.statusCode == 200){
var messages = HTMLHint.verify(body, ruleset);
callback(messages);
}
else{
callback([]);
}
});
}
Loading

0 comments on commit 7a54e14

Please sign in to comment.