Browse Source

fix eslint configuration for new format

Olivier Massot 6 months ago
parent
commit
8684560fac
4 changed files with 37 additions and 23 deletions
  1. 37 2
      eslint.config.mjs
  2. 0 6
      layouts/.eslintrc.cjs
  3. 0 6
      pages/.eslintrc.cjs
  4. 0 9
      tests/.eslintrc.cjs

+ 37 - 2
eslint.config.mjs

@@ -1,3 +1,10 @@
+// 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 vue from 'eslint-plugin-vue'
@@ -6,6 +13,7 @@ import globals from 'globals'
 import parser from 'vue-eslint-parser'
 import js from '@eslint/js'
 import { FlatCompat } from '@eslint/eslintrc'
+import { defineConfig } from "eslint/config"
 
 const __filename = fileURLToPath(import.meta.url)
 const __dirname = path.dirname(__filename)
@@ -15,7 +23,7 @@ const compat = new FlatCompat({
   allConfig: js.configs.all,
 })
 
-export default [
+const baseConfig = [
   {
     ignores: [
       '**/.nuxt',
@@ -65,7 +73,7 @@ export default [
 
       parserOptions: {
         parser: '@typescript-eslint/parser',
-        tsconfigRootDir: '/home/workspace',
+        tsconfigRootDir: __dirname,
       },
     },
 
@@ -84,3 +92,30 @@ export default [
     },
   },
 ]
+
+// Directory-specific configurations
+baseConfig.push(
+  {
+    files: ['layouts/**/*.vue'],
+    rules: {
+      'vue/multi-word-component-names': 0,
+    },
+  },
+  {
+    files: ['pages/**/*.vue'],
+    rules: {
+      'vue/multi-word-component-names': 0,
+    },
+  },
+  {
+    files: ['tests/**/*'],
+    rules: {
+      '@typescript-eslint/ban-ts-comment': 0,
+      '@typescript-eslint/no-unused-vars': 0,
+      '@typescript-eslint/no-explicit-any': 0,
+      'require-await': 0,
+    },
+  }
+)
+
+export default defineConfig(baseConfig)

+ 0 - 6
layouts/.eslintrc.cjs

@@ -1,6 +0,0 @@
-/** 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: {
-    'vue/multi-word-component-names': 0,
-  },
-}

+ 0 - 6
pages/.eslintrc.cjs

@@ -1,6 +0,0 @@
-/** 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: {
-    'vue/multi-word-component-names': 0,
-  },
-}

+ 0 - 9
tests/.eslintrc.cjs

@@ -1,9 +0,0 @@
-/** 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,
-  },
-}