From 6019a9fdc435f25fb0a1f74a1bfab3512c686e8f Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 18 Aug 2019 03:50:43 -0500 Subject: [PATCH] js: fix eslint warnings. --- .eslintrc.yml | 1 + .../src/javascripts/post_tooltips.js | 4 +-- app/javascript/src/javascripts/posts.js.erb | 30 +++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index acf33ef17..1bb08c0bc 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -4,6 +4,7 @@ env: extends: 'eslint:recommended' parserOptions: sourceType: module + ecmaVersion: 2017 globals: $: false require: false diff --git a/app/javascript/src/javascripts/post_tooltips.js b/app/javascript/src/javascripts/post_tooltips.js index 0d76b7345..d504adbab 100644 --- a/app/javascript/src/javascripts/post_tooltips.js +++ b/app/javascript/src/javascripts/post_tooltips.js @@ -107,7 +107,7 @@ PostTooltip.on_disable_tooltips = function (event) { $(event.target).parents(".qtip").qtip("hide"); if (Utility.meta("current-user-id") === "") { - Danbooru.notice('Login to disable tooltips permanently'); + Utility.notice('Login to disable tooltips permanently'); return; } @@ -115,7 +115,7 @@ PostTooltip.on_disable_tooltips = function (event) { method: "PUT", data: { "user[disable_post_tooltips]": "true" }, }).then(function() { - Danbooru.notice("Tooltips disabled; check your account settings to re-enable."); + Utility.notice("Tooltips disabled; check your account settings to re-enable."); location.reload(); }); }; diff --git a/app/javascript/src/javascripts/posts.js.erb b/app/javascript/src/javascripts/posts.js.erb index 70546d5ef..80675ef8a 100644 --- a/app/javascript/src/javascripts/posts.js.erb +++ b/app/javascript/src/javascripts/posts.js.erb @@ -69,7 +69,7 @@ Post.initialize_gestures = function() { if (hasPrev) { hammer.on("swiperight", async function(e) { $("body").css({"transition-timing-function": "ease", "transition-duration": "0.2s", "opacity": "0", "transform": "translateX(150%)"}); - await Danbooru.Utility.delay(200); + await Utility.delay(200); Post.swipe_prev(e); }); } @@ -77,7 +77,7 @@ Post.initialize_gestures = function() { if (hasNext) { hammer.on("swipeleft", async function(e) { $("body").css({"transition-timing-function": "ease", "transition-duration": "0.2s", "opacity": "0", "transform": "translateX(-150%)"}); - await Danbooru.Utility.delay(200); + await Utility.delay(200); Post.swipe_next(e); }); } @@ -251,15 +251,15 @@ Post.initialize_links = function() { other_post_id: other_post_id }, success: function(data) { - Danbooru.notice("Successfully copied notes to post #" + other_post_id + ""); + Utility.notice("Successfully copied notes to post #" + other_post_id + ""); }, error: function(data) { if (data.status === 404) { - Danbooru.error("Error: Invalid destination post"); + Utility.error("Error: Invalid destination post"); } else if (data.responseJSON && data.responseJSON.reason) { - Danbooru.error("Error: " + data.responseJSON.reason); + Utility.error("Error: " + data.responseJSON.reason); } else { - Danbooru.error("There was an error copying notes to post #" + other_post_id + ""); + Utility.error("There was an error copying notes to post #" + other_post_id + ""); } } }); @@ -467,14 +467,14 @@ Post.resize_ugoira_controls = function() { Post.notice_update = function(x) { if (x === "inc") { Post.pending_update_count += 1; - Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...", true); + Utility.notice("Updating posts (" + Post.pending_update_count + " pending)...", true); } else { Post.pending_update_count -= 1; if (Post.pending_update_count < 1) { - Danbooru.notice("Posts updated"); + Utility.notice("Posts updated"); } else { - Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...", true); + Utility.notice("Updating posts (" + Post.pending_update_count + " pending)...", true); } } } @@ -493,7 +493,7 @@ Post.update_data = function(data) { } Post.vote = function(score, id) { - Danbooru.notice("Voting..."); + Utility.notice("Voting..."); $.post("/posts/" + id + "/votes.js", { score: score @@ -518,7 +518,7 @@ Post.update = function(post_id, params) { }, error: function(data) { Post.notice_update("dec"); - Danbooru.error(`There was an error updating post #${post_id}`); + Utility.error(`There was an error updating post #${post_id}`); } }); } @@ -534,7 +534,7 @@ Post.ban = function(post_id) { $("#post_" + post_id).remove(); }, error: function(data) { - Danbooru.error(`There was an error updating post #${post_id}`); + Utility.error(`There was an error updating post #${post_id}`); } }); } @@ -545,13 +545,13 @@ Post.approve = function(post_id) { {"post_id": post_id} ).fail(function(data) { var message = $.map(data.responseJSON.errors, function(msg, attr) { return msg; }).join("; "); - Danbooru.error("Error: " + message); + Utility.error("Error: " + message); }).done(function(data) { var $post = $("#post_" + post_id); if ($post.length) { $post.data("flags", $post.data("flags").replace(/pending/, "")); $post.removeClass("post-status-pending"); - Danbooru.notice("Approved post #" + post_id); + Utility.notice("Approved post #" + post_id); } }); } @@ -616,7 +616,7 @@ Post.update_tag_count = function(event) { let tags = [...new Set($(event.target).val().match(/\S+/g))]; if (tags) { count = tags.length; - string = (count == 1) ? (count + " tag") : (count + " tags") + string = (count === 1) ? (count + " tag") : (count + " tags") } } $("#tags-container .count").html(string);