Browse Source

Enable eslint & typescript for intellisense

Bubka 3 months ago
parent
commit
2f99849adf
7 changed files with 851 additions and 102 deletions
  1. 2 0
      .gitignore
  2. 28 0
      eslint.config.js
  3. 0 5
      jsconfig.json
  4. 784 94
      package-lock.json
  5. 4 1
      package.json
  6. 14 0
      tsconfig.json
  7. 19 2
      vite.config.js

+ 2 - 0
.gitignore

@@ -12,7 +12,9 @@
 .env
 .env.backup
 .env.production
+.eslintrc-auto-import.mjs
 .phpunit.result.cache
+auto-imports.d.ts
 Homestead.json
 Homestead.yaml
 auth.json

+ 28 - 0
eslint.config.js

@@ -0,0 +1,28 @@
+import js from '@eslint/js'
+import eslintPluginVue from 'eslint-plugin-vue'
+import globals from 'globals'
+import autoImports from './.eslintrc-auto-import.mjs'
+import { defineConfig } from "eslint/config";
+
+// const compat = new FlatCompat()
+
+export default defineConfig([
+    // autoImports,
+    js.configs.recommended,
+    ...eslintPluginVue.configs['flat/essential'],
+    {
+        name: 'app/files-to-lint',
+        files: ['resources/js/**/*.{js,mjs,jsx,vue}'],
+        rules: {
+            'vue/multi-word-component-names': 'off',
+            'no-unused-vars': 'off',
+        },
+        languageOptions: {
+            globals: {
+                ...globals.node,
+                ...globals.browser,
+                ...autoImports.globals
+            },
+        },
+    },
+])

+ 0 - 5
jsconfig.json

@@ -1,5 +0,0 @@
-{
-  "include": [
-    "./resources/js/*"
-  ]
-}

File diff suppressed because it is too large
+ 784 - 94
package-lock.json


+ 4 - 1
package.json

@@ -7,6 +7,7 @@
         "rebuild": "vite build --watch"
     },
     "devDependencies": {
+        "@eslint/js": "^9.23.0",
         "@fortawesome/fontawesome-svg-core": "^6.4.2",
         "@fortawesome/free-brands-svg-icons": "^6.4.2",
         "@fortawesome/free-regular-svg-icons": "^6.4.2",
@@ -20,6 +21,7 @@
         "axios": "^1.1.2",
         "bulma": "^0.9.4",
         "bulma-checkradio": "^2.1.3",
+        "eslint-plugin-vue": "^10.0.0",
         "file-saver": "^2.0.5",
         "laravel-vite-plugin": "^1.0.2",
         "laravel-vue-i18n": "^2.7.1",
@@ -27,7 +29,8 @@
         "pinia": "^2.1.6",
         "sass": "^1.67.0",
         "sortablejs": "^1.15.0",
-        "unplugin-auto-import": "^0.16.6",
+        "typescript": "^5.8.2",
+        "unplugin-auto-import": "^19.1.2",
         "vite": "^5.2.7",
         "vue": "^3.3.4",
         "vue-qrcode-reader": "^5.4.0",

+ 14 - 0
tsconfig.json

@@ -0,0 +1,14 @@
+{
+    "include": [
+        "./resources/js/**/*",
+        "./auto-imports.d.ts"
+    ],
+    "compilerOptions": {
+        "allowJs": true,
+        "isolatedModules": true,
+        "paths": {
+            "@/*": ["./resources/js/*"]
+        },
+        "noEmit": true,
+    },
+}

+ 19 - 2
vite.config.js

@@ -34,6 +34,11 @@ export default defineConfig({
         i18n('resources/lang'),
         AutoImport({
             // https://github.com/unplugin/unplugin-auto-import?tab=readme-ov-file#configuration
+            // include: [
+            //     /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
+            //     /\.vue$/,
+            //     /\.vue\?vue/, // .vue
+            // ],
             imports: [
                 'vue',
                 'vue-router',
@@ -61,9 +66,21 @@ export default defineConfig({
             //     ElementPlusResolver(),
             // ],
             dirs: [
-                '@/composables/**',
+                './resources/js/components/**',
+                './resources/js/composables/**',
+                './resources/js/layouts/**',
+                './resources/js/router/**',
+                './resources/js/services/**',
+                './resources/js/stores/**',
             ],
             vueTemplate: true,
+            vueDirectives: true,
+            dts: './auto-imports.d.ts',
+            eslintrc: {
+                enabled: true,
+                filepath: './.eslintrc-auto-import.mjs',
+                globalsPropValue: true, // 'readonly',
+            },
         }),
     ],
     resolve: {
@@ -75,7 +92,7 @@ export default defineConfig({
         // sourcemap: true,
         rollupOptions: {
             output: {
-                banner: '/*! 2FAuth version ' + version + ' - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */',
+                banner: '/*! 2FAuth version ' + version + ' - Copyright (c) 2025 Bubka - https://github.com/Bubka/2FAuth */',
             },
         },
     },

Some files were not shown because too many files changed in this diff