From 044da18af1eb839d86ea3eb8eb9288205356d1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 3 Jul 2019 01:57:31 +0200 Subject: [PATCH] Apply JavaScript rules to prevent shadowing Using the same variable name makes the code more difficult to read. We're also enabling the `no-param-reassing` rule since we accidentally reassigned params in commit 824dd26d, and this rule will prevent us from doing so in the future. --- .eslintrc.yml | 2 ++ app/assets/javascripts/documentable.js | 6 +++--- app/assets/javascripts/imageable.js | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 7a0e70b81..31807c846 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -40,6 +40,8 @@ rules: no-multiple-empty-lines: - error - max: 1 + no-param-reassign: error + no-shadow: error no-spaced-func: error no-tabs: error no-trailing-spaces: error diff --git a/app/assets/javascripts/documentable.js b/app/assets/javascripts/documentable.js index 7c53d2fa6..3fd2857a4 100644 --- a/app/assets/javascripts/documentable.js +++ b/app/assets/javascripts/documentable.js @@ -59,9 +59,9 @@ $(data.wrapper).find(".attachment-actions .action-remove").removeClass("small-3").addClass("small-12"); destroyAttachmentLink = $(data.result.destroy_link); $(data.destroyAttachmentLinkContainer).html(destroyAttachmentLink); - $(destroyAttachmentLink).on("click", function(e) { - e.preventDefault(); - e.stopPropagation(); + $(destroyAttachmentLink).on("click", function(event) { + event.preventDefault(); + event.stopPropagation(); App.Documentable.doDeleteCachedAttachmentRequest(this.href, data); }); if (input["lockUpload"]) { diff --git a/app/assets/javascripts/imageable.js b/app/assets/javascripts/imageable.js index 72258a3c7..7f0773907 100644 --- a/app/assets/javascripts/imageable.js +++ b/app/assets/javascripts/imageable.js @@ -61,9 +61,9 @@ App.Imageable.setPreview(data); destroyAttachmentLink = $(data.result.destroy_link); $(data.destroyAttachmentLinkContainer).html(destroyAttachmentLink); - $(destroyAttachmentLink).on("click", function(e) { - e.preventDefault(); - e.stopPropagation(); + $(destroyAttachmentLink).on("click", function(event) { + event.preventDefault(); + event.stopPropagation(); App.Imageable.doDeleteCachedAttachmentRequest(this.href, data); }); },