Browse Source

update eslint configuration for new v9 format

Olivier Massot 10 tháng trước cách đây
mục cha
commit
1d287aaf2b
2 tập tin đã thay đổi với 75 bổ sung2 xóa
  1. 73 0
      eslint.config.mjs
  2. 2 2
      package.json

+ 73 - 0
eslint.config.mjs

@@ -0,0 +1,73 @@
+import vue from "eslint-plugin-vue";
+import typescriptEslint from "@typescript-eslint/eslint-plugin";
+import globals from "globals";
+import parser from "vue-eslint-parser";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import js from "@eslint/js";
+import { FlatCompat } from "@eslint/eslintrc";
+
+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
+});
+
+export default [{
+    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: parser,
+        ecmaVersion: 2020,
+        sourceType: "module",
+
+        parserOptions: {
+            parser: "@typescript-eslint/parser",
+            tsconfigRootDir: "/home/workspace",
+        },
+    },
+
+    rules: {
+        "no-console": 0,
+
+        "vue/valid-v-slot": ["error", {
+            allowModifiers: true,
+        }],
+
+        "vue/multi-word-component-names": 0,
+        "@typescript-eslint/no-inferrable-types": 0,
+    },
+}];

+ 2 - 2
package.json

@@ -35,8 +35,6 @@
     "@vuepic/vue-datepicker": "^7.4.0",
     "cleave.js": "^1.6.0",
     "date-fns": "^4.1.0",
-    "eslint-import-resolver-typescript": "^3.7.0",
-    "eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
     "event-source-polyfill": "^1.0.31",
     "file-saver": "^2.0.5",
     "glob": "^11.0.1",
@@ -83,9 +81,11 @@
     "blob-polyfill": "^9.0.20240710",
     "eslint": "^9.19.0",
     "eslint-config-prettier": "^10.0.1",
+    "eslint-import-resolver-typescript": "^3.7.0",
     "eslint-plugin-nuxt": "^4.0.0",
     "eslint-plugin-prettier": "^5.2.3",
     "eslint-plugin-vue": "^9.32.0",
+    "eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
     "jsdom": "^26.0.0",
     "prettier": "^3.4.2",
     "ts-jest": "^29.2.5",