[{"data":1,"prerenderedAt":428,"buildId":429},["ShallowReactive",2],{"diagnostic-content-NUXT0097":3,"navigation_docs":327},{"id":4,"title":5,"body":6,"category":12,"code":316,"description":317,"docsUrl":13,"extension":318,"fix":319,"framework":320,"meta":321,"navigation":130,"pack":15,"path":322,"ruleId":16,"rulePath":17,"seo":323,"severity":18,"source":19,"sourceUrl":20,"stem":324,"why":325,"__hash__":326},"diagnostics\u002Fdiagnostics\u002FNUXT0097.md","NUXT0097: Initialize each useState key in one place",{"type":7,"value":8,"toc":306},"minimark",[9,21,26,34,38,48,52,57,60,168,171,242,246,249,274,278,290,294,302],[10,11],"rule-metadata",{"category":12,"docsUrl":13,"fix":14,"pack":15,"ruleId":16,"rulePath":17,"severity":18,"source":19,"sourceUrl":20},"state","https:\u002F\u002Fnuxt.com\u002Fdocs\u002F4.x\u002Fapi\u002Fcomposables\u002Fuse-state#usage","suggestion","vite-doctor\u002Fnuxt","nuxt\u002Fstate\u002Fno-diverging-usestate-init","\u002Fnuxt\u002Frules\u002Fstate\u002Fno-diverging-usestate-init","warn","src\u002Frule-packs\u002Fnuxt\u002Frules\u002Fnuxt\u002Fno-diverging-usestate-init.ts","https:\u002F\u002Fgithub.com\u002Fwords-with-agents\u002Fvite-doctor\u002Fblob\u002Fmain\u002Fsrc\u002Frule-packs\u002Fnuxt\u002Frules\u002Fnuxt\u002Fno-diverging-usestate-init.ts",[22,23,25],"h2",{"id":24},"why-it-happens","Why it happens",[27,28,29,33],"p",{},[30,31,32],"code",{},"useState(key, init)"," runs init only while the key has no value. Once one initializer sets the value, the others are ignored, so route and render order can change the starting value. Doctor compares initializers for string-literal keys within each Nuxt app and its layers, ignoring formatting that does not change the parsed syntax. Read-only calls and dynamic keys are not reported.",[22,35,37],{"id":36},"fix","Fix",[27,39,40,41,44,45,47],{},"Put the state in one composable, such as export const useCount = () => ",[30,42,43],{},"useState('count', ()"," => 0), and call it everywhere instead of repeating ",[30,46,32],{},". If the call sites mean different state, give each its own key rather than aligning the initializers.",[22,49,51],{"id":50},"example","Example",[53,54,56],"h3",{"id":55},"initialize-the-state-in-one-composable","Initialize the state in one composable",[27,58,59],{},"Before",[61,62,67],"pre",{"className":63,"code":64,"language":65,"meta":66,"style":66},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F app\u002Fpages\u002Findex.vue\nconst count = useState('count', () => 0)\n\n\u002F\u002F app\u002Fcomponents\u002FCounter.vue\nconst count = useState('count', () => 10)\n","ts","",[30,68,69,78,125,132,138],{"__ignoreMap":66},[70,71,74],"span",{"class":72,"line":73},"line",1,[70,75,77],{"class":76},"sHwdD","\u002F\u002F app\u002Fpages\u002Findex.vue\n",[70,79,81,85,89,93,97,100,103,107,109,112,115,118,122],{"class":72,"line":80},2,[70,82,84],{"class":83},"spNyl","const",[70,86,88],{"class":87},"sTEyZ"," count ",[70,90,92],{"class":91},"sMK4o","=",[70,94,96],{"class":95},"s2Zo4"," useState",[70,98,99],{"class":87},"(",[70,101,102],{"class":91},"'",[70,104,106],{"class":105},"sfazB","count",[70,108,102],{"class":91},[70,110,111],{"class":91},",",[70,113,114],{"class":91}," ()",[70,116,117],{"class":83}," =>",[70,119,121],{"class":120},"sbssI"," 0",[70,123,124],{"class":87},")\n",[70,126,128],{"class":72,"line":127},3,[70,129,131],{"emptyLinePlaceholder":130},true,"\n",[70,133,135],{"class":72,"line":134},4,[70,136,137],{"class":76},"\u002F\u002F app\u002Fcomponents\u002FCounter.vue\n",[70,139,141,143,145,147,149,151,153,155,157,159,161,163,166],{"class":72,"line":140},5,[70,142,84],{"class":83},[70,144,88],{"class":87},[70,146,92],{"class":91},[70,148,96],{"class":95},[70,150,99],{"class":87},[70,152,102],{"class":91},[70,154,106],{"class":105},[70,156,102],{"class":91},[70,158,111],{"class":91},[70,160,114],{"class":91},[70,162,117],{"class":83},[70,164,165],{"class":120}," 10",[70,167,124],{"class":87},[27,169,170],{},"After",[61,172,174],{"className":63,"code":173,"language":65,"meta":66,"style":66},"\u002F\u002F app\u002Fcomposables\u002FuseCount.ts\nexport const useCount = () => useState('count', () => 0)\n\n\u002F\u002F app\u002Fpages\u002Findex.vue, app\u002Fcomponents\u002FCounter.vue\nconst count = useCount()\n",[30,175,176,181,219,223,228],{"__ignoreMap":66},[70,177,178],{"class":72,"line":73},[70,179,180],{"class":76},"\u002F\u002F app\u002Fcomposables\u002FuseCount.ts\n",[70,182,183,187,190,193,195,197,199,201,203,205,207,209,211,213,215,217],{"class":72,"line":80},[70,184,186],{"class":185},"s7zQu","export",[70,188,189],{"class":83}," const",[70,191,192],{"class":87}," useCount ",[70,194,92],{"class":91},[70,196,114],{"class":91},[70,198,117],{"class":83},[70,200,96],{"class":95},[70,202,99],{"class":87},[70,204,102],{"class":91},[70,206,106],{"class":105},[70,208,102],{"class":91},[70,210,111],{"class":91},[70,212,114],{"class":91},[70,214,117],{"class":83},[70,216,121],{"class":120},[70,218,124],{"class":87},[70,220,221],{"class":72,"line":127},[70,222,131],{"emptyLinePlaceholder":130},[70,224,225],{"class":72,"line":134},[70,226,227],{"class":76},"\u002F\u002F app\u002Fpages\u002Findex.vue, app\u002Fcomponents\u002FCounter.vue\n",[70,229,230,232,234,236,239],{"class":72,"line":140},[70,231,84],{"class":83},[70,233,88],{"class":87},[70,235,92],{"class":91},[70,237,238],{"class":95}," useCount",[70,240,241],{"class":87},"()\n",[22,243,245],{"id":244},"verify-the-fix","Verify the fix",[27,247,248],{},"Run only this rule after editing so the report stays focused on the diagnostic you are closing:",[61,250,254],{"className":251,"code":252,"language":253,"meta":66,"style":66},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pnpm nuxt doctor --rules nuxt\u002Fstate\u002Fno-diverging-usestate-init\n","bash",[30,255,256],{"__ignoreMap":66},[70,257,258,262,265,268,271],{"class":72,"line":73},[70,259,261],{"class":260},"sBMFI","pnpm",[70,263,264],{"class":105}," nuxt",[70,266,267],{"class":105}," doctor",[70,269,270],{"class":105}," --rules",[70,272,273],{"class":105}," nuxt\u002Fstate\u002Fno-diverging-usestate-init\n",[22,275,277],{"id":276},"useful-links","Useful links",[279,280,281],"ul",{},[282,283,284],"li",{},[285,286,289],"a",{"href":13,"rel":287},[288],"nofollow","Upstream docs",[22,291,293],{"id":292},"related-rule","Related rule",[279,295,296],{},[282,297,298],{},[285,299,300],{"href":17},[30,301,16],{},[303,304,305],"style",{},"html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}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 .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}",{"title":66,"searchDepth":80,"depth":80,"links":307},[308,309,310,313,314,315],{"id":24,"depth":80,"text":25},{"id":36,"depth":80,"text":37},{"id":50,"depth":80,"text":51,"children":311},[312],{"id":55,"depth":127,"text":56},{"id":244,"depth":80,"text":245},{"id":276,"depth":80,"text":277},{"id":292,"depth":80,"text":293},"NUXT0097","Finds a useState() key that two or more call sites initialize with different functions.","md","Put the state in one composable, such as export const useCount = () => useState('count', () => 0), and call it everywhere instead of repeating useState(key, init). If the call sites mean different state, give each its own key rather than aligning the initializers.","nuxt",{},"\u002Fdiagnostics\u002Fnuxt0097",{"title":5,"description":317},"diagnostics\u002FNUXT0097","useState(key, init) runs init only while the key has no value. Once one initializer sets the value, the others are ignored, so route and render order can change the starting value. Doctor compares initializers for string-literal keys within each Nuxt app and its layers, ignoring formatting that does not change the parsed syntax. Read-only calls and dynamic keys are not reported.","JpPww2cKxudoWP4j9wKRu3BTEKfaL5jKulvlkSWPM1c",[328,356,360,364,368,372,376,388,392,416,420,424],{"title":329,"path":330,"stem":331,"children":332,"icon":355},"CLI","\u002Fcli","1.cli\u002F1.index",[333,335,339,343,347,351],{"title":334,"path":330,"stem":331},"Run Doctor",{"title":336,"path":337,"stem":338},"Reports","\u002Fcli\u002Freports","1.cli\u002F2.reports",{"title":340,"path":341,"stem":342},"Configuration","\u002Fcli\u002Fconfiguration","1.cli\u002F3.configuration",{"title":344,"path":345,"stem":346},"CI and changed files","\u002Fcli\u002Fci","1.cli\u002F4.ci",{"title":348,"path":349,"stem":350},"Workspaces","\u002Fcli\u002Fworkspaces","1.cli\u002F5.workspaces",{"title":352,"path":353,"stem":354},"Cache and speed","\u002Fcli\u002Fcache","1.cli\u002F6.cache","i-lucide-terminal",{"title":357,"path":358,"stem":359},"Nuxt","\u002Fnuxt","2.nuxt",{"title":361,"path":362,"stem":363},"Vue","\u002Fvue","3.vue",{"title":365,"path":366,"stem":367},"Vite","\u002Fvite","4.vite",{"title":369,"path":370,"stem":371},"Nitro","\u002Fnitro","5.nitro",{"title":373,"path":374,"stem":375},"TypeScript","\u002Ftypescript","6.typescript",{"title":377,"path":378,"stem":379,"children":380,"icon":387},"Design system","\u002Fdesign-system","7.design-system\u002F1.index",[381,383],{"title":382,"path":378,"stem":379},"Overview",{"title":384,"path":385,"stem":386},"Classes and styles","\u002Fdesign-system\u002Fclasses","7.design-system\u002F2.classes","i-lucide-swatch-book",{"title":389,"path":390,"stem":391},"Package","\u002Fpackage","8.package",{"title":393,"path":394,"stem":395,"children":396,"icon":415},"Extending Doctor","\u002Fextending","9.extending\u002F1.index",[397,399,403,407,411],{"title":398,"path":394,"stem":395},"Write an extension",{"title":400,"path":401,"stem":402},"Visitors","\u002Fextending\u002Fvisitors","9.extending\u002F2.visitors",{"title":404,"path":405,"stem":406},"Ship with a library","\u002Fextending\u002Fshipping","9.extending\u002F3.shipping",{"title":408,"path":409,"stem":410},"Test a Rule","\u002Fextending\u002Ftesting","9.extending\u002F4.testing",{"title":412,"path":413,"stem":414},"Rule inputs","\u002Fextending\u002Frule-inputs","9.extending\u002F5.rule-inputs","i-lucide-puzzle",{"title":417,"path":418,"stem":419},"H3","\u002Fh3","9.h3",{"title":421,"path":422,"stem":423},"MCP","\u002Fmodel-context-protocol","9.model-context-protocol",{"title":425,"path":426,"stem":427},"Pinia","\u002Fpinia","9.pinia",1796507790419,"e745db9b-2064-477e-b678-8c0a05edc39c"]