From 034feabcff615cb89669a94afccd7482e0cb6fba Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Tue, 15 Apr 2025 13:15:49 +1000 Subject: [PATCH] Javascript code linting --- .../tag_list_input_controller.js | 14 +++++++------- .../stimulus/tag_list_input_controller_test.js | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/components/tag_list_input_component/tag_list_input_controller.js b/app/components/tag_list_input_component/tag_list_input_controller.js index 1cfa219229..b24212fd13 100644 --- a/app/components/tag_list_input_component/tag_list_input_controller.js +++ b/app/components/tag_list_input_component/tag_list_input_controller.js @@ -5,15 +5,15 @@ export default class extends Controller { addTag() { // Check if tag already exist - const newTagName = this.newTagTarget.value + const newTagName = this.newTagTarget.value; const tags = this.tagListTarget.value.split(","); const index = tags.indexOf(newTagName); if (index != -1) { // highlight the value in red - this.newTagTarget.classList.add("tag-error") - return - } - + this.newTagTarget.classList.add("tag-error"); + return; + } + // add to tagList this.tagListTarget.value = this.tagListTarget.value.concat(`,${newTagName}`); @@ -47,9 +47,9 @@ export default class extends Controller { filterInput(event) { // clear error class if key is not enter if (event.key !== "Enter") { - this.newTagTarget.classList.remove("tag-error") + this.newTagTarget.classList.remove("tag-error"); } - + // Strip comma from tag name if (event.key === ",") { event.srcElement.value = event.srcElement.value.replace(",", ""); diff --git a/spec/javascripts/stimulus/tag_list_input_controller_test.js b/spec/javascripts/stimulus/tag_list_input_controller_test.js index 99205bf068..0efef0b051 100644 --- a/spec/javascripts/stimulus/tag_list_input_controller_test.js +++ b/spec/javascripts/stimulus/tag_list_input_controller_test.js @@ -111,9 +111,9 @@ describe("TagListInputController", () => { }); it("highlights the new tag name in red", () => { - expect(variant_add_tag.classList).toContain("tag-error") + expect(variant_add_tag.classList).toContain("tag-error"); }); - }) + }); }); describe("removeTag", () => { @@ -144,11 +144,11 @@ describe("TagListInputController", () => { it("removes error highlight", () => { variant_add_tag.value = "text"; - variant_add_tag.classList.add("tag-error") + variant_add_tag.classList.add("tag-error"); variant_add_tag.dispatchEvent(new KeyboardEvent("keyup", { key: "a" })); - expect(variant_add_tag.classList).not.toContain("tag-error") + expect(variant_add_tag.classList).not.toContain("tag-error"); }); }); });