[{"data":1,"prerenderedAt":464},["ShallowReactive",2],{"navigation_docs":3,"rule-content-\u002Ftypescript\u002Frules\u002Fboundaries\u002Fno-cross-realm-builtin-instanceof":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,"description":451,"diagnosticCodes":452,"docsUrl":59,"extension":453,"fix":60,"framework":454,"meta":455,"navigation":456,"pack":61,"path":458,"recommendedReplacement":459,"ruleId":62,"seo":460,"severity":63,"source":64,"sourceUrl":65,"stem":461,"why":462,"__hash__":463},"rules\u002Ftypescript\u002Frules\u002Fboundaries\u002Fno-cross-realm-builtin-instanceof.md","Do not use instanceof for JavaScript built-ins from another realm",{"type":52,"value":53,"toc":442},"minimark",[54,66,71,109,113,129,133,154,158,170,174,179,182,282,285,438],[55,56],"rule-metadata",{"category":57,"diagnosticCodes":58,"docsUrl":59,"fix":60,"pack":61,"ruleId":62,"severity":63,"source":64,"sourceUrl":65},"boundaries","TS0016","https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FOperators\u002Finstanceof#instanceof_and_multiple_realms","structural-review","vite-doctor\u002Ftypescript","typescript\u002Fboundaries\u002Fno-cross-realm-builtin-instanceof","warn","src\u002Frule-packs\u002Ftypescript\u002Frules\u002Fno-cross-realm-builtin-instanceof.ts","https:\u002F\u002Fgithub.com\u002Fonmax\u002Fvite-doctor\u002Fblob\u002Fmain\u002Fsrc\u002Frule-packs\u002Ftypescript\u002Frules\u002Fno-cross-realm-builtin-instanceof.ts",[67,68,70],"h2",{"id":69},"run-this-rule","Run this rule",[72,73,78],"pre",{"className":74,"code":75,"language":76,"meta":77,"style":77},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pnpm vite-doctor . --extends auto,typescript\u002Fstrict --rules typescript\u002Fboundaries\u002Fno-cross-realm-builtin-instanceof\n","bash","",[79,80,81],"code",{"__ignoreMap":77},[82,83,86,90,94,97,100,103,106],"span",{"class":84,"line":85},"line",1,[82,87,89],{"class":88},"sBMFI","pnpm",[82,91,93],{"class":92},"sfazB"," vite-doctor",[82,95,96],{"class":92}," .",[82,98,99],{"class":92}," --extends",[82,101,102],{"class":92}," auto,typescript\u002Fstrict",[82,104,105],{"class":92}," --rules",[82,107,108],{"class":92}," typescript\u002Fboundaries\u002Fno-cross-realm-builtin-instanceof\n",[67,110,112],{"id":111},"why-it-matters","Why it matters",[114,115,116,117,120,121,124,125,128],"p",{},"Error, Date, Map, Set, RegExp, Promise, Array, Function and Object have one constructor per realm. A value created in a node:vm context, an iframe, or a Vitest vmThreads or vmForks pool fails instanceof against this realm's class, so the check takes the wrong branch. Values from the Vite module runner, a duplicated package, a worker or ",[79,118,119],{},"structuredClone()"," are built with this realm's built-ins, so most of these checks never see a foreign value, and the rule reports them at low confidence. It only reports values that crossed a boundary in this file: parameters typed unknown or any, results of calling a parameter, and module namespaces from ",[79,122,123],{},"import()"," or ",[79,126,127],{},"ssrLoadModule()",". A parameter of a function that the file neither exports nor passes around is skipped when every call passes a value proven local, such as a literal or an object constructed with an unshadowed built-in. Catching an error does not establish its origin.",[67,130,132],{"id":131},"recommended-fix","Recommended fix",[114,134,135,136,139,140,143,144,147,148,124,150,153],{},"Use the realm-safe check: Array.",[79,137,138],{},"isArray(value)"," for arrays, typeof value === 'function' for functions, Error.",[79,141,142],{},"isError(value)"," or an Object.prototype.toString.",[79,145,146],{},"call(value)"," brand check in a guard helper such as ",[79,149,142],{},[79,151,152],{},"isDate(value)"," for the rest.",[67,155,157],{"id":156},"useful-links","Useful links",[159,160,161],"ul",{},[162,163,164],"li",{},[165,166,169],"a",{"href":59,"rel":167},[168],"nofollow","Rule reference",[67,171,173],{"id":172},"example","Example",[175,176,178],"h3",{"id":177},"brand-check-errors-from-a-sandbox","Brand-check errors from a sandbox",[114,180,181],{},"Before",[72,183,187],{"className":184,"code":185,"language":186,"meta":77,"style":77},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","export function toSandboxError(error: unknown): Error {\n  if (error instanceof Error) return error\n  return new Error(String(error))\n}\n","ts",[79,188,189,226,253,276],{"__ignoreMap":77},[82,190,191,195,199,203,207,211,214,217,220,223],{"class":84,"line":85},[82,192,194],{"class":193},"s7zQu","export",[82,196,198],{"class":197},"spNyl"," function",[82,200,202],{"class":201},"s2Zo4"," toSandboxError",[82,204,206],{"class":205},"sMK4o","(",[82,208,210],{"class":209},"sHdIc","error",[82,212,213],{"class":205},":",[82,215,216],{"class":88}," unknown",[82,218,219],{"class":205},"):",[82,221,222],{"class":88}," Error",[82,224,225],{"class":205}," {\n",[82,227,229,232,236,239,242,244,247,250],{"class":84,"line":228},2,[82,230,231],{"class":193},"  if",[82,233,235],{"class":234},"swJcz"," (",[82,237,210],{"class":238},"sTEyZ",[82,240,241],{"class":205}," instanceof",[82,243,222],{"class":88},[82,245,246],{"class":234},") ",[82,248,249],{"class":193},"return",[82,251,252],{"class":238}," error\n",[82,254,256,259,262,264,266,269,271,273],{"class":84,"line":255},3,[82,257,258],{"class":193},"  return",[82,260,261],{"class":205}," new",[82,263,222],{"class":201},[82,265,206],{"class":234},[82,267,268],{"class":201},"String",[82,270,206],{"class":234},[82,272,210],{"class":238},[82,274,275],{"class":234},"))\n",[82,277,279],{"class":84,"line":278},4,[82,280,281],{"class":205},"}\n",[114,283,284],{},"After",[72,286,288],{"className":184,"code":287,"language":186,"meta":77,"style":77},"function isError(value: unknown): value is Error {\n  return Object.prototype.toString.call(value) === '[object Error]'\n}\n\nexport function toSandboxError(error: unknown): Error {\n  if (isError(error)) return error\n  return new Error(String(error))\n}\n",[79,289,290,319,360,364,370,393,414,433],{"__ignoreMap":77},[82,291,292,295,298,300,303,305,307,309,312,315,317],{"class":84,"line":85},[82,293,294],{"class":197},"function",[82,296,297],{"class":201}," isError",[82,299,206],{"class":205},[82,301,302],{"class":209},"value",[82,304,213],{"class":205},[82,306,216],{"class":88},[82,308,219],{"class":205},[82,310,311],{"class":209}," value",[82,313,314],{"class":205}," is",[82,316,222],{"class":88},[82,318,225],{"class":205},[82,320,321,323,326,329,332,334,337,339,342,344,346,348,351,354,357],{"class":84,"line":228},[82,322,258],{"class":193},[82,324,325],{"class":88}," Object",[82,327,328],{"class":205},".",[82,330,331],{"class":238},"prototype",[82,333,328],{"class":205},[82,335,336],{"class":238},"toString",[82,338,328],{"class":205},[82,340,341],{"class":201},"call",[82,343,206],{"class":234},[82,345,302],{"class":238},[82,347,246],{"class":234},[82,349,350],{"class":205},"===",[82,352,353],{"class":205}," '",[82,355,356],{"class":92},"[object Error]",[82,358,359],{"class":205},"'\n",[82,361,362],{"class":84,"line":255},[82,363,281],{"class":205},[82,365,366],{"class":84,"line":278},[82,367,369],{"emptyLinePlaceholder":368},true,"\n",[82,371,373,375,377,379,381,383,385,387,389,391],{"class":84,"line":372},5,[82,374,194],{"class":193},[82,376,198],{"class":197},[82,378,202],{"class":201},[82,380,206],{"class":205},[82,382,210],{"class":209},[82,384,213],{"class":205},[82,386,216],{"class":88},[82,388,219],{"class":205},[82,390,222],{"class":88},[82,392,225],{"class":205},[82,394,396,398,400,403,405,407,410,412],{"class":84,"line":395},6,[82,397,231],{"class":193},[82,399,235],{"class":234},[82,401,402],{"class":201},"isError",[82,404,206],{"class":234},[82,406,210],{"class":238},[82,408,409],{"class":234},")) ",[82,411,249],{"class":193},[82,413,252],{"class":238},[82,415,417,419,421,423,425,427,429,431],{"class":84,"line":416},7,[82,418,258],{"class":193},[82,420,261],{"class":205},[82,422,222],{"class":201},[82,424,206],{"class":234},[82,426,268],{"class":201},[82,428,206],{"class":234},[82,430,210],{"class":238},[82,432,275],{"class":234},[82,434,436],{"class":84,"line":435},8,[82,437,281],{"class":205},[439,440,441],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}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 .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 .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}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 .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}",{"title":77,"searchDepth":228,"depth":228,"links":443},[444,445,446,447,448],{"id":69,"depth":228,"text":70},{"id":111,"depth":228,"text":112},{"id":131,"depth":228,"text":132},{"id":156,"depth":228,"text":157},{"id":172,"depth":228,"text":173,"children":449},[450],{"id":177,"depth":255,"text":178},"Report instanceof checks against JavaScript built-ins, such as Error, Date, Map, RegExp, Promise, Array and Object, on values that may come from another JavaScript realm.",[58],"md","typescript",{},{"title":457},"Built-in instanceof","\u002Ftypescript\u002Frules\u002Fboundaries\u002Fno-cross-realm-builtin-instanceof","Use the realm-safe check: Array.isArray(value) for arrays, typeof value === 'function' for functions, Error.isError(value) or an Object.prototype.toString.call(value) brand check in a guard helper such as isError(value) or isDate(value) for the rest.",{"title":50,"description":451},"typescript\u002Frules\u002Fboundaries\u002Fno-cross-realm-builtin-instanceof","Error, Date, Map, Set, RegExp, Promise, Array, Function and Object have one constructor per realm. A value created in a node:vm context, an iframe, or a Vitest vmThreads or vmForks pool fails instanceof against this realm's class, so the check takes the wrong branch. Values from the Vite module runner, a duplicated package, a worker or structuredClone() are built with this realm's built-ins, so most of these checks never see a foreign value, and the rule reports them at low confidence. It only reports values that crossed a boundary in this file: parameters typed unknown or any, results of calling a parameter, and module namespaces from import() or ssrLoadModule(). A parameter of a function that the file neither exports nor passes around is skipped when every call passes a value proven local, such as a literal or an object constructed with an unshadowed built-in. Catching an error does not establish its origin.","VmkEouqJtO2Fxmbu4Bblh2ve0iUdJkPua8B_DHreYac",1795268793139]