Viet Tran a38d04c3d5
feat(search): overhaul relevance and curated design data
Overhaul BM25 relevance, reasoning and data-quality contracts; refresh UI styles and framework guidance; add resilient text, chip, badge and micro-interaction guidance; strengthen release, provenance and catalog refresh gates; update bilingual documentation.
2026-08-14 00:08:23 +07:00

12 KiB

1NoCategoryGuidelineDescriptionDoDon'tCode GoodCode BadSeverityDocs URLApplies ToStatusVerified At
21CompositionUse Composition API for new projectsComposition API offers better TypeScript support and logic reuse<script setup> for componentsOptions API for new projects<script setup>export default { data() }Mediumhttps://vuejs.org/guide/extras/composition-api-faq.htmlvue 3.5.xactive2026-08-13
32CompositionUse script setup syntaxCleaner syntax with automatic exports<script setup> with definePropssetup() function manually<script setup><script> setup() { return {} }Lowhttps://vuejs.org/api/sfc-script-setup.htmlvue 3.5.xactive2026-08-13
43ReactivityUse ref for primitivesref() for primitive values that need reactivityref() for strings numbers booleansreactive() for primitivesconst count = ref(0)const count = reactive(0)Mediumhttps://vuejs.org/guide/essentials/reactivity-fundamentals.htmlvue 3.5.xactive2026-08-13
54ReactivityUse reactive for objectsreactive() for complex objects and arraysreactive() for objects with multiple propertiesref() for complex objectsconst state = reactive({ user: null })const state = ref({ user: null })Mediumvue 3.5.xactive2026-08-13
65ReactivityAccess ref values with .valueRemember .value in script unwrap in templateUse .value in scriptForget .value in scriptcount.value++count++ (in script)Highhttps://vuejs.org/guide/essentials/reactivity-fundamentals.htmlvue 3.5.xactive2026-08-13
76ReactivityUse computed for derived stateComputed properties cache and update automaticallycomputed() for derived valuesMethods for derived valuesconst doubled = computed(() => count.value * 2)const doubled = () => count.value * 2Mediumhttps://vuejs.org/guide/essentials/computed.htmlvue 3.5.xactive2026-08-13
87ReactivityUse shallowRef for large objectsAvoid deep reactivity for performanceshallowRef for large data structuresref for large nested objectsconst bigData = shallowRef(largeObject)const bigData = ref(largeObject)Mediumhttps://vuejs.org/api/reactivity-advanced.html#shallowrefvue 3.5.xactive2026-08-13
98WatchersUse watchEffect for simple casesAuto-tracks dependencieswatchEffect for simple reactive effectswatch with explicit deps when not neededwatchEffect(() => console.log(count.value))watch(count, (val) => console.log(val))Lowhttps://vuejs.org/guide/essentials/watchers.htmlvue 3.5.xactive2026-08-13
109WatchersUse watch for specific sourcesExplicit control over what to watchwatch with specific refswatchEffect for complex conditional logicwatch(userId, fetchUser)watchEffect with conditionalsMediumvue 3.5.xactive2026-08-13
1110WatchersClean up side effectsReturn cleanup function in watchersReturn cleanup in watchEffectLeave subscriptions openwatchEffect((onCleanup) => { onCleanup(unsub) })watchEffect without cleanupHighhttps://vuejs.org/guide/essentials/watchers.htmlvue 3.5.xactive2026-08-13
1211PropsDefine props with definePropsType-safe prop definitionsdefineProps with TypeScriptProps without typesdefineProps<{ msg: string }>()defineProps(['msg'])Mediumhttps://vuejs.org/guide/typescript/composition-api.html#typing-component-propsvue 3.5.xactive2026-08-13
1312PropsUse withDefaults for default valuesProvide defaults for optional propswithDefaults with definePropsDefaults in destructuringwithDefaults(defineProps<Props>(), { count: 0 })const { count = 0 } = defineProps()Mediumvue 3.5.xactive2026-08-13
1413PropsAvoid mutating propsProps should be read-onlyEmit events to parent for changesDirect prop mutationemit('update:modelValue', newVal)props.modelValue = newValHighhttps://vuejs.org/guide/components/propsvue 3.5.xactive2026-08-13
1514EmitsDefine emits with defineEmitsType-safe event emissionsdefineEmits with typesEmit without definitiondefineEmits<{ change: [id: number] }>()emit('change', id) without defineMediumhttps://vuejs.org/guide/typescript/composition-api.html#typing-component-emitsvue 3.5.xactive2026-08-13
1615EmitsUse v-model for two-way bindingSimplified parent-child data flowv-model with modelValue prop:value + @input manually<Child v-model="value"/><Child :value="value" @input="value = $event"/>Lowhttps://vuejs.org/guide/components/v-model.htmlvue 3.5.xactive2026-08-13
1716LifecycleUse onMounted for DOM accessDOM is ready in onMountedonMounted for DOM operationsAccess DOM in setup directlyonMounted(() => el.value.focus())el.value.focus() in setupHighhttps://vuejs.org/api/composition-api-lifecycle.htmlvue 3.5.xactive2026-08-13
1817LifecycleClean up in onUnmountedRemove listeners and subscriptionsonUnmounted for cleanupLeave listeners attachedonUnmounted(() => window.removeEventListener())No cleanup on unmountHighhttps://vuejs.org/api/composition-api-lifecycle.html#onunmountedvue 3.5.xactive2026-08-13
1918LifecycleAvoid onBeforeMount for dataUse onMounted or setup for data fetchingFetch in onMounted or setupFetch in onBeforeMountonMounted(async () => await fetchData())onBeforeMount(async () => await fetchData())Lowvue 3.5.xactive2026-08-13
2019ComponentsUse single-file componentsKeep template script style together.vue files for componentsSeparate template/script filesComponent.vue with all partsComponent.js + Component.htmlLowvue 3.5.xactive2026-08-13
2120ComponentsUse PascalCase for componentsConsistent component namingPascalCase in imports and templateskebab-case in script<MyComponent/><my-component/>Lowhttps://vuejs.org/style-guide/rules-strongly-recommended.htmlvue 3.5.xactive2026-08-13
2221ComponentsPrefer composition over mixinsComposables replace mixinsComposables for shared logicMixins for code reuseconst { data } = useApi()mixins: [apiMixin]Mediumvue 3.5.xactive2026-08-13
2322ComposablesName composables with use prefixConvention for composable functionsuseFetch useAuth useFormgetData or fetchApiexport function useFetch()export function fetchData()Mediumhttps://vuejs.org/guide/reusability/composables.htmlvue 3.5.xactive2026-08-13
2423ComposablesReturn refs from composablesMaintain reactivity when destructuringReturn ref valuesReturn reactive objects that lose reactivityreturn { data: ref(null) }return reactive({ data: null })Mediumvue 3.5.xactive2026-08-13
2524ComposablesAccept ref or value paramsUse toValue for flexible inputstoValue() or unref() for paramsOnly accept ref or only valueconst val = toValue(maybeRef)const val = maybeRef.valueLowhttps://vuejs.org/api/reactivity-utilities.html#tovaluevue 3.5.xactive2026-08-13
2625TemplatesUse v-bind shorthandCleaner template syntax:prop instead of v-bind:propFull v-bind syntax<div :class="cls"><div v-bind:class="cls">Lowvue 3.5.xactive2026-08-13
2726TemplatesUse v-on shorthandCleaner event binding@event instead of v-on:eventFull v-on syntax<button @click="handler"><button v-on:click="handler">Lowvue 3.5.xactive2026-08-13
2827TemplatesAvoid v-if with v-forv-if has higher priority causes issuesWrap in template or computed filterv-if on same element as v-for<template v-for><div v-if><div v-for v-if>Highhttps://vuejs.org/style-guide/rules-essential.html#avoid-v-if-with-v-forvue 3.5.xactive2026-08-13
2928TemplatesUse key with v-forProper list rendering and updatesUnique key for each itemIndex as key for dynamic listsv-for="item in items" :key="item.id"v-for="(item, i) in items" :key="i"Highhttps://vuejs.org/guide/essentials/list.html#maintaining-state-with-keyvue 3.5.xactive2026-08-13
3029StateUse Pinia for global stateOfficial state management for Vue 3Pinia stores for shared stateVuex for new projectsconst store = useCounterStore()Vuex with mutationsMediumhttps://pinia.vuejs.org/vue 3.5.xactive2026-08-13
3130StateDefine stores with defineStoreComposition API style storesSetup stores with defineStoreOptions stores for complex statedefineStore('counter', () => {})defineStore('counter', { state })Lowvue 3.5.xactive2026-08-13
3231StateUse storeToRefs for destructuringMaintain reactivity when destructuringstoreToRefs(store)Direct destructuringconst { count } = storeToRefs(store)const { count } = storeHighhttps://pinia.vuejs.org/core-concepts/#destructuring-from-a-storevue 3.5.xactive2026-08-13
3332RoutingUse useRouter and useRouteComposition API router accessuseRouter() useRoute() in setupthis.$router this.$routeconst router = useRouter()this.$router.push()Mediumhttps://router.vuejs.org/guide/advanced/composition-api.htmlvue 3.5.xactive2026-08-13
3433RoutingLazy load route componentsCode splitting for routes() => import() for componentsStatic imports for all routescomponent: () => import('./Page.vue')component: PageMediumhttps://router.vuejs.org/guide/advanced/lazy-loading.htmlvue 3.5.xactive2026-08-13
3534RoutingUse navigation guardsProtect routes and handle redirectsbeforeEach for auth checksCheck auth in each componentrouter.beforeEach((to) => {})Check auth in onMountedMediumvue 3.5.xactive2026-08-13
3635PerformanceUse v-once for static contentSkip re-renders for static elementsv-once on never-changing contentv-once on dynamic content<div v-once>{{ staticText }}</div><div v-once>{{ dynamicText }}</div>Lowhttps://vuejs.org/api/built-in-directives.html#v-oncevue 3.5.xactive2026-08-13
3736PerformanceUse v-memo for expensive listsMemoize list itemsv-memo with dependency arrayRe-render entire list always<div v-for v-memo="[item.id]"><div v-for> without memoMediumhttps://vuejs.org/api/built-in-directives.html#v-memovue 3.5.xactive2026-08-13
3837PerformanceUse shallowReactive for flat objectsAvoid deep reactivity overheadshallowReactive for flat statereactive for simple objectsshallowReactive({ count: 0 })reactive({ count: 0 })Lowvue 3.5.xactive2026-08-13
3938PerformanceUse defineAsyncComponentLazy load heavy componentsdefineAsyncComponent for modals dialogsImport all components eagerlydefineAsyncComponent(() => import())import HeavyComponent fromMediumhttps://vuejs.org/guide/components/async.htmlvue 3.5.xactive2026-08-13
4039TypeScriptUse generic componentsType-safe reusable componentsGeneric with defineComponentAny types in components<script setup lang="ts" generic="T"><script setup> without typesMediumhttps://vuejs.org/guide/typescript/composition-api.htmlvue 3.5.xactive2026-08-13
4140TypeScriptType template refsProper typing for DOM refsref<HTMLInputElement>(null)ref(null) without typeconst input = ref<HTMLInputElement>(null)const input = ref(null)Mediumvue 3.5.xactive2026-08-13
4241TypeScriptUse PropType for complex propsType complex prop typesPropType<User> for object propsObject without typetype: Object as PropType<User>type: ObjectMediumvue 3.5.xactive2026-08-13
4342TestingUse Vue Test UtilsOfficial testing librarymount shallowMount for componentsManual DOM testingimport { mount } from '@vue/test-utils'document.createElementMediumhttps://test-utils.vuejs.org/vue 3.5.xactive2026-08-13
4443TestingTest component behaviorFocus on inputs and outputsTest props emit and rendered outputTest internal implementationexpect(wrapper.text()).toContain()expect(wrapper.vm.internalState)Mediumvue 3.5.xactive2026-08-13
4544FormsUse v-model modifiersBuilt-in input handling.lazy .number .trim modifiersManual input parsing<input v-model.number="age"><input v-model="age"> then parseLowhttps://vuejs.org/guide/essentials/forms.html#modifiersvue 3.5.xactive2026-08-13
4645FormsUse VeeValidate or FormKitForm validation librariesVeeValidate for complex formsManual validation logicuseField useForm from vee-validateCustom validation in each inputMediumvue 3.5.xactive2026-08-13
4746AccessibilityUse semantic elementsProper HTML elements in templatesbutton nav main for purposediv for everything<button @click><div @click>Highhttps://vuejs.org/guide/best-practices/accessibility.htmlvue 3.5.xactive2026-08-13
4847AccessibilityBind aria attributes dynamicallyKeep ARIA in sync with state:aria-expanded="isOpen"Static ARIA values:aria-expanded="menuOpen"aria-expanded="true"Mediumvue 3.5.xactive2026-08-13
4948SSRUse Nuxt for SSRFull-featured SSR frameworkNuxt 3 for SSR appsManual SSR setupnpx nuxi init my-appCustom SSR configurationMediumhttps://nuxt.com/vue 3.5.xactive2026-08-13
5049SSRHandle hydration mismatchesClient/server content must matchClientOnly for browser-only contentDifferent content server/client<ClientOnly><BrowserWidget/></ClientOnly><div>{{ Date.now() }}</div>Highhttps://vuejs.org/guide/scaling-up/ssr.html#hydration-mismatchvue 3.5.xactive2026-08-13