Browse Source

fix eslint errors

Olivier Massot 6 months ago
parent
commit
2898886f6f

+ 3 - 1
components/Ui/DatePicker.vue

@@ -26,7 +26,7 @@ Sélecteur de dates
       :cancel-text="$t('cancel')"
       input-class-name="date-picker-input"
       class="mb-6"
-      @update:model-value="$emit('update:modelValue', $event)"
+      @update:model-value="emit('update:modelValue', $event)"
     />
   </div>
 </template>
@@ -38,6 +38,8 @@ import type { Locale } from 'date-fns'
 import type { supportedLocales } from '~/services/utils/dateUtils';
 import DateUtils from '~/services/utils/dateUtils'
 
+const emit = defineEmits(['update:modelValue'])
+
 const props = defineProps({
   modelValue: {
     type: Object as PropType<Date | Array<Date> | null>,

+ 2 - 2
components/Ui/Form/Creation.vue

@@ -23,7 +23,7 @@ const props = defineProps({
    * Classe de l'ApiModel (ex: Organization, Notification, ...)
    */
   model: {
-    type: Function as any as () => typeof ApiModel,
+    type: Function as PropType<() => typeof ApiModel>,
     required: true,
   },
   /**
@@ -55,7 +55,7 @@ const props = defineProps({
 const router = useRouter()
 const { em } = useEntityManager()
 
-// @ts-ignore Pour une raison que j'ignore, le type Ref<ApiModel> met en erreur la prop entity de UiForm...
+// @ts-expect-error Pour une raison que j'ignore, le type Ref<ApiModel> met en erreur la prop entity de UiForm...
 const entity: ApiModel = reactive(em.newInstance(props.model))
 
 const submitActions = computed(() => {

+ 1 - 1
components/Ui/Form/Edition.vue

@@ -28,7 +28,7 @@ const props = defineProps({
    * Classe de l'ApiModel (ex: Organization, Notification, ...)
    */
   model: {
-    type: Function as any as () => typeof ApiModel,
+    type: Function as PropType<() => typeof ApiModel>,
     required: true,
   },
   /**

+ 3 - 3
components/Ui/Help.vue

@@ -71,14 +71,14 @@ const leftOrDefault: Ref<boolean> = ref(
   props.left || (!props.right && !props.bottom && !props.top),
 )
 
-const onIconClicked = (e: any) => {
+const onIconClicked = (e: MouseEvent) => {
   show.value = !show.value
   e.stopPropagation()
 }
 
-const onClickOutside = (e: any) => {
+const onClickOutside = (e: MouseEvent) => {
   if (show.value) {
-    if (e.target === (iconRef.value as any).$el) {
+    if (e.target === (iconRef.value as { $el: HTMLElement }).$el) {
       return
     }
     show.value = false

+ 7 - 2
services/data/normalizer/hydraNormalizer.ts

@@ -11,6 +11,11 @@ import type ApiResource from '~/models/ApiResource'
 class HydraNormalizer {
   static models = models
 
+  // Private constructor to prevent instantiation
+  private constructor() {
+    // This utility class is not meant to be instantiated
+  }
+
   /**
    * Normalize the given entity into a Hydra formatted content.
    * @param entity
@@ -148,7 +153,7 @@ class HydraNormalizer {
     try {
       const iri = HydraNormalizer.parseEntityIRI(item['@id'])
       entity = iri.entity
-    } catch (e) {
+    } catch (_e) {
       console.error('De-normalization error : could not parse the IRI', item)
       return item
     }
@@ -173,7 +178,7 @@ class HydraNormalizer {
   protected static denormalizeEntity(model: typeof ApiResource, item: AnyJson) {
     item.id = this.getItemIdValue(model, item)
 
-     
+
     const instance = new model(item)
     const iriEncodedFields = model.getIriEncodedFields()
 

+ 6 - 1
services/layout/menuComposer.ts

@@ -19,6 +19,11 @@ import ParametersMenuBuilder from '~/services/layout/menuBuilder/parametersMenuB
  * Gestionnaire principal des menus de l'application
  */
 export default class MenuComposer {
+  // Private constructor to prevent instantiation
+  private constructor() {
+    // This utility class is not meant to be instantiated
+  }
+
   // eslint-disable-next-line @typescript-eslint/no-explicit-any
   protected static readonly builders: Array<any> = [
     MainMenuBuilder,
@@ -49,7 +54,7 @@ export default class MenuComposer {
     layoutState: LayoutState,
   ) {
     for (const builderClass of MenuComposer.builders) {
-       
+
       const builder: MenuBuilder = new builderClass(
         runtimeConfig,
         ability,

+ 4 - 0
services/rights/roleUtils.ts

@@ -43,6 +43,10 @@ interface Role {
  * Classe permettant de mener des opérations sur les rôles
  */
 class RoleUtils {
+  // Private constructor to prevent instantiation
+  private constructor() {
+    // This utility class is not meant to be instantiated
+  }
   /**
    * Teste si une personne possède un profil suivant ses rôles
    *

+ 4 - 0
services/utils/arrayUtils.ts

@@ -1,6 +1,10 @@
 import type { AnyJson } from '~/types/data'
 
 export default class ArrayUtils {
+  // Private constructor to prevent instantiation
+  private constructor() {
+    // This utility class is not meant to be instantiated
+  }
   /**
    * Trie un tableau
    *

+ 4 - 0
services/utils/dateUtils.ts

@@ -11,6 +11,10 @@ export const enum supportedLocales {
 const defaultLocale = 'fr'
 
 export default class DateUtils {
+  private constructor() {
+    // Private constructor to prevent instantiation
+    // This utility class is not meant to be instantiated
+  }
   public static format(date: Date, fmt: string): string {
     return format(date, fmt)
   }

+ 4 - 0
services/utils/fileUtils.ts

@@ -2,6 +2,10 @@
  * Manipulation des images
  */
 class FileUtils {
+  // Private constructor to prevent instantiation
+  private constructor() {
+    // This utility class is not meant to be instantiated
+  }
   /**
    * Returns a blob with the given data and the file's type
    *

+ 4 - 0
services/utils/objectUtils.ts

@@ -7,6 +7,10 @@ import _ from 'lodash'
 import type { AnyJson } from '~/types/data'
 import StringUtils from '~/services/utils/stringUtils'
 export default class ObjectUtils {
+  // Private constructor to prevent instantiation
+  private constructor() {
+    // This utility class is not meant to be instantiated
+  }
   /**
    * Flatten un objet nested en un objet avec un seul niveau avec des noms de propriétés transformées comme cela 'foo.bar'
    * L'objet passé en paramètre reste inchangé car il est cloné

+ 4 - 0
services/utils/refUtils.ts

@@ -2,6 +2,10 @@ import type { UnwrapRef } from 'vue'
 import { ref, isRef } from 'vue'
 
 export default class RefUtils {
+  // Private constructor to prevent instantiation
+  private constructor() {
+    // This utility class is not meant to be instantiated
+  }
   /**
    * Convertit la valeur passée en référence.
    * S'il s'agit déjà d'une ref, selon que `maintainReactivity` est vrai ou faux, on conserve la référence existante

+ 4 - 0
services/utils/stringUtils.ts

@@ -1,6 +1,10 @@
 import crypto from 'crypto'
 
 export default class StringUtils {
+  // Private constructor to prevent instantiation
+  private constructor() {
+    // This utility class is not meant to be instantiated
+  }
   /**
    * Normalise une chaine de caractères en retirant la casse et les caractères spéciaux, à des fins de recherche
    * par exemple