소스 검색

update eslint config

Olivier Massot 6 달 전
부모
커밋
9fe226b129
5개의 변경된 파일674개의 추가작업 그리고 333개의 파일을 삭제
  1. 0 58
      .eslintrc.cjs
  2. 11 101
      eslint.config.mjs
  3. 21 0
      nuxt.config.ts
  4. 2 4
      package.json
  5. 640 170
      yarn.lock

+ 0 - 58
.eslintrc.cjs

@@ -1,58 +0,0 @@
-module.exports = {
-  root: true,
-  env: {
-    browser: true,
-    node: true,
-  },
-  parser: 'vue-eslint-parser',
-  parserOptions: {
-    ecmaVersion: 2020,
-    parser: '@typescript-eslint/parser',
-    sourceType: 'module',
-    tsconfigRootDir: __dirname,
-  },
-  extends: [
-    '@nuxtjs/eslint-config-typescript',
-    'plugin:nuxt/recommended',
-    'eslint:recommended',
-    'plugin:@typescript-eslint/recommended',
-    'plugin:vue/vue3-recommended',
-    'plugin:prettier/recommended',
-    'plugin:you-dont-need-lodash-underscore/compatible',
-  ],
-  ignorePatterns: [
-    '.nuxt',
-    'coverage/*',
-    'vendor/*',
-    'dist/*',
-    'models/models.ts',
-  ],
-  plugins: ['vue', '@typescript-eslint'],
-  // add your custom rules here
-  rules: {
-    'no-console': 0, // on autorise les appels à la console (puisque ceux-ci seront de toute façon nettoyés à la compilation)
-    'vue/valid-v-slot': [
-      'error',
-      {
-        allowModifiers: true,
-      },
-    ],
-    'vue/multi-word-component-names': 0,
-    '@typescript-eslint/no-inferrable-types': 0,
-  },
-  globals: {
-    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',
-  },
-}

+ 11 - 101
eslint.config.mjs

@@ -1,108 +1,17 @@
-// Polyfill for structuredClone if it doesn't exist
-if (typeof structuredClone !== 'function') {
-  globalThis.structuredClone = function(obj) {
-    return JSON.parse(JSON.stringify(obj));
-  };
-}
+// eslint.config.mjs
+import withNuxt from './.nuxt/eslint.config.mjs'
 
-import path from 'node:path'
-import { fileURLToPath } from 'node:url'
-import vue from 'eslint-plugin-vue'
-import typescriptEslint from '@typescript-eslint/eslint-plugin'
-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)
-const compat = new FlatCompat({
-  baseDirectory: __dirname,
-  recommendedConfig: js.configs.recommended,
-  allConfig: js.configs.all,
-})
-
-const baseConfig = [
-  {
-    ignores: [
-      '**/.nuxt',
-      'coverage/*',
-      'vendor/*',
-      'dist/*',
-      'models/models.ts',
-    ],
-  },
-  ...compat.extends(
-    '@nuxtjs/eslint-config-typescript',
-    'plugin:nuxt/recommended',
-    'eslint:recommended',
-    'plugin:@typescript-eslint/recommended',
-    'plugin:vue/vue3-recommended',
-    'plugin:prettier/recommended',
-    'plugin:you-dont-need-lodash-underscore/compatible',
-  ),
-  {
-    plugins: {
-      vue,
-      '@typescript-eslint': typescriptEslint,
-    },
-
-    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',
-      },
-
-      parser,
-      ecmaVersion: 2020,
-      sourceType: 'module',
-
-      parserOptions: {
-        parser: '@typescript-eslint/parser',
-        tsconfigRootDir: __dirname,
-      },
-    },
-
-    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
-baseConfig.push(
+// Configuration spécifique au projet qui sera fusionnée avec la configuration Nuxt
+const customConfig = [
+  // Configurations spécifiques par répertoire
   {
-    files: ['layouts/**/*.vue'],
+    files: ['**/*.vue'],
     rules: {
-      'vue/multi-word-component-names': 0,
+      '@typescript-eslint/no-unused-vars': 0,
     },
   },
   {
-    files: ['pages/**/*.vue'],
+    files: ['layouts/**/*.vue', 'pages/**/*.vue'],
     rules: {
       'vue/multi-word-component-names': 0,
     },
@@ -116,6 +25,7 @@ baseConfig.push(
       'require-await': 0,
     },
   }
-)
+]
 
-export default defineConfig(baseConfig)
+// Exporte la configuration en utilisant le helper de Nuxt
+export default withNuxt(customConfig)

+ 21 - 0
nuxt.config.ts

@@ -170,6 +170,27 @@ 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',
+        ]
+      }
+    }]
   ],
 
   vite: {

+ 2 - 4
package.json

@@ -28,7 +28,9 @@
     "@casl/vue": "2.2.2",
     "@fortawesome/fontawesome-free": "^6.7.2",
     "@mdi/font": "^7.4.47",
+    "@nuxt/eslint": "1.4.1",
     "@nuxt/image": "1.9.0",
+    "@nuxtjs/eslint-config-typescript": "^12.1.0",
     "@nuxtjs/i18n": "^9.1.3",
     "@pinia-orm/nuxt": "^1.10.1",
     "@pinia/nuxt": "^0.5.1",
@@ -61,9 +63,6 @@
     "@nuxt/devtools": "^1.7.0",
     "@nuxt/test-utils": "^3.15.4",
     "@nuxt/test-utils-edge": "3.8.0-28284309.b3d3d7f4",
-    "@nuxtjs/eslint-config": "^12.0.0",
-    "@nuxtjs/eslint-config-typescript": "^12.1.0",
-    "@nuxtjs/eslint-module": "^4.1.0",
     "@types/cleave.js": "^1.4.12",
     "@types/event-source-polyfill": "^1.0.5",
     "@types/file-saver": "^2.0.7",
@@ -77,7 +76,6 @@
     "@typescript-eslint/parser": "^8.22.0",
     "@vitejs/plugin-vue": "^5.2.1",
     "@vitest/coverage-v8": "3.0.4",
-    "@vue/eslint-config-standard": "^9.0.0",
     "@vue/test-utils": "^2.4.6",
     "blob-polyfill": "^9.0.20240710",
     "eslint": "^9.19.0",

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 640 - 170
yarn.lock


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.