Forráskód Böngészése

refactor eslint configuration

Olivier Massot 6 hónapja
szülő
commit
31ec9ecace
2 módosított fájl, 66 hozzáadás és 27 törlés
  1. 65 5
      eslint.config.mjs
  2. 1 22
      nuxt.config.ts

+ 65 - 5
eslint.config.mjs

@@ -1,9 +1,63 @@
-// eslint.config.mjs
+// Polyfill for structuredClone if it doesn't exist
+if (typeof structuredClone !== 'function') {
+  globalThis.structuredClone = function(obj) {
+    return JSON.parse(JSON.stringify(obj));
+  };
+}
+
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+import globals from 'globals'
 import withNuxt from './.nuxt/eslint.config.mjs'
 
-// Configuration spécifique au projet qui sera fusionnée avec la configuration Nuxt
+const __filename = fileURLToPath(import.meta.url)
+const __dirname = path.dirname(__filename)
+
+// Configuration de base personnalisée
 const customConfig = [
-  // Configurations spécifiques par répertoire
+  {
+    ignores: [
+      '**/.nuxt',
+      'coverage/*',
+      'vendor/*',
+      'dist/*',
+      'models/models.ts',
+    ],
+  },
+  {
+    languageOptions: {
+      globals: {
+        ...globals.browser,
+        ...globals.node,
+        useRuntimeConfig: 'readonly',
+        useAsyncData: 'readonly',
+        navigateTo: 'readonly',
+        computed: 'readonly',
+        ref: 'readonly',
+        definePageMeta: 'readonly',
+        useRouter: 'readonly',
+        useRoute: 'readonly',
+        useI18n: 'readonly',
+        onMounted: 'readonly',
+        onUnmounted: 'readonly',
+        watch: 'readonly',
+        useRepo: 'readonly',
+      },
+    },
+
+    rules: {
+      'no-console': 0,
+      'vue/valid-v-slot': [
+        'error',
+        {
+          allowModifiers: true,
+        },
+      ],
+      'vue/multi-word-component-names': 0,
+      '@typescript-eslint/no-inferrable-types': 0,
+    },
+  },
+  // Directory-specific configurations
   {
     files: ['**/*.vue'],
     rules: {
@@ -11,7 +65,13 @@ const customConfig = [
     },
   },
   {
-    files: ['layouts/**/*.vue', 'pages/**/*.vue'],
+    files: ['layouts/**/*.vue'],
+    rules: {
+      'vue/multi-word-component-names': 0,
+    },
+  },
+  {
+    files: ['pages/**/*.vue'],
     rules: {
       'vue/multi-word-component-names': 0,
     },
@@ -27,5 +87,5 @@ const customConfig = [
   }
 ]
 
-// Exporte la configuration en utilisant le helper de Nuxt
+// Utiliser withNuxt avec l'option standalone: false pour éviter les conflits
 export default withNuxt(customConfig)

+ 1 - 22
nuxt.config.ts

@@ -170,29 +170,8 @@ export default defineNuxtConfig({
     '@nuxt/image',
     'nuxt-prepare',
     'nuxt-vitalizer',
-    ['@nuxt/eslint', {
-      // Configuration du module ESLint
-      config: {
-        // Vos règles personnalisées que vous souhaitez conserver
-        rules: {
-          'no-console': 0,
-          'vue/multi-word-component-names': 0,
-          'vue/valid-v-slot': ['error', { allowModifiers: true }],
-          '@typescript-eslint/no-inferrable-types': 0,
-          'vue/script-setup-uses-vars': 'error'
-        },
-        // Fichiers à ignorer
-        ignores: [
-          '**/.nuxt',
-          'coverage/*',
-          'vendor/*',
-          'dist/*',
-          'models/models.ts',
-        ]
-      }
-    }]
+    '@nuxt/eslint'
   ],
-
   vite: {
     esbuild: {
       drop: process.env.DEBUG ? [] : ['console', 'debugger'],