diff --git a/package.json b/package.json index 1802f9294..e4a42721b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-i", - "version": "2.27.5", + "version": "2.27.5-1", "description": "A fork of `eslint-plugin-import` using `get-tsconfig` to replace `tsconfig-paths` and heavy `typescript` under the hood.", "funding": "https://opencollective.com/unts", "engines": { @@ -80,6 +80,7 @@ "eslint-plugin-import": "2.x", "eslint-plugin-json": "^2.1.2", "fs-copy-file-sync": "^1.1.1", + "get-tsconfig": "^4.5.0", "glob": "^7.2.3", "in-publish": "^2.0.1", "linklocal": "^2.8.2", @@ -105,7 +106,6 @@ "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.7", "eslint-module-utils": "^2.7.4", - "get-tsconfig": "^4.2.0", "has": "^1.0.3", "is-core-module": "^2.11.0", "is-glob": "^4.0.3", diff --git a/src/get-tsconfig.js b/src/get-tsconfig.js index 17baf4a44..e61229cb3 100755 --- a/src/get-tsconfig.js +++ b/src/get-tsconfig.js @@ -1,3 +1,3 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ue=require("path"),fe=require("fs"),ce=require("module");function M(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var a=M(ue),L=M(fe),re=M(ce);function _(e){return/^\\\\\?\\/.test(e)?e:e.replace(/\\/g,"/")}function S(e,l){for(;;){const t=a.default.posix.join(e,l);if(L.default.existsSync(t))return t;const n=a.default.dirname(e);if(n===e)return;e=n}}const W=/^\.{1,2}(\/.*)?$/,x=e=>_(W.test(e)?e:`./${e}`);function pe(e,l=!1){const t=e.length;let n=0,i="",s=0,o=16,m=0,f=0,v=0,k=0,p=0;function $(u,r){let c=0,j=0;for(;c=48&&T<=57)j=j*16+T-48;else if(T>=65&&T<=70)j=j*16+T-65+10;else if(T>=97&&T<=102)j=j*16+T-97+10;else break;n++,c++}return c=t){u+=e.substring(r,n),p=2;break}const c=e.charCodeAt(n);if(c===34){u+=e.substring(r,n),n++;break}if(c===92){if(u+=e.substring(r,n),n++,n>=t){p=2;break}switch(e.charCodeAt(n++)){case 34:u+='"';break;case 92:u+="\\";break;case 47:u+="/";break;case 98:u+="\b";break;case 102:u+="\f";break;case 110:u+=` -`;break;case 114:u+="\r";break;case 116:u+=" ";break;case 117:const T=$(4,!0);T>=0?u+=String.fromCharCode(T):p=4;break;default:p=5}r=n;continue}if(c>=0&&c<=31)if(F(c)){u+=e.substring(r,n),p=2;break}else p=6;n++}return u}function O(){if(i="",p=0,s=n,f=m,k=v,n>=t)return s=t,o=17;let u=e.charCodeAt(n);if(R(u)){do n++,i+=String.fromCharCode(u),u=e.charCodeAt(n);while(R(u));return o=15}if(F(u))return n++,i+=String.fromCharCode(u),u===13&&e.charCodeAt(n)===10&&(n++,i+=` -`),m++,v=n,o=14;switch(u){case 123:return n++,o=1;case 125:return n++,o=2;case 91:return n++,o=3;case 93:return n++,o=4;case 58:return n++,o=6;case 44:return n++,o=5;case 34:return n++,i=b(),o=10;case 47:const r=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n=12&&u<=15);return u}return{setPosition:B,getPosition:()=>n,scan:l?E:O,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>s,getTokenLength:()=>n-s,getTokenStartLine:()=>f,getTokenStartCharacter:()=>s-k,getTokenError:()=>p}}function R(e){return e===32||e===9}function F(e){return e===10||e===13}function U(e){return e>=48&&e<=57}var H;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(H||(H={}));var y;(function(e){e.DEFAULT={allowTrailingComma:!1}})(y||(y={}));function ae(e,l=[],t=y.DEFAULT){let n=null,i=[];const s=[];function o(f){Array.isArray(i)?i.push(f):n!==null&&(i[n]=f)}return ge(e,{onObjectBegin:()=>{const f={};o(f),s.push(i),i=f,n=null},onObjectProperty:f=>{n=f},onObjectEnd:()=>{i=s.pop()},onArrayBegin:()=>{const f=[];o(f),s.push(i),i=f,n=null},onArrayEnd:()=>{i=s.pop()},onLiteralValue:o,onError:(f,v,k)=>{l.push({error:f,offset:v,length:k})}},t),i[0]}function ge(e,l,t=y.DEFAULT){const n=pe(e,!1),i=[];function s(g){return g?()=>g(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function o(g){return g?()=>g(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function m(g){return g?w=>g(w,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function f(g){return g?w=>g(w,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}const v=o(l.onObjectBegin),k=f(l.onObjectProperty),p=s(l.onObjectEnd),$=o(l.onArrayBegin),B=s(l.onArrayEnd),A=f(l.onLiteralValue),b=m(l.onSeparator),O=s(l.onComment),d=m(l.onError),E=t&&t.disallowComments,u=t&&t.allowTrailingComma;function r(){for(;;){const g=n.scan();switch(n.getTokenError()){case 4:c(14);break;case 5:c(15);break;case 3:c(13);break;case 1:E||c(11);break;case 2:c(12);break;case 6:c(16);break}switch(g){case 12:case 13:E?c(10):O();break;case 16:c(1);break;case 15:case 14:break;default:return g}}}function c(g,w=[],z=[]){if(d(g),w.length+z.length>0){let h=n.getToken();for(;h!==17;){if(w.indexOf(h)!==-1){r();break}else if(z.indexOf(h)!==-1)break;h=r()}}}function j(g){const w=n.getTokenValue();return g?A(w):(k(w),i.push(w)),r(),!0}function T(){switch(n.getToken()){case 11:const g=n.getTokenValue();let w=Number(g);isNaN(w)&&(c(2),w=0),A(w);break;case 7:A(null);break;case 8:A(!0);break;case 9:A(!1);break;default:return!1}return r(),!0}function le(){return n.getToken()!==10?(c(3,[],[2,5]),!1):(j(!1),n.getToken()===6?(b(":"),r(),V()||c(4,[],[2,5])):c(5,[],[2,5]),i.pop(),!0)}function oe(){v(),r();let g=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(g||c(4,[],[]),b(","),r(),n.getToken()===2&&u)break}else g&&c(6,[],[]);le()||c(4,[],[2,5]),g=!0}return p(),n.getToken()!==2?c(7,[2],[]):r(),!0}function se(){$(),r();let g=!0,w=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(w||c(4,[],[]),b(","),r(),n.getToken()===4&&u)break}else w&&c(6,[],[]);g?(i.push(0),g=!1):i[i.length-1]++,V()||c(4,[],[4,5]),w=!0}return B(),g||i.pop(),n.getToken()!==4?c(8,[4],[]):r(),!0}function V(){switch(n.getToken()){case 3:return se();case 1:return oe();case 10:return j(!0);default:return T()}}return r(),n.getToken()===17?t.allowEmptyContent?!0:(c(4,[],[]),!1):V()?(n.getToken()!==17&&c(9,[],[]),!0):(c(4,[],[]),!1)}var X;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(X||(X={}));var Y;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Y||(Y={}));const me=ae;var Z;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Z||(Z={}));const q=e=>me(L.default.readFileSync(e,"utf8")),{existsSync:N}=L.default,ke=()=>{const{findPnpApi:e}=re.default;return e&&e(process.cwd())};function K(e){const l=q(e);return a.default.join(e,"..",l&&"tsconfig"in l?l.tsconfig:"tsconfig.json")}function be(e,l){let t=e;const n=e[0]===".";if(n||a.default.isAbsolute(e)){if(n&&(t===".."&&(t+="/tsconfig.json"),t=a.default.resolve(l,t)),N(t)&&L.default.statSync(t).isFile()||!t.endsWith(".json")&&(t+=".json",N(t)))return t;throw new Error(`File '${e}' not found.`)}const i=ke();if(i){const{resolveRequest:o}=i,[m,f]=e.split("/"),v=m.startsWith("@")?`${m}/${f}`:m;try{if(v===e){const k=o(a.default.join(v,"package.json"),l);if(k){const p=K(k);if(N(p))return p}}else{let k;try{k=o(e,l,{extensions:[".json"]})}catch(_){k=o(a.default.join(e,"tsconfig.json"),l)}if(k)return k}}catch(_){}}let s=S(l,a.default.join("node_modules",t));if(s){if(L.default.statSync(s).isDirectory()){const o=a.default.join(s,"package.json");if(N(o)?s=K(o):s=a.default.join(s,"tsconfig.json"),N(s))return s}else if(s.endsWith(".json"))return s}if(!t.endsWith(".json")&&(t+=".json",s=S(l,a.default.join("node_modules",t)),s))return s;throw new Error(`File '${e}' not found.`)}function J(e){var l;let t;try{t=L.default.realpathSync(e)}catch(_){throw new Error(`Cannot resolve tsconfig at path: ${e}`)}const n=a.default.dirname(t);let i=q(t)||{};if(typeof i!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);if(i.extends){const s=be(i.extends,n),o=J(s);if(delete o.references,(l=o.compilerOptions)!=null&&l.baseUrl){const{compilerOptions:f}=o;f.baseUrl=a.default.relative(n,a.default.join(a.default.dirname(s),f.baseUrl))||"./"}o.files&&(o.files=o.files.map(f=>a.default.relative(n,a.default.join(a.default.dirname(s),f)))),o.include&&(o.include=o.include.map(f=>a.default.relative(n,a.default.join(a.default.dirname(s),f)))),delete i.extends;const m={...o,...i,compilerOptions:{...o.compilerOptions,...i.compilerOptions}};o.watchOptions&&(m.watchOptions={...o.watchOptions,...i.watchOptions}),i=m}if(i.compilerOptions){const{compilerOptions:s}=i;s.baseUrl&&(s.baseUrl=x(s.baseUrl)),s.outDir&&(Array.isArray(i.exclude)||(i.exclude=[]),i.exclude.push(s.outDir),s.outDir=x(s.outDir))}else i.compilerOptions={};if(i.files&&(i.files=i.files.map(x)),i.include&&(i.include=i.include.map(_)),i.watchOptions){const{watchOptions:s}=i;s.excludeDirectories&&(s.excludeDirectories=s.excludeDirectories.map(o=>_(a.default.resolve(n,o))))}return i}function Te(e=process.cwd(),l="tsconfig.json"){const t=S(_(e),l);if(!t)return null;const n=J(t);return{path:t,config:n}}const we=/\*/g,C=(e,l)=>{const t=e.match(we);if(t&&t.length>1)throw new Error(l)};function Oe(e){if(e.includes("*")){const[l,t]=e.split("*");return{prefix:l,suffix:t}}return e}const ve=({prefix:e,suffix:l},t)=>t.startsWith(e)&&t.endsWith(l);function je(e,l,t){return Object.entries(e).map(([n,i])=>(C(n,`Pattern '${n}' can have at most one '*' character.`),{pattern:Oe(n),substitutions:i.map(s=>{if(C(s,`Substitution '${s}' in pattern '${n}' can have at most one '*' character.`),!l&&!W.test(s))throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return a.default.join(t,s)})}))}function Ae(e){if(!e.config.compilerOptions)return null;const{baseUrl:l,paths:t}=e.config.compilerOptions;if(!l&&!t)return null;const n=a.default.resolve(a.default.dirname(e.path),l||"."),i=t?je(t,l,n):[];return function(o){if(W.test(o))return[];const m=[];for(const p of i){if(p.pattern===o)return p.substitutions.map(_);typeof p.pattern!="string"&&m.push(p)}let f,v=-1;for(const p of m)ve(p.pattern,o)&&p.pattern.prefix.length>v&&(v=p.pattern.prefix.length,f=p);if(!f)return l?[_(a.default.join(n,o))]:[];const k=o.slice(f.pattern.prefix.length,o.length-f.pattern.suffix.length);return f.substitutions.map(p=>_(p.replace("*",k)))}}const ee=e=>{let l="";for(let t=0;tMath.floor(Math.random()*26),Be=e=>Array.from({length:e},()=>String.fromCodePoint(Le()+(Math.random()>.5?_e:de))).join(""),Ee=(e=L.default)=>{const l=process.execPath;if(e.existsSync(l))return!e.existsSync(ee(l));const t=`/${Be(10)}`;e.writeFileSync(t,"");const n=!e.existsSync(ee(t));return e.unlinkSync(t),n},{join:D}=a.default.posix,G={ts:[".ts",".tsx",".d.ts"],cts:[".cts",".d.cts"],mts:[".mts",".d.mts"]},Ue=e=>{const l=[...G.ts],t=[...G.cts],n=[...G.mts];return e!=null&&e.allowJs&&(l.push(".js",".jsx"),t.push(".cjs"),n.push(".mjs")),[...l,...t,...n]},$e=e=>{const l=[];if(!e)return l;const{outDir:t,declarationDir:n}=e;return t&&l.push(t),n&&l.push(n),l},ne=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Fe=["node_modules","bower_components","jspm_packages"],P=`(?!(${Fe.join("|")})(/|$))`,Ne=/(?:^|\/)[^.*?]+$/,te="**/*",I="[^/]",Q="[^./]",ie=process.platform==="win32",he=({config:e,path:l},t=Ee())=>{if("extends"in e)throw new Error("tsconfig#extends must be resolved. Use getTsconfig or parseTsconfig to resolve it.");if(!a.default.isAbsolute(l))throw new Error("The tsconfig path must be absolute");ie&&(l=_(l));const n=a.default.dirname(l),{files:i,include:s,exclude:o,compilerOptions:m}=e,f=i==null?void 0:i.map(b=>D(n,b)),v=Ue(m),k=t?"":"i",$=(o||$e(m)).map(b=>{const O=D(n,b),d=ne(O).replace(/\\\*\\\*\//g,"(.+/)?").replace(/\\\*/g,`${I}*`).replace(/\\\?/g,I);return new RegExp(`^${d}($|/)`,k)}),B=i||s?s:[te],A=B?B.map(b=>{let O=D(n,b);Ne.test(O)&&(O=D(O,te));const d=ne(O).replace(/\/\\\*\\\*/g,`(/${P}${Q}${I}*)*?`).replace(/(\/)?\\\*/g,(E,u)=>{const r=`(${Q}|(\\.(?!min\\.js$))?)*`;return u?`/${P}${Q}${r}`:r}).replace(/(\/)?\\\?/g,(E,u)=>{const r=I;return u?`/${P}${r}`:r});return new RegExp(`^${d}$`,k)}):void 0;return b=>{if(!a.default.isAbsolute(b))throw new Error("filePath must be absolute");if(ie&&(b=_(b)),f!=null&&f.includes(b))return e;if(!(!v.some(O=>b.endsWith(O))||$.some(O=>O.test(b)))&&A&&A.some(O=>O.test(b)))return e}};exports.createFilesMatcher=he,exports.createPathsMatcher=Ae,exports.getTsconfig=Te,exports.parseTsconfig=J; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ue=require("path"),fe=require("fs"),ce=require("module");function x(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var p=x(ue),L=x(fe),re=x(ce);function d(e){return/^\\\\\?\\/.test(e)?e:e.replace(/\\/g,"/")}function M(e,l){for(;;){const t=p.default.posix.join(e,l);if(L.default.existsSync(t))return t;const n=p.default.dirname(e);if(n===e)return;e=n}}const S=/^\.{1,2}(\/.*)?$/,W=e=>d(S.test(e)?e:`./${e}`);function pe(e,l=!1){const t=e.length;let n=0,i="",o=0,u=16,m=0,a=0,O=0,k=0,r=0;function $(s,c){let f=0,j=0;for(;f=48&&T<=57)j=j*16+T-48;else if(T>=65&&T<=70)j=j*16+T-65+10;else if(T>=97&&T<=102)j=j*16+T-97+10;else break;n++,f++}return f=t){s+=e.substring(c,n),r=2;break}const f=e.charCodeAt(n);if(f===34){s+=e.substring(c,n),n++;break}if(f===92){if(s+=e.substring(c,n),n++,n>=t){r=2;break}switch(e.charCodeAt(n++)){case 34:s+='"';break;case 92:s+="\\";break;case 47:s+="/";break;case 98:s+="\b";break;case 102:s+="\f";break;case 110:s+=` +`;break;case 114:s+="\r";break;case 116:s+=" ";break;case 117:const T=$(4,!0);T>=0?s+=String.fromCharCode(T):r=4;break;default:r=5}c=n;continue}if(f>=0&&f<=31)if(F(f)){s+=e.substring(c,n),r=2;break}else r=6;n++}return s}function v(){if(i="",r=0,o=n,a=m,k=O,n>=t)return o=t,u=17;let s=e.charCodeAt(n);if(R(s)){do n++,i+=String.fromCharCode(s),s=e.charCodeAt(n);while(R(s));return u=15}if(F(s))return n++,i+=String.fromCharCode(s),s===13&&e.charCodeAt(n)===10&&(n++,i+=` +`),m++,O=n,u=14;switch(s){case 123:return n++,u=1;case 125:return n++,u=2;case 91:return n++,u=3;case 93:return n++,u=4;case 58:return n++,u=6;case 44:return n++,u=5;case 34:return n++,i=b(),u=10;case 47:const c=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n=12&&s<=15);return s}return{setPosition:E,getPosition:()=>n,scan:l?B:v,getToken:()=>u,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>a,getTokenStartCharacter:()=>o-k,getTokenError:()=>r}}function R(e){return e===32||e===9}function F(e){return e===10||e===13}function U(e){return e>=48&&e<=57}var H;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(H||(H={}));var D;(function(e){e.DEFAULT={allowTrailingComma:!1}})(D||(D={}));function ae(e,l=[],t=D.DEFAULT){let n=null,i=[];const o=[];function u(a){Array.isArray(i)?i.push(a):n!==null&&(i[n]=a)}return ge(e,{onObjectBegin:()=>{const a={};u(a),o.push(i),i=a,n=null},onObjectProperty:a=>{n=a},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{const a=[];u(a),o.push(i),i=a,n=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:u,onError:(a,O,k)=>{l.push({error:a,offset:O,length:k})}},t),i[0]}function ge(e,l,t=D.DEFAULT){const n=pe(e,!1),i=[];function o(g){return g?()=>g(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function u(g){return g?()=>g(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function m(g){return g?w=>g(w,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(g){return g?w=>g(w,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}const O=u(l.onObjectBegin),k=a(l.onObjectProperty),r=o(l.onObjectEnd),$=u(l.onArrayBegin),E=o(l.onArrayEnd),A=a(l.onLiteralValue),b=m(l.onSeparator),v=o(l.onComment),_=m(l.onError),B=t&&t.disallowComments,s=t&&t.allowTrailingComma;function c(){for(;;){const g=n.scan();switch(n.getTokenError()){case 4:f(14);break;case 5:f(15);break;case 3:f(13);break;case 1:B||f(11);break;case 2:f(12);break;case 6:f(16);break}switch(g){case 12:case 13:B?f(10):v();break;case 16:f(1);break;case 15:case 14:break;default:return g}}}function f(g,w=[],z=[]){if(_(g),w.length+z.length>0){let h=n.getToken();for(;h!==17;){if(w.indexOf(h)!==-1){c();break}else if(z.indexOf(h)!==-1)break;h=c()}}}function j(g){const w=n.getTokenValue();return g?A(w):(k(w),i.push(w)),c(),!0}function T(){switch(n.getToken()){case 11:const g=n.getTokenValue();let w=Number(g);isNaN(w)&&(f(2),w=0),A(w);break;case 7:A(null);break;case 8:A(!0);break;case 9:A(!1);break;default:return!1}return c(),!0}function le(){return n.getToken()!==10?(f(3,[],[2,5]),!1):(j(!1),n.getToken()===6?(b(":"),c(),V()||f(4,[],[2,5])):f(5,[],[2,5]),i.pop(),!0)}function se(){O(),c();let g=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(g||f(4,[],[]),b(","),c(),n.getToken()===2&&s)break}else g&&f(6,[],[]);le()||f(4,[],[2,5]),g=!0}return r(),n.getToken()!==2?f(7,[2],[]):c(),!0}function oe(){$(),c();let g=!0,w=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(w||f(4,[],[]),b(","),c(),n.getToken()===4&&s)break}else w&&f(6,[],[]);g?(i.push(0),g=!1):i[i.length-1]++,V()||f(4,[],[4,5]),w=!0}return E(),g||i.pop(),n.getToken()!==4?f(8,[4],[]):c(),!0}function V(){switch(n.getToken()){case 3:return oe();case 1:return se();case 10:return j(!0);default:return T()}}return c(),n.getToken()===17?t.allowEmptyContent?!0:(f(4,[],[]),!1):V()?(n.getToken()!==17&&f(9,[],[]),!0):(f(4,[],[]),!1)}var X;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(X||(X={}));var Y;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Y||(Y={}));const me=ae;var Z;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Z||(Z={}));const q=e=>me(L.default.readFileSync(e,"utf8")),{existsSync:N}=L.default,ke=()=>{const{findPnpApi:e}=re.default;return e&&e(process.cwd())};function K(e){const l=q(e);return p.default.join(e,"..",l&&"tsconfig"in l?l.tsconfig:"tsconfig.json")}function be(e,l){let t=e;const n=e[0]===".";if(n||p.default.isAbsolute(e)){if(n&&(t===".."&&(t+="/tsconfig.json"),t=p.default.resolve(l,t)),N(t)&&L.default.statSync(t).isFile()||!t.endsWith(".json")&&(t+=".json",N(t)))return t;throw new Error(`File '${e}' not found.`)}const i=ke();if(i){const{resolveRequest:u}=i,[m,a]=e.split("/"),O=m.startsWith("@")?`${m}/${a}`:m;try{if(O===e){const k=u(p.default.join(O,"package.json"),l);if(k){const r=K(k);if(N(r))return r}}else{let k;try{k=u(e,l,{extensions:[".json"]})}catch(_){k=u(p.default.join(e,"tsconfig.json"),l)}if(k)return k}}catch(_){}}let o=M(l,p.default.join("node_modules",t));if(o){if(L.default.statSync(o).isDirectory()){const u=p.default.join(o,"package.json");if(N(u)?o=K(u):o=p.default.join(o,"tsconfig.json"),N(o))return o}else if(o.endsWith(".json"))return o}if(!t.endsWith(".json")&&(t+=".json",o=M(l,p.default.join("node_modules",t)),o))return o;throw new Error(`File '${e}' not found.`)}const Te=(e,l)=>{var t;const n=be(e,l),i=J(n);if(delete i.references,(t=i.compilerOptions)!=null&&t.baseUrl){const{compilerOptions:o}=i;o.baseUrl=p.default.relative(l,p.default.join(p.default.dirname(n),o.baseUrl))||"./"}return i.files&&(i.files=i.files.map(o=>p.default.relative(l,p.default.join(p.default.dirname(n),o)))),i.include&&(i.include=i.include.map(o=>p.default.relative(l,p.default.join(p.default.dirname(n),o)))),i},J=e=>{let l;try{l=L.default.realpathSync(e)}catch(_){throw new Error(`Cannot resolve tsconfig at path: ${e}`)}const t=p.default.dirname(l);let n=q(l)||{};if(typeof n!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);if(n.extends){const i=Array.isArray(n.extends)?n.extends:[n.extends];delete n.extends;for(const o of i.reverse()){const u=Te(o,t),m={...u,...n,compilerOptions:{...u.compilerOptions,...n.compilerOptions}};u.watchOptions&&(m.watchOptions={...u.watchOptions,...n.watchOptions}),n=m}}if(n.compilerOptions){const{compilerOptions:i}=n;i.baseUrl&&(i.baseUrl=W(i.baseUrl)),i.outDir&&(Array.isArray(n.exclude)||(n.exclude=[]),n.exclude.push(i.outDir),i.outDir=W(i.outDir))}else n.compilerOptions={};if(n.files&&(n.files=n.files.map(W)),n.include&&(n.include=n.include.map(d)),n.watchOptions){const{watchOptions:i}=n;i.excludeDirectories&&(i.excludeDirectories=i.excludeDirectories.map(o=>d(p.default.resolve(t,o))))}return n};function we(e=process.cwd(),l="tsconfig.json"){const t=M(d(e),l);if(!t)return null;const n=J(t);return{path:t,config:n}}const ve=/\*/g,C=(e,l)=>{const t=e.match(ve);if(t&&t.length>1)throw new Error(l)};function Oe(e){if(e.includes("*")){const[l,t]=e.split("*");return{prefix:l,suffix:t}}return e}const je=({prefix:e,suffix:l},t)=>t.startsWith(e)&&t.endsWith(l);function Ae(e,l,t){return Object.entries(e).map(([n,i])=>(C(n,`Pattern '${n}' can have at most one '*' character.`),{pattern:Oe(n),substitutions:i.map(o=>{if(C(o,`Substitution '${o}' in pattern '${n}' can have at most one '*' character.`),!l&&!S.test(o))throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return p.default.join(t,o)})}))}function de(e){if(!e.config.compilerOptions)return null;const{baseUrl:l,paths:t}=e.config.compilerOptions;if(!l&&!t)return null;const n=p.default.resolve(p.default.dirname(e.path),l||"."),i=t?Ae(t,l,n):[];return function(u){if(S.test(u))return[];const m=[];for(const r of i){if(r.pattern===u)return r.substitutions.map(d);typeof r.pattern!="string"&&m.push(r)}let a,O=-1;for(const r of m)je(r.pattern,u)&&r.pattern.prefix.length>O&&(O=r.pattern.prefix.length,a=r);if(!a)return l?[d(p.default.join(n,u))]:[];const k=u.slice(a.pattern.prefix.length,u.length-a.pattern.suffix.length);return a.substitutions.map(r=>d(r.replace("*",k)))}}const ee=e=>{let l="";for(let t=0;tMath.floor(Math.random()*26),Be=e=>Array.from({length:e},()=>String.fromCodePoint(Ee()+(Math.random()>.5?_e:Le))).join(""),Ue=(e=L.default)=>{const l=process.execPath;if(e.existsSync(l))return!e.existsSync(ee(l));const t=`/${Be(10)}`;e.writeFileSync(t,"");const n=!e.existsSync(ee(t));return e.unlinkSync(t),n},{join:y}=p.default.posix,G={ts:[".ts",".tsx",".d.ts"],cts:[".cts",".d.cts"],mts:[".mts",".d.mts"]},$e=e=>{const l=[...G.ts],t=[...G.cts],n=[...G.mts];return e!=null&&e.allowJs&&(l.push(".js",".jsx"),t.push(".cjs"),n.push(".mjs")),[...l,...t,...n]},Fe=e=>{const l=[];if(!e)return l;const{outDir:t,declarationDir:n}=e;return t&&l.push(t),n&&l.push(n),l},ne=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ne=["node_modules","bower_components","jspm_packages"],P=`(?!(${Ne.join("|")})(/|$))`,he=/(?:^|\/)[^.*?]+$/,te="**/*",I="[^/]",Q="[^./]",ie=process.platform==="win32",De=({config:e,path:l},t=Ue())=>{if("extends"in e)throw new Error("tsconfig#extends must be resolved. Use getTsconfig or parseTsconfig to resolve it.");if(!p.default.isAbsolute(l))throw new Error("The tsconfig path must be absolute");ie&&(l=d(l));const n=p.default.dirname(l),{files:i,include:o,exclude:u,compilerOptions:m}=e,a=i==null?void 0:i.map(b=>y(n,b)),O=$e(m),k=t?"":"i",$=(u||Fe(m)).map(b=>{const v=y(n,b),_=ne(v).replace(/\\\*\\\*\//g,"(.+/)?").replace(/\\\*/g,`${I}*`).replace(/\\\?/g,I);return new RegExp(`^${_}($|/)`,k)}),E=i||o?o:[te],A=E?E.map(b=>{let v=y(n,b);he.test(v)&&(v=y(v,te));const _=ne(v).replace(/\/\\\*\\\*/g,`(/${P}${Q}${I}*)*?`).replace(/(\/)?\\\*/g,(B,s)=>{const c=`(${Q}|(\\.(?!min\\.js$))?)*`;return s?`/${P}${Q}${c}`:c}).replace(/(\/)?\\\?/g,(B,s)=>{const c=I;return s?`/${P}${c}`:c});return new RegExp(`^${_}$`,k)}):void 0;return b=>{if(!p.default.isAbsolute(b))throw new Error("filePath must be absolute");if(ie&&(b=d(b)),a!=null&&a.includes(b))return e;if(!(!O.some(v=>b.endsWith(v))||$.some(v=>v.test(b)))&&A&&A.some(v=>v.test(b)))return e}};exports.createFilesMatcher=De,exports.createPathsMatcher=de,exports.getTsconfig=we,exports.parseTsconfig=J;