diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..da234b69a --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,13 @@ +module.exports = { + extends: ['eslint:recommended', 'plugin:prettier/recommended'], + env: { + browser: true, + amd: true, + node: true, + mocha: true, + }, + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + }, +} diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b73537336..297b12238 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,7 +1,6 @@ --- name: Bug report about: Create a report to help us improve - --- **Describe the bug** @@ -9,6 +8,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -21,15 +21,17 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] + +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] **Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] + +- Device: [e.g. iPhone6] +- OS: [e.g. iOS8.1] +- Browser [e.g. stock browser, safari] +- Version [e.g. 22] **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 066b2d920..a09db44fb 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,7 +1,6 @@ --- name: Feature request about: Suggest an idea for this project - --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25fa41bce..152008a3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,9 @@ jobs: - name: Install dependencies run: npm ci + - name: Run lint + run: npm run lint + - name: Build run: npm run build --if-present env: diff --git a/.prettierignore b/.prettierignore index a2d374c2c..3f165cf8d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,8 +7,10 @@ /coverage # production -/lib +/dist # npm package-lock.json npm-debug.log* +.nyc_output +test/html diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..22c2e20d7 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,9 @@ +{ + "semi": false, + "singleQuote": true, + "bracketSpacing": true, + "trailingComma": "es5", + "useTabs": false, + "tabWidth": 2, + "printWidth": 80 +} diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 44c416271..000000000 --- a/.prettierrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "printWidth": 80, - "tabWidth": 2, - "useTabs": false, - "singleQuote": true -} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8259a763c..f39b627ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,4 @@ -HTMLHint change log -==================== +# HTMLHint change log ## ver 0.9.14 (2016-5-2) @@ -57,7 +56,7 @@ fix: 1. close issue: #79, fix exit with 0 when hint errors 2. fix end event col -2. attr-unsafe-chars(rule): exclude `\r\n` +3. attr-unsafe-chars(rule): exclude `\r\n` ## ver 0.9.8 (2015-10-7) @@ -129,7 +128,7 @@ add: fix: -1. compatible with: +1. compatible with:
Number# | File Name | Line Number | Message |
---|---|---|---|
'+(i+1)+' | '+fileInfo.file+' | '+message.line+' | '+message.message+' |
Number# | File Name | Line Number | Message |
---|---|---|---|
' + + (i + 1) + + ' | ' + + fileInfo.file + + ' | ' + + message.line + + ' | ' + + message.message + + ' |
'; - let 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(3); - - code = '
'; - 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(1); - expect(messages[1].rule.id).to.be(ruldId); - expect(messages[1].line).to.be(2); - expect(messages[1].col).to.be(13); - }); - - it('Lowercase attr should not result in an error', function() { - const code = '
'; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Set is false should not result in an error', function() { - const code = '
'; - ruleOptions[ruldId] = false; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Set to array list should not result in an error', function() { - const code = '
'; - ruleOptions[ruldId] = ['testBox', 'tttAAA']; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Set to array list with RegExp should not result in an error', function() { - const code = '
'; - ruleOptions[ruldId] = ['testBox', /bind:.*/]; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Set to array list with regex string should not result in an error', function() { - const code = '
'; - ruleOptions[ruldId] = ['testBox', '/\\[.*\\]/']; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); +const expect = require('expect.js') + +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint + +const ruldId = 'attr-lowercase' +const ruleOptions = {} + +ruleOptions[ruldId] = true + +describe(`Rules: ${ruldId}`, function () { + it('Not all lowercase attr should result in an error', function () { + let code = '
' + let 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(3) + + code = '
' + 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(1) + expect(messages[1].rule.id).to.be(ruldId) + expect(messages[1].line).to.be(2) + expect(messages[1].col).to.be(13) + }) + + it('Lowercase attr should not result in an error', function () { + const code = '
' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) + + it('Set is false should not result in an error', function () { + const code = '
' + ruleOptions[ruldId] = false + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) + + it('Set to array list should not result in an error', function () { + const code = '
' + ruleOptions[ruldId] = ['testBox', 'tttAAA'] + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) + + it('Set to array list with RegExp should not result in an error', function () { + const code = '
' + ruleOptions[ruldId] = ['testBox', /bind:.*/] + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) + + it('Set to array list with regex string should not result in an error', function () { + const code = '
' + ruleOptions[ruldId] = ['testBox', '/\\[.*\\]/'] + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/attr-no-duplication.spec.js b/test/rules/attr-no-duplication.spec.js index 8a94e5a68..0db0caf58 100644 --- a/test/rules/attr-no-duplication.spec.js +++ b/test/rules/attr-no-duplication.spec.js @@ -1,25 +1,25 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'attr-no-duplication'; -const ruleOptions = {}; +const ruldId = 'attr-no-duplication' +const ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true -describe(`Rules: ${ruldId}`, function() { - it('Attribute name been duplication should result in an error', function() { - const code = 'bbb'; - const 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); - }); +describe(`Rules: ${ruldId}`, function () { + it('Attribute name been duplication should result in an error', function () { + const code = 'bbb' + const 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() { - const code = 'bbb'; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + it('Attribute name not been duplication should not result in an error', function () { + const code = 'bbb' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/attr-no-unnecessary-whitespace.js b/test/rules/attr-no-unnecessary-whitespace.js index 6476dd893..18fc2b1b2 100644 --- a/test/rules/attr-no-unnecessary-whitespace.js +++ b/test/rules/attr-no-unnecessary-whitespace.js @@ -1,31 +1,31 @@ -var expect = require('expect.js'); +var expect = require('expect.js') -var HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +var HTMLHint = require('../../dist/htmlhint.js').HTMLHint var ruldId = 'attr-no-unnecessary-whitespace', - ruleOptions = {}; + ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true describe('Rules: ' + ruldId, function () { - it('Attribute with spaces should result in an error', function () { - var codes = [ - '
', - '', - '', - ]; - for (var i = 0; i < codes.length; i++) { - var messages = HTMLHint.verify(codes[i], 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('Attribute with spaces should result in an error', function () { + var codes = [ + '', + '', + '', + ] + for (var i = 0; i < codes.length; i++) { + var messages = HTMLHint.verify(codes[i], 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('Attribute without spaces should not result in an error', function () { - var code = ''; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + it('Attribute without spaces should not result in an error', function () { + var code = '' + var messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/attr-sort.spec.js b/test/rules/attr-sort.spec.js index 66688eefc..b95268092 100644 --- a/test/rules/attr-sort.spec.js +++ b/test/rules/attr-sort.spec.js @@ -1,38 +1,38 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruleId = 'attr-sorted'; -const ruleOptions = {}; +const ruleId = 'attr-sorted' +const ruleOptions = {} -ruleOptions[ruleId] = true; +ruleOptions[ruleId] = true -describe(`Rules: ${ruleId}`, function() { - it('Attribute unsorted tags must result in an error', function() { - const code = ''; +describe(`Rules: ${ruleId}`, function () { + it('Attribute unsorted tags must result in an error', function () { + const code = '' - const messages = HTMLHint.verify(code, ruleOptions); + const messages = HTMLHint.verify(code, ruleOptions) - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruleId); - expect(messages[0].message).to.contain('["id","class","title"]'); - }); + expect(messages.length).to.be(1) + expect(messages[0].rule.id).to.be(ruleId) + expect(messages[0].message).to.contain('["id","class","title"]') + }) - it('Attribute unsorted tags that are unrecognizable should not throw error', function() { - const code = ''; + it('Attribute unsorted tags that are unrecognizable should not throw error', function () { + const code = '' - const messages = HTMLHint.verify(code, ruleOptions); + const messages = HTMLHint.verify(code, ruleOptions) - expect(messages.length).to.be(0); - }); + expect(messages.length).to.be(0) + }) - it('Attribute unsorted of tags of various types should throw error', function() { - const code = ''; + it('Attribute unsorted of tags of various types should throw error', function () { + const code = '' - const messages = HTMLHint.verify(code, ruleOptions); + const messages = HTMLHint.verify(code, ruleOptions) - expect(messages.length).to.be(1); - expect(messages[0].rule.id).to.be(ruleId); - expect(messages[0].message).to.contain('["type","img","id","font"]'); - }); -}); + expect(messages.length).to.be(1) + expect(messages[0].rule.id).to.be(ruleId) + expect(messages[0].message).to.contain('["type","img","id","font"]') + }) +}) diff --git a/test/rules/attr-unsafe-chars.spec.js b/test/rules/attr-unsafe-chars.spec.js index a3a3098fe..4b4068b27 100644 --- a/test/rules/attr-unsafe-chars.spec.js +++ b/test/rules/attr-unsafe-chars.spec.js @@ -1,34 +1,34 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'attr-unsafe-chars'; -const ruleOptions = {}; +const ruldId = 'attr-unsafe-chars' +const ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true -describe(`Rules: ${ruldId}`, function() { - it('Attribute value have unsafe chars should result in an error', function() { +describe(`Rules: ${ruldId}`, function () { + it('Attribute value have unsafe chars should result in an error', function () { const code = - 'Sud Web 2012'; - const 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(3); - expect(messages[0].type).to.be('warning'); - }); + 'Sud Web 2012' + const 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(3) + expect(messages[0].type).to.be('warning') + }) - it('Attribute value have no unsafe chars should not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); + it('Attribute value have no unsafe chars should not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) - it('Attribute value have \\r\\n\\t should not result in an error', function() { + it('Attribute value have \\r\\n\\t should not result in an error', function () { const code = - ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/attr-value-double-quotes.spec.js b/test/rules/attr-value-double-quotes.spec.js index eaeac9764..6deb78b45 100644 --- a/test/rules/attr-value-double-quotes.spec.js +++ b/test/rules/attr-value-double-quotes.spec.js @@ -1,31 +1,31 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'attr-value-double-quotes'; -const ruleOptions = {}; +const ruldId = 'attr-value-double-quotes' +const ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true -describe(`Rules: ${ruldId}`, function() { - it('Attribute value closed by single quotes should result in an error', function() { - const code = ""; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(3); - 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(14); - expect(messages[2].rule.id).to.be(ruldId); - expect(messages[2].line).to.be(1); - expect(messages[2].col).to.be(24); - }); +describe(`Rules: ${ruldId}`, function () { + it('Attribute value closed by single quotes should result in an error', function () { + const code = "" + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(3) + 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(14) + expect(messages[2].rule.id).to.be(ruldId) + expect(messages[2].line).to.be(1) + expect(messages[2].col).to.be(24) + }) - it('Attribute value no closed should not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + it('Attribute value no closed should not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/attr-value-not-empty.spec.js b/test/rules/attr-value-not-empty.spec.js index 4d54da5cb..7d60984b5 100644 --- a/test/rules/attr-value-not-empty.spec.js +++ b/test/rules/attr-value-not-empty.spec.js @@ -1,32 +1,32 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'attr-value-not-empty'; -const ruleOptions = {}; +const ruldId = 'attr-value-not-empty' +const ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true -describe(`Rules: ${ruldId}`, function() { - it('Attribute value have no value should result in an error', function() { - const code = ''; - const 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'); - }); +describe(`Rules: ${ruldId}`, function () { + it('Attribute value have no value should result in an error', function () { + const code = '' + const 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('Attribute value closed by quote but no value should not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); + it('Attribute value closed by quote but no value should not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) - it('Attribute value closed by quote and have value should not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + it('Attribute value closed by quote and have value should not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/attr-value-single-quotes.spec.js b/test/rules/attr-value-single-quotes.spec.js index fc2f19b64..1efd5de9d 100644 --- a/test/rules/attr-value-single-quotes.spec.js +++ b/test/rules/attr-value-single-quotes.spec.js @@ -1,31 +1,31 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'attr-value-single-quotes'; -const ruleOptions = {}; +const ruldId = 'attr-value-single-quotes' +const ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true -describe('Rules: ' + ruldId, function() { - it('Attribute value closed by double quotes should result in an error', function() { - var code = ''; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(3); - 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(14); - expect(messages[2].rule.id).to.be(ruldId); - expect(messages[2].line).to.be(1); - expect(messages[2].col).to.be(24); - }); +describe('Rules: ' + ruldId, function () { + it('Attribute value closed by double quotes should result in an error', function () { + var code = '' + var messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(3) + 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(14) + expect(messages[2].rule.id).to.be(ruldId) + expect(messages[2].line).to.be(1) + expect(messages[2].col).to.be(24) + }) - it('Attribute value no closed should not result in an error', function() { - var code = ""; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + it('Attribute value no closed should not result in an error', function () { + var code = "" + var messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/attr-whitespace.spec.js b/test/rules/attr-whitespace.spec.js index 3f4b5d4ba..d689dc186 100644 --- a/test/rules/attr-whitespace.spec.js +++ b/test/rules/attr-whitespace.spec.js @@ -1,34 +1,34 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'attr-whitespace'; -const ruleOptions = {}; +const ruldId = 'attr-whitespace' +const ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true -describe(`Rules: ${ruldId}`, function() { - it('Double spaces in attributes should result in an error', function() { - let code = ''; - let 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); - }); +describe(`Rules: ${ruldId}`, function () { + it('Double spaces in attributes should result in an error', function () { + let code = '
' + let 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) + }) - it('Leading/trailing white space should result in an error', function() { - let code = '
'; - let 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); - }); + it('Leading/trailing white space should result in an error', function () { + let code = '
' + let 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) + }) - it('Double spaces and leading/trailing white space should result in an error', function() { - let code = '
'; - let 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); - }); -}); + it('Double spaces and leading/trailing white space should result in an error', function () { + let code = '
' + let 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) + }) +}) diff --git a/test/rules/default.spec.js b/test/rules/default.spec.js index 7280ac258..5577f5d4b 100644 --- a/test/rules/default.spec.js +++ b/test/rules/default.spec.js @@ -1,11 +1,11 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -describe('Rules: default', function() { - it('should result 3 errors', function() { - const code = '
'; - const messages = HTMLHint.verify(code); - expect(messages.length).to.be(3); - }); -}); +describe('Rules: default', function () { + it('should result 3 errors', function () { + const code = '
' + const messages = HTMLHint.verify(code) + expect(messages.length).to.be(3) + }) +}) diff --git a/test/rules/doctype-first.spec.js b/test/rules/doctype-first.spec.js index fcb349f01..3988937fa 100644 --- a/test/rules/doctype-first.spec.js +++ b/test/rules/doctype-first.spec.js @@ -1,25 +1,25 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'doctype-first'; -const ruleOptions = {}; +const ruldId = 'doctype-first' +const ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true -describe(`Rules: ${ruldId}`, function() { - it('Doctype not be first should result in an error', function() { - const code = ''; - const 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(1); - }); +describe(`Rules: ${ruldId}`, function () { + it('Doctype not be first should result in an error', function () { + const code = '' + const 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(1) + }) - it('Doctype be first should not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + it('Doctype be first should not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/doctype-html5.spec.js b/test/rules/doctype-html5.spec.js index ba417f66d..49fdd3115 100644 --- a/test/rules/doctype-html5.spec.js +++ b/test/rules/doctype-html5.spec.js @@ -1,27 +1,27 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'doctype-html5'; -const ruleOptions = {}; +const ruldId = 'doctype-html5' +const ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true -describe(`Rules: ${ruldId}`, function() { - it('Doctype not html5 should result in an error', function() { +describe(`Rules: ${ruldId}`, function () { + it('Doctype not html5 should result in an error', function () { const code = - ''; - const 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(1); - expect(messages[0].type).to.be('warning'); - }); + '' + const 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(1) + expect(messages[0].type).to.be('warning') + }) - it('Doctype html5 should not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + it('Doctype html5 should not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/head-require.spec.js b/test/rules/head-require.spec.js index f509c348f..c5a1d4c27 100644 --- a/test/rules/head-require.spec.js +++ b/test/rules/head-require.spec.js @@ -1,60 +1,59 @@ -const expect = require('expect.js'); - -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; - -const ruldId = 'head-script-disabled'; -const ruleOptions = {}; - -ruleOptions[ruldId] = true; - -describe(`Rules: ${ruldId}`, function() { - it('External script in head should result in an error', function() { - const code = '
'; - const 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('Internal Script in head should result in an error', function() { - let code = ''; - let 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); +const expect = require('expect.js') + +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint + +const ruldId = 'head-script-disabled' +const ruleOptions = {} + +ruleOptions[ruldId] = true + +describe(`Rules: ${ruldId}`, function () { + it('External script in head should result in an error', function () { + const code = '' + const 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('Internal Script in head should result in an error', function () { + let code = '' + let 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) + code = '' + messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(1) code = - ''; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - code = - ''; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - }); - - it('Script in body not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Template script in head not result in an error', function() { + '' + messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(1) + }) + + it('Script in body not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) + + it('Template script in head not result in an error', function () { let code = - ''; - let messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); + '' + let messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) code = - ''; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('No head not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + '' + messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) + + it('No head not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/head-script-disabled.spec.js b/test/rules/head-script-disabled.spec.js index f509c348f..c5a1d4c27 100644 --- a/test/rules/head-script-disabled.spec.js +++ b/test/rules/head-script-disabled.spec.js @@ -1,60 +1,59 @@ -const expect = require('expect.js'); - -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; - -const ruldId = 'head-script-disabled'; -const ruleOptions = {}; - -ruleOptions[ruldId] = true; - -describe(`Rules: ${ruldId}`, function() { - it('External script in head should result in an error', function() { - const code = ''; - const 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('Internal Script in head should result in an error', function() { - let code = ''; - let 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); +const expect = require('expect.js') + +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint + +const ruldId = 'head-script-disabled' +const ruleOptions = {} + +ruleOptions[ruldId] = true + +describe(`Rules: ${ruldId}`, function () { + it('External script in head should result in an error', function () { + const code = '' + const 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('Internal Script in head should result in an error', function () { + let code = '' + let 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) + code = '' + messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(1) code = - ''; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - code = - ''; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(1); - }); - - it('Script in body not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Template script in head not result in an error', function() { + '' + messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(1) + }) + + it('Script in body not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) + + it('Template script in head not result in an error', function () { let code = - ''; - let messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); + '' + let messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) code = - ''; - messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('No head not result in an error', function() { - const code = ''; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + '' + messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) + + it('No head not result in an error', function () { + const code = '' + const messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/href-abs-or-rel.spec.js b/test/rules/href-abs-or-rel.spec.js index e59665f22..cea0c03be 100644 --- a/test/rules/href-abs-or-rel.spec.js +++ b/test/rules/href-abs-or-rel.spec.js @@ -1,52 +1,52 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'href-abs-or-rel'; -const ruleOptions = {}; +const ruldId = 'href-abs-or-rel' +const ruleOptions = {} -describe(`Rules: ${ruldId}`, function() { - it('Href value is not absolute with abs mode should result in an error', function() { +describe(`Rules: ${ruldId}`, function () { + it('Href value is not absolute with abs mode should result in an error', function () { const code = - 'aaabbbcccddd'; - ruleOptions[ruldId] = 'abs'; - const 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); - }); + 'aaabbbcccddd' + ruleOptions[ruldId] = 'abs' + const 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() { + it('Href value is absolute with abs mode should not result in an error', function () { const code = - 'aaabbbcccddd'; - ruleOptions[ruldId] = 'abs'; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); + 'aaabbbcccddd' + ruleOptions[ruldId] = 'abs' + const 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() { + it('Href value is not relative with rel mode should result in an error', function () { const code = - 'aaabbbcccddd'; - ruleOptions[ruldId] = 'rel'; - const 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); - }); + 'aaabbbcccddd' + ruleOptions[ruldId] = 'rel' + const 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() { + it('Href value is relative with rel mode should not result in an error', function () { const code = - 'aaabbbcccddd'; - ruleOptions[ruldId] = 'rel'; - const messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); -}); + 'aaabbbcccddd' + ruleOptions[ruldId] = 'rel' + const 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 c92957498..7c72c1bb1 100644 --- a/test/rules/id-class-ad-disabled.spec.js +++ b/test/rules/id-class-ad-disabled.spec.js @@ -1,127 +1,127 @@ -const expect = require('expect.js'); - -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; - -const ruldId = 'id-class-ad-disabled'; -const ruleOptions = {}; - -ruleOptions[ruldId] = true; - -describe(`Rules: ${ruldId}`, function() { - it('Id use ad keyword should result in an error', function() { - let code = 'aaa>bbb< ccc
ddd\r\neee<'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(3); - expect(messages[0].rule.id).to.be(ruldId); - expect(messages[0].line).to.be(1); - expect(messages[0].col).to.be(7); - expect(messages[1].rule.id).to.be(ruldId); - expect(messages[1].line).to.be(1); - expect(messages[1].col).to.be(11); - expect(messages[2].rule.id).to.be(ruldId); - expect(messages[2].line).to.be(2); - expect(messages[2].col).to.be(4); - }); - - it('Special characters: & should result in an error', function(){ - var code = 'Steinway & Sons
'; - 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('Normal text should not result in an error', function(){ - var code = 'abc
'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - - it('Properly formed HTML entities should not result in an error', function(){ - var code = 'Steinway & > Sons Q&A
'; - var messages = HTMLHint.verify(code, ruleOptions); - expect(messages.length).to.be(0); - }); - -}); + ruleOptions = {} + +ruleOptions[ruldId] = true + +describe('Rules: ' + ruldId, function () { + it('Special characters: <> should result in an error', function () { + var code = 'aaa>bbb< ccc
ddd\r\neee<' + var messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(3) + expect(messages[0].rule.id).to.be(ruldId) + expect(messages[0].line).to.be(1) + expect(messages[0].col).to.be(7) + expect(messages[1].rule.id).to.be(ruldId) + expect(messages[1].line).to.be(1) + expect(messages[1].col).to.be(11) + expect(messages[2].rule.id).to.be(ruldId) + expect(messages[2].line).to.be(2) + expect(messages[2].col).to.be(4) + }) + + it('Special characters: & should result in an error', function () { + var code = 'Steinway & Sons
' + 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('Normal text should not result in an error', function () { + var code = 'abc
' + var messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) + + it('Properly formed HTML entities should not result in an error', function () { + var code = 'Steinway & > Sons Q&A
' + var messages = HTMLHint.verify(code, ruleOptions) + expect(messages.length).to.be(0) + }) +}) diff --git a/test/rules/src-not-empty.spec.js b/test/rules/src-not-empty.spec.js index 096affcc9..9829feca4 100644 --- a/test/rules/src-not-empty.spec.js +++ b/test/rules/src-not-empty.spec.js @@ -1,31 +1,31 @@ -const expect = require('expect.js'); +const expect = require('expect.js') -const HTMLHint = require('../../dist/htmlhint.js').HTMLHint; +const HTMLHint = require('../../dist/htmlhint.js').HTMLHint -const ruldId = 'src-not-empty'; -const ruleOptions = {}; +const ruldId = 'src-not-empty' +const ruleOptions = {} -ruleOptions[ruldId] = true; +ruleOptions[ruldId] = true -describe(`Rules: ${ruldId}`, function() { - it('Src be emtpy should result in an error', function() { +describe(`Rules: ${ruldId}`, function () { + it('Src be emtpy should result in an error', function () { const code = - '