Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/grunt-bootlint.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tasks
diff options
context:
space:
mode:
authorfreezy <marek.viger@gmail.com>2015-08-27 20:55:43 +0300
committerfreezy <marek.viger@gmail.com>2015-08-27 20:55:43 +0300
commitbec72c2d4d7fa20fcacad9be4846fb9c7e4aef9e (patch)
tree3fc11c94b54c226fc7307f7a84d4c8a108c55ec9 /tasks
parente9e57f8606baa53743e1e54cfa88f187e744000d (diff)
Relaxerror can be defined as object of error IDs and filepath masks
Diffstat (limited to 'tasks')
-rw-r--r--tasks/bootlint.js35
1 files changed, 33 insertions, 2 deletions
diff --git a/tasks/bootlint.js b/tasks/bootlint.js
index 7574596..a0ef01c 100644
--- a/tasks/bootlint.js
+++ b/tasks/bootlint.js
@@ -11,6 +11,7 @@
module.exports = function(grunt) {
var bootlint = require('bootlint');
var chalk = require('chalk');
+ var micromatch = require('micromatch');
grunt.registerMultiTask('bootlint', 'An HTML linter for Bootstrap projects', function() {
@@ -68,7 +69,8 @@ module.exports = function(grunt) {
};
- bootlint.lintHtml(src, reporter, options.relaxerror);
+ var disabledIds = getDisabledIdsForFilepath(filepath);
+ bootlint.lintHtml(src, reporter, disabledIds);
totalFileCount++;
});
@@ -81,6 +83,35 @@ module.exports = function(grunt) {
grunt.log.ok(totalFileCount + ' file(s) lint free.');
}
});
- });
+ function getDisabledIdsForFilepath(filepath) {
+ // Relaxerror defined as array without filepaths
+ if (options.relaxerror instanceof Array) {
+ return options.relaxerror;
+ }
+
+ // Relaxerror as object with error IDs as keys and filepaths as values
+ var disabledIds = Object.keys(options.relaxerror);
+
+ // Lookup disabled IDs filepaths
+ var returnIds = disabledIds.filter(function(key) {
+ var paths = options.relaxerror[key];
+
+ // handle 'E001': true, 'E001': []
+ if (!(paths instanceof Array) || paths.length === 0) {
+ return true;
+ }
+
+ // handle 'E001': ['*']
+ if (paths.indexOf('*') !== -1) {
+ return true;
+ }
+
+ // test filepath pattern
+ return micromatch.any(filepath, paths);
+ });
+
+ return returnIds;
+ }
+ });
};