UNPKG

@eslint/config-inspector

Version:

A visual tool for inspecting and understanding your ESLint flat configs

2 lines (1 loc) 16.1 kB
import{j as X,a0 as ne,N as P,a9 as le,a3 as oe,R as ie,J as l,g as s,G as S,d as t,X as f,e as I,Y as n,i as x,F as p,O as E,f as v,H as se,aa as Q,ab as U,h as q,q as ae,p as A,w as ue,B as Z,y as re,m as de,c as z,l as r,K as M,A as fe,x as ce,a8 as pe,a7 as ge,a2 as ve,I as me,a as F,D as be,a5 as he,ac as V,ad as J,a6 as _,W as h,U as ee,r as W}from"./CpdG7ysU.js";import{_ as ye,a as K,s as xe,S as ke,b as we,F as Ce}from"./CwyqBl4x.js";import{C as $e,_ as Y,g as te}from"./kRSJCsry.js";import{_ as D}from"./PXMiJN0M.js";const Oe=["open"],je={block:""},Me={class:"absolute right-[calc(100%+10px)] top-1.5","text-right":"","color-muted":"","font-mono":"","lt-lg:hidden":""},Fe={flex:"~ gap-2 items-center","cursor-pointer":"","select-none":"","bg-hover":"",px2:"",py2:"","text-sm":"","font-mono":""},Se={flex:"","flex-auto":"","flex-col":"","flex-wrap":"","gap-3":"","md:flex-row":"","md:justify-end":""},Ee={key:1},Te={flex:"~ gap-2 items-start"},Re={"aria-hidden":"true","data-a11y-skip":"","pointer-events-none":"",absolute:"","right-2":"","top-2":"","text-right":"","text-5em":"","font-mono":"",op5:""},Ie={key:0,flex:"~ col gap-4","of-auto":"",px4:"",py3:""},De={key:0,flex:"~ gap-2 items-start"},Ae={flex:"~ col gap-2"},Ne={flex:"~ gap-2 items-center wrap"},Be={key:1,flex:"~ gap-2 items-center"},Ge={key:2,flex:"~ gap-2 items-start"},Ve={flex:"~ col gap-2"},Pe={flex:"~ gap-2 items-center wrap"},Ue=["onClick"],qe={key:3,flex:"~ gap-2 items-start"},ze={flex:"~ col gap-2"},Ke={key:0},Le={key:1},He={flex:"~ gap-2 items-center wrap"},Je={key:4},We={flex:"~ gap-2 items-center"},Xe=["onClick"],Ye={key:5,flex:"~ gap-2"},Qe={flex:"~ col gap-2","w-full":""},Ze={"of-auto":"",p2:"",px3:"","color-muted":""},_e=X({__name:"ConfigItem",props:Z({config:{},index:{},filters:{},active:{type:Boolean},matchedGlobs:{}},{open:{default:!0},openModifiers:{}}),emits:Z(["badgeClick"],["update:open"]),setup(a,{emit:k}){const N=a,B=k;function $(C){return!!N.matchedGlobs?.some(i=>re(i,C))}const j=new Set(["name"]),L=new Set(["index"]),w=ne(a,"open"),y=P(w.value);if(!y.value){const C=le(()=>{w.value&&(y.value=!0,C())})}const O=oe();function G(C){de.plugin=C,O.push("/rules")}const T=z(()=>{const C=["files","plugins","ignores","rules","name","index"];return Object.fromEntries(Object.entries(N.config).filter(([i])=>!C.includes(i)))});return(C,i)=>{const H=ie("close-popper");return l(),s("details",{class:S(["flat-config-item",a.active?"border-yellow:70":"border-base"]),open:w.value,border:"~ rounded-lg",relative:"","data-testid":"config-item",onToggle:i[1]||(i[1]=u=>w.value=u.target.open)},[t("summary",je,[t("div",Me," #"+f(a.index+1),1),t("div",Fe,[i[2]||(i[2]=t("div",{class:"[details[open]_&]:rotate-90","i-ph-caret-right":"","flex-none":"","color-muted":"",transition:""},null,-1)),t("div",Se,[t("span",{class:S(a.config.name?"":"color-muted italic"),"flex-1":""},[a.config.name?(l(),I(n($e),{key:0,name:a.config.name},null,8,["name"])):(l(),s("span",Ee,"anonymous #"+f(a.index+1),1))],2),t("div",Te,[x(D,{icon:"i-ph-file-magnifying-glass-duotone",number:a.config.files?.length||0,color:"text-yellow5",title:"Files"},null,8,["number"]),x(D,{icon:"i-ph-eye-closed-duotone",number:a.config.ignores?.length||0,color:"text-purple5 dark:text-purple4",title:"Ignores"},null,8,["number"]),x(D,{icon:"i-ph-sliders-duotone",number:Object.keys(T.value).length,color:"text-green5",title:"Options"},null,8,["number"]),x(D,{icon:"i-ph-plug-duotone",number:Object.keys(a.config.plugins||{}).length,color:"text-teal5",title:"Plugins"},null,8,["number"]),x(D,{icon:"i-ph-list-dashes-duotone",number:Object.keys(a.config.rules||{}).length,color:"text-blue5 dark:text-blue4",title:"Rules","mr-2":""},null,8,["number"])])])])]),t("div",Re," #"+f(a.index+1),1),y.value?(l(),s("div",Ie,[a.config.files?(l(),s("div",De,[i[4]||(i[4]=t("div",{"i-ph-file-magnifying-glass-duotone":"",my1:"","flex-none":""},null,-1)),t("div",Ae,[i[3]||(i[3]=t("div",null,"Applies to files matching",-1)),t("div",Ne,[(l(!0),s(p,null,E(a.config.files,(u,g)=>(l(),I(Y,{key:g,glob:u,popup:"files",active:$(u)},null,8,["glob","active"]))),128))])])])):a.config.rules||Object.keys(T.value).length?(l(),s("div",Be,[...i[5]||(i[5]=[t("div",{"i-ph-files-duotone":"","flex-none":""},null,-1),t("div",null,"Generally applies to all files",-1)])])):v("",!0),a.config.plugins?(l(),s("div",Ge,[i[6]||(i[6]=t("div",{"i-ph-plug-duotone":"",my1:"","flex-none":""},null,-1)),t("div",Ve,[t("div",null,"Plugins ("+f(Object.keys(a.config.plugins).length)+")",1),t("div",Pe,[(l(!0),s(p,null,E(Object.keys(a.config.plugins),(u,g)=>(l(),s("button",{key:g,border:"~ base rounded-full",px3:"",style:se({color:n(te)(u),backgroundColor:n(te)(u,.1)}),"font-mono":"",onClick:d=>G(u)},f(u),13,Ue))),128))])])])):v("",!0),a.config.ignores?(l(),s("div",qe,[i[7]||(i[7]=t("div",{"i-ph-eye-closed-duotone":"",my1:"","flex-none":""},null,-1)),t("div",ze,[Object.keys(a.config).some(u=>u!=="ignores"&&!n(L).has(u)&&!n(j).has(u))===!1?(l(),s("div",Ke," Ignore files globally ")):(l(),s("div",Le," Ignore ")),t("div",He,[(l(!0),s(p,null,E(a.config.ignores,(u,g)=>(l(),I(Y,{key:g,glob:u,active:$(u)},null,8,["glob","active"]))),128))])])])):v("",!0),a.config.rules&&Object.keys(a.config.rules).length?(l(),s("div",Je,[t("div",We,[i[8]||(i[8]=t("div",{"i-ph-list-dashes-duotone":"",my1:"","flex-none":""},null,-1)),t("div",null,"Rules ("+f(Object.keys(a.config.rules).length)+")",1)]),x(K,{py2:"",class:S(n(ue)?"pl6":""),rules:a.config.rules,filter:u=>!a.filters?.rule||a.filters.rule===u,"get-bind":u=>({class:n(A)(a.config.rules?.[u])==="off"?"color-muted":""})},{popup:Q(({ruleName:u,value:g})=>[x(ye,{border:"t base","is-local":!0,state:{name:u,level:n(A)(g),configIndex:a.index,options:n(ae)(g)}},null,8,["state"])]),"popup-actions":Q(({ruleName:u})=>[U((l(),s("button",{"btn-action-sm":"",onClick:g=>B("badgeClick",u)},[...i[9]||(i[9]=[t("div",{"i-ph-funnel-duotone":""},null,-1),q(" Filter by this rule ",-1)])],8,Xe)),[[H]])]),_:1},8,["class","rules","filter","get-bind"]),t("div",null,[a.filters?.rule?(l(),s("button",{key:0,ml8:"","color-muted":"",onClick:i[0]||(i[0]=u=>B("badgeClick",""))}," ..."+f(Object.keys(a.config.rules).filter(u=>u!==a.filters?.rule).length)+" others rules are hidden ",1)):v("",!0)])])):v("",!0),Object.keys(T.value).length?(l(),s("div",Ye,[i[11]||(i[11]=t("div",{"i-ph-sliders-duotone":"",my1:"","flex-none":""},null,-1)),t("div",Qe,[i[10]||(i[10]=t("div",null," Additional configurations ",-1)),(l(!0),s(p,null,E(T.value,(u,g)=>(l(),s("div",{key:g,border:"~ base rounded-lg"},[t("div",Ze,f(g),1),x(n(ke),{lang:"ts",code:n(xe)(u),"max-h-100":"","max-w-full":"","w-full":"","of-scroll":"",rounded:"","bg-code":"",p2:"","text-sm":""},null,8,["code"])]))),128))])])):v("",!0)])):v("",!0)],42,Oe)}}}),et={flex:"~ col gap-3",py4:""},tt={relative:"",flex:""},lt={pos:"absolute left-8 right-8 top-1/1",border:"~ base rounded",flex:"~ col","z-1":"","mt--1":"","max-h-80":"","of-auto":"","bg-glass":"",py1:"",shadow:""},nt=["onClick"],ot={key:0,flex:"~ gap-2 items-center wrap",mb2:""},it={key:0},st={key:0,"color-muted":""},at={key:1},ut={flex:"~ gap-2 items-center",border:"~ blue-700/30 dark:blue-300/30 rounded-full","bg-blue-50":"",px3:"",py1:"","dark:bg-blue-900:20":""},rt={flex:"~ gap-2 items-center wrap"},dt={key:0,border:"~ base rounded",flex:""},ft={key:1,flex:"~ gap-2 items-center",ml2:"","select-none":""},ct=["checked"],pt={flex:"~ gap-2 items-center wrap"},gt={class:"flat-config-item",border:"~ base rounded-lg",relative:""},vt={block:""},mt={flex:"~ gap-2 items-start","cursor-pointer":"","select-none":"","bg-hover":"",px2:"",py2:"","text-sm":"","color-base":"","font-mono":""},bt={class:"flat-config-item",border:"~ base rounded-lg",open:"",relative:""},ht={block:""},yt={flex:"~ gap-2 items-start","cursor-pointer":"","select-none":"","bg-hover":"",px2:"",py2:"","text-sm":"","color-base":"","font-mono":""},xt={px4:"",pt4:""},kt={px4:"",pt4:""},jt=X({__name:"configs",setup(a){const k=P(r.filepath);function N(){F.value=F.value.map(()=>!0)}function B(){F.value=F.value.map(()=>!1)}const $=ee([]),j=ee(null);le(()=>{let d=M.value.configs;r.filepath?(j.value=fe(r.filepath,M.value.configs,M.value.meta.basePath),j.value.configs.length?d=Array.from(new Set([...j.value.configs,...M.value.configsGeneral.filter(e=>!ce(e)).map(e=>e.index)])).sort((e,o)=>e-o).map(e=>M.value.configs[e]):d=[]):j.value=null,r.rule&&(d=d.filter(e=>r.rule in(e.rules||{}))),$.value=d});const L=z(()=>new Ce(M.value.filesResolved?.list||[],{threshold:.3,includeMatches:!0})),w=z(()=>L.value.search(r.filepath||"")),y=P(0),O=P(!1);function G(d=y.value){O.value&&(k.value=r.filepath=w.value[d]?.item||r.filepath,O.value=!1)}function T(){setTimeout(()=>{O.value=!1},100)}function C(d){O.value&&(y.value+=d,y.value<0&&(y.value+=w.value.length),y.value>=w.value.length&&(y.value-=w.value.length))}const i=z(()=>{if(!r.filepath||h.value.viewFileMatchType!=="merged")return{all:{},common:{},specific:{},specificDisabled:{},specificEnabled:{}};const d={},e={},o={};$.value.forEach(m=>{m.rules&&(Object.assign(d,m.rules),m.files?Object.assign(o,m.rules):Object.assign(e,m.rules))});const c=Object.fromEntries(Object.entries(o).filter(([m,R])=>A(R)==="off")),b=Object.fromEntries(Object.entries(o).filter(([m,R])=>A(R)!=="off"));for(const m in d)A(d[m])==="off"&&delete d[m];return{all:d,common:e,specific:o,specificDisabled:c,specificEnabled:b}}),H=X({props:{matches:Array},setup(d){return()=>d.matches?.map(e=>{let o=0;const c=e.value||"",b=[];for(const[m,R]of e.indices)o<m&&b.push(W("span",{class:"color-muted"},c.slice(o,m))),b.push(W("span",{class:"text-purple-700 dark:text-purple-300 font-bold"},c.slice(m,R+1))),o=R+1;return o<c.length&&b.push(W("span",{class:"color-muted"},c.slice(o))),b})}});pe(()=>k.value,()=>{r.filepath=k.value,y.value=0},{debounce:200}),ge(()=>r.filepath,()=>{r.filepath!==k.value&&(k.value=r.filepath)},{flush:"sync"});const u=new Map,g=ve();return me(async()=>{if(g.query.index!=null){const d=Number(g.query.index)-1;F.value=F.value.map((e,o)=>o===d),await be(),u.get(d)?.scrollIntoView({behavior:"smooth",block:"start"})}}),(d,e)=>(l(),s("div",null,[t("div",et,[t("div",tt,[U(t("input",{"onUpdate:modelValue":e[0]||(e[0]=o=>k.value=o),placeholder:"Test matching with filepath...",border:"~ base rounded-full",class:S(k.value?"font-mono":""),"w-full":"","bg-transparent":"",px3:"",py2:"",pl10:"","outline-none":"",onFocus:e[1]||(e[1]=o=>O.value=!0),onClick:e[2]||(e[2]=o=>O.value=!0),onBlur:T,onKeydown:[e[3]||(e[3]=V(o=>O.value=!1,["esc"])),e[4]||(e[4]=V(J(o=>C(1),["prevent"]),["down"])),e[5]||(e[5]=V(J(o=>C(-1),["prevent"]),["up"])),e[6]||(e[6]=V(J(o=>G(),["prevent"]),["enter"]))]},null,34),[[he,k.value]]),e[13]||(e[13]=t("div",{absolute:"","bottom-0":"","left-0":"","top-0":"",flex:"~ items-center justify-center",p4:"","color-muted":""},[t("div",{"i-ph-magnifying-glass-duotone":""})],-1)),U(t("div",lt,[(l(!0),s(p,null,E(w.value,(o,c)=>(l(),s("button",{key:o.item,class:S(c===y.value?"bg-active":""),px3:"","py0.5":"","text-left":"","font-mono":"","hover:bg-active":"",onClick:b=>G(c)},[o.matches?(l(),I(n(H),{key:0,matches:o.matches},null,8,["matches"])):(l(),s(p,{key:1},[q(f(o.item),1)],64))],10,nt))),128))],512),[[_,O.value&&w.value.length]])]),n(r).filepath||n(r).rule?(l(),s("div",ot,[n(r).filepath?(l(),s("div",it,[t("div",{flex:"~ gap-2 items-center wrap",border:"~ purple-700/30 dark:purple-300/30 rounded-full","bg-purple-50":"",px3:"",py1:"","dark:bg-purple-900:20":"",class:S({"saturate-0":!$.value.length})},[e[19]||(e[19]=t("div",{"i-ph-file-dotted-duotone":"","text-purple-700":"","dark:text-purple-300":""},null,-1)),e[20]||(e[20]=t("span",{"color-muted":""},"Filepath",-1)),t("code",null,f(n(r).filepath),1),$.value.length?n(h).viewFileMatchType==="configs"?(l(),s(p,{key:1},[e[14]||(e[14]=t("span",{"color-muted":""},"matched with",-1)),t("span",null,f($.value.length)+" / "+f(n(M).configs.length),1),e[15]||(e[15]=t("span",{"color-muted":""},"config items",-1))],64)):(l(),s(p,{key:2},[e[16]||(e[16]=t("span",{"color-muted":""},"matched with total ",-1)),t("span",null,f(Object.keys(i.value.all).length),1),e[17]||(e[17]=t("span",{"color-muted":""},"rules, ",-1)),t("span",null,f(Object.keys(i.value.specific).length),1),e[18]||(e[18]=t("span",{"color-muted":""},"of them are specific to the file",-1))],64)):(l(),s("span",st,"is not included or has been ignored")),t("button",{"i-ph-x":"","text-sm":"","color-muted":"","hover:color-base":"",onClick:e[7]||(e[7]=o=>{n(r).filepath="",k.value=""})})],2)])):v("",!0),n(r).rule?(l(),s("div",at,[t("div",ut,[e[21]||(e[21]=t("div",{"i-ph-funnel-duotone":""},null,-1)),e[22]||(e[22]=t("span",{"color-muted":""},"Filtered by",-1)),x(we,{name:n(r).rule},null,8,["name"]),e[23]||(e[23]=t("span",{"color-muted":""},"rule",-1)),t("button",{"i-ph-x":"","text-sm":"","color-muted":"","hover:color-base":"",onClick:e[8]||(e[8]=o=>n(r).rule="")})])])):v("",!0)])):v("",!0),t("div",rt,[n(r).filepath?(l(),s("div",dt,[t("button",{class:S(n(h).viewFileMatchType==="configs"?"btn-action-active":""),"btn-action":"","border-none":"",onClick:e[9]||(e[9]=o=>n(h).viewFileMatchType=n(h).viewFileMatchType==="configs"?"merged":"configs")},[...e[24]||(e[24]=[t("div",{"i-ph-stack-duotone":""},null,-1),t("span",null,"Matched Config Items",-1)])],2),e[26]||(e[26]=t("div",{border:"l base"},null,-1)),t("button",{class:S(n(h).viewFileMatchType!=="configs"?"btn-action-active":""),"btn-action":"","border-none":"",onClick:e[10]||(e[10]=o=>n(h).viewFileMatchType=n(h).viewFileMatchType==="configs"?"merged":"configs")},[...e[25]||(e[25]=[t("div",{"i-ph-film-script-duotone":""},null,-1),t("span",null,"Merged Rules",-1)])],2)])):v("",!0),n(r).filepath&&n(h).viewFileMatchType==="configs"?(l(),s("label",ft,[t("input",{checked:n(h).showSpecificOnly,type:"checkbox",onChange:e[11]||(e[11]=o=>n(h).showSpecificOnly=!!o.target.checked)},null,40,ct),e[27]||(e[27]=t("span",{"color-muted":""},"Show Specific Rules Only",-1))])):v("",!0),e[28]||(e[28]=t("div",{"flex-auto":""},null,-1)),t("button",{"btn-action":"",px3:"",onClick:N}," Expand All "),t("button",{"btn-action":"",px3:"",onClick:B}," Collapse All ")]),$.value.length?(l(),s(p,{key:2},[n(r).filepath&&n(h).viewFileMatchType==="merged"?(l(),s(p,{key:0},[t("details",gt,[t("summary",vt,[t("div",mt,[e[31]||(e[31]=t("div",{"i-ph-caret-right":"",class:"[details[open]_&]:rotate-90",transition:""},null,-1)),q(" Merged Rules: Common to every file ("+f(Object.keys(i.value.common).length)+" rules) ",1)])]),x(K,{m4:"",rules:i.value.common},null,8,["rules"])]),t("details",bt,[t("summary",ht,[t("div",yt,[e[32]||(e[32]=t("div",{"i-ph-caret-right":"",class:"[details[open]_&]:rotate-90",transition:""},null,-1)),q(" Merged Rules: Specific to matched file ("+f(Object.keys(i.value.specific).length)+" rules) ",1)])]),Object.keys(i.value.specificDisabled).length?(l(),s(p,{key:0},[t("div",xt," Disables ("+f(Object.keys(i.value.specificDisabled).length)+") ",1),x(K,{m4:"","get-bind":o=>({class:"color-muted"}),rules:i.value.specificDisabled},null,8,["rules"])],64)):v("",!0),Object.keys(i.value.specificEnabled).length?(l(),s(p,{key:1},[t("div",kt," Enables ("+f(Object.keys(i.value.specificEnabled).length)+") ",1),x(K,{m4:"",rules:i.value.specificEnabled},null,8,["rules"])],64)):v("",!0)])],64)):(l(!0),s(p,{key:1},E(n(M).configs,(o,c)=>U((l(),I(_e,{key:c,ref_for:!0,ref:b=>{n(u).set(c,b?.$el)},open:n(F)[c],"onUpdate:open":b=>n(F)[c]=b,config:o,index:c,filters:n(r),active:!!(n(r).filepath&&o.files),"matched-globs":j.value?.globs,onBadgeClick:e[12]||(e[12]=b=>n(r).rule=b)},null,8,["open","onUpdate:open","config","index","filters","active","matched-globs"])),[[_,$.value.includes(o)&&(!n(r).filepath||!n(h).showSpecificOnly||o.files)]])),128))],64)):(l(),s(p,{key:1},[e[30]||(e[30]=t("div",{mt5:"","color-muted":"",italic:""}," No matched config items. ",-1)),j.value?.globs.length?(l(),s(p,{key:0},[e[29]||(e[29]=t("div",null,"Ignored by globs:",-1)),t("div",pt,[(l(!0),s(p,null,E(j.value.globs,(o,c)=>(l(),I(Y,{key:c,glob:o,popup:"configs"},null,8,["glob"]))),128))])],64)):v("",!0)],64))])]))}});export{jt as default};