From 103117a395f05419cd3576e45f1591f05c771ee8 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 18 Feb 2014 18:00:36 +0200 Subject: [PATCH] Enable JSHint's `indent` option. Now the code should have consistent indentation. --- .jshintrc | 1 + Gruntfile.js | 12 ++++++------ dist/htmlminifier.js | 36 ++++++++++++++++++++---------------- src/htmlparser.js | 34 ++++++++++++++++++---------------- tests/minifier.js | 4 ++-- 5 files changed, 47 insertions(+), 40 deletions(-) diff --git a/.jshintrc b/.jshintrc index 5f47f88..704b0c6 100644 --- a/.jshintrc +++ b/.jshintrc @@ -5,6 +5,7 @@ "eqnull": true, "expr": true, "immed": true, + "indent": 2, "laxbreak": true, "loopfunc": true, "newcap": false, diff --git a/Gruntfile.js b/Gruntfile.js index b84d6fe..143d367 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,12 +3,12 @@ module.exports = function(grunt) { grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - banner: '/*!\n' + - ' * HTMLMinifier v<%= pkg.version %> (<%= pkg.homepage %>)\n' + - ' * Copyright 2010-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' + - ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' + - ' */\n', + pkg: grunt.file.readJSON('package.json'), + banner: '/*!\n' + + ' * HTMLMinifier v<%= pkg.version %> (<%= pkg.homepage %>)\n' + + ' * Copyright 2010-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' + + ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' + + ' */\n', jshint: { options: { diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index b43155e..158a1b5 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -30,6 +30,8 @@ * HTMLtoDOM(htmlString, document.body); * */ + + /* global ActiveXObject, DOMDocument */ (function(global){ @@ -138,18 +140,18 @@ // next tag tagMatch = html.match( startTag ); if (tagMatch) { - nextTag = tagMatch[1]; + nextTag = tagMatch[1]; } else { - tagMatch = html.match( endTag ); - if (tagMatch) { - nextTag = '/'+tagMatch[1]; - } else { - nextTag = ''; - } + tagMatch = html.match( endTag ); + if (tagMatch) { + nextTag = '/'+tagMatch[1]; + } else { + nextTag = ''; + } } if ( handler.chars ) - handler.chars(text, prevTag, nextTag); + handler.chars(text, prevTag, nextTag); } @@ -304,14 +306,16 @@ // If we're dealing with an empty document then we // need to pre-populate it with the HTML document structure - if ( !documentElement && doc.createElement ) (function(){ - var html = doc.createElement("html"); - var head = doc.createElement("head"); - head.appendChild( doc.createElement("title") ); - html.appendChild( head ); - html.appendChild( doc.createElement("body") ); - doc.appendChild( html ); - })(); + if ( !documentElement && doc.createElement ) { + (function(){ + var html = doc.createElement("html"); + var head = doc.createElement("head"); + head.appendChild( doc.createElement("title") ); + html.appendChild( head ); + html.appendChild( doc.createElement("body") ); + doc.appendChild( html ); + })(); + } // Find all the unique elements if ( doc.getElementsByTagName ) diff --git a/src/htmlparser.js b/src/htmlparser.js index cc26808..0fd033d 100644 --- a/src/htmlparser.js +++ b/src/htmlparser.js @@ -133,18 +133,18 @@ // next tag tagMatch = html.match( startTag ); if (tagMatch) { - nextTag = tagMatch[1]; + nextTag = tagMatch[1]; } else { - tagMatch = html.match( endTag ); - if (tagMatch) { - nextTag = '/'+tagMatch[1]; - } else { - nextTag = ''; - } + tagMatch = html.match( endTag ); + if (tagMatch) { + nextTag = '/'+tagMatch[1]; + } else { + nextTag = ''; + } } if ( handler.chars ) - handler.chars(text, prevTag, nextTag); + handler.chars(text, prevTag, nextTag); } @@ -299,14 +299,16 @@ // If we're dealing with an empty document then we // need to pre-populate it with the HTML document structure - if ( !documentElement && doc.createElement ) (function(){ - var html = doc.createElement("html"); - var head = doc.createElement("head"); - head.appendChild( doc.createElement("title") ); - html.appendChild( head ); - html.appendChild( doc.createElement("body") ); - doc.appendChild( html ); - })(); + if ( !documentElement && doc.createElement ) { + (function(){ + var html = doc.createElement("html"); + var head = doc.createElement("head"); + head.appendChild( doc.createElement("title") ); + html.appendChild( head ); + html.appendChild( doc.createElement("body") ); + doc.appendChild( html ); + })(); + } // Find all the unique elements if ( doc.getElementsByTagName ) diff --git a/tests/minifier.js b/tests/minifier.js index e1e5d12..5062332 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -528,7 +528,7 @@ output = '
 $foo = "baz"; 
'; equal(minify(input, { collapseWhitespace: true }), output); - input = '