From 587c7d34286c5572b82a147b053d2aa06bc5bcc1 Mon Sep 17 00:00:00 2001 From: Alexandr SaVBaD Waltz Date: Sun, 1 Jun 2025 18:10:45 +0300 Subject: [PATCH] Features: 1) Add ESLint dependencies for Vue and Astro projects, including `eslint-plugin-astro` and `eslint-plugin-vue`; Fixes: None; Extra: 1) Update `package-lock.json` with multiple development-related dependencies, including `vue-eslint-parser` and packages for TypeScript compatibility; --- storefront/eslint.config.mjs | 96 ++ storefront/package-lock.json | 1341 ++++++++++++++++- storefront/package.json | 6 +- storefront/src/apollo/index.js | 4 +- storefront/src/components/app-initializer.vue | 25 + storefront/src/layouts/default-layout.astro | 37 +- storefront/src/layouts/default-layout.vue | 38 + storefront/src/pages/index.astro | 19 +- storefront/src/plugins/index.js | 24 +- storefront/src/stores/app.js | 25 + 10 files changed, 1569 insertions(+), 46 deletions(-) create mode 100644 storefront/eslint.config.mjs create mode 100644 storefront/src/components/app-initializer.vue create mode 100644 storefront/src/layouts/default-layout.vue create mode 100644 storefront/src/stores/app.js diff --git a/storefront/eslint.config.mjs b/storefront/eslint.config.mjs new file mode 100644 index 00000000..91d61066 --- /dev/null +++ b/storefront/eslint.config.mjs @@ -0,0 +1,96 @@ +module.exports = { + root: true, + env: { + browser: true, + node: true, + es2021: true, + }, + parserOptions: { + ecmaVersion: 2021, + sourceType: 'module', + // Allow ESLint to recognize .vue and .astro files + extraFileExtensions: ['.vue', '.astro'], + }, + extends: [ + // Basic recommended rules from ESLint + 'eslint:recommended', + + // Vue 3 best practices (uses vue-eslint-parser under the hood) + 'plugin:vue/vue3-recommended', // :contentReference[oaicite:0]{index=0} + + // TypeScript support (if you’re using TS in .js/.ts or inside .vue/.astro) + 'plugin:@typescript-eslint/recommended', + + // Astro’s own recommended ruleset + 'plugin:astro/recommended', // :contentReference[oaicite:1]{index=1} + ], + plugins: [ + 'vue', + '@typescript-eslint', + 'astro', + ], + rules: { + // Customize global rules here (if needed). For example: + // '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], + }, + overrides: [ + // ————— Override for `.astro` files ————— + { + files: ['*.astro'], + parser: 'astro-eslint-parser', + parserOptions: { + // Inside \ No newline at end of file diff --git a/storefront/src/layouts/default-layout.astro b/storefront/src/layouts/default-layout.astro index 962f455e..708c13a2 100644 --- a/storefront/src/layouts/default-layout.astro +++ b/storefront/src/layouts/default-layout.astro @@ -1,30 +1,41 @@ --- +import AppInitializer from "@/components/app-initializer.vue"; import {useRefresh} from "@/composables/auth"; import {useCompanyInfo} from "@/composables/company"; import {useLanguages} from "@/composables/languages/index.js"; import BaseHeader from "@/components/base/header/base-header.vue"; import BaseFooter from "@/components/base/base-footer.vue"; -document.addEventListener('DOMContentLoaded', async () => { - const { refresh } = useRefresh(); - const { getCompanyInfo } = useCompanyInfo(); - const { getLanguages } = useLanguages(); +const { refresh } = useRefresh(); +const { getCompanyInfo } = useCompanyInfo(); +const { getLanguages } = useLanguages(); +await refresh(); +await getCompanyInfo(); +await getLanguages(); + +setInterval(async () => { await refresh(); - await getCompanyInfo(); - await getLanguages(); - - setInterval(async () => { - await refresh(); - }, 600000); -}); +}, 600000); --- -
+ + + + + + + Astro + + +
-
+ + + + \ No newline at end of file diff --git a/storefront/src/pages/index.astro b/storefront/src/pages/index.astro index 72c60fc0..7cfc324f 100644 --- a/storefront/src/pages/index.astro +++ b/storefront/src/pages/index.astro @@ -1,18 +1,7 @@ --- -import DefaultLayout from '../layouts/default-layout.astro'; +import DefaultLayout from "../layouts/default-layout.astro"; --- - - - - - - - Astro - - - -

Astro

-
- - + +

Astro

+
diff --git a/storefront/src/plugins/index.js b/storefront/src/plugins/index.js index e6b63054..0e0f25d3 100644 --- a/storefront/src/plugins/index.js +++ b/storefront/src/plugins/index.js @@ -1,10 +1,26 @@ import { setupI18n } from './i18n.js' import { pinia } from "../stores/index.js"; +import { createApolloClient } from "../apollo/index.js"; +import { DefaultApolloClient } from "@vue/apollo-composable"; +import ElementPlus from 'element-plus'; + export default function (app) { - app.use(pinia) + app.use(pinia); - setupI18n().then(i18n => { - app.use(i18n) - }) + app.use(ElementPlus); + + const apolloClient = createApolloClient(); + app.provide(DefaultApolloClient, apolloClient); + + const i18n = setupI18n(); + if (i18n instanceof Promise) { + i18n.then(i18nInstance => { + app.use(i18nInstance); + }); + } else { + app.use(i18n); + } + + return app; } \ No newline at end of file diff --git a/storefront/src/stores/app.js b/storefront/src/stores/app.js new file mode 100644 index 00000000..909c35b1 --- /dev/null +++ b/storefront/src/stores/app.js @@ -0,0 +1,25 @@ +import { defineStore } from "pinia"; +import { ref, computed } from "vue"; + +export const useAppStore = defineStore('app', () => { + const activeState = ref(null); + + const setActiveState = (state) => { + activeState.value = state; + }; + + const isSignUp = computed(() => activeState.value === "signUp"); + const isSignIn = computed(() => activeState.value === "signIn"); + const isForgot = computed(() => activeState.value === "reset-password"); + const isReset = computed(() => activeState.value === "new-password"); + + return { + activeState, + setActiveState, + + isSignUp, + isSignIn, + isForgot, + isReset + }; +}); \ No newline at end of file