Skip to content

Commit

Permalink
rule copyediting
Browse files Browse the repository at this point in the history
  • Loading branch information
dishad committed Aug 18, 2015
1 parent ba1a629 commit f357289
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions src/rules/alt-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
HTMLHint.addRule({
id: 'alt-require',
description: 'Alt of img must be present and alt of area[href] and input[type=image] must be set value.',
description: 'The alt attribute of an <img> element must be present and alt attribute of area[href] and input[type=image] must have a value.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
Expand All @@ -14,13 +14,13 @@ HTMLHint.addRule({
col = event.col + tagName.length + 1,
selector;
if(tagName === 'img' && !('alt' in mapAttrs)){
reporter.warn('Alt of img tag must be present.', event.line, col, self, event.raw);
reporter.warn('An alt attribute must be present on <img> elements.', event.line, col, self, event.raw);
}
else if((tagName === 'area' && 'href' in mapAttrs) ||
(tagName === 'input' && mapAttrs['type'] === 'image')){
if(!('alt' in mapAttrs) || mapAttrs['alt'] === ''){
selector = tagName === 'area' ? 'area[href]' : 'input[type=image]';
reporter.warn('Alt of ' + selector + ' must be set value.', event.line, col, self, event.raw);
reporter.warn('The alt attribute of ' + selector + ' must have a value.', event.line, col, self, event.raw);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/rules/attr-lowercase.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'attr-lowercase',
description: 'Attribute name must be lowercase.',
description: 'All attribute names must be in lowercase.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
Expand All @@ -15,7 +15,7 @@ HTMLHint.addRule({
attr = attrs[i];
var attrName = attr.name;
if(attrName !== attrName.toLowerCase()){
reporter.error('Attribute name [ '+attrName+' ] must be lower case.', event.line, col + attr.index, self, attr.raw);
reporter.error('The attribute name of [ '+attrName+' ] must be in lowercase.', event.line, col + attr.index, self, attr.raw);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/rules/attr-no-duplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'attr-no-duplication',
description: 'Attribute name can not been duplication.',
description: 'Elements cannot have duplicate attributes.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
Expand All @@ -18,7 +18,7 @@ HTMLHint.addRule({
attr = attrs[i];
attrName = attr.name;
if(mapAttrName[attrName] === true){
reporter.error('The name of attribute [ '+attr.name+' ] been duplication.', event.line, col + attr.index, self, attr.raw);
reporter.error('Duplicate of attribute name [ '+attr.name+' ] was found.', event.line, col + attr.index, self, attr.raw);
}
mapAttrName[attrName] = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/rules/attr-unsafe-chars.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'attr-unsafe-chars',
description: 'Attribute value cant not use unsafe chars.',
description: 'Attribute values cannot contain unsafe chars.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
Expand All @@ -15,7 +15,7 @@ HTMLHint.addRule({
for(var i=0, l=attrs.length;i<l;i++){
attr = attrs[i];
if(regUnsafe.test(attr.value) === true){
reporter.warn('The value of attribute [ '+attr.name+' ] cant not use unsafe chars.', event.line, col + attr.index, self, attr.raw);
reporter.warn('The value of attribute [ '+attr.name+' ] cannot contain an unsafe char.', event.line, col + attr.index, self, attr.raw);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/rules/attr-value-double-quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'attr-value-double-quotes',
description: 'Attribute value must closed by double quotes.',
description: 'Attribute values must be in double quotes.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
Expand All @@ -15,7 +15,7 @@ HTMLHint.addRule({
attr = attrs[i];
if((attr.value !== '' && attr.quote !== '"') ||
(attr.value === '' && attr.quote === "'")){
reporter.error('The value of attribute [ '+attr.name+' ] must closed by double quotes.', event.line, col + attr.index, self, attr.raw);
reporter.error('The value of attribute [ '+attr.name+' ] must be in double quotes.', event.line, col + attr.index, self, attr.raw);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/rules/attr-value-not-empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'attr-value-not-empty',
description: 'Attribute must set value.',
description: 'All attributes must have values.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
Expand All @@ -14,7 +14,7 @@ HTMLHint.addRule({
for(var i=0, l=attrs.length;i<l;i++){
attr = attrs[i];
if(attr.quote === '' && attr.value === ''){
reporter.warn('The attribute [ '+attr.name+' ] must set value.', event.line, col + attr.index, self, attr.raw);
reporter.warn('The attribute [ '+attr.name+' ] must have a value.', event.line, col + attr.index, self, attr.raw);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/rules/doctype-first.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
*/
HTMLHint.addRule({
id: 'doctype-first',
description: 'Doctype must be first.',
description: 'Doctype must be declared first.',
init: function(parser, reporter){
var self = this;
var allEvent = function(event){
if(event.type === 'start' || (event.type === 'text' && /^\s*$/.test(event.raw))){
return;
}
if((event.type !== 'comment' && event.long === false) || /^DOCTYPE\s+/i.test(event.content) === false){
reporter.error('Doctype must be first.', event.line, event.col, self, event.raw);
reporter.error('Doctype must be declared first.', event.line, event.col, self, event.raw);
}
parser.removeListener('all', allEvent);
};
Expand Down
4 changes: 2 additions & 2 deletions src/rules/doctype-html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/
HTMLHint.addRule({
id: 'doctype-html5',
description: 'Doctype must be html5.',
description: 'Invalid doctype. Use: "<!DOCTYPE html>"',
init: function(parser, reporter){
var self = this;
function onComment(event){
if(event.long === false && event.content.toLowerCase() !== 'doctype html'){
reporter.warn('Doctype must be html5.', event.line, event.col, self, event.raw);
reporter.warn('Invalid doctype. Use: "<!DOCTYPE html>"', event.line, event.col, self, event.raw);
}
}
function onTagStart(){
Expand Down
4 changes: 2 additions & 2 deletions src/rules/head-script-disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'head-script-disabled',
description: 'The script tag can not be used in head.',
description: 'The <script> tag cannot be used in a <head> tag.',
init: function(parser, reporter){
var self = this;
var reScript = /^(text\/javascript|application\/javascript)$/i;
Expand All @@ -13,7 +13,7 @@ HTMLHint.addRule({
var type = mapAttrs.type;
if(event.tagName.toLowerCase() === 'script' &&
(!type || reScript.test(type) === true)){
reporter.warn('The script tag can not be used in head.', event.line, event.col, self, event.raw);
reporter.warn('The <script> tag cannot be used in a <head> tag.', event.line, event.col, self, event.raw);
}
}
function onTagEnd(event){
Expand Down
4 changes: 2 additions & 2 deletions src/rules/href-abs-or-rel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'href-abs-or-rel',
description: 'Href must be absolute or relative.',
description: 'An href attribute must be either absolute or relative.',
init: function(parser, reporter, options){
var self = this;

Expand All @@ -20,7 +20,7 @@ HTMLHint.addRule({
if(attr.name === 'href'){
if((hrefMode === 'absolute' && /^\w+?:/.test(attr.value) === false) ||
(hrefMode === 'relative' && /^https?:\/\//.test(attr.value) === true)){
reporter.warn('The value of href [ '+attr.value+' ] must be '+hrefMode+'.', event.line, col + attr.index, self, attr.raw);
reporter.warn('The value of the href attribute [ '+attr.value+' ] must be '+hrefMode+'.', event.line, col + attr.index, self, attr.raw);
}
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/rules/id-class-ad-disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'id-class-ad-disabled',
description: 'Id and class can not use ad keyword, it will blocked by adblock software.',
description: 'The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
Expand All @@ -18,7 +18,7 @@ HTMLHint.addRule({
attrName = attr.name;
if(/^(id|class)$/i.test(attrName)){
if(/(^|[-\_])ad([-\_]|$)/i.test(attr.value)){
reporter.warn('The value of '+attrName+' can not use ad keyword.', event.line, col + attr.index, self, attr.raw);
reporter.warn('The value of attribute '+attrName+' cannot use the ad keyword.', event.line, col + attr.index, self, attr.raw);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/rules/id-class-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
*/
HTMLHint.addRule({
id: 'id-class-value',
description: 'Id and class value must meet some rules.',
description: 'The id and class attribute values must meet the specified rules.',
init: function(parser, reporter, options){
var self = this;
var arrRules = {
'underline': {
'regId': /^[a-z\d]+(_[a-z\d]+)*$/,
'message': 'Id and class value must lower case and split by underline.'
'message': 'The id and class attribute values must be in lowercase and split by an underscore.'
},
'dash': {
'regId': /^[a-z\d]+(-[a-z\d]+)*$/,
'message': 'Id and class value must lower case and split by dash.'
'message': 'The id and class attribute values must be in lowercase and split by a dash.'
},
'hump': {
'regId': /^[a-z][a-zA-Z\d]*([A-Z][a-zA-Z\d]*)*$/,
'message': 'Id and class value must meet hump style.'
'message': 'The id and class attribute values must meet the camelCase style.'
}
}, rule;
if(typeof options === 'string'){
Expand Down
4 changes: 2 additions & 2 deletions src/rules/id-unique.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'id-unique',
description: 'Id must be unique.',
description: 'The value of id attributes must be unique.',
init: function(parser, reporter){
var self = this;
var mapIdCount = {};
Expand All @@ -25,7 +25,7 @@ HTMLHint.addRule({
mapIdCount[id] ++;
}
if(mapIdCount[id] > 1){
reporter.error('Id redefinition of [ '+id+' ].', event.line, col + attr.index, self, attr.raw);
reporter.error('The id value [ '+id+' ] must be unique.', event.line, col + attr.index, self, attr.raw);
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions src/rules/space-tab-mixed-disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'space-tab-mixed-disabled',
description: 'Spaces and tabs can not mixed in front of line.',
description: 'Do not mix tabs and spaces for indentation.',
init: function(parser, reporter){
var self = this;
parser.addListener('text', function(event){
Expand All @@ -13,7 +13,7 @@ HTMLHint.addRule({
var match;
while((match = reMixed.exec(raw))){
var fixedPos = parser.fixPos(event, match.index + match[1].length);
reporter.warn('Mixed spaces and tabs in front of line.', fixedPos.line, 1, self, event.raw);
reporter.warn('Do not mix tabs and spaces for indentation.', fixedPos.line, 1, self, event.raw);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/rules/src-not-empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
HTMLHint.addRule({
id: 'src-not-empty',
description: 'Src of img(script,link) must set value.',
description: 'The src attribute of an img(script,link) must have a value.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
Expand All @@ -18,7 +18,7 @@ HTMLHint.addRule({
(tagName === 'link' && attr.name === 'href') ||
(tagName === 'object' && attr.name === 'data')) &&
attr.value === ''){
reporter.error('[ '+attr.name + '] of [ '+tagName+' ] must set value.', event.line, col + attr.index, self, attr.raw);
reporter.error('The attribute [ '+attr.name + ' ] of the tag [ '+tagName+' ] must have a value.', event.line, col + attr.index, self, attr.raw);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/rules/style-disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/
HTMLHint.addRule({
id: 'style-disabled',
description: 'Style tag can not be used.',
description: '<style> tags cannot be used.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart', function(event){
if(event.tagName.toLowerCase() === 'style'){
reporter.warn('Style tag can not be used.', event.line, event.col, self, event.raw);
reporter.warn('The <style> tag cannot be used.', event.line, event.col, self, event.raw);
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/rules/tag-pair.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ HTMLHint.addRule({
arrTags.push('</'+stack[i]+'>');
}
if(arrTags.length > 0){
reporter.error('Tag must be paired, Missing: [ '+ arrTags.join('') + ' ]', event.line, event.col, self, event.raw);
reporter.error('Tag must be paired, missing: [ '+ arrTags.join('') + ' ]', event.line, event.col, self, event.raw);
}
stack.length=pos;
}
else{
reporter.error('Tag must be paired, No start tag: [ ' + event.raw + ' ]', event.line, event.col, self, event.raw);
reporter.error('Tag must be paired, no start tag: [ ' + event.raw + ' ]', event.line, event.col, self, event.raw);
}
});
parser.addListener('end', function(event){
Expand All @@ -43,7 +43,7 @@ HTMLHint.addRule({
arrTags.push('</'+stack[i]+'>');
}
if(arrTags.length > 0){
reporter.error('Tag must be paired, Missing: [ '+ arrTags.join('') + ' ]', event.line, event.col, self, '');
reporter.error('Tag must be paired, missing: [ '+ arrTags.join('') + ' ]', event.line, event.col, self, '');
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/rules/tag-self-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
*/
HTMLHint.addRule({
id: 'tag-self-close',
description: 'The empty tag must closed by self.',
description: 'Empty tags must be self closed.',
init: function(parser, reporter){
var self = this;
var mapEmptyTags = parser.makeMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed");//HTML 4.01
parser.addListener('tagstart', function(event){
var tagName = event.tagName.toLowerCase();
if(mapEmptyTags[tagName] !== undefined){
if(!event.close){
reporter.warn('The empty tag : [ '+tagName+' ] must closed by self.', event.line, event.col, self, event.raw);
reporter.warn('The empty tag : [ '+tagName+' ] must be self closed.', event.line, event.col, self, event.raw);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/rules/tagname-lowercase.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
*/
HTMLHint.addRule({
id: 'tagname-lowercase',
description: 'Tagname must be lowercase.',
description: 'All html element names must be in lowercase.',
init: function(parser, reporter){
var self = this;
parser.addListener('tagstart,tagend', function(event){
var tagName = event.tagName;
if(tagName !== tagName.toLowerCase()){
reporter.error('Tagname [ '+tagName+' ] must be lower case.', event.line, event.col, self, event.raw);
reporter.error('The html element name of [ '+tagName+' ] must be in lowercase.', event.line, event.col, self, event.raw);
}
});
}
Expand Down

0 comments on commit f357289

Please sign in to comment.