From 182ecbdd6f23297c3e6de4d643cf0ac3ab515855 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Wed, 10 Sep 2025 08:32:39 +0200 Subject: [PATCH] T2639 FIX eslint in JS Removed ignore from my2 JS files and run pre-commit --- .eslintignore | 2 +- .../static/src/js/child_profile_tabs.js | 4 ++-- my_compassion/static/src/js/my2_add_a_gift.js | 10 ++++------ .../static/src/js/my2_donation_details.js | 10 ++++------ .../static/src/js/my2_donation_form.js | 5 ++--- .../static/src/js/my2_gift_package.js | 20 ++++++++----------- my_compassion/static/src/js/my2_new_letter.js | 12 +++++------ .../js/my2_new_letter_add_a_picture_input.js | 6 +++--- .../src/js/my2_new_sponsorship_wizard.js | 2 +- my_compassion/static/src/js/toast_service.js | 16 +++++++-------- 10 files changed, 39 insertions(+), 48 deletions(-) diff --git a/.eslintignore b/.eslintignore index 8224e3da..691911fd 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1 @@ -my_compassion/**/*.js +my_compassion/**/!(my2*).js diff --git a/my_compassion/static/src/js/child_profile_tabs.js b/my_compassion/static/src/js/child_profile_tabs.js index acca9738..02939350 100644 --- a/my_compassion/static/src/js/child_profile_tabs.js +++ b/my_compassion/static/src/js/child_profile_tabs.js @@ -37,9 +37,9 @@ document.addEventListener("DOMContentLoaded", function () { return this._super.apply(this, arguments); }, - //-------------------------------------------------------------------------- + // -------------------------------------------------------------------------- // Handlers - //-------------------------------------------------------------------------- + // -------------------------------------------------------------------------- /** * When the mobile dropdown value changes, find the corresponding desktop diff --git a/my_compassion/static/src/js/my2_add_a_gift.js b/my_compassion/static/src/js/my2_add_a_gift.js index 3aa6f1e6..a6ec6e10 100644 --- a/my_compassion/static/src/js/my2_add_a_gift.js +++ b/my_compassion/static/src/js/my2_add_a_gift.js @@ -47,12 +47,10 @@ document.addEventListener("DOMContentLoaded", function (event) { route: "/my2/gifts/new", params: data, }) - .then( - function (data) { - // Redirect user to gift package page - window.location.href = "/my2/gift-package"; - }.bind(this) - ) + .then(function (data) { + // Redirect user to gift package page + window.location.href = "/my2/gift-package"; + }) .guardedCatch( function () { // Re-enable buttons diff --git a/my_compassion/static/src/js/my2_donation_details.js b/my_compassion/static/src/js/my2_donation_details.js index a4e2cf95..15ef866b 100644 --- a/my_compassion/static/src/js/my2_donation_details.js +++ b/my_compassion/static/src/js/my2_donation_details.js @@ -30,12 +30,10 @@ document.addEventListener("DOMContentLoaded", function (event) { route: "/my2/gifts/new", params: data, }) - .then( - function (data) { - // Redirect user to gift package page - window.location.href = "/my2/gift-package"; - }.bind(this) - ) + .then(function (data) { + // Redirect user to gift package page + window.location.href = "/my2/gift-package"; + }) .guardedCatch( function () { // Re-enable buttons diff --git a/my_compassion/static/src/js/my2_donation_form.js b/my_compassion/static/src/js/my2_donation_form.js index 40be8d5e..4e36db8a 100644 --- a/my_compassion/static/src/js/my2_donation_form.js +++ b/my_compassion/static/src/js/my2_donation_form.js @@ -139,9 +139,8 @@ odoo.define("my_compassion.donation_form", function (require) { ) { this.$(".limit-error-message").removeAttr("hidden"); return; - } else { - this.$(".limit-error-message").attr("hidden", true); } + this.$(".limit-error-message").attr("hidden", true); // Trigger submission event this.$el.trigger(this.$(".btn-submit").data("submission-event"), [ @@ -172,7 +171,7 @@ odoo.define("my_compassion.donation_form", function (require) { /** * Validates the payment form. - * @returns {boolean} - True if valid, false otherwise. + * @returns {Boolean} - True if valid, false otherwise. */ _validateForm: function () { var isValid = true; diff --git a/my_compassion/static/src/js/my2_gift_package.js b/my_compassion/static/src/js/my2_gift_package.js index 0276ca44..28160ae6 100644 --- a/my_compassion/static/src/js/my2_gift_package.js +++ b/my_compassion/static/src/js/my2_gift_package.js @@ -66,12 +66,10 @@ document.addEventListener("DOMContentLoaded", function (event) { } }.bind(this) ) - .guardedCatch( - function () { - // Replace spinner with error - $("#edit-donation-form").html("Error"); - }.bind(this) - ); + .guardedCatch(function () { + // Replace spinner with error + $("#edit-donation-form").html("Error"); + }); }, /** @@ -128,12 +126,10 @@ document.addEventListener("DOMContentLoaded", function (event) { route: "/my2/gifts/edit", params: data, }) - .then( - function (data) { - // Redirect user to gift package page - window.location.href = "/my2/gift-package"; - }.bind(this) - ) + .then(function (data) { + // Redirect user to gift package page + window.location.href = "/my2/gift-package"; + }) .guardedCatch( function () { // Re-enable buttons diff --git a/my_compassion/static/src/js/my2_new_letter.js b/my_compassion/static/src/js/my2_new_letter.js index d0bc255a..e4228ec8 100644 --- a/my_compassion/static/src/js/my2_new_letter.js +++ b/my_compassion/static/src/js/my2_new_letter.js @@ -119,10 +119,10 @@ document.addEventListener("DOMContentLoaded", function () { * @async * @function * @returns {Promise} A promise that resolves to an object containing: - * @property {string} childId - The ID of the selected child. - * @property {string|null} templateId - The ID of the selected template, or null if not selected. - * @property {string} letterBody - The body text of the letter. - * @property {Array<{filename: string, content: string}>} attachments - The list of base64-encoded attachments. + * @property {String} childId - The ID of the selected child. + * @property {String|null} templateId - The ID of the selected template, or null if not selected. + * @property {String} letterBody - The body text of the letter. + * @property {Array<{filename: String, content: String}>} attachments - The list of base64-encoded attachments. */ _collectFormData: async function () { const childId = this.$("#child-dropdown").val(); @@ -203,9 +203,9 @@ document.addEventListener("DOMContentLoaded", function () { * * @async * @function - * @param {string} mode - Submission mode: `'send'` to submit the letter, `'preview'` to show a preview. + * @param {String} mode - Submission mode: `'send'` to submit the letter, `'preview'` to show a preview. * @param {Object} result - The result object returned by the server. - * @param {string} childId - The ID of the selected child, used in the redirect URL. + * @param {String} childId - The ID of the selected child, used in the redirect URL. * * @returns {Promise} Resolves when the UI navigation or update is complete. */ diff --git a/my_compassion/static/src/js/my2_new_letter_add_a_picture_input.js b/my_compassion/static/src/js/my2_new_letter_add_a_picture_input.js index 79f0a3a8..aeff063d 100644 --- a/my_compassion/static/src/js/my2_new_letter_add_a_picture_input.js +++ b/my_compassion/static/src/js/my2_new_letter_add_a_picture_input.js @@ -20,7 +20,7 @@ document.addEventListener("DOMContentLoaded", () => { * Generates a unique key for a file based on its metadata. * * @param {File} file - The file to generate a key for. - * @returns {string} A unique key combining the file's name, size, type, and last modified date. + * @returns {String} A unique key combining the file's name, size, type, and last modified date. */ const generateFileKey = (file) => `${file.name}-${file.size}-${file.type}-${file.lastModified}`; @@ -38,7 +38,7 @@ document.addEventListener("DOMContentLoaded", () => { * Reads a file as a Data URL (base64 encoded string). * * @param {File} file - The file to read. - * @returns {Promise} A promise that resolves with the file's Data URL. + * @returns {Promise} A promise that resolves with the file's Data URL. */ const readFileAsDataURL = (file) => new Promise((resolve, reject) => { @@ -111,7 +111,7 @@ document.addEventListener("DOMContentLoaded", () => { * Includes a preview image, file name, and a remove button. * * @param {File} file - The file to create an element for. - * @param {string} dataUrl - The Data URL of the file for the preview. + * @param {String} dataUrl - The Data URL of the file for the preview. * @returns {HTMLElement} The created file container element. */ const createFileElement = (file, dataUrl) => { diff --git a/my_compassion/static/src/js/my2_new_sponsorship_wizard.js b/my_compassion/static/src/js/my2_new_sponsorship_wizard.js index 3da9f91c..fbd1fdda 100644 --- a/my_compassion/static/src/js/my2_new_sponsorship_wizard.js +++ b/my_compassion/static/src/js/my2_new_sponsorship_wizard.js @@ -103,7 +103,7 @@ document.addEventListener("DOMContentLoaded", function (event) { /** * Validates required fields in the current step. - * @returns {boolean} - True if valid, false otherwise. + * @returns {Boolean} - True if valid, false otherwise. */ _validateForm: function () { var isValid = true; diff --git a/my_compassion/static/src/js/toast_service.js b/my_compassion/static/src/js/toast_service.js index 0f73246c..7aa78890 100644 --- a/my_compassion/static/src/js/toast_service.js +++ b/my_compassion/static/src/js/toast_service.js @@ -14,8 +14,8 @@ odoo.define("my_compassion.toast_service", function (require) { const ToastService = { /** * Show an informational toast message - * @param {string} msg - The message body - * @param {string} title - Optional title (defaults to 'Info') + * @param {String} msg - The message body + * @param {String} title - Optional title (defaults to 'Info') */ info(msg, title = "Info") { new Toast(null, { @@ -27,8 +27,8 @@ odoo.define("my_compassion.toast_service", function (require) { /** * Show a success toast message - * @param {string} msg - The message body - * @param {string} title - Optional title (defaults to 'Success') + * @param {String} msg - The message body + * @param {String} title - Optional title (defaults to 'Success') */ success(msg, title = "Success") { new Toast(null, { @@ -40,8 +40,8 @@ odoo.define("my_compassion.toast_service", function (require) { /** * Show a warning toast message - * @param {string} msg - The message body - * @param {string} title - Optional title (defaults to 'Warning') + * @param {String} msg - The message body + * @param {String} title - Optional title (defaults to 'Warning') */ warning(msg, title = "Warning") { new Toast(null, { @@ -53,8 +53,8 @@ odoo.define("my_compassion.toast_service", function (require) { /** * Show an error toast message - * @param {string} msg - The message body - * @param {string} title - Optional title (defaults to 'Error') + * @param {String} msg - The message body + * @param {String} title - Optional title (defaults to 'Error') */ error(msg, title = "Error") { new Toast(null, {