From: XhmikosR Date: Sun, 9 Mar 2014 12:25:21 +0000 (+0200) Subject: Enable `requireSpacesInFunctionExpression`. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ef4107223af1895381661943abfa73d97c7a2320;p=html-minifier.git Enable `requireSpacesInFunctionExpression`. --- diff --git a/.jscsrc b/.jscsrc index 2376224..2058190 100644 --- a/.jscsrc +++ b/.jscsrc @@ -2,7 +2,8 @@ "requireCurlyBraces": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], "requireSpaceAfterBinaryOperators": ["+", "-", "*", "=", "==", "===", "!=", "!=="], "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], - "requireSpaceBeforeBinaryOperators": ["+", "-", "*", "=", "==", "===", "!=", "!=="], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", "<", ">=", "<="], + "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true }, "requireCamelCaseOrUpperCaseIdentifiers": true, "requireCapitalizedConstructors": true, diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index 02a6b2d..157296c 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -33,7 +33,7 @@ /* global ActiveXObject, DOMDocument */ -(function(global){ +(function(global) { 'use strict'; // Regular Expressions for parsing tags and attributes @@ -64,11 +64,11 @@ // Special Elements (can contain anything) var special = makeMap('script,style'); - var reCache = { }, stackedTag, reStackedTag, tagMatch; + var reCache = {}, stackedTag, reStackedTag, tagMatch; var HTMLParser = global.HTMLParser = function( html, handler ) { var index, chars, match, stack = [], last = html, prevTag, nextTag; - stack.last = function(){ + stack.last = function() { return this[ this.length - 1 ]; }; @@ -329,7 +329,7 @@ // 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(){ + (function() { var html = doc.createElement('html'); var head = doc.createElement('head'); head.appendChild( doc.createElement('title') ); @@ -397,7 +397,7 @@ return doc; }; - function makeMap(str){ + function makeMap(str) { var obj = {}, items = str.split(','); for ( var i = 0; i < items.length; i++ ) { obj[ items[i] ] = true; @@ -407,7 +407,7 @@ } })(typeof exports === 'undefined' ? this : exports); -(function(global){ +(function(global) { 'use strict'; var log, HTMLParser; @@ -418,7 +418,7 @@ }; } else { - log = function(){ }; + log = function() {}; } if (global.HTMLParser) { @@ -695,7 +695,7 @@ function minify(value, options) { - options = options || { }; + options = options || {}; value = trimWhitespace(value); setDefaultTesters(options); diff --git a/master.js b/master.js index b8b51ff..bc37a5a 100644 --- a/master.js +++ b/master.js @@ -1,5 +1,5 @@ /* global HTMLLint, minify */ -(function(){ +(function() { 'use strict'; function byId(id) { diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 858caa9..b609be5 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -1,4 +1,4 @@ -(function(global){ +(function(global) { 'use strict'; var log, HTMLParser; @@ -9,7 +9,7 @@ }; } else { - log = function(){ }; + log = function() {}; } if (global.HTMLParser) { @@ -286,7 +286,7 @@ function minify(value, options) { - options = options || { }; + options = options || {}; value = trimWhitespace(value); setDefaultTesters(options); diff --git a/src/htmlparser.js b/src/htmlparser.js index 6225ebe..d11272b 100644 --- a/src/htmlparser.js +++ b/src/htmlparser.js @@ -28,7 +28,7 @@ /* global ActiveXObject, DOMDocument */ -(function(global){ +(function(global) { 'use strict'; // Regular Expressions for parsing tags and attributes @@ -59,11 +59,11 @@ // Special Elements (can contain anything) var special = makeMap('script,style'); - var reCache = { }, stackedTag, reStackedTag, tagMatch; + var reCache = {}, stackedTag, reStackedTag, tagMatch; var HTMLParser = global.HTMLParser = function( html, handler ) { var index, chars, match, stack = [], last = html, prevTag, nextTag; - stack.last = function(){ + stack.last = function() { return this[ this.length - 1 ]; }; @@ -324,7 +324,7 @@ // 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(){ + (function() { var html = doc.createElement('html'); var head = doc.createElement('head'); head.appendChild( doc.createElement('title') ); @@ -392,7 +392,7 @@ return doc; }; - function makeMap(str){ + function makeMap(str) { var obj = {}, items = str.split(','); for ( var i = 0; i < items.length; i++ ) { obj[ items[i] ] = true; diff --git a/test.js b/test.js index 7aaa783..e996399 100644 --- a/test.js +++ b/test.js @@ -12,7 +12,7 @@ testrunner.run({ './tests/lint.js', ] }, function(err, report) { - if(report.failed > 0){ + if(report.failed > 0) { process.on('exit', function() { process.exit(1); }); diff --git a/tests/lint.js b/tests/lint.js index 8588afc..429e9fb 100644 --- a/tests/lint.js +++ b/tests/lint.js @@ -1,5 +1,5 @@ /* global test, ok, equal */ -(function(global){ +(function(global) { 'use strict'; var minify = global.minify || require('../dist/htmlminifier.js').minify, @@ -22,7 +22,7 @@ equal('function', typeof lint.testAttribute, '`testAttribute` method exists'); }); - test('deprecated element (font)', function(){ + test('deprecated element (font)', function() { minify('foo', { lint: lint }); var log = lint.log.join(''); diff --git a/tests/minifier.js b/tests/minifier.js index 5f52892..9535af0 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -1,5 +1,5 @@ /* global test, ok, equal */ -(function(global){ +(function(global) { 'use strict'; var minify = global.minify || require('../dist/htmlminifier.js').minify, @@ -81,10 +81,10 @@ equal(minify(''), ''); }); - test('space normalization around text', function(){ + test('space normalization around text', function() { equal(minify('

blah

\n\n\n '), '

blah

'); // tags from collapseWhitespaceSmart() - ['a', 'b', 'big', 'button', 'code', 'em', 'font', 'i', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'time', 'tt', 'u'].forEach(function(el){ + ['a', 'b', 'big', 'button', 'code', 'em', 'font', 'i', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'time', 'tt', 'u'].forEach(function(el) { equal(minify('

foo <' + el + '>baz bar

', { collapseWhitespace: true }), '

foo <' + el + '>baz bar

'); equal(minify('

foo<' + el + '>bazbar

', { collapseWhitespace: true }), '

foo<' + el + '>bazbar

'); equal(minify('

foo <' + el + '>bazbar

', { collapseWhitespace: true }), '

foo <' + el + '>bazbar

'); @@ -111,7 +111,7 @@ equal(minify(input, { useShortDoctype: false }), input); }); - test('removing comments', function(){ + test('removing comments', function() { input = ''; equal(minify(input, { removeComments: true }), ''); @@ -129,7 +129,7 @@ equal(minify(input, { removeComments: true }), '