From 3dd3147b19c5f9db42e3f1554055dc6ab0605d8a Mon Sep 17 00:00:00 2001 From: Julien Nahum Date: Thu, 27 Mar 2025 11:07:39 +0100 Subject: [PATCH] Enhance ESLint Configuration and Improve Code Consistency - Updated ESLint configuration in `.eslintrc.cjs` to enforce error handling for unused variables, allowing for better code quality and maintainability. - Added `clone-deep` import in `OpenForm.vue` to facilitate deep cloning of objects, enhancing functionality. - Refactored variable destructuring in `ColumnCondition.vue` and `useAlert.js` to improve readability by using underscore for ignored parameters. - Modified `pinia-history.js` to use underscore for unused parameters in the `get` and `set` functions, aligning with the new ESLint rules. These changes aim to improve code quality, maintainability, and consistency across the codebase. --- client/.eslintrc.cjs | 2 ++ client/components/open/forms/OpenForm.vue | 1 + .../components/form-logic-components/ColumnCondition.vue | 2 +- client/composables/useAlert.js | 4 ++-- client/plugins/pinia-history.js | 6 ++---- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs index cdf4982d..e6e9b6af 100644 --- a/client/.eslintrc.cjs +++ b/client/.eslintrc.cjs @@ -14,5 +14,7 @@ module.exports = { "prefer-rest-params": "off", "vue/valid-template-root": "off", "no-undef": "off", + "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }], + "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }] }, }; diff --git a/client/components/open/forms/OpenForm.vue b/client/components/open/forms/OpenForm.vue index 97706fcd..e8b29948 100644 --- a/client/components/open/forms/OpenForm.vue +++ b/client/components/open/forms/OpenForm.vue @@ -134,6 +134,7 @@ import CachedDefaultTheme from "~/lib/forms/themes/CachedDefaultTheme.js" import FormTimer from './FormTimer.vue' import { storeToRefs } from 'pinia' import { FormMode, createFormModeStrategy } from "~/lib/forms/FormModeStrategy.js" +import clonedeep from 'clone-deep' export default { name: 'OpenForm', diff --git a/client/components/open/forms/components/form-logic-components/ColumnCondition.vue b/client/components/open/forms/components/form-logic-components/ColumnCondition.vue index 4dba8dd2..46f036a6 100644 --- a/client/components/open/forms/components/form-logic-components/ColumnCondition.vue +++ b/client/components/open/forms/components/form-logic-components/ColumnCondition.vue @@ -104,7 +104,7 @@ export default { }, operators() { return Object.entries(this.available_filters[this.property.type].comparators) - .filter(([filterKey, value]) => this.customValidation || (!this.customValidation && !value.custom_validation_only)) + .filter(([_, value]) => this.customValidation || (!this.customValidation && !value.custom_validation_only)) .map(([filterKey]) => { return { value: filterKey, diff --git a/client/composables/useAlert.js b/client/composables/useAlert.js index 2de068e9..67781d4e 100644 --- a/client/composables/useAlert.js +++ b/client/composables/useAlert.js @@ -66,11 +66,11 @@ export function useAlert () { let description = '' if (Object.keys(error.errors).length > 0) { const errorLines = Object.entries(error.errors) - .map(([field, messages]) => { + .map(([_, messages]) => { // Format each message const formattedMessages = messages.map(message => { return `
  • ${message}
  • ` - }); + }) return formattedMessages.join('') }) diff --git a/client/plugins/pinia-history.js b/client/plugins/pinia-history.js index a1e7bcdb..1940dc52 100644 --- a/client/plugins/pinia-history.js +++ b/client/plugins/pinia-history.js @@ -12,12 +12,10 @@ function mergeOptions(options) { max: 30, persistent: false, persistentStrategy: { - // eslint-disable-next-line no-unused-vars - get: function (store, type) { + get: function (_store, _type) { // Todo }, - // eslint-disable-next-line no-unused-vars - set: function (store, type, value) { + set: function (_store, _type, _value) { // Todo }, remove: function (store, type) {