[{"data":1,"prerenderedAt":475,"buildId":476},["ShallowReactive",2],{"diagnostic-content-PINIA0006":3,"navigation_docs":374},{"id":4,"title":5,"body":6,"category":12,"code":363,"description":364,"docsUrl":13,"extension":365,"fix":366,"framework":367,"meta":368,"navigation":110,"pack":15,"path":369,"ruleId":16,"rulePath":17,"seo":370,"severity":18,"source":19,"sourceUrl":20,"stem":371,"why":372,"__hash__":373},"diagnostics\u002Fdiagnostics\u002FPINIA0006.md","PINIA0006: Call stores inside setup or functions, not at module scope",{"type":7,"value":8,"toc":353},"minimark",[9,21,26,42,46,60,64,69,72,204,207,289,293,296,321,325,337,341,349],[10,11],"rule-metadata",{"category":12,"docsUrl":13,"fix":14,"pack":15,"ruleId":16,"rulePath":17,"severity":18,"source":19,"sourceUrl":20},"stores","https:\u002F\u002Fpinia.vuejs.org\u002Fcore-concepts\u002Foutside-component-usage.html","no","vite-doctor\u002Fpinia","pinia\u002Fstores\u002Fno-module-scope-store","\u002Fpinia\u002Frules\u002Fstores\u002Fno-module-scope-store","warn","src\u002Frule-packs\u002Fpinia\u002Frules\u002Fno-module-scope-store.ts","https:\u002F\u002Fgithub.com\u002Fwords-with-agents\u002Fvite-doctor\u002Fblob\u002Fmain\u002Fsrc\u002Frule-packs\u002Fpinia\u002Frules\u002Fno-module-scope-store.ts",[22,23,25],"h2",{"id":24},"why-it-happens","Why it happens",[27,28,29,33,34,37,38,41],"p",{},[30,31,32],"code",{},"useXStore()"," finds its Pinia instance through the current app's injection context, falling back to the active Pinia. At module scope there is no app context: before app.",[30,35,36],{},"use(pinia)"," runs, Pinia throws \"",[30,39,40],{},"getActivePinia()","\" was called but there was no active Pinia, and with server-side rendering the module runs once per server process, so every request shares the store it got.",[22,43,45],{"id":44},"fix","Fix",[27,47,48,49,51,52,55,56,59],{},"Move the ",[30,50,32],{}," call into the function that needs the store: ",[30,53,54],{},"\u003Cscript setup>",", ",[30,57,58],{},"setup()",", a composable, a store action, a router guard, or a Nuxt plugin or middleware callback.",[22,61,63],{"id":62},"example","Example",[65,66,68],"h3",{"id":67},"call-the-store-inside-the-guard-that-uses-it","Call the store inside the guard that uses it",[27,70,71],{},"Before",[73,74,79],"pre",{"className":75,"code":76,"language":77,"meta":78,"style":78},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const user = useUserStore()\n\nrouter.beforeEach((to) => {\n  if (to.meta.requiresAuth && !user.isLoggedIn) return '\u002Flogin'\n})\n","ts","",[30,80,81,105,112,142,195],{"__ignoreMap":78},[82,83,86,90,94,98,102],"span",{"class":84,"line":85},"line",1,[82,87,89],{"class":88},"spNyl","const",[82,91,93],{"class":92},"sTEyZ"," user ",[82,95,97],{"class":96},"sMK4o","=",[82,99,101],{"class":100},"s2Zo4"," useUserStore",[82,103,104],{"class":92},"()\n",[82,106,108],{"class":84,"line":107},2,[82,109,111],{"emptyLinePlaceholder":110},true,"\n",[82,113,115,118,121,124,127,129,133,136,139],{"class":84,"line":114},3,[82,116,117],{"class":92},"router",[82,119,120],{"class":96},".",[82,122,123],{"class":100},"beforeEach",[82,125,126],{"class":92},"(",[82,128,126],{"class":96},[82,130,132],{"class":131},"sHdIc","to",[82,134,135],{"class":96},")",[82,137,138],{"class":88}," =>",[82,140,141],{"class":96}," {\n",[82,143,145,149,153,155,157,160,162,165,168,171,174,176,179,182,185,188,192],{"class":84,"line":144},4,[82,146,148],{"class":147},"s7zQu","  if",[82,150,152],{"class":151},"swJcz"," (",[82,154,132],{"class":92},[82,156,120],{"class":96},[82,158,159],{"class":92},"meta",[82,161,120],{"class":96},[82,163,164],{"class":92},"requiresAuth",[82,166,167],{"class":96}," &&",[82,169,170],{"class":96}," !",[82,172,173],{"class":92},"user",[82,175,120],{"class":96},[82,177,178],{"class":92},"isLoggedIn",[82,180,181],{"class":151},") ",[82,183,184],{"class":147},"return",[82,186,187],{"class":96}," '",[82,189,191],{"class":190},"sfazB","\u002Flogin",[82,193,194],{"class":96},"'\n",[82,196,198,201],{"class":84,"line":197},5,[82,199,200],{"class":96},"}",[82,202,203],{"class":92},")\n",[27,205,206],{},"After",[73,208,210],{"className":75,"code":209,"language":77,"meta":78,"style":78},"router.beforeEach((to) => {\n  const user = useUserStore()\n  if (to.meta.requiresAuth && !user.isLoggedIn) return '\u002Flogin'\n})\n",[30,211,212,232,247,283],{"__ignoreMap":78},[82,213,214,216,218,220,222,224,226,228,230],{"class":84,"line":85},[82,215,117],{"class":92},[82,217,120],{"class":96},[82,219,123],{"class":100},[82,221,126],{"class":92},[82,223,126],{"class":96},[82,225,132],{"class":131},[82,227,135],{"class":96},[82,229,138],{"class":88},[82,231,141],{"class":96},[82,233,234,237,240,243,245],{"class":84,"line":107},[82,235,236],{"class":88},"  const",[82,238,239],{"class":92}," user",[82,241,242],{"class":96}," =",[82,244,101],{"class":100},[82,246,104],{"class":151},[82,248,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281],{"class":84,"line":114},[82,250,148],{"class":147},[82,252,152],{"class":151},[82,254,132],{"class":92},[82,256,120],{"class":96},[82,258,159],{"class":92},[82,260,120],{"class":96},[82,262,164],{"class":92},[82,264,167],{"class":96},[82,266,170],{"class":96},[82,268,173],{"class":92},[82,270,120],{"class":96},[82,272,178],{"class":92},[82,274,181],{"class":151},[82,276,184],{"class":147},[82,278,187],{"class":96},[82,280,191],{"class":190},[82,282,194],{"class":96},[82,284,285,287],{"class":84,"line":144},[82,286,200],{"class":96},[82,288,203],{"class":92},[22,290,292],{"id":291},"verify-the-fix","Verify the fix",[27,294,295],{},"Run only this rule after editing so the report stays focused on the diagnostic you are closing:",[73,297,301],{"className":298,"code":299,"language":300,"meta":78,"style":78},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pnpm vite-doctor . --rules pinia\u002Fstores\u002Fno-module-scope-store\n","bash",[30,302,303],{"__ignoreMap":78},[82,304,305,309,312,315,318],{"class":84,"line":85},[82,306,308],{"class":307},"sBMFI","pnpm",[82,310,311],{"class":190}," vite-doctor",[82,313,314],{"class":190}," .",[82,316,317],{"class":190}," --rules",[82,319,320],{"class":190}," pinia\u002Fstores\u002Fno-module-scope-store\n",[22,322,324],{"id":323},"useful-links","Useful links",[326,327,328],"ul",{},[329,330,331],"li",{},[332,333,336],"a",{"href":13,"rel":334},[335],"nofollow","Upstream docs",[22,338,340],{"id":339},"related-rule","Related rule",[326,342,343],{},[329,344,345],{},[332,346,347],{"href":17},[30,348,16],{},[350,351,352],"style",{},"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 .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 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 .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}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":78,"searchDepth":107,"depth":107,"links":354},[355,356,357,360,361,362],{"id":24,"depth":107,"text":25},{"id":44,"depth":107,"text":45},{"id":62,"depth":107,"text":63,"children":358},[359],{"id":67,"depth":114,"text":68},{"id":291,"depth":107,"text":292},{"id":323,"depth":107,"text":324},{"id":339,"depth":107,"text":340},"PINIA0006","Report useXStore() calls that run when a module is first imported instead of inside setup, a composable, an action, or a callback.","md","Move the useXStore() call into the function that needs the store: \u003Cscript setup>, setup(), a composable, a store action, a router guard, or a Nuxt plugin or middleware callback.","pinia",{},"\u002Fdiagnostics\u002Fpinia0006",{"title":5,"description":364},"diagnostics\u002FPINIA0006","useXStore() finds its Pinia instance through the current app's injection context, falling back to the active Pinia. At module scope there is no app context: before app.use(pinia) runs, Pinia throws \"getActivePinia()\" was called but there was no active Pinia, and with server-side rendering the module runs once per server process, so every request shares the store it got.","52gfgYu39nckR5NvwLlhpFE5VVrMlEGEMbum-RpGYD4",[375,403,407,411,415,419,423,435,439,463,467,471],{"title":376,"path":377,"stem":378,"children":379,"icon":402},"CLI","\u002Fcli","1.cli\u002F1.index",[380,382,386,390,394,398],{"title":381,"path":377,"stem":378},"Run Doctor",{"title":383,"path":384,"stem":385},"Reports","\u002Fcli\u002Freports","1.cli\u002F2.reports",{"title":387,"path":388,"stem":389},"Configuration","\u002Fcli\u002Fconfiguration","1.cli\u002F3.configuration",{"title":391,"path":392,"stem":393},"CI and changed files","\u002Fcli\u002Fci","1.cli\u002F4.ci",{"title":395,"path":396,"stem":397},"Workspaces","\u002Fcli\u002Fworkspaces","1.cli\u002F5.workspaces",{"title":399,"path":400,"stem":401},"Cache and speed","\u002Fcli\u002Fcache","1.cli\u002F6.cache","i-lucide-terminal",{"title":404,"path":405,"stem":406},"Nuxt","\u002Fnuxt","2.nuxt",{"title":408,"path":409,"stem":410},"Vue","\u002Fvue","3.vue",{"title":412,"path":413,"stem":414},"Vite","\u002Fvite","4.vite",{"title":416,"path":417,"stem":418},"Nitro","\u002Fnitro","5.nitro",{"title":420,"path":421,"stem":422},"TypeScript","\u002Ftypescript","6.typescript",{"title":424,"path":425,"stem":426,"children":427,"icon":434},"Design system","\u002Fdesign-system","7.design-system\u002F1.index",[428,430],{"title":429,"path":425,"stem":426},"Overview",{"title":431,"path":432,"stem":433},"Classes and styles","\u002Fdesign-system\u002Fclasses","7.design-system\u002F2.classes","i-lucide-swatch-book",{"title":436,"path":437,"stem":438},"Package","\u002Fpackage","8.package",{"title":440,"path":441,"stem":442,"children":443,"icon":462},"Extending Doctor","\u002Fextending","9.extending\u002F1.index",[444,446,450,454,458],{"title":445,"path":441,"stem":442},"Write an extension",{"title":447,"path":448,"stem":449},"Visitors","\u002Fextending\u002Fvisitors","9.extending\u002F2.visitors",{"title":451,"path":452,"stem":453},"Ship with a library","\u002Fextending\u002Fshipping","9.extending\u002F3.shipping",{"title":455,"path":456,"stem":457},"Test a Rule","\u002Fextending\u002Ftesting","9.extending\u002F4.testing",{"title":459,"path":460,"stem":461},"Rule inputs","\u002Fextending\u002Frule-inputs","9.extending\u002F5.rule-inputs","i-lucide-puzzle",{"title":464,"path":465,"stem":466},"H3","\u002Fh3","9.h3",{"title":468,"path":469,"stem":470},"MCP","\u002Fmodel-context-protocol","9.model-context-protocol",{"title":472,"path":473,"stem":474},"Pinia","\u002Fpinia","9.pinia",1796507794379,"e745db9b-2064-477e-b678-8c0a05edc39c"]