-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc174fd
commit bdd5a5f
Showing
34 changed files
with
865 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const defaultRules = { | ||
'tagname-lowercase': true, | ||
'attr-lowercase': true, | ||
'attr-value-double-quotes': true, | ||
'doctype-first': false, | ||
'tag-pair': true, | ||
'spec-char-escape': true, | ||
'id-unique': true, | ||
'src-not-empty': true, | ||
'attr-no-duplication': true | ||
}; | ||
|
||
module.exports = function (CodeMirror, HTMLHint) { | ||
return function(text, options) { | ||
const found = []; | ||
|
||
const messages = HTMLHint.verify(text, options && options.rules || defaultRules); | ||
for (let i = 0; i < messages.length; i++) { | ||
const message = messages[i]; | ||
var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col; | ||
found.push({ | ||
from: CodeMirror.Pos(startLine, startCol), | ||
to: CodeMirror.Pos(endLine, endCol), | ||
message: message.message, | ||
severity : message.type | ||
}); | ||
} | ||
return found; | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = function (CodeMirror, jsonlint) { | ||
CodeMirror.registerHelper("lint", "json", function(text) { | ||
var found = []; | ||
jsonlint.parseError = function(str, hash) { | ||
var loc = hash.loc; | ||
found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column), | ||
to: CodeMirror.Pos(loc.last_line - 1, loc.last_column), | ||
message: str}); | ||
}; | ||
try { jsonlint.parse(text); } | ||
catch(e) {} | ||
return found; | ||
}); | ||
} |
Oops, something went wrong.