[{"data":1,"prerenderedAt":447},["ShallowReactive",2],{"navigation_docs":3,"diagnostic-content-VUE0034":48},[4,8,12,16,20,24,28,32,36,40,44],{"title":5,"path":6,"stem":7},"CLI","\u002Fcli","1.cli",{"title":9,"path":10,"stem":11},"Nuxt","\u002Fnuxt","2.nuxt",{"title":13,"path":14,"stem":15},"Vue","\u002Fvue","3.vue",{"title":17,"path":18,"stem":19},"Vite","\u002Fvite","4.vite",{"title":21,"path":22,"stem":23},"Nitro","\u002Fnitro","5.nitro",{"title":25,"path":26,"stem":27},"TypeScript","\u002Ftypescript","6.typescript",{"title":29,"path":30,"stem":31},"shadcn","\u002Fshadcn","7.shadcn",{"title":33,"path":34,"stem":35},"Package","\u002Fpackage","8.package",{"title":37,"path":38,"stem":39},"Extending Doctor","\u002Fextending","9.extending",{"title":41,"path":42,"stem":43},"MCP","\u002Fmcp","9.mcp",{"title":45,"path":46,"stem":47},"Pinia","\u002Fpinia","9.pinia",{"id":49,"title":50,"body":51,"category":57,"code":436,"description":437,"docsUrl":58,"extension":438,"fix":439,"framework":111,"meta":440,"navigation":441,"pack":60,"path":442,"ruleId":61,"rulePath":62,"seo":443,"severity":63,"source":64,"sourceUrl":65,"stem":444,"why":445,"__hash__":446},"diagnostics\u002Fdiagnostics\u002FVUE0034.md","VUE0034: Derive state with computed() instead of a watcher",{"type":52,"value":53,"toc":426},"minimark",[54,66,71,84,88,94,98,103,106,264,267,350,354,357,394,398,410,414,422],[55,56],"rule-metadata",{"category":57,"docsUrl":58,"fix":59,"pack":60,"ruleId":61,"rulePath":62,"severity":63,"source":64,"sourceUrl":65},"reactivity","https:\u002F\u002Fvuejs.org\u002Fguide\u002Fessentials\u002Fcomputed.html","suggestion","vite-doctor\u002Fvue","vue\u002Freactivity\u002Fprefer-computed-over-watch-assign","\u002Fvue\u002Frules\u002Freactivity\u002Fprefer-computed-over-watch-assign","warn","src\u002Frule-packs\u002Fvue\u002Frules\u002Fvue\u002Fprefer-computed-over-watch-assign.ts","https:\u002F\u002Fgithub.com\u002Fonmax\u002Fvite-doctor\u002Fblob\u002Fmain\u002Fsrc\u002Frule-packs\u002Fvue\u002Frules\u002Fvue\u002Fprefer-computed-over-watch-assign.ts",[67,68,70],"h2",{"id":69},"why-it-happens","Why it happens",[72,73,74,75,79,80,83],"p",{},"A ref fed by a watcher is a second copy of derived state. A ",[76,77,78],"code",{},"watch()"," without immediate does not run until a source changes, and Vue skips it entirely during server rendering, so the ref keeps its initial value until then. Other watchers write the ref in a later flush, so code that reads it right after changing a source sees the old value. ",[76,81,82],{},"computed()"," derives the value on read, caches it, and cannot drift from its sources.",[67,85,87],{"id":86},"fix","Fix",[72,89,90,91,93],{},"Replace the ref and the watcher with a ",[76,92,82],{},". This Rule is in the strict preset: a non-immediate watcher also skips its first run on the client, so server and client render the same initial value and the pattern is a design choice, not a hydration defect.",[67,95,97],{"id":96},"example","Example",[99,100,102],"h3",{"id":101},"derive-state-with-computed","Derive state with computed()",[72,104,105],{},"Before",[107,108,113],"pre",{"className":109,"code":110,"language":111,"meta":112,"style":112},"language-vue shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003Cscript setup lang=\"ts\">\nconst count = ref(1)\nconst doubled = ref(0)\nwatch(count, (value) => {\n  doubled.value = value * 2\n})\n\u003C\u002Fscript>\n","vue","",[76,114,115,150,176,195,223,246,254],{"__ignoreMap":112},[116,117,120,124,128,132,135,138,141,145,147],"span",{"class":118,"line":119},"line",1,[116,121,123],{"class":122},"sMK4o","\u003C",[116,125,127],{"class":126},"swJcz","script",[116,129,131],{"class":130},"spNyl"," setup",[116,133,134],{"class":130}," lang",[116,136,137],{"class":122},"=",[116,139,140],{"class":122},"\"",[116,142,144],{"class":143},"sfazB","ts",[116,146,140],{"class":122},[116,148,149],{"class":122},">\n",[116,151,153,156,160,162,166,169,173],{"class":118,"line":152},2,[116,154,155],{"class":130},"const",[116,157,159],{"class":158},"sTEyZ"," count ",[116,161,137],{"class":122},[116,163,165],{"class":164},"s2Zo4"," ref",[116,167,168],{"class":158},"(",[116,170,172],{"class":171},"sbssI","1",[116,174,175],{"class":158},")\n",[116,177,179,181,184,186,188,190,193],{"class":118,"line":178},3,[116,180,155],{"class":130},[116,182,183],{"class":158}," doubled ",[116,185,137],{"class":122},[116,187,165],{"class":164},[116,189,168],{"class":158},[116,191,192],{"class":171},"0",[116,194,175],{"class":158},[116,196,198,201,204,207,210,214,217,220],{"class":118,"line":197},4,[116,199,200],{"class":164},"watch",[116,202,203],{"class":158},"(count",[116,205,206],{"class":122},",",[116,208,209],{"class":122}," (",[116,211,213],{"class":212},"sHdIc","value",[116,215,216],{"class":122},")",[116,218,219],{"class":130}," =>",[116,221,222],{"class":122}," {\n",[116,224,226,229,232,234,237,240,243],{"class":118,"line":225},5,[116,227,228],{"class":158},"  doubled",[116,230,231],{"class":122},".",[116,233,213],{"class":158},[116,235,236],{"class":122}," =",[116,238,239],{"class":158}," value",[116,241,242],{"class":122}," *",[116,244,245],{"class":171}," 2\n",[116,247,249,252],{"class":118,"line":248},6,[116,250,251],{"class":122},"}",[116,253,175],{"class":158},[116,255,257,260,262],{"class":118,"line":256},7,[116,258,259],{"class":122},"\u003C\u002F",[116,261,127],{"class":126},[116,263,149],{"class":122},[72,265,266],{},"After",[107,268,270],{"className":109,"code":269,"language":111,"meta":112,"style":112},"\u003Cscript setup lang=\"ts\">\nconst count = ref(1)\nconst doubled = computed(() => count.value * 2)\n\u003C\u002Fscript>\n",[76,271,272,292,308,342],{"__ignoreMap":112},[116,273,274,276,278,280,282,284,286,288,290],{"class":118,"line":119},[116,275,123],{"class":122},[116,277,127],{"class":126},[116,279,131],{"class":130},[116,281,134],{"class":130},[116,283,137],{"class":122},[116,285,140],{"class":122},[116,287,144],{"class":143},[116,289,140],{"class":122},[116,291,149],{"class":122},[116,293,294,296,298,300,302,304,306],{"class":118,"line":152},[116,295,155],{"class":130},[116,297,159],{"class":158},[116,299,137],{"class":122},[116,301,165],{"class":164},[116,303,168],{"class":158},[116,305,172],{"class":171},[116,307,175],{"class":158},[116,309,310,312,314,316,319,321,324,326,329,331,334,337,340],{"class":118,"line":178},[116,311,155],{"class":130},[116,313,183],{"class":158},[116,315,137],{"class":122},[116,317,318],{"class":164}," computed",[116,320,168],{"class":158},[116,322,323],{"class":122},"()",[116,325,219],{"class":130},[116,327,328],{"class":158}," count",[116,330,231],{"class":122},[116,332,333],{"class":158},"value ",[116,335,336],{"class":122},"*",[116,338,339],{"class":171}," 2",[116,341,175],{"class":158},[116,343,344,346,348],{"class":118,"line":197},[116,345,259],{"class":122},[116,347,127],{"class":126},[116,349,149],{"class":122},[67,351,353],{"id":352},"verify-the-fix","Verify the fix",[72,355,356],{},"Run only this rule after editing so the report stays focused on the diagnostic you are closing:",[107,358,362],{"className":359,"code":360,"language":361,"meta":112,"style":112},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pnpm vite-doctor . --framework vue --extends auto,vue\u002Fstrict --rules vue\u002Freactivity\u002Fprefer-computed-over-watch-assign\n","bash",[76,363,364],{"__ignoreMap":112},[116,365,366,370,373,376,379,382,385,388,391],{"class":118,"line":119},[116,367,369],{"class":368},"sBMFI","pnpm",[116,371,372],{"class":143}," vite-doctor",[116,374,375],{"class":143}," .",[116,377,378],{"class":143}," --framework",[116,380,381],{"class":143}," vue",[116,383,384],{"class":143}," --extends",[116,386,387],{"class":143}," auto,vue\u002Fstrict",[116,389,390],{"class":143}," --rules",[116,392,393],{"class":143}," vue\u002Freactivity\u002Fprefer-computed-over-watch-assign\n",[67,395,397],{"id":396},"useful-links","Useful links",[399,400,401],"ul",{},[402,403,404],"li",{},[405,406,409],"a",{"href":58,"rel":407},[408],"nofollow","Upstream docs",[67,411,413],{"id":412},"related-rule","Related rule",[399,415,416],{},[402,417,418],{},[405,419,420],{"href":62},[76,421,61],{},[423,424,425],"style",{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}",{"title":112,"searchDepth":152,"depth":152,"links":427},[428,429,430,433,434,435],{"id":69,"depth":152,"text":70},{"id":86,"depth":152,"text":87},{"id":96,"depth":152,"text":97,"children":431},[432],{"id":101,"depth":178,"text":102},{"id":352,"depth":152,"text":353},{"id":396,"depth":152,"text":397},{"id":412,"depth":152,"text":413},"VUE0034","Finds watchers whose only effect is assigning a value derived from their sources to a local ref.","md","Replace the ref and the watcher with a computed(). This Rule is in the strict preset: a non-immediate watcher also skips its first run on the client, so server and client render the same initial value and the pattern is a design choice, not a hydration defect.",{},true,"\u002Fdiagnostics\u002Fvue0034",{"title":50,"description":437},"diagnostics\u002FVUE0034","A ref fed by a watcher is a second copy of derived state. A watch() without immediate does not run until a source changes, and Vue skips it entirely during server rendering, so the ref keeps its initial value until then. Other watchers write the ref in a later flush, so code that reads it right after changing a source sees the old value. computed() derives the value on read, caches it, and cannot drift from its sources.","EByOkjnp4tGA9wZrklKoV_PTLy3aRtusAquBGFm-j_g",1795268812236]