DEV: prettier/eslint

approved

#1

DEV: prettier/eslint

diff --git a/.gitignore b/.gitignore
index 5020ac3..31b2ae7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@ tmp
 .yardoc
 _yardoc
 doc/
+node_modules/
 
 *.swp
 
diff --git a/assets/javascripts/spoiler.js b/assets/javascripts/spoiler.js
index c8de2b7..67d6ed5 100644
--- a/assets/javascripts/spoiler.js
+++ b/assets/javascripts/spoiler.js
@@ -1,43 +1,49 @@
 (function($) {
-
-  var isIE = /*@cc_on!@*/false || document.documentMode,
-      isFirefox = typeof InstallTrigger !== 'undefined',
-      DEFAULTS = {
-        max: { text: 10, link: 10, image: 20 },
-        partial: { text: 5, link: 5, image: 6},
-        none: { text: 0, link: 0, image: 0}
-      };
+  var isIE = /*@cc_on!@*/ false || document.documentMode,
+    isFirefox = typeof InstallTrigger !== "undefined",
+    DEFAULTS = {
+      max: { text: 10, link: 10, image: 20 },
+      partial: { text: 5, link: 5, image: 6 },
+      none: { text: 0, link: 0, image: 0 }
+    };
 
   // handle lazyYT onebox
   function blurLazyYT($spoiler) {
     $("div.lazyYT", $spoiler).each(function() {
-      $(this).replaceWith("<p>https://youtube.com/watch?v=" + $(this).data('youtube-id') + "</p>");
+      $(this).replaceWith(
+        "<p>https://youtube.com/watch?v=" + $(this).data("youtube-id") + "</p>"
+      );
     });
-  };
+  }
 
   function blurText($spoiler, radius) {
     // spoiler text is gray so as to maintain plugin compatibility with both light and dark theme sites.
     var textShadow = "gray 0 0 " + radius + "px",
-        userSelect = "-webkit-user-select";
+      userSelect = "-webkit-user-select";
 
     if (isIE) {
-      textShadow = radius <= 0 ? "0 0 0 0 gray" : "0 0 " + radius + "px .1px gray";
+      textShadow =
+        radius <= 0 ? "0 0 0 0 gray" : "0 0 " + radius + "px .1px gray";
       userSelect = "-ms-user-select";
     }
     if (isFirefox) {
       userSelect = "-moz-user-select";
     }
 
-    $spoiler.css("background-color", "transparent")
-            .css("color", "rgba(0,0,0,0)")
-            .css("text-shadow", textShadow)
-            .css(userSelect, "none");
-  };
+    $spoiler
+      .css("background-color", "transparent")
+      .css("color", "rgba(0,0,0,0)")
+      .css("text-shadow", textShadow)
+      .css(userSelect, "none");
+  }
 
   function blurSelector($sel, radius) {
     var value = radius > 0 ? "blur(" + radius + "px)" : "";
     if (isIE) {
-      $sel.css("-ms-filter", "progid:DXImageTransform.Microsoft.Blur(pixelradius="+radius+")");
+      $sel.css(
+        "-ms-filter",
+        "progid:DXImageTransform.Microsoft.Blur(pixelradius=" + radius + ")"
+      );
     } else {
       $sel.css("filter", value).css("-webkit-filter", value);
     }
@@ -49,16 +55,16 @@
     $("a,pre", $spoiler).each(function(index, linkOrPre) {
       blurSelector($(linkOrPre), radius);
     });
-  };
+  }
 
   function blurImageIE($spoiler, radius) {
-    var $images = $('img', $spoiler);
+    var $images = $("img", $spoiler);
     if (isIE) {
-      $images.css('opacity', radius == 0 ? '1.0' : '0.0');
+      $images.css("opacity", radius === 0 ? "1.0" : "0.0");
     } else {
       blurSelector($images, radius);
     }
-  };
+  }
 
   var applyBlur = function($spoiler, option) {
     blurLazyYT($spoiler);
@@ -69,36 +75,41 @@
 
   var applySpoilers = function($spoiler, options) {
     var maxBlur = options.max,
-        partialBlur = options.partial,
-        noBlur = options.none;
+      partialBlur = options.partial,
+      noBlur = options.none;
 
     $spoiler.data("spoiler-state", "blurred");
 
     applyBlur($spoiler, maxBlur);
 
-    $spoiler.on("mouseover", function() {
-      $spoiler.css("cursor", "pointer");
-      if ($spoiler.data("spoiler-state") === "blurred") { applyBlur($spoiler, partialBlur); }
-    }).on("mouseout", function() {
-      if ($spoiler.data("spoiler-state") === "blurred") { applyBlur($spoiler, maxBlur); }
-    }).on("click", function(e) {
-      if ($spoiler.data("spoiler-state") === "blurred") {
-        $spoiler.data("spoiler-state", "revealed").css("cursor", "auto");
-        applyBlur($spoiler, noBlur);
-      } else {
-        $spoiler.data("spoiler-state", "blurred").css("cursor", "pointer");
-        applyBlur($spoiler, partialBlur);
-      }
-      e.preventDefault();
-    });
-
+    $spoiler
+      .on("mouseover", function() {
+        $spoiler.css("cursor", "pointer");
+        if ($spoiler.data("spoiler-state") === "blurred") {
+          applyBlur($spoiler, partialBlur);
+        }
+      })
+      .on("mouseout", function() {
+        if ($spoiler.data("spoiler-state") === "blurred") {
+          applyBlur($spoiler, maxBlur);
+        }
+      })
+      .on("click", function(e) {
+        if ($spoiler.data("spoiler-state") === "blurred") {
+          $spoiler.data("spoiler-state", "revealed").css("cursor", "auto");
+          applyBlur($spoiler, noBlur);
+        } else {
+          $spoiler.data("spoiler-state", "blurred").css("cursor", "pointer");
+          applyBlur($spoiler, partialBlur);
+        }
+        e.preventDefault();
+      });
   };
 
   $.fn.spoil = function(options) {
     var opts = $.extend(DEFAULTS, options || {});
-    return this.each(function () {
+    return this.each(function() {
       applySpoilers($(this), opts);
     });
   };
-
 })(jQuery);
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..e77c8a6
--- /dev/null
+++ b/package.json
@@ -0,0 +1,12 @@
+{
+  "name": "discourse",
+  "version": "1.0.0",
+  "repository": "git@github.com:discourse/discourse-spoiler-alert.git",
+  "author": "Discourse",
+  "license": "MIT",
+  "devDependencies": {
+    "babel-eslint": "^8.2",
+    "eslint": "^4.19",
+    "prettier": "1.14.3"
+  }
+}
diff --git a/yarn.lock b/yarn.lock
new file mode 100644
index 0000000..36b2054
--- /dev/null
+++ b/yarn.lock
@@ -0,0 +1,1020 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@babel/code-frame@7.0.0-beta.44":
+  version "7.0.0-beta.44"
+  resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9"
+  integrity sha512-cuAuTTIQ9RqcFRJ/Y8PvTh+paepNcaGxwQwjIDRWPXmzzyAeCO4KqS9ikMvq0MCbRk6GlYKwfzStrcP3/jSL8g==
+  dependencies:
+    "@babel/highlight" "7.0.0-beta.44"
+
+"@babel/generator@7.0.0-beta.44":
+  version "7.0.0-beta.44"
+  resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.0.0-beta.44.tgz#c7e67b9b5284afcf69b309b50d7d37f3e5033d42"
+  integrity sha512-5xVb7hlhjGcdkKpMXgicAVgx8syK5VJz193k0i/0sLP6DzE6lRrU1K3B/rFefgdo9LPGMAOOOAWW4jycj07ShQ==
+  dependencies:
+    "@babel/types" "7.0.0-beta.44"
+    jsesc "^2.5.1"
+    lodash "^4.2.0"
+    source-map "^0.5.0"
+    trim-right "^1.0.1"
+
+"@babel/helper-function-name@7.0.0-beta.44":
+  version "7.0.0-beta.44"
+  resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.44.tgz#e18552aaae2231100a6e485e03854bc3532d44dd"
+  integrity sha512-MHRG2qZMKMFaBavX0LWpfZ2e+hLloT++N7rfM3DYOMUOGCD8cVjqZpwiL8a0bOX3IYcQev1ruciT0gdFFRTxzg==
+  dependencies:
+    "@babel/helper-get-function-arity" "7.0.0-beta.44"
+    "@babel/template" "7.0.0-beta.44"
+    "@babel/types" "7.0.0-beta.44"
+
+"@babel/helper-get-function-arity@7.0.0-beta.44":
+  version "7.0.0-beta.44"
+  resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.44.tgz#d03ca6dd2b9f7b0b1e6b32c56c72836140db3a15"
+  integrity sha512-w0YjWVwrM2HwP6/H3sEgrSQdkCaxppqFeJtAnB23pRiJB5E/O9Yp7JAAeWBl+gGEgmBFinnTyOv2RN7rcSmMiw==
+  dependencies:
+    "@babel/types" "7.0.0-beta.44"
+
+"@babel/helper-split-export-declaration@7.0.0-beta.44":
+  version "7.0.0-beta.44"
+  resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.44.tgz#c0b351735e0fbcb3822c8ad8db4e583b05ebd9dc"
+  integrity sha512-aQ7QowtkgKKzPGf0j6u77kBMdUFVBKNHw2p/3HX/POt5/oz8ec5cs0GwlgM8Hz7ui5EwJnzyfRmkNF1Nx1N7aA==

[... diff too long, it was truncated ...]

GitHub sha: 88c9ea2d


#2