fix no-useless-escape warnings from eslint 3.9.1
authoralexlamsl <alexlamsl@gmail.com>
Sun, 6 Nov 2016 08:47:44 +0000 (16:47 +0800)
committeralexlamsl <alexlamsl@gmail.com>
Sun, 6 Nov 2016 08:47:44 +0000 (16:47 +0800)
Gruntfile.js
src/htmlminifier.js
src/htmlparser.js
tests/minifier.js

index 0f7cb53..d5f0c42 100644 (file)
@@ -67,7 +67,7 @@ module.exports = function(grunt) {
         '$1(v<%= pkg.version %>)$2'
       ],
       './tests/index.html': [
-        /("[^"]+\/qunit-)[0-9\.]+?(\.(?:css|js)")/g,
+        /("[^"]+\/qunit-)[0-9.]+?(\.(?:css|js)")/g,
         '$1<%= qunit_ver %>$2'
       ]
     },
index 4b78012..c5fee37 100644 (file)
@@ -78,7 +78,7 @@ function collapseWhitespaceSmart(str, prevTag, nextTag, options) {
 }
 
 function isConditionalComment(text) {
-  return /^\[if\s[^\]]+\]|\[endif\]$/.test(text);
+  return /^\[if\s[^\]]+]|\[endif]$/.test(text);
 }
 
 function isIgnoredComment(text, options) {
@@ -351,7 +351,7 @@ function unwrapMediaQuery(text) {
 }
 
 function cleanConditionalComment(comment, options) {
-  return options.processConditionalComments ? comment.replace(/^(\[if\s[^\]]+\]>)([\s\S]*?)(<!\[endif\])$/, function(match, prefix, text, suffix) {
+  return options.processConditionalComments ? comment.replace(/^(\[if\s[^\]]+]>)([\s\S]*?)(<!\[endif])$/, function(match, prefix, text, suffix) {
     return prefix + minify(text, options, true) + suffix;
   }) : comment;
 }
index 3bcfdde..cc7daf0 100644 (file)
@@ -37,7 +37,7 @@ function makeMap(values) {
 }
 
 // Regular Expressions for parsing tags and attributes
-var singleAttrIdentifier = /([^\s"'<>\/=]+)/,
+var singleAttrIdentifier = /([^\s"'<>/=]+)/,
     singleAttrAssign = /=/,
     singleAttrAssigns = [singleAttrAssign],
     singleAttrValues = [
@@ -219,7 +219,7 @@ function HTMLParser(html, handler) {
         if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
           text = text
             .replace(/<!--([\s\S]*?)-->/g, '$1')
-            .replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
+            .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
         }
 
         if (handler.chars) {
index 54495f0..f13c9af 100644 (file)
@@ -1610,7 +1610,7 @@ QUnit.test('phrasing content with Web Components', function(assert) {
 // https://github.com/kangax/html-minifier/issues/10
 QUnit.test('Ignore custom fragments', function(assert) {
   var input, output;
-  var reFragments = [/<\?[^\?]+\?>/, /<%[^%]+%>/, /\{\{[^\}]*\}\}/];
+  var reFragments = [/<\?[^?]+\?>/, /<%[^%]+%>/, /\{\{[^}]*\}\}/];
 
   input = 'This is the start. <% ... %>\r\n<%= ... %>\r\n<? ... ?>\r\n<!-- This is the middle, and a comment. -->\r\nNo comment, but middle.\r\n{{ ... }}\r\n<?php ... ?>\r\n<?xml ... ?>\r\nHello, this is the end!';
   output = 'This is the start. <% ... %> <%= ... %> <? ... ?> No comment, but middle. {{ ... }} <?php ... ?> <?xml ... ?> Hello, this is the end!';
@@ -2604,7 +2604,7 @@ QUnit.test('custom attribute collapse', function(assert) {
   output = '<div data-bind="css: {fadeIn: selected(),fadeOut: !selected()},visible: function () {return pageWeAreOn() == \'home\';}">foo</div>';
 
   assert.equal(minify(input), input);
-  assert.equal(minify(input, { customAttrCollapse: /data\-bind/ }), output);
+  assert.equal(minify(input, { customAttrCollapse: /data-bind/ }), output);
 
   input = '<div style="' +
             'color: red;' +
@@ -2623,7 +2623,7 @@ QUnit.test('custom attribute collapse', function(assert) {
   '> ' +
   '</div>';
   output = '<div class="fragment square" ng-hide="square1.hide" ng-class="{\'bounceInDown\': !square1.hide, \'bounceOutDown\': square1.hide }"> </div>';
-  assert.equal(minify(input, { customAttrCollapse: /ng\-class/ }), output);
+  assert.equal(minify(input, { customAttrCollapse: /ng-class/ }), output);
 });
 
 QUnit.test('custom attribute collapse with empty attribute value', function(assert) {
@@ -2638,7 +2638,7 @@ QUnit.test('custom attribute collapse with newlines, whitespace, and carriage re
           '               value2:false \n\r' +
           '               }"></div>';
   var output = '<div ng-class="{value:true,value2:false}"></div>';
-  assert.equal(minify(input, { customAttrCollapse: /ng\-class/ }), output);
+  assert.equal(minify(input, { customAttrCollapse: /ng-class/ }), output);
 });
 
 QUnit.test('do not escape attribute value', function(assert) {