blob: 5a7342b94a9ba46b5617d0ae297d1cd1ee1d277a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* grunt-bootlint
* https://github.com/zacechola/grunt-bootlint
*
* Copyright (c) 2014 Zac Echola
* Licensed under the MIT license.
*/
'use strict';
module.exports = function(grunt) {
var bootlint = require('bootlint');
var msg = {
start: 'Validation started for ',
ok: 'Validation successful!',
done: 'No Bootlint errors!'.bold
};
grunt.registerMultiTask('bootlint', 'An HTML linter for Bootstrap projects', function() {
var options = this.options({
stoponerror: false,
relaxerror: []
});
var totalErrCount = 0;
var reporter = function(lint) {
if (options.stoponerror) {
grunt.fail.warn(lint.message);
} else {
totalErrCount += 1;
grunt.log.warn(lint.message);
}
};
// Iterate over all specified file groups.
this.files.forEach(function(f) {
f.src.filter(function(filepath) {
if (!grunt.file.exists(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
} else {
return true;
}
})
.forEach(function(filepath) {
var src = grunt.file.read(filepath);
grunt.log.writeln(msg.start + filepath);
bootlint.lintHtml(src, reporter, options.relaxerror);
});
if (totalErrCount > 0) {
grunt.log.writeln().fail(totalErrCount + ' lint errors found.');
} else {
grunt.log.writeln().success(msg.done);
}
});
});
};
|