diff --git a/.travis.yml b/.travis.yml index 92a4f5560..f20eeb07d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,11 +19,10 @@ script: - "grunt" - istanbul cover ./node_modules/mocha/bin/_mocha --reporter test -- -R spec - codecov -after_success: - - npm run travis-deploy-once "npm run semantic-release" branches: only: - master + - develop - /^greenkeeper/.*$/ except: - /^v\d+\.\d+\.\d+$/ diff --git a/Gruntfile.js b/Gruntfile.js index 70805e333..763dfbd79 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -48,7 +48,6 @@ module.exports = function(grunt) { uglify: { htmlhint: { options: { - banner: "/*!\r\n * HTMLHint v<%= pkg.version %>\r\n * https://github.com/yaniswang/HTMLHint\r\n *\r\n * (c) 2014-"+new Date().getFullYear()+" Yanis Wang .\r\n * MIT Licensed\r\n */\n", beautify: { ascii_only: true } @@ -92,13 +91,13 @@ module.exports = function(grunt) { date = new Date(); } var map = { - "M": date.getMonth() + 1, //月份 - "d": date.getDate(), //日 - "h": date.getHours(), //小时 - "m": date.getMinutes(), //分 - "s": date.getSeconds(), //秒 - "q": Math.floor((date.getMonth() + 3) / 3), //季度 - "S": date.getMilliseconds() //毫秒 + "M": date.getMonth() + 1, // Monat + "d": date.getDate(), // Tag + "h": date.getHours(), // Hour + "m": date.getMinutes(), // Minute + "s": date.getSeconds(), // Second + "q": Math.floor((date.getMonth() + 3) / 3), // Quarter + "S": date.getMilliseconds() // Millisecond }; format = format.replace(/([yMdhmsqS])(\1)*/g, function(all, t){ var v = map[t]; diff --git a/README.md b/README.md index fe002c419..0de70edf3 100644 --- a/README.md +++ b/README.md @@ -4,78 +4,95 @@ [![codecov](https://codecov.io/gh/thedaviddias/HTMLHint/branch/master/graph/badge.svg)](https://codecov.io/gh/thedaviddias/HTMLHint) [![NPM version](https://img.shields.io/npm/v/htmlhint.svg?style=flat)](https://www.npmjs.com/package/htmlhint) [![NPM count](https://img.shields.io/npm/dm/htmlhint.svg?style=flat)](https://www.npmjs.com/package/htmlhint) +[![Greenkeeper badge](https://badges.greenkeeper.io/thedaviddias/HTMLHint.svg?style=flat)](https://greenkeeper.io/) +[![NPM count](https://img.shields.io/npm/dt/htmlhint.svg?style=flat)](https://www.npmjs.com/package/htmlhint) [![License](https://img.shields.io/npm/l/htmlhint.svg?style=flat)](https://www.npmjs.com/package/htmlhint) +[![Discord](https://img.shields.io/badge/chat-on%20discord-7289da.svg?style=flat)](https://discord.gg/nJ6J9CP) HTMLHint is a Static Code Analysis Tool for HTML, you can use it with IDE or in build system. -## Getting started - -1. Installation & hints - - npm install htmlhint -g - htmlhint -V - htmlhint --help - htmlhint www - htmlhint www/test.html - htmlhint www/**/*.xhtml - htmlhint www/**/*.{htm,html} - htmlhint http://www.alibaba.com/ - cat test.html | htmlhint stdin - -2. Results - - test.html - L5 | - ^ must be present in <head> tag. (title-require) - L8 | </body> - ^ Tag must be paired, missing: [ </div> ], start tag match failed [ <div> ] on line 7. (tag-pair) - - 2 errors in 1 files - -3. Config rules - - search `.htmlhintrc` file in current directory and all parent directories: - - htmlhint - htmlhint test.html - - custom config file: - - htmlhint --config htmlhint.conf test.html - - custom rules: - - htmlhint --rules tag-pair,id-class-value=underline test.html - - Inline rules in `test.html`: - - <!--htmlhint tag-pair,id-class-value:underline --> - <html> - <head> - ... - -## Guide +## 📟 Installation and Usage + +Prerequisites: Node.js (>=6.14), npm version 3+. + +There are two ways to install HTMLHint: globally and locally. + +### Local Installation and Usage + +In case you want to include HTMLHint as part of your project, you can install it locally using NPM: + +``` +$ npm install htmlhint --save-dev +``` +After that, You can run HTMLHint on any file or directory like this: +``` +$ ./node_modules/.bin/htmlhint www/index.html +$ ./node_modules/.bin/htmlhint www/**/*.html +``` +### Global Installation and Usage + +If you want to make HTMLHint available to tools that run across all of your projects, you can instal HTMLHint globally using NPM: + +``` +$ npm install htmlhint -g +``` +After that, you can run HTMLHint on any file like this: +``` +$ htmlhint www/index.html +$ htmlhint www/**/*.html +``` +You can even launch HTMLHint to analyse an URL: +``` +$ htmlhint https://htmlhint.io/ +``` +## 📃 Example output + + +## 🔧 Configuration + +Search `.htmlhintrc` file in current directory and all parent directories: +``` +$ htmlhint +$ htmlhint test.html +``` +Custom config file: +``` +$ htmlhint --config htmlhint.conf test.html +``` +Custom rules: +``` +$ htmlhint --rules tag-pair,id-class-value=underline index.html +``` + +Inline rules in `test.html`: +``` +<!--htmlhint tag-pair,id-class-value:underline --> +<html> +<head> +... +``` +## 🗺 Guide 1. [How to use](https://github.com/thedaviddias/HTMLHint/wiki/Usage) 2. [All Rules](https://github.com/thedaviddias/HTMLHint/wiki/Rules) -2. [How to Develop](https://github.com/thedaviddias/HTMLHint/wiki/Developer-guide) +3. [How to Develop](https://github.com/thedaviddias/HTMLHint/wiki/Developer-guide) -## License +## © License -[The MIT License](https://raw.githubusercontent.com/thedaviddias/HTMLHint/master/LICENSE). +[MIT License](./LICENSE). -## Contributors +## 💪🏻 Contributors This project exists thanks to all these people. [Contribute](CONTRIBUTING.md). <a href="https://github.com/thedaviddias/HTMLHint/graphs/contributors"><img src="https://opencollective.com/htmlhint/contributors.svg?width=890" /></a> -## Backers +## 🏅 Backers Thank you to all our backers! [Become a backer](https://opencollective.com/stylelint#backer). <a href="https://opencollective.com/htmlhint#backers" target="_blank"><img src="https://opencollective.com/htmlhint/backers.svg?width=890"></a> -## Sponsors +## 🎖 Sponsors Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor](https://opencollective.com/htmlhint#sponsor). diff --git a/bin/formatters/checkstyle.js b/bin/formatters/checkstyle.js index ae770bd21..1319430a5 100644 --- a/bin/formatters/checkstyle.js +++ b/bin/formatters/checkstyle.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ var xml = require('xml'); var checkstyleFormatter = function(formatter){ diff --git a/bin/formatters/compact.js b/bin/formatters/compact.js index 75797d4e8..fc4ae8ae8 100644 --- a/bin/formatters/compact.js +++ b/bin/formatters/compact.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ var compactFormatter = function(formatter, HTMLHint, options){ var nocolor = options.nocolor; formatter.on('file', function(event){ diff --git a/bin/formatters/default.js b/bin/formatters/default.js index 03a48d4a9..121348071 100644 --- a/bin/formatters/default.js +++ b/bin/formatters/default.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ var defaultFormatter = function(formatter, HTMLHint, options){ var nocolor = options.nocolor; formatter.on('start', function(){ diff --git a/bin/formatters/json.js b/bin/formatters/json.js index 47186e96c..96c968988 100644 --- a/bin/formatters/json.js +++ b/bin/formatters/json.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ var jsonFormatter = function(formatter){ formatter.on('end', function(event){ console.log(JSON.stringify(event.arrAllMessages)); diff --git a/bin/formatters/junit.js b/bin/formatters/junit.js index af4eeb597..7ed0da426 100644 --- a/bin/formatters/junit.js +++ b/bin/formatters/junit.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ var xml = require('xml'); var junitFormatter = function(formatter, HTMLHint){ diff --git a/bin/formatters/markdown.js b/bin/formatters/markdown.js index 1f20a6fd7..1b2bcb82b 100644 --- a/bin/formatters/markdown.js +++ b/bin/formatters/markdown.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ var markdownFormatter = function(formatter, HTMLHint){ formatter.on('end', function(event){ console.log('# TOC'); diff --git a/bin/formatters/unix.js b/bin/formatters/unix.js index 06358466a..3cf4efade 100644 --- a/bin/formatters/unix.js +++ b/bin/formatters/unix.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ var unixFormatter = function(formatter, HTMLHint, options){ var nocolor = options.nocolor; formatter.on('file', function(event){ diff --git a/bin/htmlhint b/bin/htmlhint index 89e6e656b..ebb06f8e7 100755 --- a/bin/htmlhint +++ b/bin/htmlhint @@ -268,7 +268,6 @@ function getGlobInfo(target){ var globInfo = parseGlob(target); var base = path.resolve(globInfo.base); base += /\/$/.test(base) ? '' : '/'; - base = path.resolve(base); var pattern = globInfo.glob; var globPath = globInfo.path; var defaultGlob = '*.{htm,html}'; @@ -313,10 +312,11 @@ function getConfig(configPath, base, formatter){ } if(fs.existsSync(configPath)){ - var config = fs.readFileSync(configPath, 'utf-8'), + var configJson = fs.readFileSync(configPath, 'utf-8'), ruleset; try{ - ruleset = JSON.parse(stripJsonComments(config)); + var config = JSON.parse(stripJsonComments(configJson)); + ruleset = config.rules; formatter.emit('config', { ruleset: ruleset, configPath: configPath diff --git a/package.json b/package.json index 3b2d2dba7..f0f0db8d1 100644 --- a/package.json +++ b/package.json @@ -4,32 +4,32 @@ "description": "The Static Code Analysis Tool for your HTML", "main": "./index", "dependencies": { - "async": "1.5.2", - "colors": "1.1.2", - "commander": "2.9.0", - "csslint": "0.10.0", - "glob": "7.0.3", - "jshint": "2.9.4", + "async": "2.6.1", + "colors": "1.3.2", + "commander": "2.17.1", + "csslint": "1.0.5", + "glob": "7.1.3", + "jshint": "2.9.6", "parse-glob": "3.0.4", - "path-parse": "1.0.5", - "request": "2.72.0", + "path-parse": "1.0.6", + "request": "2.88.0", "strip-json-comments": "2.0.1", "xml": "1.0.1" }, "devDependencies": { "expect.js": "0.3.1", - "grunt": "0.4.1", - "grunt-cli": "0.1.6", - "grunt-contrib-clean": "0.4.0", - "grunt-contrib-concat": "0.1.3", - "grunt-contrib-jshint": "0.11.3", - "grunt-contrib-uglify": "0.2.0", - "grunt-contrib-watch": "0.3.1", - "grunt-exec": "0.4.6", - "grunt-replace": "0.4.0", - "istanbul": "0.4.3", + "grunt": "1.0.3", + "grunt-cli": "1.3.1", + "grunt-contrib-clean": "1.1.0", + "grunt-contrib-concat": "1.0.1", + "grunt-contrib-jshint": "1.1.0", + "grunt-contrib-uglify": "3.4.0", + "grunt-contrib-watch": "1.1.0", + "grunt-exec": "3.0.0", + "grunt-replace": "1.0.1", + "istanbul": "0.4.5", "istanbul-coveralls": "1.0.3", - "mocha": "2.4.5", + "mocha": "5.2.0", "semantic-release": "^15.9.9" }, "bin": { @@ -48,7 +48,25 @@ "analysis", "javascript" ], - "author": "David Dias (thedaviddias@gmail.com)", + "author": { + "name": "David Dias", + "email": "thedaviddias@gmail.com", + "url": "https://thedaviddias.me" + }, + "contributors": [ + { + "name": "Yanis Wang", + "email": "yanis.wang@gmail.com" + }, + { + "name": "Serj Lavrin", + "url": "https://lavrins.com" + }, + { + "name": "Christopher Quadflieg", + "email": "chrissi92@hotmail.de" + } + ], "license": "MIT", "scripts": { "semantic-release": "semantic-release" diff --git a/src/core.js b/src/core.js index f9da415b8..c0f9e2e29 100644 --- a/src/core.js +++ b/src/core.js @@ -1,8 +1,4 @@ /* jshint -W079 */ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ var HTMLHint = (function (undefined) { var HTMLHint = {}; @@ -12,7 +8,7 @@ var HTMLHint = (function (undefined) { HTMLHint.rules = {}; - //默认配置 + // standard configuration HTMLHint.defaultRuleset = { 'tagname-lowercase': true, 'attr-lowercase': true, diff --git a/src/htmlparser.js b/src/htmlparser.js index 0b2302a7a..7cc1ef9f7 100644 --- a/src/htmlparser.js +++ b/src/htmlparser.js @@ -1,8 +1,4 @@ /* jshint -W079 */ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ var HTMLParser = (function(undefined){ var HTMLParser = function(){ @@ -49,19 +45,19 @@ var HTMLParser = (function(undefined){ while((match = regTag.exec(html))){ matchIndex = match.index; - if(matchIndex > lastIndex){//保存前面的文本或者CDATA + if(matchIndex > lastIndex){// Save the previous text or CDATA text = html.substring(lastIndex, matchIndex); if(tagCDATA){ arrCDATA.push(text); } - else{//文本 + else{// text saveBlock('text', text, lastIndex); } } lastIndex = regTag.lastIndex; if((tagName = match[1])){ - if(tagCDATA && tagName === tagCDATA){//结束标签前输出CDATA + if(tagCDATA && tagName === tagCDATA){// Output CDATA before closing the label text = arrCDATA.join(''); saveBlock('cdata', text, lastCDATAIndex, { 'tagName': tagCDATA, @@ -72,7 +68,7 @@ var HTMLParser = (function(undefined){ arrCDATA = null; } if(!tagCDATA){ - //标签结束 + // End of label saveBlock('tagend', match[0], matchIndex, { 'tagName': tagName }); @@ -84,7 +80,7 @@ var HTMLParser = (function(undefined){ arrCDATA.push(match[0]); } else{ - if((tagName = match[4])){//标签开始 + if((tagName = match[4])){// Label start arrAttrs = []; var attrs = match[5], attrMatch, @@ -112,11 +108,11 @@ var HTMLParser = (function(undefined){ lastCDATAIndex = lastIndex; } } - else{//如果出现漏匹配,则把当前内容匹配为text + else{// If a miss match occurs, the current content is matched to text saveBlock('text', match[0], matchIndex); } } - else if(match[2] || match[3]){//注释标签 + else if(match[2] || match[3]){// Comment tag saveBlock('comment', match[0], matchIndex, { 'content': match[2] || match[3], 'long': match[2]?true:false @@ -126,7 +122,7 @@ var HTMLParser = (function(undefined){ } if(html.length > lastIndex){ - //结尾文本 + // End text text = html.substring(lastIndex, html.length); saveBlock('text', text, lastIndex); } @@ -137,7 +133,7 @@ var HTMLParser = (function(undefined){ col: html.length - lastLineIndex + 1 }); - //存储区块 + // Memory block function saveBlock(type, raw, pos, data){ var col = pos - lastLineIndex + 1; if(data === undefined){ diff --git a/src/reporter.js b/src/reporter.js index 444b6da0f..e7d379ddf 100644 --- a/src/reporter.js +++ b/src/reporter.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ (function(HTMLHint, undefined){ var Reporter = function(){ diff --git a/src/rules/alt-require.js b/src/rules/alt-require.js index 9804791c9..c2df01954 100644 --- a/src/rules/alt-require.js +++ b/src/rules/alt-require.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * Copyright (c) 2014, Takeshi Kurosawa <taken.spc@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'alt-require', 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.', diff --git a/src/rules/attr-lowercase.js b/src/rules/attr-lowercase.js index 058d24d95..55648bf6e 100644 --- a/src/rules/attr-lowercase.js +++ b/src/rules/attr-lowercase.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'attr-lowercase', description: 'All attribute names must be in lowercase.', diff --git a/src/rules/attr-no-duplication.js b/src/rules/attr-no-duplication.js index 60e1b7cf3..ae2e8fcdb 100644 --- a/src/rules/attr-no-duplication.js +++ b/src/rules/attr-no-duplication.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2014, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'attr-no-duplication', description: 'Elements cannot have duplicate attributes.', @@ -24,4 +20,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/attr-unsafe-chars.js b/src/rules/attr-unsafe-chars.js index de6b7fdcd..b91d988f2 100644 --- a/src/rules/attr-unsafe-chars.js +++ b/src/rules/attr-unsafe-chars.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2014, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'attr-unsafe-chars', description: 'Attribute values cannot contain unsafe chars.', diff --git a/src/rules/attr-value-double-quotes.js b/src/rules/attr-value-double-quotes.js index 971fd9524..c54833570 100644 --- a/src/rules/attr-value-double-quotes.js +++ b/src/rules/attr-value-double-quotes.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'attr-value-double-quotes', description: 'Attribute values must be in double quotes.', @@ -20,4 +16,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/attr-value-not-empty.js b/src/rules/attr-value-not-empty.js index 5fecf48ac..7ad85e794 100644 --- a/src/rules/attr-value-not-empty.js +++ b/src/rules/attr-value-not-empty.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'attr-value-not-empty', description: 'All attributes must have values.', @@ -19,4 +15,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/csslint.js b/src/rules/csslint.js index a5fd62394..ba546e163 100644 --- a/src/rules/csslint.js +++ b/src/rules/csslint.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'csslint', description: 'Scan css with csslint.', @@ -35,4 +31,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/doctype-first.js b/src/rules/doctype-first.js index 566b970c1..f5eb55c87 100644 --- a/src/rules/doctype-first.js +++ b/src/rules/doctype-first.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'doctype-first', description: 'Doctype must be declared first.', @@ -18,4 +14,4 @@ HTMLHint.addRule({ }; parser.addListener('all', allEvent); } -}); \ No newline at end of file +}); diff --git a/src/rules/doctype-html5.js b/src/rules/doctype-html5.js index 6586c7d6e..d134de8ff 100644 --- a/src/rules/doctype-html5.js +++ b/src/rules/doctype-html5.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'doctype-html5', description: 'Invalid doctype. Use: "<!DOCTYPE html>"', @@ -19,4 +15,4 @@ HTMLHint.addRule({ parser.addListener('all', onComment); parser.addListener('tagstart', onTagStart); } -}); \ No newline at end of file +}); diff --git a/src/rules/head-script-disabled.js b/src/rules/head-script-disabled.js index 9f9ffd0f9..f8afed300 100644 --- a/src/rules/head-script-disabled.js +++ b/src/rules/head-script-disabled.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'head-script-disabled', description: 'The <script> tag cannot be used in a <head> tag.', diff --git a/src/rules/href-abs-or-rel.js b/src/rules/href-abs-or-rel.js index 05ffcc3e1..5f5d9fe80 100644 --- a/src/rules/href-abs-or-rel.js +++ b/src/rules/href-abs-or-rel.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2014, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'href-abs-or-rel', description: 'An href attribute must be either absolute or relative.', @@ -27,4 +23,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/id-class-ad-disabled.js b/src/rules/id-class-ad-disabled.js index d934b426a..7d5c60b2f 100644 --- a/src/rules/id-class-ad-disabled.js +++ b/src/rules/id-class-ad-disabled.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2014, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'id-class-ad-disabled', description: 'The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.', @@ -24,4 +20,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/id-class-value.js b/src/rules/id-class-value.js index d050e6141..6a8f505e6 100644 --- a/src/rules/id-class-value.js +++ b/src/rules/id-class-value.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'id-class-value', description: 'The id and class attribute values must meet the specified rules.', @@ -54,4 +50,4 @@ HTMLHint.addRule({ }); } } -}); \ No newline at end of file +}); diff --git a/src/rules/id-unique.js b/src/rules/id-unique.js index 6e671347e..9f416b48e 100644 --- a/src/rules/id-unique.js +++ b/src/rules/id-unique.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'id-unique', description: 'The value of id attributes must be unique.', @@ -33,4 +29,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/inline-script-disabled.js b/src/rules/inline-script-disabled.js index cbdddd79a..0c764f9f6 100644 --- a/src/rules/inline-script-disabled.js +++ b/src/rules/inline-script-disabled.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'inline-script-disabled', description: 'Inline script cannot be used.', diff --git a/src/rules/inline-style-disabled.js b/src/rules/inline-style-disabled.js index b56ce81be..4747ded00 100644 --- a/src/rules/inline-style-disabled.js +++ b/src/rules/inline-style-disabled.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'inline-style-disabled', description: 'Inline style cannot be used.', diff --git a/src/rules/jshint.js b/src/rules/jshint.js index 336d1b987..c00c29edf 100644 --- a/src/rules/jshint.js +++ b/src/rules/jshint.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'jshint', description: 'Scan script with jshint.', @@ -32,7 +28,7 @@ HTMLHint.addRule({ styleCol = event.col - 1; var code = event.raw.replace(/\t/g,' '); try{ - var status = jsVerify(code, options); + var status = jsVerify(code, options, options.globals); if(status === false){ jsVerify.errors.forEach(function(error){ var line = error.line; @@ -46,4 +42,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/space-tab-mixed-disabled.js b/src/rules/space-tab-mixed-disabled.js index 7b5212ed3..5b879cb57 100644 --- a/src/rules/space-tab-mixed-disabled.js +++ b/src/rules/space-tab-mixed-disabled.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2014, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'space-tab-mixed-disabled', description: 'Do not mix tabs and spaces for indentation.', diff --git a/src/rules/spec-char-escape.js b/src/rules/spec-char-escape.js index c074db09b..d68569985 100644 --- a/src/rules/spec-char-escape.js +++ b/src/rules/spec-char-escape.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'spec-char-escape', description: 'Special characters must be escaped.', @@ -17,4 +13,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/src-not-empty.js b/src/rules/src-not-empty.js index d864aa455..5f5ed2a25 100644 --- a/src/rules/src-not-empty.js +++ b/src/rules/src-not-empty.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'src-not-empty', description: 'The src attribute of an img(script,link) must have a value.', @@ -23,4 +19,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/style-disabled.js b/src/rules/style-disabled.js index f04d2c88f..5d84d39f9 100644 --- a/src/rules/style-disabled.js +++ b/src/rules/style-disabled.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'style-disabled', description: '<style> tags cannot be used.', diff --git a/src/rules/tag-pair.js b/src/rules/tag-pair.js index 060e941b9..8f6fe359f 100644 --- a/src/rules/tag-pair.js +++ b/src/rules/tag-pair.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'tag-pair', description: 'Tag must be paired.', @@ -21,7 +17,7 @@ HTMLHint.addRule({ }); parser.addListener('tagend', function(event){ var tagName = event.tagName.toLowerCase(); - //向上寻找匹配的开始标签 + // Look up the matching start tag for(var pos = stack.length-1;pos >= 0; pos--){ if(stack[pos].tagName === tagName){ break; diff --git a/src/rules/tag-self-close.js b/src/rules/tag-self-close.js index cb89a2dbe..e7b00ca8b 100644 --- a/src/rules/tag-self-close.js +++ b/src/rules/tag-self-close.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'tag-self-close', description: 'Empty tags must be self closed.', diff --git a/src/rules/tagname-lowercase.js b/src/rules/tagname-lowercase.js index 39bf157e7..3ae51fdc2 100644 --- a/src/rules/tagname-lowercase.js +++ b/src/rules/tagname-lowercase.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'tagname-lowercase', description: 'All html element names must be in lowercase.', @@ -14,4 +10,4 @@ HTMLHint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/title-require.js b/src/rules/title-require.js index 199fde820..c6aaaee8e 100644 --- a/src/rules/title-require.js +++ b/src/rules/title-require.js @@ -1,7 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ HTMLHint.addRule({ id: 'title-require', description: '<title> must be present in <head> tag.', diff --git a/test/core-spec.js b/test/core-spec.js index c5e61e155..1b6cd4fbe 100644 --- a/test/core-spec.js +++ b/test/core-spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2014, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../index").HTMLHint; diff --git a/test/htmlparser.spec.js b/test/htmlparser.spec.js index 2fc46aa57..3a1afc4f0 100644 --- a/test/htmlparser.spec.js +++ b/test/htmlparser.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLParser = require("../index").HTMLParser; diff --git a/test/rules/alt-require.spec.js b/test/rules/alt-require.spec.js index 04ee3bff3..fc89a3107 100644 --- a/test/rules/alt-require.spec.js +++ b/test/rules/alt-require.spec.js @@ -1,116 +1,110 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * Copyright (c) 2014, Takeshi Kurosawa <taken.spc@gmail.com> - * MIT Licensed - */ - -var expect = require("expect.js"); - -var HTMLHint = require("../../index").HTMLHint; - -var ruldId = 'alt-require', - ruleOptions = {}; - -ruleOptions[ruldId] = true; - -describe('Rules: '+ruldId, function(){ - - it('Img tag have empty alt attribute should not result in an error', function(){ - var code = '<img width="200" height="300" alt="">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Img tag have non empty alt attribute should not result in an error', function(){ - var code = '<img width="200" height="300" alt="test">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Img tag have not alt attribute should result in an error', function(){ - var code = '<img width="200" height="300">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - expect(messages[0].type).to.be('warning'); - }); - - /* A tag can have shape and coords attributes and not have alt attribute */ - it('A tag have not alt attribute should not result in an error', function(){ - var code = '<a>'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Area tag have not href and alt attributes should not result in an error', function(){ - var code = '<area>'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Area[href] tag have not alt attribute should result in an error', function(){ - var code = '<area href="#test">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(6); - expect(messages[0].type).to.be('warning'); - }); - - it('Area[href] tag have empty alt attribute should result in an error', function(){ - var code = '<area href="#test" alt="">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(6); - expect(messages[0].type).to.be('warning'); - }); - - it('Area[href] tag have non emtpy alt attribute should not result in an error', function(){ - var code = '<area href="#test" alt="test">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Input tag have not type and alt attributes should not result in an error', function(){ - var code = '<input>'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Input[type="text"] tag have not alt attribute should not result in an error', function(){ - var code = '<input type="text">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Input[type="image"] tag have not alt attribute should result in an error', function(){ - var code = '<input type="image">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(7); - expect(messages[0].type).to.be('warning'); - }); - - it('Input[type="image"] tag have empty alt attribute should result in an error', function(){ - var code = '<input type="image" alt="">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(7); - expect(messages[0].type).to.be('warning'); - }); - - it('Input[type="image"] tag have non emtpy alt attribute should not result in an error', function(){ - var code = '<input type="image" alt="test">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); +var expect = require("expect.js"); + +var HTMLHint = require("../../index").HTMLHint; + +var ruldId = 'alt-require', + ruleOptions = {}; + +ruleOptions[ruldId] = true; + +describe('Rules: '+ruldId, function(){ + + it('Img tag have empty alt attribute should not result in an error', function(){ + var code = '<img width="200" height="300" alt="">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('Img tag have non empty alt attribute should not result in an error', function(){ + var code = '<img width="200" height="300" alt="test">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('Img tag have not alt attribute should result in an error', function(){ + var code = '<img width="200" height="300">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + expect(messages[0].type).to.be('warning'); + }); + + /* A tag can have shape and coords attributes and not have alt attribute */ + it('A tag have not alt attribute should not result in an error', function(){ + var code = '<a>'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('Area tag have not href and alt attributes should not result in an error', function(){ + var code = '<area>'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('Area[href] tag have not alt attribute should result in an error', function(){ + var code = '<area href="#test">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(6); + expect(messages[0].type).to.be('warning'); + }); + + it('Area[href] tag have empty alt attribute should result in an error', function(){ + var code = '<area href="#test" alt="">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(6); + expect(messages[0].type).to.be('warning'); + }); + + it('Area[href] tag have non emtpy alt attribute should not result in an error', function(){ + var code = '<area href="#test" alt="test">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('Input tag have not type and alt attributes should not result in an error', function(){ + var code = '<input>'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('Input[type="text"] tag have not alt attribute should not result in an error', function(){ + var code = '<input type="text">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('Input[type="image"] tag have not alt attribute should result in an error', function(){ + var code = '<input type="image">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(7); + expect(messages[0].type).to.be('warning'); + }); + + it('Input[type="image"] tag have empty alt attribute should result in an error', function(){ + var code = '<input type="image" alt="">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(7); + expect(messages[0].type).to.be('warning'); + }); + + it('Input[type="image"] tag have non emtpy alt attribute should not result in an error', function(){ + var code = '<input type="image" alt="test">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); +}); diff --git a/test/rules/attr-lowercase.spec.js b/test/rules/attr-lowercase.spec.js index ae3c7aea6..ff03d4e8c 100644 --- a/test/rules/attr-lowercase.spec.js +++ b/test/rules/attr-lowercase.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; diff --git a/test/rules/attr-no-duplication.spec.js b/test/rules/attr-no-duplication.spec.js index 04f859449..c5358c806 100644 --- a/test/rules/attr-no-duplication.spec.js +++ b/test/rules/attr-no-duplication.spec.js @@ -1,32 +1,27 @@ -/** - * Copyright (c) 2014, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - -var expect = require("expect.js"); - -var HTMLHint = require("../../index").HTMLHint; - -var ruldId = 'attr-no-duplication', - ruleOptions = {}; - -ruleOptions[ruldId] = true; - -describe('Rules: '+ruldId, function(){ - - it('Attribute name been duplication should result in an error', function(){ - var code = '<a href="a" href="b">bbb</a>'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(12); - }); - - it('Attribute name not been duplication should not result in an error', function(){ - var code = '<a href="a">bbb</a>'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - -}); \ No newline at end of file +var expect = require("expect.js"); + +var HTMLHint = require("../../index").HTMLHint; + +var ruldId = 'attr-no-duplication', + ruleOptions = {}; + +ruleOptions[ruldId] = true; + +describe('Rules: '+ruldId, function(){ + + it('Attribute name been duplication should result in an error', function(){ + var code = '<a href="a" href="b">bbb</a>'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(12); + }); + + it('Attribute name not been duplication should not result in an error', function(){ + var code = '<a href="a">bbb</a>'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + +}); diff --git a/test/rules/attr-unsafe-chars.spec.js b/test/rules/attr-unsafe-chars.spec.js index 538bbe8e3..614955411 100644 --- a/test/rules/attr-unsafe-chars.spec.js +++ b/test/rules/attr-unsafe-chars.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; diff --git a/test/rules/attr-value-double-quotes.spec.js b/test/rules/attr-value-double-quotes.spec.js index 04093be21..4ad99555f 100644 --- a/test/rules/attr-value-double-quotes.spec.js +++ b/test/rules/attr-value-double-quotes.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -35,4 +30,4 @@ describe('Rules: '+ruldId, function(){ expect(messages.length).to.be(0); }); -}); \ No newline at end of file +}); diff --git a/test/rules/attr-value-not-empty.spec.js b/test/rules/attr-value-not-empty.spec.js index 5c7a58ebd..9c4d54f27 100644 --- a/test/rules/attr-value-not-empty.spec.js +++ b/test/rules/attr-value-not-empty.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -36,4 +31,4 @@ describe('Rules: '+ruldId, function(){ expect(messages.length).to.be(0); }); -}); \ No newline at end of file +}); diff --git a/test/rules/csslint.spec.js b/test/rules/csslint.spec.js index 191c5f0aa..b7705260c 100644 --- a/test/rules/csslint.spec.js +++ b/test/rules/csslint.spec.js @@ -1,34 +1,29 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - -var expect = require("expect.js"); - -var HTMLHint = require("../../index").HTMLHint; - -var ruldId = 'csslint', - ruleOptions = {}; - -ruleOptions[ruldId] = { - "display-property-grouping": true, - "known-properties": true - }; - -describe('Rules: '+ruldId, function(){ - - it('should result in an error', function(){ - var code = 'a<style> \r\n body{color:red1;\r\ndisplay:inline;height:100px;}</style>b'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(2); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(2); - expect(messages[0].col).to.be(7); - expect(messages[0].type).to.be('warning'); - expect(messages[1].rule.id).to.be(ruldId); - expect(messages[1].line).to.be(3); - expect(messages[1].col).to.be(16); - expect(messages[1].type).to.be('warning'); - }); - -}); \ No newline at end of file +var expect = require("expect.js"); + +var HTMLHint = require("../../index").HTMLHint; + +var ruldId = 'csslint', + ruleOptions = {}; + +ruleOptions[ruldId] = { + "display-property-grouping": true, + "known-properties": true + }; + +describe('Rules: '+ruldId, function(){ + + it('should result in an error', function(){ + var code = 'a<style> \r\n body{color:red1;\r\ndisplay:inline;height:100px;}</style>b'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(2); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(2); + expect(messages[0].col).to.be(7); + expect(messages[0].type).to.be('warning'); + expect(messages[1].rule.id).to.be(ruldId); + expect(messages[1].line).to.be(3); + expect(messages[1].col).to.be(16); + expect(messages[1].type).to.be('warning'); + }); + +}); diff --git a/test/rules/default.spec.js b/test/rules/default.spec.js index a7840ae8b..e7af0307d 100644 --- a/test/rules/default.spec.js +++ b/test/rules/default.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -15,4 +10,4 @@ describe('Rules: default', function(){ expect(messages.length).to.be(3); }); -}); \ No newline at end of file +}); diff --git a/test/rules/doctype-first.spec.js b/test/rules/doctype-first.spec.js index 5b35b3152..6cd2ec1d2 100644 --- a/test/rules/doctype-first.spec.js +++ b/test/rules/doctype-first.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -29,4 +24,4 @@ describe('Rules: '+ruldId, function(){ expect(messages.length).to.be(0); }); -}); \ No newline at end of file +}); diff --git a/test/rules/doctype-html5.spec.js b/test/rules/doctype-html5.spec.js index 94abdf9e5..6d3e02b59 100644 --- a/test/rules/doctype-html5.spec.js +++ b/test/rules/doctype-html5.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; diff --git a/test/rules/head-require.spec.js b/test/rules/head-require.spec.js index 650c4cd96..0a15b09cb 100644 --- a/test/rules/head-require.spec.js +++ b/test/rules/head-require.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; diff --git a/test/rules/head-script-disabled.spec.js b/test/rules/head-script-disabled.spec.js index 650c4cd96..0a15b09cb 100644 --- a/test/rules/head-script-disabled.spec.js +++ b/test/rules/head-script-disabled.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; diff --git a/test/rules/href-abs-or-rel.spec.js b/test/rules/href-abs-or-rel.spec.js index 5799f1cb4..7c4ebf801 100644 --- a/test/rules/href-abs-or-rel.spec.js +++ b/test/rules/href-abs-or-rel.spec.js @@ -1,55 +1,50 @@ -/** - * Copyright (c) 2014, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - -var expect = require("expect.js"); - -var HTMLHint = require("../../index").HTMLHint; - -var ruldId = 'href-abs-or-rel'; -var ruleOptions = {}; - -describe('Rules: '+ruldId, function(){ - - it('Href value is not absolute with abs mode should result in an error', function(){ - var code = '<a href="a.html">aaa</a><a href="../b.html">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'; - ruleOptions[ruldId] = 'abs'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(2); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(3); - expect(messages[1].rule.id).to.be(ruldId); - expect(messages[1].line).to.be(1); - expect(messages[1].col).to.be(27); - }); - - it('Href value is absolute with abs mode should not result in an error', function(){ - var code = '<a href="http://www.alibaba.com/">aaa</a><a href="https://www.alibaba.com/">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'; - ruleOptions[ruldId] = 'abs'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Href value is not relative with rel mode should result in an error', function(){ - var code = '<a href="http://www.alibaba.com/">aaa</a><a href="https://www.alibaba.com/">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'; - ruleOptions[ruldId] = 'rel'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(2); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(3); - expect(messages[1].rule.id).to.be(ruldId); - expect(messages[1].line).to.be(1); - expect(messages[1].col).to.be(44); - }); - - it('Href value is relative with rel mode should not result in an error', function(){ - var code = '<a href="a.html">aaa</a><a href="../b.html">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'; - ruleOptions[ruldId] = 'rel'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - -}); \ No newline at end of file +var expect = require("expect.js"); + +var HTMLHint = require("../../index").HTMLHint; + +var ruldId = 'href-abs-or-rel'; +var ruleOptions = {}; + +describe('Rules: '+ruldId, function(){ + + it('Href value is not absolute with abs mode should result in an error', function(){ + var code = '<a href="a.html">aaa</a><a href="../b.html">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'; + ruleOptions[ruldId] = 'abs'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(2); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(3); + expect(messages[1].rule.id).to.be(ruldId); + expect(messages[1].line).to.be(1); + expect(messages[1].col).to.be(27); + }); + + it('Href value is absolute with abs mode should not result in an error', function(){ + var code = '<a href="http://www.alibaba.com/">aaa</a><a href="https://www.alibaba.com/">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'; + ruleOptions[ruldId] = 'abs'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('Href value is not relative with rel mode should result in an error', function(){ + var code = '<a href="http://www.alibaba.com/">aaa</a><a href="https://www.alibaba.com/">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'; + ruleOptions[ruldId] = 'rel'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(2); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(3); + expect(messages[1].rule.id).to.be(ruldId); + expect(messages[1].line).to.be(1); + expect(messages[1].col).to.be(44); + }); + + it('Href value is relative with rel mode should not result in an error', function(){ + var code = '<a href="a.html">aaa</a><a href="../b.html">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'; + ruleOptions[ruldId] = 'rel'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + +}); diff --git a/test/rules/id-class-ad-disabled.spec.js b/test/rules/id-class-ad-disabled.spec.js index 5cafe4f46..d34c64e84 100644 --- a/test/rules/id-class-ad-disabled.spec.js +++ b/test/rules/id-class-ad-disabled.spec.js @@ -1,134 +1,129 @@ -/** - * Copyright (c) 2014, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - -var expect = require("expect.js"); - -var HTMLHint = require("../../index").HTMLHint; - -var ruldId = 'id-class-ad-disabled', - ruleOptions = {}; - -ruleOptions[ruldId] = true; - -describe('Rules: '+ruldId, function(){ - - it('Id use ad keyword should result in an error', function(){ - var code = '<div id="ad">test</div>'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].type).to.be('warning'); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div id="ad-222">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div id="ad_222">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div id="111-ad">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div id="111_ad">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div id="111-ad-222">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div id="111_ad_222">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - }); - - it('Class use ad keyword should result in an error', function(){ - var code = '<div class="ad">test</div>'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div class="ad-222">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div class="ad_222">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div class="111-ad">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div class="111_ad">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div class="111-ad-222">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - - code = '<div class="111_ad_222">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(5); - }); - - it('Id and class no ad keyword used should not result in an error', function(){ - var code = '<div id="ad1" class="ad2">test</div>'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - - code = '<div id="ad1-222" class="ad2-222">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - - code = '<div id="111-ad1" class="111-ad2">test</div>'; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - -}); \ No newline at end of file +var expect = require("expect.js"); + +var HTMLHint = require("../../index").HTMLHint; + +var ruldId = 'id-class-ad-disabled', + ruleOptions = {}; + +ruleOptions[ruldId] = true; + +describe('Rules: '+ruldId, function(){ + + it('Id use ad keyword should result in an error', function(){ + var code = '<div id="ad">test</div>'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].type).to.be('warning'); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div id="ad-222">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div id="ad_222">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div id="111-ad">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div id="111_ad">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div id="111-ad-222">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div id="111_ad_222">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + }); + + it('Class use ad keyword should result in an error', function(){ + var code = '<div class="ad">test</div>'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div class="ad-222">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div class="ad_222">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div class="111-ad">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div class="111_ad">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div class="111-ad-222">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + + code = '<div class="111_ad_222">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(1); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(1); + expect(messages[0].col).to.be(5); + }); + + it('Id and class no ad keyword used should not result in an error', function(){ + var code = '<div id="ad1" class="ad2">test</div>'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + + code = '<div id="ad1-222" class="ad2-222">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + + code = '<div id="111-ad1" class="111-ad2">test</div>'; + messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + +}); diff --git a/test/rules/id-class-value.spec.js b/test/rules/id-class-value.spec.js index ddc54730e..894b0cc63 100644 --- a/test/rules/id-class-value.spec.js +++ b/test/rules/id-class-value.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -94,4 +89,4 @@ describe('Rules: '+ruldId, function(){ expect(messages.length).to.be(0); }); -}); \ No newline at end of file +}); diff --git a/test/rules/id-unique.spec.js b/test/rules/id-unique.spec.js index 5c9f33781..86c3008cf 100644 --- a/test/rules/id-unique.spec.js +++ b/test/rules/id-unique.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -30,4 +25,4 @@ describe('Rules: '+ruldId, function(){ expect(messages.length).to.be(0); }); -}); \ No newline at end of file +}); diff --git a/test/rules/inline-script-disabled.spec.js b/test/rules/inline-script-disabled.spec.js index 831c1b58a..3db0675bb 100644 --- a/test/rules/inline-script-disabled.spec.js +++ b/test/rules/inline-script-disabled.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; diff --git a/test/rules/inline-style-disabled.spec.js b/test/rules/inline-style-disabled.spec.js index 866bf281b..67c3855ea 100644 --- a/test/rules/inline-style-disabled.spec.js +++ b/test/rules/inline-style-disabled.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; diff --git a/test/rules/jshint.spec.js b/test/rules/jshint.spec.js index e32d1001c..847b6e597 100644 --- a/test/rules/jshint.spec.js +++ b/test/rules/jshint.spec.js @@ -1,60 +1,55 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - -var expect = require("expect.js"); - -var HTMLHint = require("../../index").HTMLHint; - -var ruldId = 'jshint', - ruleOptions = {}; - -ruleOptions[ruldId] = { - "undef": true, - "unused": true - }; - -describe('Rules: '+ruldId, function(){ - - it('should result in an error', function(){ - var code = 'a<script>\r\nvar b;\r\n debugger;\r\na=1</script>b'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(4); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(3); - expect(messages[0].col).to.be(3); - expect(messages[0].type).to.be('warning'); - expect(messages[1].rule.id).to.be(ruldId); - expect(messages[1].line).to.be(4); - expect(messages[1].col).to.be(4); - expect(messages[1].type).to.be('warning'); - expect(messages[2].rule.id).to.be(ruldId); - expect(messages[2].line).to.be(4); - expect(messages[2].col).to.be(1); - expect(messages[2].type).to.be('warning'); - expect(messages[3].rule.id).to.be(ruldId); - expect(messages[3].line).to.be(2); - expect(messages[3].col).to.be(5); - expect(messages[3].type).to.be('warning'); - }); - - it('type of script be not text/javascript should not result in an error', function(){ - var code = 'a<script type="text/html">\r\nvar b;\r\n debugger;\r\na=1</script>b'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('type of script be text/javascript should result in an error', function(){ - var code = 'a<script type="text/javascript">\r\nvar b;\r\n debugger;\r\na=1</script>b'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).not.to.be(0); - }); - - it('type of script be text/javascript but have src should not result in an error', function(){ - var code = 'a<script type="text/javascript" src="test.js">\r\nvar b;\r\n debugger;\r\na=1</script>b'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - -}); \ No newline at end of file +var expect = require("expect.js"); + +var HTMLHint = require("../../index").HTMLHint; + +var ruldId = 'jshint', + ruleOptions = {}; + +ruleOptions[ruldId] = { + "undef": true, + "unused": true + }; + +describe('Rules: '+ruldId, function(){ + + it('should result in an error', function(){ + var code = 'a<script>\r\nvar b;\r\n debugger;\r\na=1</script>b'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(4); + expect(messages[0].rule.id).to.be(ruldId); + expect(messages[0].line).to.be(3); + expect(messages[0].col).to.be(3); + expect(messages[0].type).to.be('warning'); + expect(messages[1].rule.id).to.be(ruldId); + expect(messages[1].line).to.be(4); + expect(messages[1].col).to.be(4); + expect(messages[1].type).to.be('warning'); + expect(messages[2].rule.id).to.be(ruldId); + expect(messages[2].line).to.be(4); + expect(messages[2].col).to.be(1); + expect(messages[2].type).to.be('warning'); + expect(messages[3].rule.id).to.be(ruldId); + expect(messages[3].line).to.be(2); + expect(messages[3].col).to.be(5); + expect(messages[3].type).to.be('warning'); + }); + + it('type of script be not text/javascript should not result in an error', function(){ + var code = 'a<script type="text/html">\r\nvar b;\r\n debugger;\r\na=1</script>b'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('type of script be text/javascript should result in an error', function(){ + var code = 'a<script type="text/javascript">\r\nvar b;\r\n debugger;\r\na=1</script>b'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).not.to.be(0); + }); + + it('type of script be text/javascript but have src should not result in an error', function(){ + var code = 'a<script type="text/javascript" src="test.js">\r\nvar b;\r\n debugger;\r\na=1</script>b'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + +}); diff --git a/test/rules/space-tab-mixed-disabled.spec.js b/test/rules/space-tab-mixed-disabled.spec.js index 21528aa37..e85205d2a 100644 --- a/test/rules/space-tab-mixed-disabled.spec.js +++ b/test/rules/space-tab-mixed-disabled.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2014-2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; diff --git a/test/rules/spec-char-escape.spec.js b/test/rules/spec-char-escape.spec.js index 89e4b24d2..67384a3ae 100644 --- a/test/rules/spec-char-escape.spec.js +++ b/test/rules/spec-char-escape.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -35,4 +30,4 @@ describe('Rules: '+ruldId, function(){ expect(messages.length).to.be(0); }); -}); \ No newline at end of file +}); diff --git a/test/rules/src-not-empty.spec.js b/test/rules/src-not-empty.spec.js index 5df5f34d1..701129cf5 100644 --- a/test/rules/src-not-empty.spec.js +++ b/test/rules/src-not-empty.spec.js @@ -1,35 +1,30 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - -var expect = require("expect.js"); - -var HTMLHint = require("../../index").HTMLHint; - -var ruldId = 'src-not-empty', - ruleOptions = {}; - -ruleOptions[ruldId] = true; - -describe('Rules: '+ruldId, function(){ - - it('Src be emtpy should result in an error', function(){ - var code = '<img src="" /><img src /><script src=""></script><script src></script><link href="" type="text/css" /><link href type="text/css" /><embed src=""><embed src><bgsound src="" /><bgsound src /><iframe src=""><iframe src><object data=""><object data>'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(14); - }); - - it('Src be non-empty should not result in an error', function(){ - var code = '<img src="test.png" /><script src="test.js"></script><link href="test.css" type="text/css" /><embed src="test.swf"><bgsound src="test.mid" /><iframe src="test.html"><object data="test.swf">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Src be not set value should not result in an error', function(){ - var code = '<img width="200" /><script></script><link type="text/css" /><embed width="200"><bgsound /><iframe width="200"><object width="200">'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - -}); \ No newline at end of file +var expect = require("expect.js"); + +var HTMLHint = require("../../index").HTMLHint; + +var ruldId = 'src-not-empty', + ruleOptions = {}; + +ruleOptions[ruldId] = true; + +describe('Rules: '+ruldId, function(){ + + it('Src be emtpy should result in an error', function(){ + var code = '<img src="" /><img src /><script src=""></script><script src></script><link href="" type="text/css" /><link href type="text/css" /><embed src=""><embed src><bgsound src="" /><bgsound src /><iframe src=""><iframe src><object data=""><object data>'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(14); + }); + + it('Src be non-empty should not result in an error', function(){ + var code = '<img src="test.png" /><script src="test.js"></script><link href="test.css" type="text/css" /><embed src="test.swf"><bgsound src="test.mid" /><iframe src="test.html"><object data="test.swf">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + + it('Src be not set value should not result in an error', function(){ + var code = '<img width="200" /><script></script><link type="text/css" /><embed width="200"><bgsound /><iframe width="200"><object width="200">'; + var messages = HTMLHint.verify(code, ruleOptions); + expect(messages.length).to.be(0); + }); + +}); diff --git a/test/rules/style-disabled.spec.js b/test/rules/style-disabled.spec.js index ba4a9c04f..63eda6f17 100644 --- a/test/rules/style-disabled.spec.js +++ b/test/rules/style-disabled.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -30,4 +25,4 @@ describe('Rules: '+ruldId, function(){ expect(messages.length).to.be(0); }); -}); \ No newline at end of file +}); diff --git a/test/rules/tag-pair.spec.js b/test/rules/tag-pair.spec.js index 94dbf0ee1..7546fe471 100644 --- a/test/rules/tag-pair.spec.js +++ b/test/rules/tag-pair.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; diff --git a/test/rules/tag-self-close.spec.js b/test/rules/tag-self-close.spec.js index 0d62caed0..260d7235f 100644 --- a/test/rules/tag-self-close.spec.js +++ b/test/rules/tag-self-close.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -34,4 +29,4 @@ describe('Rules: '+ruldId, function(){ expect(messages.length).to.be(0); }); -}); \ No newline at end of file +}); diff --git a/test/rules/tagname-lowercase.spec.js b/test/rules/tagname-lowercase.spec.js index cda6611d1..edd960445 100644 --- a/test/rules/tagname-lowercase.spec.js +++ b/test/rules/tagname-lowercase.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint; @@ -38,4 +33,4 @@ describe('Rules: '+ruldId, function(){ expect(messages.length).to.be(0); }); -}); \ No newline at end of file +}); diff --git a/test/rules/title-require.spec.js b/test/rules/title-require.spec.js index 1f9905f97..889f3c82b 100644 --- a/test/rules/title-require.spec.js +++ b/test/rules/title-require.spec.js @@ -1,8 +1,3 @@ -/** - * Copyright (c) 2015, Yanis Wang <yanis.wang@gmail.com> - * MIT Licensed - */ - var expect = require("expect.js"); var HTMLHint = require("../../index").HTMLHint;