UNPKG

@eslint/config-inspector

Version:

A visual tool for inspecting and understanding your ESLint flat configs

2 lines (1 loc) 7.02 kB
import{j as U,a0 as _,J as n,g as d,F as B,O as A,B as D,C as M,d as o,P as j,G as V,ab as N,a4 as P,h as y,X as v,N as G,a8 as R,a5 as z,Y as a,m as s,i as h,aa as $,e as S,f as p,b as E,W as w,K as u,c as x}from"./CpdG7ysU.js";import{c as T,a as L,F as W}from"./CwyqBl4x.js";import{g as F}from"./kRSJCsry.js";const q={flex:"~ inline gap-1 wrap","of-hidden":"","text-sm":""},J=["title"],K=["value","title"],C=U({__name:"OptionSelectGroup",props:D({options:{},titles:{},classes:{},props:{}},{modelValue:{type:[String,Number]},modelModifiers:{}}),emits:["update:modelValue"],setup(i){const m=_(i,"modelValue");return(g,c)=>(n(),d("fieldset",q,[(n(!0),d(B,null,A(i.options,(f,r)=>(n(),d("label",M({key:f,border:"~ base rounded-full",relative:"","px2.5":"","py0.5":"","hover:bg-hover":"",class:[f===m.value?"bg-active":"saturate-0 hover:saturate-100",i.props?.[r]?.class||""]},{ref_for:!0},i.props?.[r],{title:i.titles?.[r]}),[o("div",{class:V([f===m.value?"":"op50",i.titles?.[r]?"":"capitalize",i.classes?.[r]||""])},[j(g.$slots,"default",{value:f,title:i.titles?.[r],index:r},()=>[y(v(i.titles?.[r]??f),1)])],2),N(o("input",{"onUpdate:modelValue":c[0]||(c[0]=k=>m.value=k),type:"radio",value:f,title:i.titles?.[r],absolute:"","inset-0":"","op-0.1":""},null,8,K),[[P,m.value]])],16,J))),128))]))}}),X={py4:"",flex:"~ col gap-2"},Y={relative:"",flex:""},H={grid:"~ cols-[max-content_1fr] gap-2",my2:"","items-center":""},I={class:"flex items-center"},Q={"ml--1":"","mr-1":"",flex:"","items-center":""},Z={flex:"","items-center":"","gap-1":""},ee={key:0,"i-ph-check-square-duotone":"","ml--0.5":"","text-green-700":"","dark:text-green-300":""},te={key:1,"i-ph-wrench-duotone":"","ml--0.5":"","text-amber-700":"","dark:text-amber-300":""},le={key:2,"i-ph-prohibit-inset-duotone":"","ml--1":"","color-muted":""},se={"items-center":"","justify-between":"","gap-2":"","md:flex":""},oe={flex:"~ gap-2","lt-sm:flex-col":""},ae={flex:"~ inline gap-2 items-center",border:"~ gray/30 rounded-full","bg-gray:10":"",px3:"",py1:""},re={"color-base":""},ne={"text-sm":"","color-muted":""},ie={key:0,flex:"~ gap-1"},fe=U({__name:"rules",setup(i){const m=x(()=>Object.values(u.value.rules)),g=x(()=>Array.from(new Set(m.value.map(l=>l.plugin))).filter(Boolean)),c=x(()=>{let l=m.value;switch(s.plugin&&(l=l.filter(e=>e.plugin===s.plugin)),s.fixable!=null&&(l=l.filter(e=>!!e.fixable===s.fixable)),s.state){case"using":l=l.filter(e=>u.value.ruleToState.get(e.name));break;case"unused":l=l.filter(e=>!u.value.ruleToState.get(e.name));break;case"overloads":l=l.filter(e=>(u.value.ruleToState.get(e.name)?.length||0)>1);break;case"error":l=l.filter(e=>u.value.ruleToState.get(e.name)?.some(t=>t.level==="error"));break;case"warn":l=l.filter(e=>u.value.ruleToState.get(e.name)?.some(t=>t.level==="warn"));break;case"off":l=l.filter(e=>u.value.ruleToState.get(e.name)?.some(t=>t.level==="off"));break;case"off-only":l=l.filter(e=>{const t=u.value.ruleToState.get(e.name);return t?.length?t.every(b=>b.level==="off"):!1});break}switch(s.status){case"active":l=l.filter(e=>!e.deprecated);break;case"recommended":l=l.filter(e=>e.docs?.recommended);break;case"fixable":l=l.filter(e=>e.fixable);break;case"deprecated":l=l.filter(e=>e.deprecated);break}return l}),f=x(()=>new W(c.value,{keys:["name","docs.description"],threshold:.5})),r=G(c.value);R(()=>[s.search,c.value],()=>{if(!s.search)return r.value=c.value;r.value=f.value.search(s.search).map(l=>l.item)},{debounce:200});const k=x(()=>!(s.search||s.plugin||s.state!=="using"||s.status!=="active"));function O(){s.search="",s.plugin="",s.state="using",s.status="active"}return(l,e)=>(n(),d("div",null,[o("div",X,[o("div",Y,[N(o("input",{"onUpdate:modelValue":e[0]||(e[0]=t=>a(s).search=t),class:V(a(s).search?"font-mono":""),placeholder:"Search rules...",border:"~ base rounded-full","w-full":"","bg-transparent":"",px3:"",py2:"",pl10:"","outline-none":""},null,2),[[z,a(s).search]]),e[7]||(e[7]=o("div",{absolute:"","bottom-0":"","left-0":"","top-0":"",flex:"~ items-center justify-center",p4:"","color-muted":""},[o("div",{"i-ph-magnifying-glass-duotone":""})],-1))]),o("div",H,[e[8]||(e[8]=o("div",{"text-right":"","text-sm":"","color-muted":""}," Plugins ",-1)),h(C,{modelValue:a(s).plugin,"onUpdate:modelValue":e[1]||(e[1]=t=>a(s).plugin=t),options:["",...g.value],titles:["All",...g.value],props:[{},...g.value.map(t=>({class:"font-mono",style:a(s).plugin===t?{color:a(F)(t),backgroundColor:a(F)(t,.1)}:{}}))]},null,8,["modelValue","options","titles","props"]),e[9]||(e[9]=o("div",{"text-right":"","text-sm":"","color-muted":""}," Usage ",-1)),h(C,{modelValue:a(s).state,"onUpdate:modelValue":e[2]||(e[2]=t=>a(s).state=t),options:["","using","unused","error","warn","off","overloads","off-only"],titles:["All","Using","Unused","Error","Warn","Off","Overloaded","Off Only"]},{default:$(({value:t,title:b})=>[o("div",I,[o("div",Q,[t==="error"||t==="overloads"?(n(),S(T,{key:0,level:"error"})):p("",!0),t==="warn"||t==="overloads"?(n(),S(T,{key:1,level:"warn"})):p("",!0),t==="off"||t==="off-only"||t==="overloads"?(n(),S(T,{key:2,level:"off"})):p("",!0)]),y(" "+v(b||t),1)])]),_:1},8,["modelValue"]),e[10]||(e[10]=o("div",{"text-right":"","text-sm":"","color-muted":""}," State ",-1)),h(C,{modelValue:a(s).status,"onUpdate:modelValue":e[3]||(e[3]=t=>a(s).status=t),options:["","active","recommended","fixable","deprecated"],titles:["All","Active","Recommended","Fixable","Deprecated"]},{default:$(({value:t,title:b})=>[o("div",Z,[t==="recommended"?(n(),d("div",ee)):p("",!0),t==="fixable"?(n(),d("div",te)):p("",!0),t==="deprecated"?(n(),d("div",le)):p("",!0),y(" "+v(b||t),1)])]),_:1},8,["modelValue"])])]),o("div",se,[o("div",oe,[o("div",ae,[e[11]||(e[11]=o("div",{"i-ph-list-checks-duotone":""},null,-1)),o("span",null,v(r.value.length),1),o("span",re,"rules "+v(k.value?"enabled":"filtered"),1),o("span",ne,"out of "+v(m.value.length)+" rules",1)]),k.value?p("",!0):(n(),d("button",{key:0,flex:"~ inline gap-2 items-center self-start",border:"~ purple-700/30 dark:purple-300/30 rounded-full","bg-purple-50":"",px3:"",py1:"","dark:bg-purple-900:20":"",onClick:e[4]||(e[4]=t=>O())},[...e[12]||(e[12]=[o("div",{"i-ph-funnel-duotone":"","text-purple-700":"","dark:text-purple-300":""},null,-1),o("span",{"color-muted":""},"Clear Filter",-1),o("div",{"i-ph-x":"","ml--1":"","text-sm":"","color-muted":"","hover:color-base":""},null,-1)])]))]),a(E)?p("",!0):(n(),d("div",ie,[o("button",{"btn-action":"",class:V({"btn-action-active":a(w).viewType==="list"}),onClick:e[5]||(e[5]=t=>a(w).viewType="list")},[...e[13]||(e[13]=[o("div",{"i-ph-list-duotone":""},null,-1),y(" List ",-1)])],2),o("button",{"btn-action":"",class:V({"btn-action-active":a(w).viewType==="grid"}),onClick:e[6]||(e[6]=t=>a(w).viewType="grid")},[...e[14]||(e[14]=[o("div",{"i-ph-grid-four-duotone":""},null,-1),y(" Grid ",-1)])],2)]))]),h(L,{my4:"",rules:r.value,"get-bind":t=>({class:a(u).ruleToState.get(t)?.length||a(s).state==="unused"?"":"color-muted"})},null,8,["rules","get-bind"])]))}});export{fe as default};