UNPKG

@eslint/config-inspector

Version:

A visual tool for inspecting and understanding your ESLint flat configs

2 lines (1 loc) 5.42 kB
import{v as w,j as y,r as h,c as p,a3 as M,J as o,g as s,d as m,G as A,X as F,l as N,e as _,S as H,Y as C,z as L,aa as $,F as x,O as j,f as g,i as P,K as b,V as B,T as R}from"./CpdG7ysU.js";const z={ts:200,typescript:200,"@typescript-eslint":200,ignore:"#888888",ignores:"#888888",disable:"#888888",disables:"#888888",vue:"#41b883",nuxt:"#41b883",svelte:"#ff3e00",react:"#61dafb",node:110,n:110,js:50,javascript:50,antfu:170,markdown:270};function G(n,t=1){let e=0;for(let u=0;u<n.length;u++)e=n.charCodeAt(u)+((e<<5)-e);const i=e%360;return V(i,t)}function V(n,t=1){const e=w.value?55:70,i=w.value?72:28;return`hsla(${n}, ${e}%, ${i}%, ${t})`}function J(n,t=1){if(z[n]){const e=z[n];if(typeof e=="number")return V(e,t);{if(t===1)return e;const i=Math.floor(t*255).toString(16).padStart(2,"0");return e+i}}return G(n,t)}const K=y({props:{name:{type:String},index:{type:Number}},setup(n){const t=p(()=>n.name?.split(" > ").map(e=>e.split(/([:/])/g).filter(Boolean)));return()=>{if(t.value){const e=[];return t.value.forEach((i,u)=>{u>0&&e.push(h("span",{class:"i-ph-caret-right inline-block color-faint",style:{margin:"0 0.25em",verticalAlign:"-0.1em"}})),i.forEach((f,v)=>{e.push(h("span",[":","/"].includes(f)?{class:"color-faint",style:{margin:"0 1px"}}:v!==i.length-1?{style:{color:J(f)}}:null,f))})}),h("span",e)}else return h("span",[h("span",{class:"color-muted italic"},"anonymous"),n.index!=null?h("span",{class:"color-muted text-sm"},` #${n.index+1}`):null])}}}),O=[{match:/package\.json$/,icon:"i-file-icons-npm text-red scale-110"},{match:/eslint\.config\.\w+$/,icon:"i-file-icons-eslint text-primary"},{match:/\.[mc]?jsx?$/,icon:"i-vscode-icons-file-type-js-official"},{match:/\.[mc]?tsx?$/,icon:"i-file-icons-typescript-alt text-blue3"},{match:/\.vue$/,icon:"i-logos-vue"},{match:/\.svelte$/,icon:"i-logos-svelte-icon"},{match:/\.html?$/,icon:"i-devicon-html5"},{match:/\.md$/,icon:"i-simple-icons-markdown text-gray"},{match:/\.json[c5]?$/,icon:"i-simple-icons-json text-gray"},{match:/\.css$/,icon:"i-vscode-icons-file-type-css"}],X={flex:"~ gap-2 items-center","data-testid":"file-item"},Y=y({__name:"FileItem",props:{filepath:{}},setup(n){const t=n,e=p(()=>{for(const f of O)if(f.match.test(t.filepath))return f.icon;return"i-ph-file-duotone"}),i=M();function u(){N.filepath=t.filepath,N.rule=void 0,i.push("/configs")}return(f,v)=>(o(),s("div",X,[m("div",{class:A(e.value),"flex-none":"",h:"1em","translate-y-1px":""},null,2),m("button",{"color-muted":"",hover:"color-base underline",onClick:u},F(n.filepath),1)]))}}),q={key:0,mx1:"","color-muted":""},Q=["innerHTML"],U={key:0,"max-h":"30vh","min-w-80":"","of-auto":"",p3:""},W={key:0,mb2:"","text-xs":"","color-muted":""},Z={key:1,flex:"~ col gap-1"},ee={key:2,"text-center":"","color-muted":"",italic:""},te={key:1,"max-h":"30vh","min-w-80":"","of-auto":"",p3:""},ne={key:0,mb2:"","text-xs":"","color-muted":""},oe={key:1,flex:"~ col gap-1"},se=["onClick"],ie={key:2,"text-center":"","color-muted":"",italic:""},ae=y({__name:"GlobItem",props:{glob:{},popup:{},active:{type:[Boolean,null],default:null}},setup(n){const t=n,e=p(()=>Array.isArray(t.glob)?t.glob:[t.glob]),i=p(()=>e.value.length>1);function u(a){return B.value?B.value.codeToHtml(a,{lang:"glob",theme:w.value?"vitesse-dark":"vitesse-light",structure:"inline"}):R(a)}const f=p(()=>e.value.map(u)),v=p(()=>t.popup==="files"&&b.value.filesResolved||t.popup==="configs"),S=p(()=>{if(t.popup!=="files")return;const a=b.value.filesResolved?.globToFiles;if(!a)return;const r=e.value.map(l=>a.get(l));if(r.length===0||r.some(l=>!l))return new Set;const c=r;if(c.length===1)return c[0];const d=c[0];return new Set([...d].filter(l=>c.slice(1).every(k=>k.has(l))))}),T=p(()=>{if(t.popup==="configs")return i.value?b.value.configs.filter(a=>{if(!a.files)return!1;const r=a.files.flat();return e.value.every(c=>r.includes(c))}):b.value.globToConfigs.get(e.value[0])}),D=M();function E(a){N.filepath="",D.push(`/configs?index=${a+1}`)}const I=y({setup:(a,{slots:r})=>()=>r.default?.()});return(a,r)=>(o(),_(H(v.value?C(L):C(I)),null,{popper:$(({shown:c,hide:d})=>[c&&n.popup==="files"?(o(),s("div",U,[i.value?(o(),s("div",W," Compound glob (intersection of "+F(e.value.length)+" patterns) ",1)):g("",!0),S.value?.size?(o(),s("div",Z,[r[0]||(r[0]=m("div",null,"Files that matches this glob",-1)),(o(!0),s(x,null,j(S.value,l=>(o(),_(Y,{key:l,filepath:l,"font-mono":"",onClick:k=>d()},null,8,["filepath","onClick"]))),128))])):(o(),s("div",ee," No files matched this glob. "))])):g("",!0),c&&n.popup==="configs"?(o(),s("div",te,[i.value?(o(),s("div",ne," Compound glob (intersection of "+F(e.value.length)+" patterns) ",1)):g("",!0),T.value?.length?(o(),s("div",oe,[r[1]||(r[1]=m("div",null,"Configs that contains this glob",-1)),(o(!0),s(x,null,j(T.value,l=>(o(),s("div",{key:l.name,flex:"~ gap-2"},[m("button",{"btn-badge":"",onClick:k=>E(l.index)},[P(C(K),{name:l.name,index:l.index},null,8,["name","index"])],8,se)]))),128))])):(o(),s("div",ie," No configs matched this glob. "))])):g("",!0)]),default:$(()=>[(o(),_(H(v.value?"button":"div"),{"data-a11y-skip":"","font-mono":"",class:A(n.active===!0?"badge-active":n.active===!1?"badge op50":"badge")},{default:$(()=>[(o(!0),s(x,null,j(f.value,(c,d)=>(o(),s(x,{key:d},[d>0?(o(),s("span",q,"&")):g("",!0),m("span",{class:"filter-hue-rotate-180",innerHTML:c},null,8,Q)],64))),128))]),_:1},8,["class"]))]),_:1}))}});export{K as C,ae as _,Y as a,J as g};