Add wiki URLs to console output; fixes #342

Note this will only work in the browser.
Also adds a `url` property to LintError & LintWarning.

Closes #353
This commit is contained in:
Thomas Lindner 2016-02-01 22:40:37 -06:00 коммит произвёл Chris Rebert
Родитель 494ff55f30
Коммит 6630a83a79
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -60,6 +60,7 @@ var LocationIndex = _location.LocationIndex;
'script[src$="/bootstrap.min.js"]',
'script[src="bootstrap.min.js"]'
].join(',');
var WIKI_URL = 'https://github.com/twbs/bootlint/wiki/';
function compareNums(a, b) {
return a - b;
@ -269,6 +270,7 @@ var LocationIndex = _location.LocationIndex;
*/
function LintError(id, message, elements) {
this.id = id;
this.url = WIKI_URL + id;
this.message = message;
this.elements = elements || cheerio('');
}
@ -282,6 +284,7 @@ var LocationIndex = _location.LocationIndex;
*/
function LintWarning(id, message, elements) {
this.id = id;
this.url = WIKI_URL + id;
this.message = message;
this.elements = elements || cheerio('');
}
@ -1189,10 +1192,10 @@ var LocationIndex = _location.LocationIndex;
}
if (!lint.elements.length) {
console.warn("bootlint: %c " + lint.id + " ", background, lint.message);
console.warn("bootlint: %c " + lint.id + " ", background, lint.message + " Documentation: " + lint.url);
}
else {
console.warn("bootlint: %c " + lint.id + " ", background, lint.message + '\n', lint.elements);
console.warn("bootlint: %c " + lint.id + " ", background, lint.message + " Documentation: " + lint.url, lint.elements);
}
errorCount++;
};