-
-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
space-tab-mixed-disabled(rule): Support space and tab mode, for check…
… only space or tab
- Loading branch information
Showing
5 changed files
with
87 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
/** | ||
* Copyright (c) 2014, Yanis Wang <[email protected]> | ||
* Copyright (c) 2014-2015, Yanis Wang <[email protected]> | ||
* MIT Licensed | ||
*/ | ||
|
||
var expect = require("expect.js"); | ||
|
||
var HTMLHint = require("../../index").HTMLHint; | ||
|
||
var ruldId = 'space-tab-mixed-disabled', | ||
ruleOptions = {}; | ||
var ruldId = 'space-tab-mixed-disabled'; | ||
var ruleMixOptions = {}; | ||
var ruleSpaceOptions = {}; | ||
var ruleTabOptions = {}; | ||
|
||
ruleOptions[ruldId] = true; | ||
ruleMixOptions[ruldId] = true; | ||
ruleSpaceOptions[ruldId] = 'space'; | ||
ruleTabOptions[ruldId] = 'tab'; | ||
|
||
describe('Rules: '+ruldId, function(){ | ||
|
||
it('Spaces and tabs mixed in front of line should result in an error', function(){ | ||
// space before tab | ||
var code = ' <a href="a">bbb</a>'; | ||
var messages = HTMLHint.verify(code, ruleOptions); | ||
var messages = HTMLHint.verify(code, ruleMixOptions); | ||
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); | ||
// tab before space | ||
code = ' <a href="a">bbb</a>'; | ||
messages = HTMLHint.verify(code, ruleOptions); | ||
messages = HTMLHint.verify(code, ruleMixOptions); | ||
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); | ||
// multi line | ||
code = '<div>\r\n <a href="a">bbb</a>'; | ||
messages = HTMLHint.verify(code, ruleOptions); | ||
messages = HTMLHint.verify(code, ruleMixOptions); | ||
expect(messages.length).to.be(1); | ||
expect(messages[0].rule.id).to.be(ruldId); | ||
expect(messages[0].line).to.be(2); | ||
|
@@ -40,18 +44,64 @@ describe('Rules: '+ruldId, function(){ | |
|
||
it('Only spaces in front of line should not result in an error', function(){ | ||
var code = ' <a href="a">bbb</a>'; | ||
var messages = HTMLHint.verify(code, ruleOptions); | ||
var messages = HTMLHint.verify(code, ruleMixOptions); | ||
expect(messages.length).to.be(0); | ||
|
||
code = '<div>\r\n <a href="a">bbb</a>'; | ||
messages = HTMLHint.verify(code, ruleOptions); | ||
messages = HTMLHint.verify(code, ruleMixOptions); | ||
expect(messages.length).to.be(0); | ||
}); | ||
|
||
it('Only tabs in front of line should not result in an error', function(){ | ||
var code = ' <a href="a">bbb</a>'; | ||
var messages = HTMLHint.verify(code, ruleOptions); | ||
var messages = HTMLHint.verify(code, ruleMixOptions); | ||
expect(messages.length).to.be(0); | ||
}); | ||
|
||
}); | ||
|
||
it('Not only space in front of line should result in an error', function(){ | ||
// mixed 1 | ||
var code = ' <a href="a">bbb</a>'; | ||
var messages = HTMLHint.verify(code, ruleSpaceOptions); | ||
expect(messages.length).to.be(1); | ||
|
||
// mixed 2 | ||
code = ' <a href="a">bbb</a>'; | ||
messages = HTMLHint.verify(code, ruleSpaceOptions); | ||
expect(messages.length).to.be(1); | ||
|
||
// only tab | ||
code = ' <a href="a">bbb</a>'; | ||
messages = HTMLHint.verify(code, ruleSpaceOptions); | ||
expect(messages.length).to.be(1); | ||
}); | ||
|
||
it('Only space in front of line should not result in an error', function(){ | ||
var code = ' <a href="a">bbb</a>'; | ||
var messages = HTMLHint.verify(code, ruleSpaceOptions); | ||
expect(messages.length).to.be(0); | ||
}); | ||
|
||
it('Not only tab in front of line should result in an error', function(){ | ||
// mixed 1 | ||
var code = ' <a href="a">bbb</a>'; | ||
var messages = HTMLHint.verify(code, ruleTabOptions); | ||
expect(messages.length).to.be(1); | ||
|
||
// mixed 2 | ||
code = ' <a href="a">bbb</a>'; | ||
messages = HTMLHint.verify(code, ruleTabOptions); | ||
expect(messages.length).to.be(1); | ||
|
||
// only space | ||
code = ' <a href="a">bbb</a>'; | ||
messages = HTMLHint.verify(code, ruleTabOptions); | ||
expect(messages.length).to.be(1); | ||
}); | ||
|
||
it('Only tab in front of line should not result in an error', function(){ | ||
// only tab | ||
var code = ' <a href="a">bbb</a>'; | ||
var messages = HTMLHint.verify(code, ruleTabOptions); | ||
expect(messages.length).to.be(0); | ||
}); | ||
}); |