Explorar el Código

finalize eslint configuration and various fixes

Olivier Massot hace 1 año
padre
commit
a94ad449eb

+ 0 - 1
.eslintrc.cjs

@@ -24,7 +24,6 @@ module.exports = {
     "coverage/*",
     "vendor/*",
     "dist/*",
-    "tests/*",
   ],
   plugins: [
     "vue",

+ 7 - 7
pages/parameters/website.vue

@@ -123,13 +123,8 @@
                   >
                     {{ $t('cancel') }}
                   </v-btn>
-                  <v-btn
-                    class="theme-primary"
-                    @click="
-                      showWebsiteDeactivationDialog = false
-                      deactivateWebsite()
-                    "
-                  >
+
+                  <v-btn class="theme-primary" @click="onDialogYesBtnClick">
                     {{ $t('yes') }}
                   </v-btn>
                 </template>
@@ -195,6 +190,11 @@ const deactivateWebsite = () => {
 const reactivateWebsite = () => {
   parameters.value!.desactivateOpentalentSiteWeb = false
 }
+
+const onDialogYesBtnClick = () => {
+  showWebsiteDeactivationDialog.value = false
+  deactivateWebsite()
+}
 </script>
 
 <style scoped lang="scss">

+ 5 - 1
services/utils/dateUtils.ts

@@ -1,4 +1,7 @@
-import { format, enUS, fr } from 'date-fns'
+// eslint-disable-next-line import/no-duplicates
+import { format } from 'date-fns'
+// eslint-disable-next-line import/no-duplicates
+import { enUS, fr } from 'date-fns/locale'
 import ArrayUtils from '~/services/utils/arrayUtils'
 
 export const enum supportedLocales {
@@ -43,6 +46,7 @@ export default class DateUtils {
   }
 
   public static getFnsLocale(code: supportedLocales): Locale {
+    // noinspection TypeScriptUnresolvedReference
     const mapping = {
       en: enUS,
       fr,

+ 9 - 0
tests/.eslintrc.cjs

@@ -0,0 +1,9 @@
+/** On désactive cette règle pour les pages et les layouts seulement : https://eslint.vuejs.org/rules/multi-word-component-names.html */
+module.exports = {
+  rules: {
+    "@typescript-eslint/ban-ts-comment": 0,
+    "@typescript-eslint/no-unused-vars": 0,
+    "@typescript-eslint/no-explicit-any": 0,
+    "require-await": 0
+  }
+}

+ 3 - 3
tests/units/services/data/imageManager.test.ts

@@ -6,7 +6,7 @@ import 'blob-polyfill'
 let apiRequestService: ApiRequestService
 let imageManager: ImageManager
 
-let init_console_error: any
+let initConsoleError: any
 
 beforeEach(() => {
   // @ts-ignore
@@ -15,12 +15,12 @@ beforeEach(() => {
   imageManager = new ImageManager(apiRequestService)
 
   // Important : Restore console error after mocking
-  init_console_error = console.error
+  initConsoleError = console.error
 })
 
 afterEach(() => {
   vi.restoreAllMocks()
-  console.error = init_console_error
+  console.error = initConsoleError
 })
 
 describe('get', () => {

+ 1 - 1
tests/units/services/data/normalizer/hydraNormalizer.test.ts

@@ -300,7 +300,7 @@ describe('denormalizeItem', () => {
 
     // @ts-ignore
     HydraNormalizer.parseEntityIRI = vi.fn((iri) => {
-      throw 'parsing error'
+      throw new Error('parsing error')
     })
 
     console.error = vi.fn((msg) => {})

+ 2 - 2
tests/units/services/sse/sseSource.test.ts

@@ -42,7 +42,7 @@ let onMessage: (data: Array<any>) => any
 let onClose: () => any
 let sseSource: TestableSseSource
 
-const init_console_log = console.log
+const initConsoleLog = console.log
 
 beforeEach(() => {
   mercureUrl = 'https://my.mercure.com'
@@ -63,7 +63,7 @@ beforeEach(() => {
 })
 
 afterEach(() => {
-  console.log = init_console_log
+  console.log = initConsoleLog
   vi.restoreAllMocks()
 })
 

+ 2 - 2
tests/units/services/validation/subdomainValidation.test.ts

@@ -43,7 +43,7 @@ describe('isAvailable', () => {
       async (url: string, query: AssociativeArray) => {
         if (
           url !== '/api/subdomains/is_available' ||
-          !query.hasOwnProperty('subdomain') ||
+          !Object.prototype.hasOwnProperty.call(query, 'subdomain') ||
           query.subdomain !== 'abc'
         ) {
           throw new Error('Invalid arguments')
@@ -60,7 +60,7 @@ describe('isAvailable', () => {
       async (url: string, query: AssociativeArray) => {
         if (
           url !== '/api/subdomains/is_available' ||
-          !query.hasOwnProperty('subdomain') ||
+          !Object.prototype.hasOwnProperty.call(query, 'subdomain') ||
           query.subdomain !== 'abc'
         ) {
           throw new Error('Invalid arguments')