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
diff options
context:
space:
mode:
authorZac Echola <zac.echola@gmail.com>2014-07-26 11:04:31 +0400
committerZac Echola <zac.echola@gmail.com>2014-07-26 11:04:31 +0400
commit79b358c6770b22e30ca29426d04d77b3986ad0e4 (patch)
treec9e9b4ab2a0ece848d7bb3fc26519b8e39378a05
parentc3437edcbceeec4215b9ab40aadbdb19d78ce388 (diff)
really basic thing so far.
-rw-r--r--Gruntfile.js17
-rw-r--r--tasks/bootlint.js54
-rw-r--r--test/fixtures/1231
-rw-r--r--test/fixtures/missing-doctype1
-rw-r--r--test/fixtures/testing1
5 files changed, 38 insertions, 36 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
index 483e8b7..58094fc 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -30,22 +30,7 @@ module.exports = function(grunt) {
// Configuration to be run (and then tested).
bootlint: {
- default_options: {
- options: {
- },
- files: {
- 'tmp/default_options': ['test/fixtures/testing', 'test/fixtures/123']
- }
- },
- custom_options: {
- options: {
- separator: ': ',
- punctuation: ' !!!'
- },
- files: {
- 'tmp/custom_options': ['test/fixtures/testing', 'test/fixtures/123']
- }
- }
+ files: ['test/fixtures/missing-doctype']
},
// Unit tests.
diff --git a/tasks/bootlint.js b/tasks/bootlint.js
index a8f00aa..5819c97 100644
--- a/tasks/bootlint.js
+++ b/tasks/bootlint.js
@@ -9,41 +9,59 @@
'use strict';
module.exports = function(grunt) {
+ var bootlint = require('../node_modules/bootlint/src/bootlint'); // Explicit since the search algo fails on the bootlint directory structure
+ var colors = require('colors');
+
+ colors.setTheme({
+ ok: 'green',
+ error: 'red',
+ warning: 'yellow'
+ });
+
+ var msg = {
+ start: 'Validation started for '.ok,
+ ok: 'Validation successful!'.ok,
+ error: 'Error:'.error,
+ done: 'All Done!'.bold.ok
+ };
+
+ var totalErrCount = 0;
- // Please see the Grunt documentation for more information regarding task
- // creation: http://gruntjs.com/creating-tasks
grunt.registerMultiTask('bootlint', 'An HTML linter for Bootstrap projects', function() {
- // Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
- punctuation: '.',
- separator: ', '
+ stoponerror: false
});
// Iterate over all specified file groups.
this.files.forEach(function(f) {
- // Concat specified files.
- var src = f.src.filter(function(filepath) {
- // Warn on and remove invalid source files (if nonull was set).
+
+ f.src.filter(function(filepath) {
if (!grunt.file.exists(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
} else {
return true;
}
- }).map(function(filepath) {
- // Read file source.
- return grunt.file.read(filepath);
- }).join(grunt.util.normalizelf(options.separator));
- // Handle options.
- src += options.punctuation;
+ })
+ .forEach(function(filepath) {
+ var src = grunt.file.read(filepath);
+
+ var errs = bootlint.lintHtml(src);
+ totalErrCount += errs.length;
- // Write the destination file.
- grunt.file.write(f.dest, src);
+ errs.forEach(function (msg) {
+ grunt.log.warn(filepath + ':', msg.error);
+ if (options.stoponerror) return;
+ });
+ });
- // Print a success message.
- grunt.log.writeln('File "' + f.dest + '" created.');
+ if (totalErrCount > 0) {
+ grunt.log.warn(totalErrCount + ' lint errors found.');
+ } else {
+ grunt.log.writeln(msg.done);
+ }
});
});
diff --git a/test/fixtures/123 b/test/fixtures/123
deleted file mode 100644
index 703ca85..0000000
--- a/test/fixtures/123
+++ /dev/null
@@ -1 +0,0 @@
-1 2 3 \ No newline at end of file
diff --git a/test/fixtures/missing-doctype b/test/fixtures/missing-doctype
new file mode 100644
index 0000000..4abd01c
--- /dev/null
+++ b/test/fixtures/missing-doctype
@@ -0,0 +1 @@
+<html><head><title>Cred</title><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Kaushan+Script"><link rel="stylesheet" href="/stylesheets/index.css"></head><body><div class="introduction animated infinite sway"><div class="container"><h1 class="text-center">Cred</h1><p class="text-center">A character study of credential screens</p><p class="text-center">By Zac Echola</p></div></div><div class="container"><div class="row"><div class="col-xs-12"><div class="get-started"><h2>Purpose</h2><p>The original intent was to go beyond just creating login and signup screens, to be an excercise in learning the limits of various front-end tools: LESS, Bootstrap, jade/express, bower, grunt, npm.</p><p>Along the way I hoped to learn a little bit about different design techniques. For example, CSS animations have begun to interest me, so you will find little touches throughout the examples. </p><p>I've also become somewhat obsessed with newfangled front-end tools for pipeline managment. It's pretty amazing how in the last few years, the monotony of front-end work has been automated to a significant degree. Obviously these things happen in the background to the designs herein. You are encouraged to look through the <a href="">code</a>.</p><h2>Get Started</h2><form><div class="form-group"><label class="control-label">Username</label><input type="text" class="form-control"></div><div class="form-group"><label class="control-label">Password</label><input type="text" class="form-control"></div><button class="btn btn-default">Start</button></form></div></div></div></div><script src="//code.jquery.com/jquery-1.11.0.min.js"></script><script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script></body></html>
diff --git a/test/fixtures/testing b/test/fixtures/testing
deleted file mode 100644
index 0a90125..0000000
--- a/test/fixtures/testing
+++ /dev/null
@@ -1 +0,0 @@
-Testing \ No newline at end of file