@ls-stack/extended-lint 0.79.0 → 0.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import{AST_NODE_TYPES as he}from"@typescript-eslint/utils";import{z as M}from"zod/v4";import{ESLintUtils as fi}from"@typescript-eslint/utils";import*as Ln from"zod/v4";function H(e){let r=fi.RuleCreator(t=>`https://github.com/lucasols/extended-lint#${t}`)(e);return{name:e.name,rule:r}}function z(e){return Ln.toJSONSchema(e)}var mi=M.object({disallow:M.array(M.object({selector:M.string(),message:M.string(),replace:M.optional(M.union([M.string(),M.object({regex:M.string(),with:M.string()})])),replaceType:M.optional(M.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:M.optional(M.array(M.object({fn:M.string(),withArgs:M.optional(M.array(M.object({atIndex:M.number(),value:M.union([M.string(),M.number(),M.boolean()])}))),message:M.string(),replaceWith:M.optional(M.string()),ignoreRegex:M.optional(M.string())}))),__dev_simulateFileName:M.optional(M.string()),mustMatchSyntax:M.optional(M.array(M.object({includeRegex:M.string(),mustCallFn:M.optional(M.array(M.object({anyCall:M.array(M.object({fn:M.string(),withArgs:M.array(M.object({atIndex:M.number(),literal:M.union([M.string(),M.number(),M.boolean()])}))})),message:M.optional(M.string())}))),mustMatchSelector:M.optional(M.array(M.object({selector:M.string(),message:M.string()}))),mustHaveExport:M.optional(M.array(M.object({name:M.string(),type:M.enum(["function","variable","any"]).default("any"),message:M.string()})))})))}),Ct=H({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[z(mi)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[n]){let r={},{mustMatchSyntax:t,__dev_simulateFileName:o,disallow:s,disallowFnCalls:i}=n,l=o??e.filename,c=[],a=new Map,u=new Set,m=new Map,y=new Set,C=new Map;function f(b){for(let w of b.specifiers)w.type===he.ImportSpecifier&&w.imported.type===he.Identifier&&w.imported.name!==w.local.name&&C.set(w.local.name,w.imported.name)}function E(b){if(b.declaration){if(b.declaration.type===he.FunctionDeclaration&&b.declaration.id){let w=b.declaration.id.name;for(let k of Array.from(y)){let[N,p]=k.split(":");N===w&&(p==="function"||p==="any")&&y.delete(k)}}else if(b.declaration.type===he.VariableDeclaration){for(let w of b.declaration.declarations)if(w.id.type===he.Identifier){let k=w.id.name;for(let N of Array.from(y)){let[p,R]=N.split(":");p===k&&(R==="variable"||R==="any")&&y.delete(N)}}}}for(let w of b.specifiers)if(w.exported.type===he.Identifier){let k=w.exported.name;for(let N of Array.from(y)){let[p,R]=N.split(":");p===k&&R==="any"&&y.delete(N)}}}function x(b){b.id.type===he.Identifier&&b.init?.type===he.Identifier&&C.set(b.id.name,b.init.name)}function S(b){return C.get(b)??b}function I(b,w){return S(b)===w||b===w}for(let{includeRegex:b,mustCallFn:w,mustMatchSelector:k,mustHaveExport:N}of t??[]){let R=function(d){let g=d;for(let{name:F,value:P}of p??[])g=g.replaceAll(F,P);return g};var h=R;let p=yi(l,new RegExp(b));if(p){for(let{anyCall:d,message:g}of w??[]){let F=`Expected file to call the function: ${d.map(({fn:P})=>P).join(" or ")}`;u.add(F),c.push(P=>{let{callee:j}=P;if(j.type===he.Identifier){for(let{fn:J,withArgs:G}of d)if(j.name===J){u.delete(F);for(let Y of G){let D=P.arguments[Y.atIndex],Z=typeof Y.literal=="string"?R(Y.literal):Y.literal;if(!D){e.report({node:P,messageId:"default",data:{message:`Missing argument with value "${Z}" at index ${Y.atIndex}${g?`: ${R(g)}`:""}`}});continue}if(D.type!==he.Literal){e.report({node:D,messageId:"default",data:{message:`Argument at position ${Y.atIndex} should the literal "${Z}"${g?`: ${R(g)}`:""}`}});continue}D.value!==Z&&e.report({node:D,messageId:"default",data:{message:`Argument should have the value "${Z}"${g?`: ${R(g)}`:""}`},fix:q=>q.replaceText(D,typeof Z=="string"?`'${Z}'`:String(Z))})}break}}})}for(let{selector:d,message:g}of k??[])m.set(d,R(g)),a.set(R(d),()=>{m.delete(d)});for(let{name:d,type:g,message:F}of N??[]){let P=R(d),j=R(F);y.add(`${P}:${g}:${j}`)}}}for(let{fn:b,withArgs:w,message:k,replaceWith:N,ignoreRegex:p}of i??[])p&&new RegExp(p).test(l)||c.push(R=>{let{callee:d}=R;if(d.type!==he.Identifier||!I(d.name,b))return;if(w)for(let F of w){let P=R.arguments[F.atIndex];if(!P){e.report({node:R,messageId:"default",data:{message:`Missing argument with value "${F.value}" at index ${F.atIndex}: ${k}`}});return}if(P.type!==he.Literal||P.value!==F.value)return}let g=F=>N?F.replaceText(R,N):null;e.report({node:R,messageId:"default",data:{message:k},suggest:N?[{messageId:"default",data:{message:`Replace with "${N}"`},fix:g}]:void 0})});function A(b,w){let k=r[b];k?r[b]=N=>{k(N),w(N)}:r[b]=w}for(let{selector:b,message:w,replace:k,replaceType:N="suggestion"}of s??[]){if(b==="CallExpression"){c.push(p=>{T(k,p,w,N)});continue}r[b]=p=>{T(k,p,w,N)}}if(a.size>0)for(let[b,w]of a)A(b,w);return c.length>0&&(r.CallExpression=b=>{if(b.type===he.CallExpression)for(let w of c)w(b)}),r.ImportDeclaration=b=>{b.type===he.ImportDeclaration&&f(b)},r.ExportNamedDeclaration=b=>{b.type===he.ExportNamedDeclaration&&E(b)},r.VariableDeclarator=b=>{b.type===he.VariableDeclarator&&x(b)},r["Program:exit"]=b=>{for(let w of u)e.report({node:b,messageId:"default",data:{message:w}});for(let[,w]of m)e.report({node:b,messageId:"default",data:{message:w}});for(let w of y){let[k,N,p]=w.split(":");e.report({node:b,messageId:"default",data:{message:`Missing required export "${k}" of type ${N}: ${p}`}})}},r;function T(b,w,k,N){let p=R=>{if(!b)return null;if(typeof b=="string")return R.replaceText(w,b);{let d=new RegExp(b.regex),g=e.sourceCode.getText(w);return R.replaceText(w,g.replace(d,b.with))}};e.report({node:w,messageId:"default",data:{message:k},fix:b&&N==="autofix"?p:void 0,suggest:b&&N==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof b=="string"?b:b.with}"`},fix:p}]:void 0})}}});function yi(e,n){let r=[],t=n.exec(e);if(!t)return null;let[o,...s]=t;r.push({name:"$0_lowercase",value:o.toLowerCase()}),r.push({name:"$0_capitalize",value:Mn(o)}),r.push({name:"$0_uncapitalize",value:_n(o)}),r.push({name:"$0",value:o});for(let i=0;i<s.length;i++){let l=`$${i+1}`,c=s[i];c!==void 0&&(r.push({name:`${l}_lowercase`,value:c.toLowerCase()}),r.push({name:`${l}_capitalize`,value:Mn(c)}),r.push({name:`${l}_uncapitalize`,value:_n(c)}),r.push({name:l,value:c}))}return r}function Mn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function _n(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as oe,AST_TOKEN_TYPES as $n,ESLintUtils as di}from"@typescript-eslint/utils";import{z as Je}from"zod/v4";var gi=di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zn="collapse-simple-objs-in-one-line",Si=Je.object({maxLineLength:Je.number().optional(),maxProperties:Je.number().optional(),nestedObjMaxLineLength:Je.number().optional(),nestedObjMaxProperties:Je.number().optional(),ignoreTypesWithSuffix:Je.array(Je.string()).optional()}),Ti=gi({name:zn,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[z(Si)]},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=n.ignoreTypesWithSuffix??[],o=n.maxProperties??2,s=n.nestedObjMaxLineLength??n.maxLineLength,i=n.nestedObjMaxProperties??3;function l(a){if(a.type===oe.ObjectExpression){let u=a.parent.type===oe.Property,m=u?i:o,y=a.properties.length;if(y>m)return!1;if(y===1){let f=a.properties[0];return!f||f.type===oe.Property&&f.value.type===oe.ObjectExpression||f.type===oe.Property&&f.value.type===oe.ArrayExpression&&!f.value.elements.every(x=>x&&It(x))?!1:{text:r.getText(f),isNested:u,propsSize:y}}let C=[];for(let f of a.properties){if(f.type===oe.Property&&!It(f.value))return!1;C.push(r.getText(f))}return{text:C.join(", "),isNested:u,propsSize:y}}else{let u=a.parent.parent?.type===oe.TSPropertySignature,m=u?i:o,y=a.members.length;if(y>m)return!1;if(t.length>0&&a.parent.type===oe.TSTypeAliasDeclaration){let f=a.parent.id.name;if(t.some(E=>f.endsWith(E)))return!1}if(y===1){let f=a.members[0];return!f||f.type===oe.TSPropertySignature&&f.typeAnnotation?.typeAnnotation.type===oe.TSTypeLiteral?!1:{text:r.getText(f),isNested:u,propsSize:1}}if(a.parent.type===oe.TSIntersectionType||a.parent.type===oe.TSUnionType&&a.parent.types[0]!==a)return!1;let C=[];for(let f of a.members){if(f.type!==oe.TSPropertySignature)return!1;let E=f.typeAnnotation?.typeAnnotation;if(!E||E.type===oe.TSTypeLiteral||!Un(E))return!1;if(E.type===oe.TSTypeReference&&E.typeArguments){if(E.typeArguments.params.length>1)return!1;let S=E.typeArguments.params[0];if(!S||!Un(S))return!1}let x=r.getText(f).trim();(x.endsWith(";")||x.endsWith(","))&&(x=x.slice(0,-1)),C.push(x)}return{text:C.join("; "),isNested:u,propsSize:y}}}function c(a){if(a.loc.start.line===a.loc.end.line)return;if(a.parent.type!==oe.JSXExpressionContainer){let E=0,x=!1,S=r.getTokenAfter(a,{filter:A=>A.type!==$n.Punctuator||x?!0:A.value===","?(E++,!1):A.value===";"?(E++,x=!0,!1):A.value===")"||A.value==="}"?(E++,!1):!0});if(E>4)return;let I=S?.type===$n.Template&&S.value.startsWith(`}
2
- `);if(S?.loc.start.line===a.loc.end.line&&!I)return}let u=l(a);if(!u)return;let m=u.text;if(m.includes(`
3
- `)||r.getCommentsInside(a).length>0)return;m.endsWith(";")&&(m=m.slice(0,-1));let y=`{ ${m} }`,C=Ei(r,a),f=u.isNested&&u.propsSize>2?s:n.maxLineLength;f&&y.length+C.length+hi(a,r)>f||e.report({node:a,messageId:"singleLineProp",fix:E=>E.replaceText(a,y)})}return{TSTypeLiteral:c,ObjectExpression:c}}});function Un(e){return e.type===oe.TSLiteralType||e.type===oe.TSTypeReference||e.type===oe.TSNumberKeyword||e.type===oe.TSStringKeyword||e.type===oe.TSBooleanKeyword||e.type===oe.TSNullKeyword||e.type===oe.TSUndefinedKeyword}function It(e,n){return!!(e.type===oe.Literal||e.type===oe.Identifier||e.type===oe.TemplateLiteral||e.type===oe.TaggedTemplateExpression||!n&&e.type===oe.ArrayExpression&&e.elements.every(r=>r&&It(r,!0)))}function hi(e,n){let r=n.getLastToken(e);if(!r)return 0;let t=n.text.indexOf(`
4
- `,r.range[1]);return(t!==-1?t:n.text.length)-r.range[1]}function Ei(e,n){return e.text.slice(n.range[0]-n.loc.start.column,n.range[0])}var At={name:zn,rule:Ti};var bi=/eslint +react-compiler\/react-compiler: +\["error/,Vn={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"},reactCompilerIsEnabled:{type:"boolean"}}}]},create(e){let n=!1,r=typeof e.getSource=="function"?I=>r(I):I=>e.sourceCode.getText(I),t=typeof e.getScope=="function"?()=>t():I=>e.sourceCode.getScope(I),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,s=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:s};function l(I){s&&Array.isArray(I.suggest)&&I.suggest.length>0&&(I.fix=I.suggest[0].fix),e.report(I)}let c=e.getSourceCode().scopeManager,a=new WeakMap,u=new WeakSet,m=new WeakMap,y=new WeakMap,C=new WeakSet;function f(I,A){return function(T){if(A.has(T))return A.get(T);let h=I(T);return A.set(T,h),h}}function E(I,A,T,h,b){b&&I.async&&l({node:I,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ import{AST_NODE_TYPES as he}from"@typescript-eslint/utils";import{z as M}from"zod/v4";import{ESLintUtils as yi}from"@typescript-eslint/utils";import*as _n from"zod/v4";function X(e){let r=yi.RuleCreator(t=>`https://github.com/lucasols/extended-lint#${t}`)(e);return{name:e.name,rule:r}}function U(e){return _n.toJSONSchema(e)}var di=M.object({disallow:M.array(M.object({selector:M.string(),message:M.string(),replace:M.optional(M.union([M.string(),M.object({regex:M.string(),with:M.string()})])),replaceType:M.optional(M.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:M.optional(M.array(M.object({fn:M.string(),withArgs:M.optional(M.array(M.object({atIndex:M.number(),value:M.union([M.string(),M.number(),M.boolean()])}))),message:M.string(),replaceWith:M.optional(M.string()),ignoreRegex:M.optional(M.string())}))),__dev_simulateFileName:M.optional(M.string()),mustMatchSyntax:M.optional(M.array(M.object({includeRegex:M.string(),mustCallFn:M.optional(M.array(M.object({anyCall:M.array(M.object({fn:M.string(),withArgs:M.array(M.object({atIndex:M.number(),literal:M.union([M.string(),M.number(),M.boolean()])}))})),message:M.optional(M.string())}))),mustMatchSelector:M.optional(M.array(M.object({selector:M.string(),message:M.string()}))),mustHaveExport:M.optional(M.array(M.object({name:M.string(),type:M.enum(["function","variable","any"]).default("any"),message:M.string()})))})))}),It=X({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[U(di)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[n]){let r={},{mustMatchSyntax:t,__dev_simulateFileName:o,disallow:s,disallowFnCalls:i}=n,l=o??e.filename,c=[],a=new Map,u=new Set,f=new Map,y=new Set,C=new Map;function m(b){for(let w of b.specifiers)w.type===he.ImportSpecifier&&w.imported.type===he.Identifier&&w.imported.name!==w.local.name&&C.set(w.local.name,w.imported.name)}function E(b){if(b.declaration){if(b.declaration.type===he.FunctionDeclaration&&b.declaration.id){let w=b.declaration.id.name;for(let k of Array.from(y)){let[N,p]=k.split(":");N===w&&(p==="function"||p==="any")&&y.delete(k)}}else if(b.declaration.type===he.VariableDeclaration){for(let w of b.declaration.declarations)if(w.id.type===he.Identifier){let k=w.id.name;for(let N of Array.from(y)){let[p,R]=N.split(":");p===k&&(R==="variable"||R==="any")&&y.delete(N)}}}}for(let w of b.specifiers)if(w.exported.type===he.Identifier){let k=w.exported.name;for(let N of Array.from(y)){let[p,R]=N.split(":");p===k&&R==="any"&&y.delete(N)}}}function x(b){b.id.type===he.Identifier&&b.init?.type===he.Identifier&&C.set(b.id.name,b.init.name)}function S(b){return C.get(b)??b}function I(b,w){return S(b)===w||b===w}for(let{includeRegex:b,mustCallFn:w,mustMatchSelector:k,mustHaveExport:N}of t??[]){let R=function(d){let g=d;for(let{name:F,value:P}of p??[])g=g.replaceAll(F,P);return g};var h=R;let p=gi(l,new RegExp(b));if(p){for(let{anyCall:d,message:g}of w??[]){let F=`Expected file to call the function: ${d.map(({fn:P})=>P).join(" or ")}`;u.add(F),c.push(P=>{let{callee:j}=P;if(j.type===he.Identifier){for(let{fn:V,withArgs:G}of d)if(j.name===V){u.delete(F);for(let Y of G){let D=P.arguments[Y.atIndex],Z=typeof Y.literal=="string"?R(Y.literal):Y.literal;if(!D){e.report({node:P,messageId:"default",data:{message:`Missing argument with value "${Z}" at index ${Y.atIndex}${g?`: ${R(g)}`:""}`}});continue}if(D.type!==he.Literal){e.report({node:D,messageId:"default",data:{message:`Argument at position ${Y.atIndex} should the literal "${Z}"${g?`: ${R(g)}`:""}`}});continue}D.value!==Z&&e.report({node:D,messageId:"default",data:{message:`Argument should have the value "${Z}"${g?`: ${R(g)}`:""}`},fix:q=>q.replaceText(D,typeof Z=="string"?`'${Z}'`:String(Z))})}break}}})}for(let{selector:d,message:g}of k??[])f.set(d,R(g)),a.set(R(d),()=>{f.delete(d)});for(let{name:d,type:g,message:F}of N??[]){let P=R(d),j=R(F);y.add(`${P}:${g}:${j}`)}}}for(let{fn:b,withArgs:w,message:k,replaceWith:N,ignoreRegex:p}of i??[])p&&new RegExp(p).test(l)||c.push(R=>{let{callee:d}=R;if(d.type!==he.Identifier||!I(d.name,b))return;if(w)for(let F of w){let P=R.arguments[F.atIndex];if(!P){e.report({node:R,messageId:"default",data:{message:`Missing argument with value "${F.value}" at index ${F.atIndex}: ${k}`}});return}if(P.type!==he.Literal||P.value!==F.value)return}let g=F=>N?F.replaceText(R,N):null;e.report({node:R,messageId:"default",data:{message:k},suggest:N?[{messageId:"default",data:{message:`Replace with "${N}"`},fix:g}]:void 0})});function A(b,w){let k=r[b];k?r[b]=N=>{k(N),w(N)}:r[b]=w}for(let{selector:b,message:w,replace:k,replaceType:N="suggestion"}of s??[]){if(b==="CallExpression"){c.push(p=>{T(k,p,w,N)});continue}r[b]=p=>{T(k,p,w,N)}}if(a.size>0)for(let[b,w]of a)A(b,w);return c.length>0&&(r.CallExpression=b=>{if(b.type===he.CallExpression)for(let w of c)w(b)}),r.ImportDeclaration=b=>{b.type===he.ImportDeclaration&&m(b)},r.ExportNamedDeclaration=b=>{b.type===he.ExportNamedDeclaration&&E(b)},r.VariableDeclarator=b=>{b.type===he.VariableDeclarator&&x(b)},r["Program:exit"]=b=>{for(let w of u)e.report({node:b,messageId:"default",data:{message:w}});for(let[,w]of f)e.report({node:b,messageId:"default",data:{message:w}});for(let w of y){let[k,N,p]=w.split(":");e.report({node:b,messageId:"default",data:{message:`Missing required export "${k}" of type ${N}: ${p}`}})}},r;function T(b,w,k,N){let p=R=>{if(!b)return null;if(typeof b=="string")return R.replaceText(w,b);{let d=new RegExp(b.regex),g=e.sourceCode.getText(w);return R.replaceText(w,g.replace(d,b.with))}};e.report({node:w,messageId:"default",data:{message:k},fix:b&&N==="autofix"?p:void 0,suggest:b&&N==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof b=="string"?b:b.with}"`},fix:p}]:void 0})}}});function gi(e,n){let r=[],t=n.exec(e);if(!t)return null;let[o,...s]=t;r.push({name:"$0_lowercase",value:o.toLowerCase()}),r.push({name:"$0_capitalize",value:$n(o)}),r.push({name:"$0_uncapitalize",value:Un(o)}),r.push({name:"$0",value:o});for(let i=0;i<s.length;i++){let l=`$${i+1}`,c=s[i];c!==void 0&&(r.push({name:`${l}_lowercase`,value:c.toLowerCase()}),r.push({name:`${l}_capitalize`,value:$n(c)}),r.push({name:`${l}_uncapitalize`,value:Un(c)}),r.push({name:l,value:c}))}return r}function $n(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Un(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as oe,AST_TOKEN_TYPES as zn,ESLintUtils as Si}from"@typescript-eslint/utils";import{z as Ve}from"zod/v4";var Ti=Si.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jn="collapse-simple-objs-in-one-line",hi=Ve.object({maxLineLength:Ve.number().optional(),maxProperties:Ve.number().optional(),nestedObjMaxLineLength:Ve.number().optional(),nestedObjMaxProperties:Ve.number().optional(),ignoreTypesWithSuffix:Ve.array(Ve.string()).optional()}),Ei=Ti({name:Jn,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[U(hi)]},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=n.ignoreTypesWithSuffix??[],o=n.maxProperties??2,s=n.nestedObjMaxLineLength??n.maxLineLength,i=n.nestedObjMaxProperties??3;function l(a){if(a.type===oe.ObjectExpression){let u=a.parent.type===oe.Property,f=u?i:o,y=a.properties.length;if(y>f)return!1;if(y===1){let m=a.properties[0];return!m||m.type===oe.Property&&m.value.type===oe.ObjectExpression||m.type===oe.Property&&m.value.type===oe.ArrayExpression&&!m.value.elements.every(x=>x&&At(x))?!1:{text:r.getText(m),isNested:u,propsSize:y}}let C=[];for(let m of a.properties){if(m.type===oe.Property&&!At(m.value))return!1;C.push(r.getText(m))}return{text:C.join(", "),isNested:u,propsSize:y}}else{let u=a.parent.parent?.type===oe.TSPropertySignature,f=u?i:o,y=a.members.length;if(y>f)return!1;if(t.length>0&&a.parent.type===oe.TSTypeAliasDeclaration){let m=a.parent.id.name;if(t.some(E=>m.endsWith(E)))return!1}if(y===1){let m=a.members[0];return!m||m.type===oe.TSPropertySignature&&m.typeAnnotation?.typeAnnotation.type===oe.TSTypeLiteral?!1:{text:r.getText(m),isNested:u,propsSize:1}}if(a.parent.type===oe.TSIntersectionType||a.parent.type===oe.TSUnionType&&a.parent.types[0]!==a)return!1;let C=[];for(let m of a.members){if(m.type!==oe.TSPropertySignature)return!1;let E=m.typeAnnotation?.typeAnnotation;if(!E||E.type===oe.TSTypeLiteral||!Wn(E))return!1;if(E.type===oe.TSTypeReference&&E.typeArguments){if(E.typeArguments.params.length>1)return!1;let S=E.typeArguments.params[0];if(!S||!Wn(S))return!1}let x=r.getText(m).trim();(x.endsWith(";")||x.endsWith(","))&&(x=x.slice(0,-1)),C.push(x)}return{text:C.join("; "),isNested:u,propsSize:y}}}function c(a){if(a.loc.start.line===a.loc.end.line)return;if(a.parent.type!==oe.JSXExpressionContainer){let E=0,x=!1,S=r.getTokenAfter(a,{filter:A=>A.type!==zn.Punctuator||x?!0:A.value===","?(E++,!1):A.value===";"?(E++,x=!0,!1):A.value===")"||A.value==="}"?(E++,!1):!0});if(E>4)return;let I=S?.type===zn.Template&&S.value.startsWith(`}
2
+ `);if(S?.loc.start.line===a.loc.end.line&&!I)return}let u=l(a);if(!u)return;let f=u.text;if(f.includes(`
3
+ `)||r.getCommentsInside(a).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let y=`{ ${f} }`,C=xi(r,a),m=u.isNested&&u.propsSize>2?s:n.maxLineLength;m&&y.length+C.length+bi(a,r)>m||e.report({node:a,messageId:"singleLineProp",fix:E=>E.replaceText(a,y)})}return{TSTypeLiteral:c,ObjectExpression:c}}});function Wn(e){return e.type===oe.TSLiteralType||e.type===oe.TSTypeReference||e.type===oe.TSNumberKeyword||e.type===oe.TSStringKeyword||e.type===oe.TSBooleanKeyword||e.type===oe.TSNullKeyword||e.type===oe.TSUndefinedKeyword}function At(e,n){return!!(e.type===oe.Literal||e.type===oe.Identifier||e.type===oe.TemplateLiteral||e.type===oe.TaggedTemplateExpression||!n&&e.type===oe.ArrayExpression&&e.elements.every(r=>r&&At(r,!0)))}function bi(e,n){let r=n.getLastToken(e);if(!r)return 0;let t=n.text.indexOf(`
4
+ `,r.range[1]);return(t!==-1?t:n.text.length)-r.range[1]}function xi(e,n){return e.text.slice(n.range[0]-n.loc.start.column,n.range[0])}var wt={name:Jn,rule:Ei};var Ci=/eslint +react-compiler\/react-compiler: +\["error/,Xn={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"},reactCompilerIsEnabled:{type:"boolean"}}}]},create(e){let n=!1,r=typeof e.getSource=="function"?I=>r(I):I=>e.sourceCode.getText(I),t=typeof e.getScope=="function"?()=>t():I=>e.sourceCode.getScope(I),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,s=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:s};function l(I){s&&Array.isArray(I.suggest)&&I.suggest.length>0&&(I.fix=I.suggest[0].fix),e.report(I)}let c=e.getSourceCode().scopeManager,a=new WeakMap,u=new WeakSet,f=new WeakMap,y=new WeakMap,C=new WeakSet;function m(I,A){return function(T){if(A.has(T))return A.get(T);let h=I(T);return A.set(T,h),h}}function E(I,A,T,h,b){b&&I.async&&l({node:I,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
5
5
 
6
6
  useEffect(() => {
7
7
  async function fetchData() {
@@ -12,15 +12,15 @@ useEffect(() => {
12
12
  fetchData();
13
13
  }, [someId]); // Or [] if effect doesn't need props or state
14
14
 
15
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let w=c.acquire(I),k=new Set,N=null;{let v=w.upper;for(;v&&(k.add(v),v.type!=="function");)v=v.upper;if(!v)return;N=v}let p=Array.isArray;function R(v){if(!p(v.defs))return!1;let O=v.defs[0];if(O==null||O.node.type!=="VariableDeclarator")return!1;let _=O.node.init;if(_==null)return!1;for(;_.type==="TSAsExpression";)_=_.expression;let U=O.node.parent;if(U==null&&(Ft(N.block,O.node.id),U=O.node.parent,U==null))return!1;if(U.kind==="const"&&_.type==="Literal"&&(typeof _.value=="string"||typeof _.value=="number"||_.value===null))return!0;if(_.type!=="CallExpression")return!1;let B=_.callee;if(B.type==="MemberExpression"&&B.object.name==="React"&&B.property!=null&&!B.computed&&(B=B.property),B.type!=="Identifier")return!1;let V=O.node.id,{name:K}=B;if(K==="useRef"&&V.type==="Identifier")return!0;if(wi(B)&&V.type==="Identifier"){for(let ee of v.references)ee!==V&&C.add(ee.identifier);return!0}else if(K==="useState"||K==="useReducer"){if(V.type==="ArrayPattern"&&V.elements.length===2&&p(v.identifiers)){if(V.elements[1]===v.identifiers[0]){if(K==="useState"){let ee=v.references,we=0;for(let Le=0;Le<ee.length;Le++){if(ee[Le].isWrite()&&we++,we>1)return!1;a.set(ee[Le].identifier,V.elements[0])}}return!0}else if(V.elements[0]===v.identifiers[0]){if(K==="useState"){let ee=v.references;for(let we=0;we<ee.length;we++)u.add(ee[we].identifier)}return!1}}}else if(K==="useTransition"&&V.type==="ArrayPattern"&&V.elements.length===2&&Array.isArray(v.identifiers)&&V.elements[1]===v.identifiers[0])return!0;return!1}function d(v){if(!p(v.defs))return!1;let O=v.defs[0];if(O==null||O.node==null||O.node.id==null)return!1;let _=O.node,U=N.childScopes,B=null,V;for(V=0;V<U.length;V++){let K=U[V],ee=K.block;if(_.type==="FunctionDeclaration"&&ee===_||_.type==="VariableDeclarator"&&ee.parent===_){B=K;break}}if(B==null)return!1;for(V=0;V<B.through.length;V++){let K=B.through[V];if(K.resolved!=null&&k.has(K.resolved.scope)&&!g(K.resolved))return!1}return!0}let g=f(R,m),F=f(d,y),P=new Map;function j(v){let O=v.from,_=!1;for(;O.block!==I;)O.type==="function"&&(_=O.block.parent!=null&&O.block.parent.type==="ReturnStatement"),O=O.upper;return _}let J=new Map,G=new Map;Y(w);function Y(v){for(let O of v.references){if(!O.resolved||!k.has(O.resolved.scope))continue;let _=Ft(I,O.identifier),U=Jn(_),B=Me(U,G);if(b&&U.type==="Identifier"&&(U.parent.type==="MemberExpression"||U.parent.type==="OptionalMemberExpression")&&!U.parent.computed&&U.parent.property.type==="Identifier"&&U.parent.property.name==="current"&&j(O)&&P.set(B,{reference:O,dependencyNode:U}),U.parent.type==="TSTypeQuery"||U.parent.type==="TSTypeReference")continue;let V=O.resolved.defs[0];if(V!=null&&!(V.node!=null&&V.node.init===I.parent)&&V.type!=="TypeParameter")if(J.has(B))J.get(B).references.push(O);else{let K=O.resolved,ee=g(K)||F(K);J.set(B,{isStable:ee,references:[O]})}}for(let O of v.childScopes)Y(O)}P.forEach(({reference:v,dependencyNode:O},_)=>{let U=v.resolved.references,B=!1;for(let V=0;V<U.length;V++){let{identifier:K}=U[V],{parent:ee}=K;if(ee!=null&&ee.type==="MemberExpression"&&!ee.computed&&ee.property.type==="Identifier"&&ee.property.name==="current"&&ee.parent.type==="AssignmentExpression"&&ee.parent.left===ee){B=!0;break}}B||l({node:O.parent.property,message:`The ref value '${_}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${_}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let D=new Set;function Z(v,O){D.has(O)||(D.add(O),l({node:v,message:`Assignments to the '${O}' variable from inside React Hook ${r(T)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${r(T)}.`}))}let q=new Set;if(J.forEach(({isStable:v,references:O},_)=>{v&&q.add(_),O.forEach(U=>{U.writeExpr&&Z(U.writeExpr,_)})}),D.size>0)return;if(!A){let v=null;if(J.forEach(({isStable:O,references:_},U)=>{v||_.forEach(B=>{if(v)return;let V=B.identifier;if(!a.has(V))return;let ee=B.from;for(;ee.type!=="function";)ee=ee.upper;ee.block===I&&(v=U)})}),v){let{suggestedDependencies:O}=wt({dependencies:J,declaredDependencies:[],stableDependencies:q,externalDependencies:new Set,isEffect:!0});l({node:T,message:`React Hook ${h} contains a call to '${v}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+O.join(", ")+`] as a second argument to the ${h} Hook.`,suggest:[{desc:`Add dependencies array: [${O.join(", ")}]`,fix(_){return _.insertTextAfter(I,`, [${O.join(", ")}]`)}}]})}return}let ce=[],ue=new Set;A.type!=="ArrayExpression"?l({node:A,message:`React Hook ${r(T)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):A.elements.forEach(v=>{if(v===null)return;if(v.type==="SpreadElement"){l({node:v,message:`React Hook ${r(T)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}C.has(v)&&l({node:v,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(v)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(v)}\``,fix(B){return B.removeRange(v.range)}}]});let O;try{O=Me(v,G)}catch(B){if(/Unsupported node type/.test(B.message)){v.type==="Literal"?J.has(v.value)?l({node:v,message:`The ${v.raw} literal is not a valid dependency because it never changes. Did you mean to include ${v.value} in the array instead?`}):l({node:v,message:`The ${v.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):l({node:v,message:`React Hook ${r(T)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw B}let _=v;for(;_.type==="MemberExpression"||_.type==="OptionalMemberExpression"||_.type==="ChainExpression";)_=_.object||_.expression.object;let U=!N.through.some(B=>B.identifier===_);ce.push({key:O,node:v}),U||ue.add(O)});let{suggestedDependencies:Ae,unnecessaryDependencies:Ue,missingDependencies:ge,duplicateDependencies:et}=wt({dependencies:J,declaredDependencies:ce,stableDependencies:q,externalDependencies:ue,isEffect:b}),He=Ae;if(et.size+ge.size+Ue.size===0){if(n)return;xi({declaredDependencies:ce,declaredDependenciesNode:A,componentScope:N,scope:w}).forEach(({construction:O,isUsedOutsideOfHook:_,depType:U})=>{let B=U==="function"?"useCallback":"useMemo",V=U==="function"?"definition":"initialization",K=`wrap the ${V} of '${O.name.name}' in its own ${B}() Hook.`,ee=_?`To fix this, ${K}`:`Move it inside the ${h} callback. Alternatively, ${K}`,we=U==="conditional"||U==="logical expression"?"could make":"makes",Le=`The '${O.name.name}' ${U} ${we} the dependencies of ${h} Hook (at line ${A.loc.start.line}) change on every render. ${ee}`,Dn;_&&O.type==="Variable"&&U==="function"&&(Dn=[{desc:`Wrap the ${V} of '${O.name.name}' in its own ${B}() Hook.`,fix(jn){let[ci,ui]=B==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[jn.insertTextBefore(O.node.init,ci),jn.insertTextAfter(O.node.init,ui)]}}]),l({node:O.node,message:Le,suggest:Dn})});return}!b&&ge.size>0&&(He=wt({dependencies:J,declaredDependencies:[],stableDependencies:q,externalDependencies:ue,isEffect:b}).suggestedDependencies);function Ee(){if(ce.length===0)return!0;let v=ce.map(_=>_.key),O=v.slice().sort();return v.join(",")===O.join(",")}Ee()&&He.sort();function xe(v){let O=v.split("."),_="";for(let U=0;U<O.length;U++){if(U!==0){let B=O.slice(0,U+1).join("."),V=G.get(B)===!0;_+=V?"?.":"."}_+=O[U]}return _}function xt(v,O,_,U){return v.size===0?null:(v.size>1?"":O+" ")+_+" "+(v.size>1?"dependencies":"dependency")+": "+Ii(Array.from(v).sort().map(B=>"'"+xe(B)+"'"))+`. Either ${U} ${v.size>1?"them":"it"} or remove the dependency array.`}let ke="";if(Ue.size>0){let v=null;if(Array.from(Ue.keys()).forEach(O=>{v===null&&O.endsWith(".current")&&(v=O)}),v!==null)ke=` Mutable values like '${v}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ue.size>0){let O=Array.from(ue)[0];w.set.has(O)||(ke=` Outer scope values like '${O}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ke&&ge.has("props")){let v=J.get("props");if(v==null)return;let O=v.references;if(!Array.isArray(O))return;let _=!0;for(let U=0;U<O.length;U++){let B=O[U],V=Ft(N.block,B.identifier);if(!V){_=!1;break}let K=V.parent;if(K==null){_=!1;break}if(K.type!=="MemberExpression"&&K.type!=="OptionalMemberExpression"){_=!1;break}}_&&(ke=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${h} call and refer to those specific props inside ${r(T)}.`)}if(!ke&&ge.size>0){let v=null;ge.forEach(O=>{if(v)return;let _=N.set.get(O),U=J.get(O);if(U.references[0].resolved!==_)return;let B=_.defs[0];if(B==null||B.name==null||B.type!=="Parameter")return;let V=!1,K;for(let ee=0;ee<U.references.length;ee++)if(K=U.references[ee].identifier,K!=null&&K.parent!=null&&(K.parent.type==="CallExpression"||K.parent.type==="OptionalCallExpression")&&K.parent.callee===K){V=!0;break}V&&(v=O)}),v!==null&&(ke=` If '${v}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ke&&ge.size>0){let v=null;if(ge.forEach(O=>{if(v!==null)return;let U=J.get(O).references,B,V;for(let K=0;K<U.length;K++){for(B=U[K].identifier,V=B.parent;V!=null&&V!==N.block;){if(V.type==="CallExpression"){let ee=a.get(V.callee);if(ee!=null){if(ee.name===O)v={missingDep:O,setter:V.callee.name,form:"updater"};else if(u.has(B))v={missingDep:O,setter:V.callee.name,form:"reducer"};else{let we=U[K].resolved;if(we!=null){let Le=we.defs[0];Le!=null&&Le.type==="Parameter"&&(v={missingDep:O,setter:V.callee.name,form:"inlineReducer"})}}break}}V=V.parent}if(v!==null)break}}),v!==null)switch(v.form){case"reducer":ke=` You can also replace multiple useState variables with useReducer if '${v.setter}' needs the current value of '${v.missingDep}'.`;break;case"inlineReducer":ke=` If '${v.setter}' needs the current value of '${v.missingDep}', you can also switch to useReducer instead of useState and read '${v.missingDep}' in the reducer.`;break;case"updater":ke=` You can also do a functional update '${v.setter}(${v.missingDep.slice(0,1)} => ...)' if you only need '${v.missingDep}' in the '${v.setter}' call.`;break;default:throw new Error("Unknown case.")}}l({node:A,message:`React Hook ${r(T)} has `+(xt(ge,"a","missing","include")||xt(Ue,"an","unnecessary","exclude")||xt(et,"a","duplicate","omit"))+ke,suggest:[{desc:`Update the dependencies array to be: [${He.map(xe).join(", ")}]`,fix(v){return v.replaceText(A,`[${He.map(xe).join(", ")}]`)}}]})}function x(I){let A=Ci(I.callee,i);if(A===-1)return;let T=I.arguments[A],h=I.callee,b=Xn(h).name,w=I.arguments[A+1],k=/Effect($|[^a-z])/g.test(b);if(!T){l({node:h,message:`React Hook ${b} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(n&&!k)){if(!w&&!k){(b==="useMemo"||b==="useCallback")&&l({node:h,message:`React Hook ${b} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(T.type){case"FunctionExpression":case"ArrowFunctionExpression":E(T,w,h,b,k);return;case"Identifier":if(!w||w.elements&&w.elements.some(R=>R&&R.type==="Identifier"&&R.name===T.name))return;let N=t(I).set.get(T.name);if(N==null||N.defs==null)return;let p=N.defs[0];if(!p||!p.node||p.type!=="Variable"&&p.type!=="FunctionName")break;switch(p.node.type){case"FunctionDeclaration":E(p.node,w,h,b,k);return;case"VariableDeclarator":let R=p.node.init;if(!R)break;switch(R.type){case"ArrowFunctionExpression":case"FunctionExpression":E(R,w,h,b,k);return}break}break;default:l({node:h,message:`React Hook ${b} received a function whose dependencies are unknown. Pass an inline function instead.`});return}l({node:h,message:`React Hook ${b} has a missing dependency: '${T.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${T.name}]`,fix(N){return N.replaceText(w,`[${T.name}]`)}}]})}}let S=!!e.options[0]?.reactCompilerIsEnabled;if(e.options[0]?.ignoreIfReactCompilerIsEnabled||S){for(let I of e.sourceCode.getAllComments())if(S||bi.test(I.value))return n=!0,{CallExpression:A=>x(A,!0)}}return{CallExpression:I=>x(I)}}};function wt({dependencies:e,declaredDependencies:n,stableDependencies:r,externalDependencies:t,isEffect:o}){let s=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,x)=>{let S=l(s,x);S.isUsed=!0,c(s,x,I=>{I.isSubtreeUsed=!0})}),n.forEach(({key:E})=>{let x=l(s,E);x.isSatisfiedRecursively=!0}),r.forEach(E=>{let x=l(s,E);x.isSatisfiedRecursively=!0});function l(E,x){let S=x.split("."),I=E;for(let A of S){let T=I.children.get(A);T||(T=i(),I.children.set(A,T)),I=T}return I}function c(E,x,S){let I=x.split("."),A=E;for(let T of I){let h=A.children.get(T);if(!h)return;S(h),A=h}}let a=new Set,u=new Set;m(s,a,u,E=>E);function m(E,x,S,I){E.children.forEach((A,T)=>{let h=I(T);if(A.isSatisfiedRecursively){A.isSubtreeUsed&&S.add(h);return}if(A.isUsed){x.add(h);return}m(A,x,S,b=>h+"."+b)})}let y=[],C=new Set,f=new Set;return n.forEach(({key:E})=>{u.has(E)?y.indexOf(E)===-1?y.push(E):f.add(E):C.add(E)}),a.forEach(E=>{y.push(E)}),{suggestedDependencies:y,unnecessaryDependencies:C,duplicateDependencies:f,missingDependencies:a}}function ze(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return ze(e.consequent)!=null||ze(e.alternate)!=null?"conditional":null;case"LogicalExpression":return ze(e.left)!=null||ze(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return ze(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return ze(e.expression);case"TSAsExpression":return ze(e.expression)}return null}function xi({declaredDependencies:e,declaredDependenciesNode:n,componentScope:r,scope:t}){let o=e.map(({key:i})=>{let l=r.variables.find(a=>a.name===i);if(l==null)return null;let c=l.defs[0];if(c==null)return null;if(c.type==="Variable"&&c.node.type==="VariableDeclarator"&&c.node.id.type==="Identifier"&&c.node.init!=null){let a=ze(c.node.init);if(a!=null)return[l,a]}return c.type==="FunctionName"&&c.node.type==="FunctionDeclaration"?[l,"function"]:c.type==="ClassName"&&c.node.type==="ClassDeclaration"?[l,"class"]:null}).filter(Boolean);function s(i){let l=!1;for(let c=0;c<i.references.length;c++){let a=i.references[c];if(a.writeExpr){if(l)return!0;l=!0;continue}let u=a.from;for(;u!==t&&u!=null;)u=u.upper;if(u!==t&&!Bn(n,a.identifier))return!0}return!1}return o.map(([i,l])=>({construction:i.defs[0],depType:l,isUsedOutsideOfHook:s(i)}))}function Jn(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?Jn(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Rt(e,n,r){n&&(e.optional?n.has(r)||n.set(r,!0):n.has(r)||n.set(r,!1))}function Me(e,n){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return n&&n.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=Me(e.object,n),t=Me(e.property,null),o=`${r}.${t}`;return Rt(e,n,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Me(e.object,n),t=Me(e.property,null),o=`${r}.${t}`;return Rt(e,n,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let t=Me(r.object,n),o=Me(r.property,null),s=`${t}.${o}`;return Rt(r,n,s),s}else throw new Error(`Unsupported node type: ${e.type}`)}function Xn(e,n){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Ci(e,n){let r=Xn(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&n&&n.additionalHooks){let t;try{t=Me(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return n.additionalHooks.test(t)?0:-1}else return-1}}function Ft(e,n){let r=[e],t=null;for(;r.length;){if(t=r.shift(),Ai(t,n))return t;if(Bn(t,n))for(let[o,s]of Object.entries(t))o!=="parent"&&(Wn(s)?(s.parent=t,r.push(s)):Array.isArray(s)&&s.forEach(i=>{Wn(i)&&(i.parent=t,r.push(i))}))}return null}function Ii(e){let n="";for(let r=0;r<e.length;r++)n+=e[r],r===0&&e.length===2?n+=" and ":r===e.length-2&&e.length>2?n+=", and ":r<e.length-1&&(n+=", ");return n}function Wn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Ai(e,n){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===n.type&&e.name===n.name&&e.range[0]===n.range[0]&&e.range[1]===n.range[1]}function Bn(e,n){return e.range[0]<=n.range[0]&&e.range[1]>=n.range[1]}function wi(e){return!1}import{AST_NODE_TYPES as pe,ESLintUtils as Qn}from"@typescript-eslint/utils";import X from"typescript";import{z as Zn}from"zod/v4";import{AST_NODE_TYPES as Hn}from"@typescript-eslint/utils";function Ye(e,n,r=1/0){if(r!==0&&e.parent)return e.type===n?e:Ye(e.parent,n,r===1/0?r:r-1)}function*vt(e){yield e,e.parent&&(yield*vt(e.parent))}function kt(e,n){for(let r of e){let t=n(r);if(t!=null&&t!==!1)return t}}function qn(e,n,r){let o=r.getDeclaredVariables(e).find(s=>s.name===n||s.identifiers[0]?.parent.type===Hn.Property&&s.identifiers[0].parent.key.type===Hn.Identifier&&s.identifiers[0].parent.key.name===n);return o?o.references.filter(s=>!s.init):[]}function Yn(e){return e===null||typeof e!="object"||!("type"in e)?!1:typeof e.type=="string"}function Ri(e,n){return e[n]}function Pe(e,n,r){let t=r.visitorKeys,o=new Set;function s(i){if(o.has(i))return!1;if(o.add(i),n(i)===!0)return!0;let c=t[i.type];if(c)for(let a of c){let u=Ri(i,a);if(u){if(Array.isArray(u)){for(let m of u)if(Yn(m)&&s(m))return!0}else if(Yn(u)&&s(u))return!0}}return!1}s(e)}var Fi=Qn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gn="improved-no-unnecessary-condition",vi=Zn.object({alternativeForInCondition:Zn.string().optional().describe("Alternative to appear in the error for `in` condition")}),Kn={object:"Array",property:"isArray"},ki=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Pi=new Set(ki),Pt={name:Gn,rule:Fi({name:Gn,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".',unnecessaryStartsWithCondition:"This startsWith check is unnecessary as it always evaluates to true.",alwaysFalseStartsWithCondition:"This startsWith check will always be false.",unnecessaryEndsWithCondition:"This endsWith check is unnecessary as it always evaluates to true.",alwaysFalseEndsWithCondition:"This endsWith check will always be false.",unnecessaryIncludesCondition:"This includes check is unnecessary as it always evaluates to true.",alwaysFalseIncludesCondition:"This includes check will always be false.",unnecessaryArrayIsArrayCondition:"This Array.isArray check is unnecessary as it always evaluates to true.",alwaysFalseArrayIsArrayCondition:"This Array.isArray check will always be false.",unnecessaryLengthCondition:"This length comparison is unnecessary as it always evaluates to true.",alwaysFalseLengthCondition:"This length comparison will always be false.",unnecessaryInCondition:'This in check is unnecessary. Property "{{property}}" always exists on type "{{type}}".{{alternative}}',alwaysFalseInCondition:'This in check will always be false. Property "{{property}}" does not exist on type "{{type}}".{{alternative}}'},schema:[z(vi)]},defaultOptions:[{}],create(e,[n]){let r=Qn.getParserServices(e,!0),t=r.program?.getTypeChecker();if(!t||!r.program)throw new Error("TypeScript services or program not available");function o(p){return p.type===pe.UnaryExpression&&p.operator==="typeof"}function s(p){return p.flags&X.TypeFlags.Any||p.flags&X.TypeFlags.Unknown?null:p.flags&X.TypeFlags.StringLike?["string"]:p.flags&X.TypeFlags.NumberLike?["number"]:p.flags&X.TypeFlags.BigIntLike?["bigint"]:p.flags&X.TypeFlags.BooleanLike?["boolean"]:p.flags&X.TypeFlags.ESSymbolLike?["symbol"]:p.flags&X.TypeFlags.Undefined||p.flags&X.TypeFlags.Void?["undefined"]:p.flags&X.TypeFlags.Null?["object"]:p.getCallSignatures().length>0?["function"]:p.flags&X.TypeFlags.Object?p.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:p.flags&X.TypeFlags.NonPrimitive?["object"]:p.flags&X.TypeFlags.Never?["never"]:null}function i(p){if(!t)return null;let R=r.esTreeNodeToTSNodeMap.get(p),d=t.getTypeAtLocation(R.expression);if(d.flags&X.TypeFlags.Any||d.flags&X.TypeFlags.Unknown)return null;let g=[];if(d.isUnion()){for(let P of d.types){let j=s(P);if(j)g.push(...j);else return null}return g}let F=s(d);return F?(g.push(...F),g):null}function l(p){if(!(p.operator==="==="||p.operator==="!=="))return;let d=null,g=null;if(o(p.left)?(d=p.left,g=p.right.type===pe.Literal&&typeof p.right.value=="string"?p.right.value:null):o(p.right)&&(d=p.right,g=p.left.type===pe.Literal&&typeof p.left.value=="string"?p.left.value:null),!d||!g||!Oi(g,Pi))return;let F=i(d);if(!F)return;let P=p.operator==="!==",j=F.includes(g);F.length===1?j&&!P?e.report({node:p,messageId:"unnecessaryTypeofCondition",data:{name:qe(d,e),type:g}}):!j&&P?e.report({node:p,messageId:"unnecessaryTypeofCondition",data:{name:qe(d,e),type:Array.from(F)[0]}}):!j&&!P?e.report({node:p,messageId:"alwaysFalseTypeofCondition",data:{name:qe(d,e),actualType:pt(F),conditionType:g}}):j&&P&&e.report({node:p,messageId:"alwaysFalseTypeofCondition",data:{name:qe(d,e),actualType:pt(F),conditionType:g}}):!j&&!P?e.report({node:p,messageId:"alwaysFalseTypeofCondition",data:{name:qe(d,e),actualType:pt(F),conditionType:g}}):!j&&P&&e.report({node:p,messageId:"unnecessaryTypeofCondition",data:{name:qe(d,e),type:pt(F)}})}function c(p){if(p.flags&X.TypeFlags.Any||p.flags&X.TypeFlags.Unknown)return null;if(p.isUnion()){let R=[];for(let d of p.types)if(d.flags&X.TypeFlags.StringLiteral){let g=d.value;R.push(g)}else return null;return R}return p.flags&X.TypeFlags.StringLiteral?[p.value]:null}function a(p){if(!t)return null;let R=r.esTreeNodeToTSNodeMap.get(p),d=t.getTypeAtLocation(R),g=c(d);if(g)return g;let F=t.getSymbolAtLocation(R);if(F){let P=t.getTypeOfSymbolAtLocation(F,R),j=c(P);if(j)return j}return null}function u(p){let R=e.sourceCode.ast,d=null;return Pe(R,g=>{if(g.type===pe.VariableDeclarator&&g.id.type===pe.Identifier&&g.id.name===p.name&&g.id.typeAnnotation){let F=g.id.typeAnnotation.typeAnnotation;if(F.type===pe.TSUnionType){let P=[];for(let j of F.types)if(j.type===pe.TSLiteralType&&j.literal.type===pe.Literal&&typeof j.literal.value=="string")P.push(j.literal.value);else return!0;return d=P,!0}if(F.type===pe.TSLiteralType&&F.literal.type===pe.Literal&&typeof F.literal.value=="string")return d=[F.literal.value],!0}return!1},e.sourceCode),d}function m(p){return p==="Array"||p==="ReadonlyArray"?!0:p.endsWith(".Array")||p.endsWith(".ReadonlyArray")}function y(p){if(!t)return!1;if(t.isArrayType(p)||t.isTupleType(p))return!0;let R=t.getApparentType(p);if(R!==p&&(t.isArrayType(R)||t.isTupleType(R)))return!0;if(p.aliasSymbol){let g=t.getFullyQualifiedName(p.aliasSymbol);if(m(g))return!0}let d=p.getSymbol();if(d){let g=t.getFullyQualifiedName(d);if(m(g))return!0}return!1}function C(p){if(!t)return!1;if(p.flags&X.TypeFlags.StringLike||p.flags&X.TypeFlags.NumberLike||p.flags&X.TypeFlags.BigIntLike||p.flags&X.TypeFlags.BooleanLike||p.flags&X.TypeFlags.ESSymbolLike||p.flags&X.TypeFlags.EnumLike||p.flags&X.TypeFlags.Null||p.flags&X.TypeFlags.Undefined||p.flags&X.TypeFlags.Void||p.flags&X.TypeFlags.Never)return!0;let R=p.getSymbol();if(R){let d=t.getFullyQualifiedName(R);if(d==="__function"||d==="__object"&&!y(p))return!0}return!1}function f(p){if(p.flags&X.TypeFlags.Any||p.flags&X.TypeFlags.Unknown)return"unknown";if(p.isUnion()){let R=!0,d=!0;for(let g of p.types){let F=f(g);if(F==="unknown")return"unknown";F!=="alwaysTrue"&&(R=!1),F!=="alwaysFalse"&&(d=!1)}return R?"alwaysTrue":d?"alwaysFalse":"unknown"}return y(p)?"alwaysTrue":C(p)?"alwaysFalse":"unknown"}function E(p){return!p.computed&&p.object.type===pe.Identifier&&p.object.name===Kn.object&&p.property.type===pe.Identifier&&p.property.name===Kn.property}function x(p){if(!t||p.callee.type!==pe.MemberExpression||!E(p.callee)||p.arguments.length===0)return;let[R]=p.arguments;if(!R||R.type===pe.SpreadElement)return;let d=r.esTreeNodeToTSNodeMap.get(R),g=t.getTypeAtLocation(d),F=f(g);F==="alwaysTrue"?e.report({node:p,messageId:"unnecessaryArrayIsArrayCondition"}):F==="alwaysFalse"&&e.report({node:p,messageId:"alwaysFalseArrayIsArrayCondition"})}function S(p){if(p.callee.type!==pe.MemberExpression||p.callee.property.type!==pe.Identifier||p.callee.computed)return;let R=p.callee.property.name;if(R!=="startsWith"&&R!=="endsWith"&&R!=="includes"||p.arguments.length!==1)return;let[d]=p.arguments;if(!d||d.type!==pe.Literal||typeof d.value!="string")return;let g=p.callee.object,F=a(g);if(!F&&g.type===pe.Identifier&&(F=u(g)),!F||F.length===0)return;let P=d.value;if(R==="includes"&&F.length>1)return;let j=0,J=0;for(let G of F)if((R==="startsWith"?G.startsWith(P):R==="endsWith"?G.endsWith(P):G.includes(P))?j++:J++,j>0&&J>0)return;if(j>0&&J===0){let G=R==="startsWith"?"unnecessaryStartsWithCondition":R==="endsWith"?"unnecessaryEndsWithCondition":"unnecessaryIncludesCondition";e.report({node:p,messageId:G})}else if(J>0&&j===0){let G=R==="startsWith"?"alwaysFalseStartsWithCondition":R==="endsWith"?"alwaysFalseEndsWithCondition":"alwaysFalseIncludesCondition";e.report({node:p,messageId:G})}}function I(p){if(!new Set(["===","!==",">",">=","<","<="]).has(p.operator))return;function d(Y){if(Y.type!==pe.MemberExpression||Y.computed||Y.property.type!==pe.Identifier||Y.property.name!=="length")return null;let D=Y.object,Z=a(D);if(!Z||Z.length===0)return null;let q=[];for(let ce of Z)q.push(ce.length);return{values:q}}let g=d(p.left),F=d(p.right),P=null,j=null;if(g?p.right.type===pe.Literal&&typeof p.right.value=="number"&&(P=g.values,j=p.right.value):F&&p.left.type===pe.Literal&&typeof p.left.value=="number"&&(P=F.values,j=p.left.value),!P||j===null)return;let J=0,G=0;for(let Y of P){let D=!1;if(p.operator==="==="?D=Y===j:p.operator==="!=="?D=Y!==j:p.operator===">"?D=Y>j:p.operator===">="?D=Y>=j:p.operator==="<"?D=Y<j:p.operator==="<="&&(D=Y<=j),D?J++:G++,J>0&&G>0)return}J>0&&G===0?e.report({node:p,messageId:"unnecessaryLengthCondition"}):G>0&&J===0&&e.report({node:p,messageId:"alwaysFalseLengthCondition"})}function A(p){if(p.type===pe.Literal&&typeof p.value=="string")return p.value;let R=a(p);if(!R||R.length!==1)return null;let[d]=R;return d??null}function T(p){return(p.flags&X.TypeFlags.Intersection)!==0}function h(p){return(p.flags&X.TypeFlags.Object)!==0}function b(p){return!t||t.getIndexTypeOfType(p,X.IndexKind.String)?!0:!!t.getIndexTypeOfType(p,X.IndexKind.Number)}function w(p,R){if(!t||b(p)||p.getProperties().length===0)return"unknown";let d=t.getPropertyOfType(p,R);return d?d.flags&X.SymbolFlags.Optional?"optional":"required":"absent"}function k(p,R){if(p.flags&X.TypeFlags.Any||p.flags&X.TypeFlags.Unknown||p.flags&X.TypeFlags.Never||p.flags&X.TypeFlags.TypeParameter||p.flags&X.TypeFlags.IndexedAccess||p.flags&X.TypeFlags.StringLike||p.flags&X.TypeFlags.NumberLike||p.flags&X.TypeFlags.BigIntLike||p.flags&X.TypeFlags.BooleanLike||p.flags&X.TypeFlags.EnumLike||p.flags&X.TypeFlags.ESSymbolLike||p.flags&X.TypeFlags.NonPrimitive||p.flags&X.TypeFlags.Null||p.flags&X.TypeFlags.Undefined||p.flags&X.TypeFlags.Void)return"unknown";if(p.isUnion()){let d=!0,g=!0;for(let F of p.types){let P=k(F,R);if(P==="unknown"||(P!=="required"&&(d=!1),P!=="absent"&&(g=!1),P==="optional"))return"unknown"}return d?"required":g?"absent":"unknown"}if(T(p)){let d=p,g=!1,F=!1;for(let P of d.types){let j=k(P,R);if(j==="unknown")return"unknown";j==="required"?g=!0:j==="optional"&&(F=!0)}return g?"required":F?"optional":"absent"}return h(p)?w(p,R):"unknown"}function N(p){if(p.operator!=="in"||p.left.type===pe.PrivateIdentifier)return;let R=A(p.left);if(!R)return;let d=p.right,g=r.esTreeNodeToTSNodeMap.get(d);if(!t)return;let F=t.getTypeAtLocation(g),P=k(F,R);P==="required"?e.report({node:p,messageId:"unnecessaryInCondition",data:{property:R,type:t.typeToString(F),alternative:n.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${n.alternativeForInCondition}`:""}}):P==="absent"&&e.report({node:p,messageId:"alwaysFalseInCondition",data:{property:R,type:t.typeToString(F),alternative:n.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${n.alternativeForInCondition}`:""}})}return{BinaryExpression(p){l(p),I(p),N(p)},CallExpression(p){S(p),x(p)}}}})};function pt(e){return Array.from(new Set(e)).join(" | ")||"never"}function qe(e,n){let r=e.argument;return r.type===pe.Identifier?r.name:n.sourceCode.getText(r)}function Oi(e,n){return n.has(e)}import{AST_NODE_TYPES as Ni,ESLintUtils as Di}from"@typescript-eslint/utils";import{z as Ot}from"zod/v4";var ji=Di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),er="no-call-with-explicit-generics",Li=Ot.object({functions:Ot.array(Ot.string())}),Mi=ji({name:er,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[z(Li)]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Set(n.functions);return{CallExpression(t){let{callee:o}=t;o.type===Ni.Identifier&&r.has(o.name)&&t.typeArguments&&e.report({node:t,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),Nt={name:er,rule:Mi};import{AST_NODE_TYPES as ct,ESLintUtils as _i}from"@typescript-eslint/utils";var $i=_i.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tr="no-call-with-inferred-generics",Ui=$i({name:tr,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Map(n.functions.map(t=>[t.name,t]));return{CallExpression(t){let{callee:o}=t;if(o.type!==ct.Identifier)return;let s=r.get(o.name);if(!s)return;let{minGenerics:i=1,allowAny:l,disallowTypes:c=n.disallowTypes}=s;(t.typeArguments?.params.length||0)<(i||0)&&e.report({node:t,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(l&&!c)&&t.typeArguments?.params.some(u=>!l&&u.type===ct.TSAnyKeyword||c&&u.type===ct.TSTypeReference&&u.typeName.type===ct.Identifier&&c.includes(u.typeName.name))&&e.report({node:t,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),Dt={name:tr,rule:Ui};import{ESLintUtils as zi}from"@typescript-eslint/utils";var Wi=zi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ir="no-commented-out-code",Vi=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],Ji=/^\s*return\s+/,Xi=/\w=("|'|`)/,Bi=/\w+:\s*('|"|`)/,Hi=/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,Yi=/\w+-\w+:/,qi=/\w+_\w+:/,Zi=/\?\s+\w/,Gi=/:\s+\w/,Ki=/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,Qi=/^\s*\d+[,}]/,eo=/^\s*\[[^\]]*\][,}]/,to=/^\s*\{[^}]*\}[,}]/,no=/\.\w+\(/,ro=/\[\w+\]/,io=/^\s*(['"`]).+?\1\s*:/,oo=/^<[A-Z]\w*(\s|>|\/)/,so=/^<[a-z]+(\s|>|\/)/,ao=/<[A-Z]\w*(\s.*)?>/,lo=/<\/[A-Z]\w*>/,po=/<[a-z]+(\s.*)?>/,co=/<\/[a-z]+>/,uo=/^\s*[*\s]*$/,fo=/^[a-zA-Z]/,mo=/^[A-Z][A-Za-z]*(?:\s+\d+)?(?:\s+[a-z]+)*:\s+[A-Za-z]/,yo=/```[\s\S]*?```/g,go=/`[^`]*`/g,nr=/[a-zA-Z0-9]/,So=/\.[A-Za-z_][A-Za-z0-9_]*\(/,To=/[{}[\]()`=<>]/,ho=/:\s*(['"`[{(]|\w+\s*=>)/,Eo=/\bif\s*\(|\belse\b|=>/,fe={returnStatement:Ji,stringAssignment:Xi,objectPropertyWithQuotes:Bi,computedPropertyAssignment:Hi,kebabCaseProperty:Yi,snakeCaseProperty:qi,ternaryOperator:Zi,colonWithWord:Gi,quotedString:Ki,numberWithComma:Qi,arrayWithComma:eo,objectWithComma:to,methodCall:no,arrayAccess:ro,quotedPropertyKey:io,jsxSelfClosing:oo,jsxElement:so,jsxOpeningTag:ao,jsxClosingTag:lo,htmlOpeningTag:po,htmlClosingTag:co,jsdocComment:uo};function bo(e){if(e.includes(":")){let r=e.split(":")[0]?.trim();if(r&&fo.test(r)&&r.includes(" "))return!0}let n=e.trim();return n.length===0||So.test(n)||To.test(n)||ho.test(n)||Eo.test(n)?!1:!!(n.includes(":")&&mo.test(n))}var xo=[") {","return;",fe.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",fe.stringAssignment,");",fe.objectPropertyWithQuotes,fe.computedPropertyAssignment,fe.kebabCaseProperty,fe.snakeCaseProperty,"&&","||","()",fe.ternaryOperator,fe.colonWithWord,fe.quotedString,fe.numberWithComma,fe.arrayWithComma,fe.objectWithComma,fe.methodCall,fe.arrayAccess,"?.(","??","=>",fe.quotedPropertyKey],Co=["/>","</",fe.jsxSelfClosing,fe.jsxElement,fe.jsxOpeningTag,fe.jsxClosingTag,fe.htmlOpeningTag,fe.htmlClosingTag],rr=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Io=Wi({name:ir,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function n(t,o){if(t.startsWith("/"))return!1;let s=t.trimStart();if(t.startsWith("*")||s.startsWith("eslint-disable")||t.includes("@deprecated")||t.includes("@example")||t.includes("@param")||t.includes("@returns")||t.includes("@throws")||t.includes("typescript-eslint")||t.includes("@ts-")||t.includes("prettier-ignore")||fe.jsdocComment.test(t))return!1;for(let i of rr)if(s.startsWith(i))return!1;if(t.includes("https://")||bo(s))return!1;if(o==="Block"){for(let i of Co)if(typeof i=="string"){if(t.includes(i))return{wrongPattern:i}}else if(i.test(t))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Vi)if(s.startsWith(i))return{wrongPattern:i};for(let i of xo)if(typeof i=="string"){if(t.includes(i))return{wrongPattern:i}}else if(i.test(t))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(t,o){let s=t,i=s.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return s;if(o==="Block"&&s.includes("```")){let a=s.split(yo);a.some(m=>nr.test(m))&&(s=a.join(""))}if(!s.includes("`"))return s;let l=s.split(go);return l.some(a=>nr.test(a))?l.join(""):s}return{Program(){let o=e.sourceCode.getAllComments();for(let s of o){let i=r(s.value,s.type),l=n(i,s.type);l&&e.report({node:s,messageId:"commentedOutCode",data:{wrongPattern:l.wrongPattern,allowedPrefixes:rr.join(", ")}})}}}}}),jt={name:ir,rule:Io};import{ESLintUtils as Ao,TSESTree as wo}from"@typescript-eslint/utils";var Ro=Ao.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),or="no-default-export",Fo=Ro({name:or,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(n){e.report({node:n,messageId:"noDefaultExport"})},ExportNamedDeclaration(n){for(let r of n.specifiers)r.exported.type===wo.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:n,messageId:"noDefaultExport"})}}}}),Lt={name:or,rule:Fo};import{ESLintUtils as vo}from"@typescript-eslint/utils";var ko=vo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sr="no-leaked-text-in-jsx",Po=[",",";","[","]","(",")"],Oo=ko({name:sr,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(n){let r=n.value.trim();if(!r)return;let t="";Po.includes(r)?t=r:r.includes("&&")?t="&&":r.includes("||")?t="||":r.endsWith("? (")&&(t="? ("),t&&e.report({node:n,messageId:"leakedTextInJSX",data:{text:t}})}}}}),Mt={name:sr,rule:Oo};import{AST_NODE_TYPES as tt,ESLintUtils as No}from"@typescript-eslint/utils";var Do=No.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lr="no-non-camel-case-functions",jo=/^(\$?[a-z][a-zA-Z0-9]*)$/;function ar(e){if(e.typeName.type!==tt.TSQualifiedName)return!1;let{left:n,right:r}=e.typeName;return n.type===tt.Identifier&&n.name==="JSX"&&r.name==="Element"}var Lo=Do({name:lr,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(n){if(n.id&&!jo.test(n.id.name)){let r=n.returnType?.typeAnnotation;if(r&&(r.type===tt.TSTypeReference?ar(r):r.type===tt.TSUnionType&&r.types.some(o=>o.type===tt.TSTypeReference&&ar(o))))return;e.report({node:n.id,messageId:"nonCamelCaseFunction",data:{functionName:n.id.name}})}}}}}),_t={name:lr,rule:Lo};import{ESLintUtils as Mo,TSESTree as se}from"@typescript-eslint/utils";var _o=Mo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pr="no-optional-root-props",$o=_o({name:pr,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function n(t){let s=e.sourceCode.getDeclaredVariables(t)[0];if(!s||s.references.length!==1)return!1;let i=s.references[0];if(!i)return!1;for(let l of vt(i.identifier)){if("returnType"in l||l.type===se.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let c=l.parent;if(!c)return!1;if(c.type===se.AST_NODE_TYPES.TSTypeParameterInstantiation&&c.parent.type===se.AST_NODE_TYPES.TSTypeReference&&c.parent.typeName.type===se.AST_NODE_TYPES.Identifier&&c.parent.typeName.name==="FC"){let u=Ye(c.parent.parent,se.AST_NODE_TYPES.VariableDeclaration,4);if(!u)return!1;let m=ut(u,e.sourceCode);return m?!(m.parent.type===se.AST_NODE_TYPES.CallExpression&&m.parent.callee.type===se.AST_NODE_TYPES.Identifier&&m.parent.callee.name==="memo"):!1}if(l.type===se.AST_NODE_TYPES.AssignmentPattern)return!1;if(c.type===se.AST_NODE_TYPES.ArrowFunctionExpression){let a=Ye(c,se.AST_NODE_TYPES.VariableDeclaration);return a?!!ut(a,e.sourceCode):!1}if(c.type===se.AST_NODE_TYPES.FunctionDeclaration)return!!ut(c,e.sourceCode)}return!1}function r(t){t.key.type!==se.AST_NODE_TYPES.Identifier||!t.optional||e.report({node:t.key,messageId:"optionalNotAllowed",data:{propertyName:t.key.name},suggest:[{messageId:"suggestion",fix:o=>{let s=Ye(t,se.AST_NODE_TYPES.TSPropertySignature);if(!s)return null;let i=e.sourceCode.getText(s);return o.replaceText(s,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(t){if(t.typeAnnotation.type===se.AST_NODE_TYPES.TSTypeLiteral&&!(ft(t)||!n(t)))for(let o of t.typeAnnotation.members)o.type===se.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(t){if(!(ft(t)||!n(t)))for(let o of t.body.body)o.type===se.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(t){if(t.typeName.type!==se.AST_NODE_TYPES.Identifier||t.typeName.name!=="FC"||!t.typeArguments?.params[0])return;let o=t.typeArguments.params[0];if(o.type!==se.AST_NODE_TYPES.TSTypeLiteral)return;let s=Ye(t.parent,se.AST_NODE_TYPES.VariableDeclaration,4);if(!s)return;let i=ut(s,e.sourceCode);if(!(!i||i.parent.type===se.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===se.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let c of o.members)c.type===se.AST_NODE_TYPES.TSPropertySignature&&r(c)}}}});function ft(e){return e?e.parent?.type===se.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===se.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function ut(e,n){if(ft(e))return;let r;if(e.type===se.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===se.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let t=n.getScope(e);e.type===se.AST_NODE_TYPES.FunctionDeclaration&&t.upper&&(t=t.upper);let o=t.variables.find(i=>i.identifiers.includes(r));if(!o)return;let s=o.references.filter(i=>i.identifier!==r);if(!(s.length!==1||!s[0])&&!ft(s[0].identifier.parent.parent))return s[0].identifier}var $t={name:pr,rule:$o};import{AST_NODE_TYPES as mt}from"@typescript-eslint/utils";var nt=H({name:"no-reexport",meta:{type:"problem",docs:{description:"Disallow re-exports to prevent indirection"},schema:[],messages:{noReexport:"Re-exports are not allowed. Use direct exports only."}},defaultOptions:[],create(e){let n=new Set;function r(t){return t?t.type===mt.Identifier?n.has(t.name):t.type===mt.MemberExpression?r(t.object):!1:!1}return{ImportDeclaration(t){for(let o of t.specifiers)n.add(o.local.name)},ExportNamedDeclaration(t){if(t.source){e.report({node:t,messageId:"noReexport"});return}if(t.declaration?.type===mt.VariableDeclaration)for(let o of t.declaration.declarations)r(o.init)&&e.report({node:t,messageId:"noReexport"});t.specifiers.length>0&&e.report({node:t,messageId:"noReexport"})},ExportDefaultDeclaration(t){t.declaration.type===mt.Identifier&&n.has(t.declaration.name)&&e.report({node:t,messageId:"noReexport"})},ExportAllDeclaration(t){e.report({node:t,messageId:"noReexport"})}}}});import{ESLintUtils as Uo}from"@typescript-eslint/utils";import Ut from"path";import{z as We}from"zod/v4";var zo=Uo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cr="no-relative-imports",Wo=We.object({find:We.string(),replacement:We.string()}),Vo=We.object({aliases:We.array(Wo),rootDir:We.string().optional(),allowNotFoundAliases:We.boolean().optional(),_dev_simulateFileName:We.string().optional()}),Jo=zo({name:cr,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[z(Vo)]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[n]){let r=n._dev_simulateFileName??e.filename;function t(i){return i.startsWith(".")||i.startsWith("..")}function o(i,l){let c=Ut.dirname(l);return Ut.resolve(c,i)}function s(i){let l=n.rootDir??process.cwd(),c=Ut.relative(l,i);if(c.startsWith("."))return null;c.startsWith("/")||(c=`/${c}`);for(let{find:a,replacement:u}of n.aliases)if(c.startsWith(u)){let m=c.replace(u,a);return{alias:a,newPath:m}}return null}return{ImportDeclaration(i){let l=i.source.value;if(!t(l))return;let c=o(l,r),a=s(c);!a&&n.allowNotFoundAliases||e.report({node:i,messageId:a?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:a?.alias},fix:a?u=>u.replaceText(i.source,`'${a.newPath}'`):void 0})}}}}),zt={name:cr,rule:Jo};import{AST_NODE_TYPES as me}from"@typescript-eslint/utils";import{z as ur}from"zod/v4";var Xo=ur.object({customMessage:ur.string().optional()}),Wt=H({name:"no-static-style-prop",meta:{type:"problem",docs:{description:"Prevent using static style props in JSX, only dynamic values should be allowed"},schema:[z(Xo)],messages:{noStaticStyleProp:"Static style props are not allowed use css instead.{{customMessage}}"}},defaultOptions:[{}],create(e,[n]){function r(t){switch(t.type){case me.Literal:return!0;case me.ObjectExpression:return t.properties.every(o=>o.type===me.Property?o.computed||o.value.type===me.Identifier&&o.key.type===me.Identifier&&o.key.name===o.value.name?!1:r(o.value):!1);case me.ArrayExpression:return t.elements.every(o=>o?o.type===me.SpreadElement?!1:r(o):!0);case me.TemplateLiteral:return t.expressions.length===0;case me.ConditionalExpression:case me.LogicalExpression:case me.BinaryExpression:case me.UnaryExpression:case me.CallExpression:case me.MemberExpression:case me.Identifier:case me.ArrowFunctionExpression:case me.FunctionExpression:return!1;default:return!1}}return{JSXAttribute(t){if(t.name.type===me.JSXIdentifier&&t.name.name==="style"&&t.value){let o=null;t.value.type===me.JSXExpressionContainer?t.value.expression.type!==me.JSXEmptyExpression&&(o=t.value.expression):t.value.type===me.Literal&&(o=t.value),o&&r(o)&&e.report({node:t,messageId:"noStaticStyleProp",data:{customMessage:n.customMessage?` ${n.customMessage}`:""}})}}}}});import{AST_NODE_TYPES as yt}from"@typescript-eslint/utils";import*as Xe from"zod/v4";var Bo=Xe.object({alternativeMsgs:Xe.object({inArrayFind:Xe.string().optional(),inArrayFilter:Xe.string().optional()}).optional(),__dev_simulateFileName:Xe.string().optional()});function Ho(e){return e.typeAnnotation.type!==yt.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}var Yo=/(typeGuards|type-guards)\.(ts|tsx)$/;function qo(e){return Yo.test(e)}function Zo(e){let n=e.parent;for(;n;){if(n.type===yt.CallExpression&&n.callee.type===yt.MemberExpression&&n.callee.property.type===yt.Identifier){let r=n.callee.property.name;if(r==="filter"||r==="find")return{method:r}}n=n.parent}return null}var Vt=H({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Check if the type guard can be inferred by typescript, in most cases it can, e.g. `.filter((nullable) => nullable !== null)`. If not, type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[z(Bo)],hasSuggestions:!0},defaultOptions:[{}],create(e,[n]){let r=n.__dev_simulateFileName??e.filename;if(qo(r))return{};function t(o){if(!Ho(o))return;let s=Zo(o);if(n.alternativeMsgs&&s){let i=s.method==="filter"?n.alternativeMsgs.inArrayFilter:n.alternativeMsgs.inArrayFind;if(i){let l=s.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:l,data:{message:i}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":t,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":t,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":t}}});import{AST_NODE_TYPES as Ze}from"@typescript-eslint/utils";var Go="no-unnecessary-async-on-jsx-props";function Ko(e){if(e.body.type!==Ze.BlockStatement)return!1;let n=e.body.body;if(n.length!==1)return!1;let r=n[0];return!r||r.type!==Ze.ExpressionStatement?!1:r.expression.type===Ze.AwaitExpression}var Jt=H({name:Go,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function n(r){Ko(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(t){let o=e.sourceCode,s=[],i=o.getFirstToken(r,c=>c.value==="async");if(i){let c=o.getTokenAfter(i);c?s.push(t.replaceTextRange([i.range[0],c.range[0]],"")):s.push(t.remove(i))}function l(c){if(c.type===Ze.AwaitExpression){let a=o.getFirstToken(c);if(a&&a.value==="await"){let u=o.getTokenAfter(a);u?s.push(t.replaceTextRange([a.range[0],u.range[0]],"")):s.push(t.remove(a))}}if(c.type===Ze.BlockStatement)for(let a of c.body)l(a);else c.type===Ze.ExpressionStatement&&l(c.expression)}return l(r.body),s}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":n,"JSXAttribute FunctionExpression[async=true]":n}}});import{AST_NODE_TYPES as rt,ESLintUtils as mr}from"@typescript-eslint/utils";import*as Xt from"typescript";import it from"zod/v4";var Qo=mr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fr="no-unnecessary-casting",es=it.object({additionalCastFunctions:it.array(it.object({name:it.string(),expectedType:it.enum(["string","number"])})).optional()}),Bt={name:fr,rule:Qo({name:fr,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[z(es)],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],t=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=mr.getParserServices(e,!0),s=o.program?.getTypeChecker();if(!s||!o.program)throw new Error("TypeScript services or program not available");function i(u,m){switch(u.type){case rt.Literal:return m==="number"?typeof u.value=="number":typeof u.value=="string";case rt.TemplateLiteral:return m==="string";case rt.UnaryExpression:return m==="number"?u.operator==="+"||u.operator==="-"||u.operator==="~":!1;default:return!1}}function l(u,m){return m==="number"?!!(u.flags&Xt.TypeFlags.NumberLike):!!(u.flags&Xt.TypeFlags.StringLike)}function c(u,m){return y=>y.replaceText(u,e.sourceCode.getText(m))}function a(u){if(!s||u.arguments.length!==1)return;let m=u.arguments[0];if(!m||m.type===rt.SpreadElement)return;let{callee:y}=u;if(y.type!==rt.Identifier)return;let C=y.name,f=t.find(x=>x.name===C);if(!f)return;if(i(m,f.expectedType)||l(s.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(m)),f.expectedType)){let x,S;C==="Number"?x="unnecessaryNumberCasting":C==="String"?x="unnecessaryStringCasting":(x="unnecessaryCustomCasting",S={name:f.name,type:f.expectedType}),e.report({node:u,messageId:x,...S?{data:S}:{},fix:c(u,m)})}}return{CallExpression:a}}})};import{AST_NODE_TYPES as Re}from"@typescript-eslint/utils";import*as dt from"zod/v4";var ts=dt.object({ignoreWithDescription:dt.string().optional()}),Ht=H({name:"no-unnecessary-describe",meta:{type:"suggestion",docs:{description:"Disallow unnecessary describe blocks that wrap all tests in a file"},messages:{unnecessaryDescribe:"Describe blocks that solely wrap all tests in the file are unnecessary, they just add unnecessary nesting to the code. The file itself should be enough to group tests. Remove it.",removeDescribe:"Remove the describe block"},hasSuggestions:!0,schema:[z(ts)]},defaultOptions:[{}],create(e,[n]){let r=e.getSourceCode(),t=r.ast;function o(c){let a=c.arguments[0];return a&&a.type===Re.Literal&&typeof a.value=="string"?a.value:null}function s(c){return!c||!n.ignoreWithDescription?!1:new RegExp(n.ignoreWithDescription).test(c)}function i(c){return c.length!==1?!1:t.body.filter(u=>{if(u.type===Re.ExpressionStatement){let m=u.expression;if(m.type===Re.CallExpression&&m.callee.type===Re.Identifier){let y=m.callee.name;return["test","it","beforeEach","afterEach","beforeAll","afterAll"].includes(y)}}return!1}).length===0}function l(c){let a=c.arguments[1];if(a&&(a.type===Re.FunctionExpression||a.type===Re.ArrowFunctionExpression)&&a.body.type===Re.BlockStatement){let u=a.body.body;return u.length===0?"":u.map(y=>r.text.slice(y.range[0],y.range[1])).join(`
15
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let w=c.acquire(I),k=new Set,N=null;{let v=w.upper;for(;v&&(k.add(v),v.type!=="function");)v=v.upper;if(!v)return;N=v}let p=Array.isArray;function R(v){if(!p(v.defs))return!1;let O=v.defs[0];if(O==null||O.node.type!=="VariableDeclarator")return!1;let _=O.node.init;if(_==null)return!1;for(;_.type==="TSAsExpression";)_=_.expression;let z=O.node.parent;if(z==null&&(vt(N.block,O.node.id),z=O.node.parent,z==null))return!1;if(z.kind==="const"&&_.type==="Literal"&&(typeof _.value=="string"||typeof _.value=="number"||_.value===null))return!0;if(_.type!=="CallExpression")return!1;let H=_.callee;if(H.type==="MemberExpression"&&H.object.name==="React"&&H.property!=null&&!H.computed&&(H=H.property),H.type!=="Identifier")return!1;let J=O.node.id,{name:K}=H;if(K==="useRef"&&J.type==="Identifier")return!0;if(Fi(H)&&J.type==="Identifier"){for(let ee of v.references)ee!==J&&C.add(ee.identifier);return!0}else if(K==="useState"||K==="useReducer"){if(J.type==="ArrayPattern"&&J.elements.length===2&&p(v.identifiers)){if(J.elements[1]===v.identifiers[0]){if(K==="useState"){let ee=v.references,we=0;for(let Le=0;Le<ee.length;Le++){if(ee[Le].isWrite()&&we++,we>1)return!1;a.set(ee[Le].identifier,J.elements[0])}}return!0}else if(J.elements[0]===v.identifiers[0]){if(K==="useState"){let ee=v.references;for(let we=0;we<ee.length;we++)u.add(ee[we].identifier)}return!1}}}else if(K==="useTransition"&&J.type==="ArrayPattern"&&J.elements.length===2&&Array.isArray(v.identifiers)&&J.elements[1]===v.identifiers[0])return!0;return!1}function d(v){if(!p(v.defs))return!1;let O=v.defs[0];if(O==null||O.node==null||O.node.id==null)return!1;let _=O.node,z=N.childScopes,H=null,J;for(J=0;J<z.length;J++){let K=z[J],ee=K.block;if(_.type==="FunctionDeclaration"&&ee===_||_.type==="VariableDeclarator"&&ee.parent===_){H=K;break}}if(H==null)return!1;for(J=0;J<H.through.length;J++){let K=H.through[J];if(K.resolved!=null&&k.has(K.resolved.scope)&&!g(K.resolved))return!1}return!0}let g=m(R,f),F=m(d,y),P=new Map;function j(v){let O=v.from,_=!1;for(;O.block!==I;)O.type==="function"&&(_=O.block.parent!=null&&O.block.parent.type==="ReturnStatement"),O=O.upper;return _}let V=new Map,G=new Map;Y(w);function Y(v){for(let O of v.references){if(!O.resolved||!k.has(O.resolved.scope))continue;let _=vt(I,O.identifier),z=Bn(_),H=Me(z,G);if(b&&z.type==="Identifier"&&(z.parent.type==="MemberExpression"||z.parent.type==="OptionalMemberExpression")&&!z.parent.computed&&z.parent.property.type==="Identifier"&&z.parent.property.name==="current"&&j(O)&&P.set(H,{reference:O,dependencyNode:z}),z.parent.type==="TSTypeQuery"||z.parent.type==="TSTypeReference")continue;let J=O.resolved.defs[0];if(J!=null&&!(J.node!=null&&J.node.init===I.parent)&&J.type!=="TypeParameter")if(V.has(H))V.get(H).references.push(O);else{let K=O.resolved,ee=g(K)||F(K);V.set(H,{isStable:ee,references:[O]})}}for(let O of v.childScopes)Y(O)}P.forEach(({reference:v,dependencyNode:O},_)=>{let z=v.resolved.references,H=!1;for(let J=0;J<z.length;J++){let{identifier:K}=z[J],{parent:ee}=K;if(ee!=null&&ee.type==="MemberExpression"&&!ee.computed&&ee.property.type==="Identifier"&&ee.property.name==="current"&&ee.parent.type==="AssignmentExpression"&&ee.parent.left===ee){H=!0;break}}H||l({node:O.parent.property,message:`The ref value '${_}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${_}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let D=new Set;function Z(v,O){D.has(O)||(D.add(O),l({node:v,message:`Assignments to the '${O}' variable from inside React Hook ${r(T)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${r(T)}.`}))}let q=new Set;if(V.forEach(({isStable:v,references:O},_)=>{v&&q.add(_),O.forEach(z=>{z.writeExpr&&Z(z.writeExpr,_)})}),D.size>0)return;if(!A){let v=null;if(V.forEach(({isStable:O,references:_},z)=>{v||_.forEach(H=>{if(v)return;let J=H.identifier;if(!a.has(J))return;let ee=H.from;for(;ee.type!=="function";)ee=ee.upper;ee.block===I&&(v=z)})}),v){let{suggestedDependencies:O}=Rt({dependencies:V,declaredDependencies:[],stableDependencies:q,externalDependencies:new Set,isEffect:!0});l({node:T,message:`React Hook ${h} contains a call to '${v}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+O.join(", ")+`] as a second argument to the ${h} Hook.`,suggest:[{desc:`Add dependencies array: [${O.join(", ")}]`,fix(_){return _.insertTextAfter(I,`, [${O.join(", ")}]`)}}]})}return}let ce=[],ue=new Set;A.type!=="ArrayExpression"?l({node:A,message:`React Hook ${r(T)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):A.elements.forEach(v=>{if(v===null)return;if(v.type==="SpreadElement"){l({node:v,message:`React Hook ${r(T)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}C.has(v)&&l({node:v,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(v)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(v)}\``,fix(H){return H.removeRange(v.range)}}]});let O;try{O=Me(v,G)}catch(H){if(/Unsupported node type/.test(H.message)){v.type==="Literal"?V.has(v.value)?l({node:v,message:`The ${v.raw} literal is not a valid dependency because it never changes. Did you mean to include ${v.value} in the array instead?`}):l({node:v,message:`The ${v.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):l({node:v,message:`React Hook ${r(T)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw H}let _=v;for(;_.type==="MemberExpression"||_.type==="OptionalMemberExpression"||_.type==="ChainExpression";)_=_.object||_.expression.object;let z=!N.through.some(H=>H.identifier===_);ce.push({key:O,node:v}),z||ue.add(O)});let{suggestedDependencies:Ae,unnecessaryDependencies:Ue,missingDependencies:ge,duplicateDependencies:tt}=Rt({dependencies:V,declaredDependencies:ce,stableDependencies:q,externalDependencies:ue,isEffect:b}),Ye=Ae;if(tt.size+ge.size+Ue.size===0){if(n)return;Ii({declaredDependencies:ce,declaredDependenciesNode:A,componentScope:N,scope:w}).forEach(({construction:O,isUsedOutsideOfHook:_,depType:z})=>{let H=z==="function"?"useCallback":"useMemo",J=z==="function"?"definition":"initialization",K=`wrap the ${J} of '${O.name.name}' in its own ${H}() Hook.`,ee=_?`To fix this, ${K}`:`Move it inside the ${h} callback. Alternatively, ${K}`,we=z==="conditional"||z==="logical expression"?"could make":"makes",Le=`The '${O.name.name}' ${z} ${we} the dependencies of ${h} Hook (at line ${A.loc.start.line}) change on every render. ${ee}`,Ln;_&&O.type==="Variable"&&z==="function"&&(Ln=[{desc:`Wrap the ${J} of '${O.name.name}' in its own ${H}() Hook.`,fix(Mn){let[fi,mi]=H==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Mn.insertTextBefore(O.node.init,fi),Mn.insertTextAfter(O.node.init,mi)]}}]),l({node:O.node,message:Le,suggest:Ln})});return}!b&&ge.size>0&&(Ye=Rt({dependencies:V,declaredDependencies:[],stableDependencies:q,externalDependencies:ue,isEffect:b}).suggestedDependencies);function Ee(){if(ce.length===0)return!0;let v=ce.map(_=>_.key),O=v.slice().sort();return v.join(",")===O.join(",")}Ee()&&Ye.sort();function xe(v){let O=v.split("."),_="";for(let z=0;z<O.length;z++){if(z!==0){let H=O.slice(0,z+1).join("."),J=G.get(H)===!0;_+=J?"?.":"."}_+=O[z]}return _}function Ct(v,O,_,z){return v.size===0?null:(v.size>1?"":O+" ")+_+" "+(v.size>1?"dependencies":"dependency")+": "+wi(Array.from(v).sort().map(H=>"'"+xe(H)+"'"))+`. Either ${z} ${v.size>1?"them":"it"} or remove the dependency array.`}let ke="";if(Ue.size>0){let v=null;if(Array.from(Ue.keys()).forEach(O=>{v===null&&O.endsWith(".current")&&(v=O)}),v!==null)ke=` Mutable values like '${v}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ue.size>0){let O=Array.from(ue)[0];w.set.has(O)||(ke=` Outer scope values like '${O}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ke&&ge.has("props")){let v=V.get("props");if(v==null)return;let O=v.references;if(!Array.isArray(O))return;let _=!0;for(let z=0;z<O.length;z++){let H=O[z],J=vt(N.block,H.identifier);if(!J){_=!1;break}let K=J.parent;if(K==null){_=!1;break}if(K.type!=="MemberExpression"&&K.type!=="OptionalMemberExpression"){_=!1;break}}_&&(ke=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${h} call and refer to those specific props inside ${r(T)}.`)}if(!ke&&ge.size>0){let v=null;ge.forEach(O=>{if(v)return;let _=N.set.get(O),z=V.get(O);if(z.references[0].resolved!==_)return;let H=_.defs[0];if(H==null||H.name==null||H.type!=="Parameter")return;let J=!1,K;for(let ee=0;ee<z.references.length;ee++)if(K=z.references[ee].identifier,K!=null&&K.parent!=null&&(K.parent.type==="CallExpression"||K.parent.type==="OptionalCallExpression")&&K.parent.callee===K){J=!0;break}J&&(v=O)}),v!==null&&(ke=` If '${v}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ke&&ge.size>0){let v=null;if(ge.forEach(O=>{if(v!==null)return;let z=V.get(O).references,H,J;for(let K=0;K<z.length;K++){for(H=z[K].identifier,J=H.parent;J!=null&&J!==N.block;){if(J.type==="CallExpression"){let ee=a.get(J.callee);if(ee!=null){if(ee.name===O)v={missingDep:O,setter:J.callee.name,form:"updater"};else if(u.has(H))v={missingDep:O,setter:J.callee.name,form:"reducer"};else{let we=z[K].resolved;if(we!=null){let Le=we.defs[0];Le!=null&&Le.type==="Parameter"&&(v={missingDep:O,setter:J.callee.name,form:"inlineReducer"})}}break}}J=J.parent}if(v!==null)break}}),v!==null)switch(v.form){case"reducer":ke=` You can also replace multiple useState variables with useReducer if '${v.setter}' needs the current value of '${v.missingDep}'.`;break;case"inlineReducer":ke=` If '${v.setter}' needs the current value of '${v.missingDep}', you can also switch to useReducer instead of useState and read '${v.missingDep}' in the reducer.`;break;case"updater":ke=` You can also do a functional update '${v.setter}(${v.missingDep.slice(0,1)} => ...)' if you only need '${v.missingDep}' in the '${v.setter}' call.`;break;default:throw new Error("Unknown case.")}}l({node:A,message:`React Hook ${r(T)} has `+(Ct(ge,"a","missing","include")||Ct(Ue,"an","unnecessary","exclude")||Ct(tt,"a","duplicate","omit"))+ke,suggest:[{desc:`Update the dependencies array to be: [${Ye.map(xe).join(", ")}]`,fix(v){return v.replaceText(A,`[${Ye.map(xe).join(", ")}]`)}}]})}function x(I){let A=Ai(I.callee,i);if(A===-1)return;let T=I.arguments[A],h=I.callee,b=Hn(h).name,w=I.arguments[A+1],k=/Effect($|[^a-z])/g.test(b);if(!T){l({node:h,message:`React Hook ${b} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(n&&!k)){if(!w&&!k){(b==="useMemo"||b==="useCallback")&&l({node:h,message:`React Hook ${b} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(T.type){case"FunctionExpression":case"ArrowFunctionExpression":E(T,w,h,b,k);return;case"Identifier":if(!w||w.elements&&w.elements.some(R=>R&&R.type==="Identifier"&&R.name===T.name))return;let N=t(I).set.get(T.name);if(N==null||N.defs==null)return;let p=N.defs[0];if(!p||!p.node||p.type!=="Variable"&&p.type!=="FunctionName")break;switch(p.node.type){case"FunctionDeclaration":E(p.node,w,h,b,k);return;case"VariableDeclarator":let R=p.node.init;if(!R)break;switch(R.type){case"ArrowFunctionExpression":case"FunctionExpression":E(R,w,h,b,k);return}break}break;default:l({node:h,message:`React Hook ${b} received a function whose dependencies are unknown. Pass an inline function instead.`});return}l({node:h,message:`React Hook ${b} has a missing dependency: '${T.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${T.name}]`,fix(N){return N.replaceText(w,`[${T.name}]`)}}]})}}let S=!!e.options[0]?.reactCompilerIsEnabled;if(e.options[0]?.ignoreIfReactCompilerIsEnabled||S){for(let I of e.sourceCode.getAllComments())if(S||Ci.test(I.value))return n=!0,{CallExpression:A=>x(A,!0)}}return{CallExpression:I=>x(I)}}};function Rt({dependencies:e,declaredDependencies:n,stableDependencies:r,externalDependencies:t,isEffect:o}){let s=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,x)=>{let S=l(s,x);S.isUsed=!0,c(s,x,I=>{I.isSubtreeUsed=!0})}),n.forEach(({key:E})=>{let x=l(s,E);x.isSatisfiedRecursively=!0}),r.forEach(E=>{let x=l(s,E);x.isSatisfiedRecursively=!0});function l(E,x){let S=x.split("."),I=E;for(let A of S){let T=I.children.get(A);T||(T=i(),I.children.set(A,T)),I=T}return I}function c(E,x,S){let I=x.split("."),A=E;for(let T of I){let h=A.children.get(T);if(!h)return;S(h),A=h}}let a=new Set,u=new Set;f(s,a,u,E=>E);function f(E,x,S,I){E.children.forEach((A,T)=>{let h=I(T);if(A.isSatisfiedRecursively){A.isSubtreeUsed&&S.add(h);return}if(A.isUsed){x.add(h);return}f(A,x,S,b=>h+"."+b)})}let y=[],C=new Set,m=new Set;return n.forEach(({key:E})=>{u.has(E)?y.indexOf(E)===-1?y.push(E):m.add(E):C.add(E)}),a.forEach(E=>{y.push(E)}),{suggestedDependencies:y,unnecessaryDependencies:C,duplicateDependencies:m,missingDependencies:a}}function ze(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return ze(e.consequent)!=null||ze(e.alternate)!=null?"conditional":null;case"LogicalExpression":return ze(e.left)!=null||ze(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return ze(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return ze(e.expression);case"TSAsExpression":return ze(e.expression)}return null}function Ii({declaredDependencies:e,declaredDependenciesNode:n,componentScope:r,scope:t}){let o=e.map(({key:i})=>{let l=r.variables.find(a=>a.name===i);if(l==null)return null;let c=l.defs[0];if(c==null)return null;if(c.type==="Variable"&&c.node.type==="VariableDeclarator"&&c.node.id.type==="Identifier"&&c.node.init!=null){let a=ze(c.node.init);if(a!=null)return[l,a]}return c.type==="FunctionName"&&c.node.type==="FunctionDeclaration"?[l,"function"]:c.type==="ClassName"&&c.node.type==="ClassDeclaration"?[l,"class"]:null}).filter(Boolean);function s(i){let l=!1;for(let c=0;c<i.references.length;c++){let a=i.references[c];if(a.writeExpr){if(l)return!0;l=!0;continue}let u=a.from;for(;u!==t&&u!=null;)u=u.upper;if(u!==t&&!Yn(n,a.identifier))return!0}return!1}return o.map(([i,l])=>({construction:i.defs[0],depType:l,isUsedOutsideOfHook:s(i)}))}function Bn(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?Bn(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ft(e,n,r){n&&(e.optional?n.has(r)||n.set(r,!0):n.has(r)||n.set(r,!1))}function Me(e,n){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return n&&n.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=Me(e.object,n),t=Me(e.property,null),o=`${r}.${t}`;return Ft(e,n,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Me(e.object,n),t=Me(e.property,null),o=`${r}.${t}`;return Ft(e,n,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let t=Me(r.object,n),o=Me(r.property,null),s=`${t}.${o}`;return Ft(r,n,s),s}else throw new Error(`Unsupported node type: ${e.type}`)}function Hn(e,n){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Ai(e,n){let r=Hn(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&n&&n.additionalHooks){let t;try{t=Me(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return n.additionalHooks.test(t)?0:-1}else return-1}}function vt(e,n){let r=[e],t=null;for(;r.length;){if(t=r.shift(),Ri(t,n))return t;if(Yn(t,n))for(let[o,s]of Object.entries(t))o!=="parent"&&(Vn(s)?(s.parent=t,r.push(s)):Array.isArray(s)&&s.forEach(i=>{Vn(i)&&(i.parent=t,r.push(i))}))}return null}function wi(e){let n="";for(let r=0;r<e.length;r++)n+=e[r],r===0&&e.length===2?n+=" and ":r===e.length-2&&e.length>2?n+=", and ":r<e.length-1&&(n+=", ");return n}function Vn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Ri(e,n){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===n.type&&e.name===n.name&&e.range[0]===n.range[0]&&e.range[1]===n.range[1]}function Yn(e,n){return e.range[0]<=n.range[0]&&e.range[1]>=n.range[1]}function Fi(e){return!1}import{AST_NODE_TYPES as pe,ESLintUtils as tr}from"@typescript-eslint/utils";import B from"typescript";import{z as Kn}from"zod/v4";import{AST_NODE_TYPES as qn}from"@typescript-eslint/utils";function qe(e,n,r=1/0){if(r!==0&&e.parent)return e.type===n?e:qe(e.parent,n,r===1/0?r:r-1)}function*kt(e){yield e,e.parent&&(yield*kt(e.parent))}function Pt(e,n){for(let r of e){let t=n(r);if(t!=null&&t!==!1)return t}}function Gn(e,n,r){let o=r.getDeclaredVariables(e).find(s=>s.name===n||s.identifiers[0]?.parent.type===qn.Property&&s.identifiers[0].parent.key.type===qn.Identifier&&s.identifiers[0].parent.key.name===n);return o?o.references.filter(s=>!s.init):[]}function Zn(e){return e===null||typeof e!="object"||!("type"in e)?!1:typeof e.type=="string"}function vi(e,n){return e[n]}function Pe(e,n,r){let t=r.visitorKeys,o=new Set;function s(i){if(o.has(i))return!1;if(o.add(i),n(i)===!0)return!0;let c=t[i.type];if(c)for(let a of c){let u=vi(i,a);if(u){if(Array.isArray(u)){for(let f of u)if(Zn(f)&&s(f))return!0}else if(Zn(u)&&s(u))return!0}}return!1}s(e)}var ki=tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qn="improved-no-unnecessary-condition",Pi=Kn.object({alternativeForInCondition:Kn.string().optional().describe("Alternative to appear in the error for `in` condition")}),er={object:"Array",property:"isArray"},Oi=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Ni=new Set(Oi),Ot={name:Qn,rule:ki({name:Qn,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".',unnecessaryStartsWithCondition:"This startsWith check is unnecessary as it always evaluates to true.",alwaysFalseStartsWithCondition:"This startsWith check will always be false.",unnecessaryEndsWithCondition:"This endsWith check is unnecessary as it always evaluates to true.",alwaysFalseEndsWithCondition:"This endsWith check will always be false.",unnecessaryIncludesCondition:"This includes check is unnecessary as it always evaluates to true.",alwaysFalseIncludesCondition:"This includes check will always be false.",unnecessaryArrayIsArrayCondition:"This Array.isArray check is unnecessary as it always evaluates to true.",alwaysFalseArrayIsArrayCondition:"This Array.isArray check will always be false.",unnecessaryLengthCondition:"This length comparison is unnecessary as it always evaluates to true.",alwaysFalseLengthCondition:"This length comparison will always be false.",unnecessaryInCondition:'This in check is unnecessary. Property "{{property}}" always exists on type "{{type}}".{{alternative}}',alwaysFalseInCondition:'This in check will always be false. Property "{{property}}" does not exist on type "{{type}}".{{alternative}}'},schema:[U(Pi)]},defaultOptions:[{}],create(e,[n]){let r=tr.getParserServices(e,!0),t=r.program?.getTypeChecker();if(!t||!r.program)throw new Error("TypeScript services or program not available");function o(p){return p.type===pe.UnaryExpression&&p.operator==="typeof"}function s(p){return p.flags&B.TypeFlags.Any||p.flags&B.TypeFlags.Unknown?null:p.flags&B.TypeFlags.StringLike?["string"]:p.flags&B.TypeFlags.NumberLike?["number"]:p.flags&B.TypeFlags.BigIntLike?["bigint"]:p.flags&B.TypeFlags.BooleanLike?["boolean"]:p.flags&B.TypeFlags.ESSymbolLike?["symbol"]:p.flags&B.TypeFlags.Undefined||p.flags&B.TypeFlags.Void?["undefined"]:p.flags&B.TypeFlags.Null?["object"]:p.getCallSignatures().length>0?["function"]:p.flags&B.TypeFlags.Object?p.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:p.flags&B.TypeFlags.NonPrimitive?["object"]:p.flags&B.TypeFlags.Never?["never"]:null}function i(p){if(!t)return null;let R=r.esTreeNodeToTSNodeMap.get(p),d=t.getTypeAtLocation(R.expression);if(d.flags&B.TypeFlags.Any||d.flags&B.TypeFlags.Unknown)return null;let g=[];if(d.isUnion()){for(let P of d.types){let j=s(P);if(j)g.push(...j);else return null}return g}let F=s(d);return F?(g.push(...F),g):null}function l(p){if(!(p.operator==="==="||p.operator==="!=="))return;let d=null,g=null;if(o(p.left)?(d=p.left,g=p.right.type===pe.Literal&&typeof p.right.value=="string"?p.right.value:null):o(p.right)&&(d=p.right,g=p.left.type===pe.Literal&&typeof p.left.value=="string"?p.left.value:null),!d||!g||!Di(g,Ni))return;let F=i(d);if(!F)return;let P=p.operator==="!==",j=F.includes(g);F.length===1?j&&!P?e.report({node:p,messageId:"unnecessaryTypeofCondition",data:{name:Ze(d,e),type:g}}):!j&&P?e.report({node:p,messageId:"unnecessaryTypeofCondition",data:{name:Ze(d,e),type:Array.from(F)[0]}}):!j&&!P?e.report({node:p,messageId:"alwaysFalseTypeofCondition",data:{name:Ze(d,e),actualType:ct(F),conditionType:g}}):j&&P&&e.report({node:p,messageId:"alwaysFalseTypeofCondition",data:{name:Ze(d,e),actualType:ct(F),conditionType:g}}):!j&&!P?e.report({node:p,messageId:"alwaysFalseTypeofCondition",data:{name:Ze(d,e),actualType:ct(F),conditionType:g}}):!j&&P&&e.report({node:p,messageId:"unnecessaryTypeofCondition",data:{name:Ze(d,e),type:ct(F)}})}function c(p){if(p.flags&B.TypeFlags.Any||p.flags&B.TypeFlags.Unknown)return null;if(p.isUnion()){let R=[];for(let d of p.types)if(d.flags&B.TypeFlags.StringLiteral){let g=d.value;R.push(g)}else return null;return R}return p.flags&B.TypeFlags.StringLiteral?[p.value]:null}function a(p){if(!t)return null;let R=r.esTreeNodeToTSNodeMap.get(p),d=t.getTypeAtLocation(R),g=c(d);if(g)return g;let F=t.getSymbolAtLocation(R);if(F){let P=t.getTypeOfSymbolAtLocation(F,R),j=c(P);if(j)return j}return null}function u(p){let R=e.sourceCode.ast,d=null;return Pe(R,g=>{if(g.type===pe.VariableDeclarator&&g.id.type===pe.Identifier&&g.id.name===p.name&&g.id.typeAnnotation){let F=g.id.typeAnnotation.typeAnnotation;if(F.type===pe.TSUnionType){let P=[];for(let j of F.types)if(j.type===pe.TSLiteralType&&j.literal.type===pe.Literal&&typeof j.literal.value=="string")P.push(j.literal.value);else return!0;return d=P,!0}if(F.type===pe.TSLiteralType&&F.literal.type===pe.Literal&&typeof F.literal.value=="string")return d=[F.literal.value],!0}return!1},e.sourceCode),d}function f(p){return p==="Array"||p==="ReadonlyArray"?!0:p.endsWith(".Array")||p.endsWith(".ReadonlyArray")}function y(p){if(!t)return!1;if(t.isArrayType(p)||t.isTupleType(p))return!0;let R=t.getApparentType(p);if(R!==p&&(t.isArrayType(R)||t.isTupleType(R)))return!0;if(p.aliasSymbol){let g=t.getFullyQualifiedName(p.aliasSymbol);if(f(g))return!0}let d=p.getSymbol();if(d){let g=t.getFullyQualifiedName(d);if(f(g))return!0}return!1}function C(p){if(!t)return!1;if(p.flags&B.TypeFlags.StringLike||p.flags&B.TypeFlags.NumberLike||p.flags&B.TypeFlags.BigIntLike||p.flags&B.TypeFlags.BooleanLike||p.flags&B.TypeFlags.ESSymbolLike||p.flags&B.TypeFlags.EnumLike||p.flags&B.TypeFlags.Null||p.flags&B.TypeFlags.Undefined||p.flags&B.TypeFlags.Void||p.flags&B.TypeFlags.Never)return!0;let R=p.getSymbol();if(R){let d=t.getFullyQualifiedName(R);if(d==="__function"||d==="__object"&&!y(p))return!0}return!1}function m(p){if(p.flags&B.TypeFlags.Any||p.flags&B.TypeFlags.Unknown)return"unknown";if(p.isUnion()){let R=!0,d=!0;for(let g of p.types){let F=m(g);if(F==="unknown")return"unknown";F!=="alwaysTrue"&&(R=!1),F!=="alwaysFalse"&&(d=!1)}return R?"alwaysTrue":d?"alwaysFalse":"unknown"}return y(p)?"alwaysTrue":C(p)?"alwaysFalse":"unknown"}function E(p){return!p.computed&&p.object.type===pe.Identifier&&p.object.name===er.object&&p.property.type===pe.Identifier&&p.property.name===er.property}function x(p){if(!t||p.callee.type!==pe.MemberExpression||!E(p.callee)||p.arguments.length===0)return;let[R]=p.arguments;if(!R||R.type===pe.SpreadElement)return;let d=r.esTreeNodeToTSNodeMap.get(R),g=t.getTypeAtLocation(d),F=m(g);F==="alwaysTrue"?e.report({node:p,messageId:"unnecessaryArrayIsArrayCondition"}):F==="alwaysFalse"&&e.report({node:p,messageId:"alwaysFalseArrayIsArrayCondition"})}function S(p){if(p.callee.type!==pe.MemberExpression||p.callee.property.type!==pe.Identifier||p.callee.computed)return;let R=p.callee.property.name;if(R!=="startsWith"&&R!=="endsWith"&&R!=="includes"||p.arguments.length!==1)return;let[d]=p.arguments;if(!d||d.type!==pe.Literal||typeof d.value!="string")return;let g=p.callee.object,F=a(g);if(!F&&g.type===pe.Identifier&&(F=u(g)),!F||F.length===0)return;let P=d.value;if(R==="includes"&&F.length>1)return;let j=0,V=0;for(let G of F)if((R==="startsWith"?G.startsWith(P):R==="endsWith"?G.endsWith(P):G.includes(P))?j++:V++,j>0&&V>0)return;if(j>0&&V===0){let G=R==="startsWith"?"unnecessaryStartsWithCondition":R==="endsWith"?"unnecessaryEndsWithCondition":"unnecessaryIncludesCondition";e.report({node:p,messageId:G})}else if(V>0&&j===0){let G=R==="startsWith"?"alwaysFalseStartsWithCondition":R==="endsWith"?"alwaysFalseEndsWithCondition":"alwaysFalseIncludesCondition";e.report({node:p,messageId:G})}}function I(p){if(!new Set(["===","!==",">",">=","<","<="]).has(p.operator))return;function d(Y){if(Y.type!==pe.MemberExpression||Y.computed||Y.property.type!==pe.Identifier||Y.property.name!=="length")return null;let D=Y.object,Z=a(D);if(!Z||Z.length===0)return null;let q=[];for(let ce of Z)q.push(ce.length);return{values:q}}let g=d(p.left),F=d(p.right),P=null,j=null;if(g?p.right.type===pe.Literal&&typeof p.right.value=="number"&&(P=g.values,j=p.right.value):F&&p.left.type===pe.Literal&&typeof p.left.value=="number"&&(P=F.values,j=p.left.value),!P||j===null)return;let V=0,G=0;for(let Y of P){let D=!1;if(p.operator==="==="?D=Y===j:p.operator==="!=="?D=Y!==j:p.operator===">"?D=Y>j:p.operator===">="?D=Y>=j:p.operator==="<"?D=Y<j:p.operator==="<="&&(D=Y<=j),D?V++:G++,V>0&&G>0)return}V>0&&G===0?e.report({node:p,messageId:"unnecessaryLengthCondition"}):G>0&&V===0&&e.report({node:p,messageId:"alwaysFalseLengthCondition"})}function A(p){if(p.type===pe.Literal&&typeof p.value=="string")return p.value;let R=a(p);if(!R||R.length!==1)return null;let[d]=R;return d??null}function T(p){return(p.flags&B.TypeFlags.Intersection)!==0}function h(p){return(p.flags&B.TypeFlags.Object)!==0}function b(p){return!t||t.getIndexTypeOfType(p,B.IndexKind.String)?!0:!!t.getIndexTypeOfType(p,B.IndexKind.Number)}function w(p,R){if(!t||b(p)||p.getProperties().length===0)return"unknown";let d=t.getPropertyOfType(p,R);return d?d.flags&B.SymbolFlags.Optional?"optional":"required":"absent"}function k(p,R){if(p.flags&B.TypeFlags.Any||p.flags&B.TypeFlags.Unknown||p.flags&B.TypeFlags.Never||p.flags&B.TypeFlags.TypeParameter||p.flags&B.TypeFlags.IndexedAccess||p.flags&B.TypeFlags.StringLike||p.flags&B.TypeFlags.NumberLike||p.flags&B.TypeFlags.BigIntLike||p.flags&B.TypeFlags.BooleanLike||p.flags&B.TypeFlags.EnumLike||p.flags&B.TypeFlags.ESSymbolLike||p.flags&B.TypeFlags.NonPrimitive||p.flags&B.TypeFlags.Null||p.flags&B.TypeFlags.Undefined||p.flags&B.TypeFlags.Void)return"unknown";if(p.isUnion()){let d=!0,g=!0;for(let F of p.types){let P=k(F,R);if(P==="unknown"||(P!=="required"&&(d=!1),P!=="absent"&&(g=!1),P==="optional"))return"unknown"}return d?"required":g?"absent":"unknown"}if(T(p)){let d=p,g=!1,F=!1;for(let P of d.types){let j=k(P,R);if(j==="unknown")return"unknown";j==="required"?g=!0:j==="optional"&&(F=!0)}return g?"required":F?"optional":"absent"}return h(p)?w(p,R):"unknown"}function N(p){if(p.operator!=="in"||p.left.type===pe.PrivateIdentifier)return;let R=A(p.left);if(!R)return;let d=p.right,g=r.esTreeNodeToTSNodeMap.get(d);if(!t)return;let F=t.getTypeAtLocation(g),P=k(F,R);P==="required"?e.report({node:p,messageId:"unnecessaryInCondition",data:{property:R,type:t.typeToString(F),alternative:n.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${n.alternativeForInCondition}`:""}}):P==="absent"&&e.report({node:p,messageId:"alwaysFalseInCondition",data:{property:R,type:t.typeToString(F),alternative:n.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${n.alternativeForInCondition}`:""}})}return{BinaryExpression(p){l(p),I(p),N(p)},CallExpression(p){S(p),x(p)}}}})};function ct(e){return Array.from(new Set(e)).join(" | ")||"never"}function Ze(e,n){let r=e.argument;return r.type===pe.Identifier?r.name:n.sourceCode.getText(r)}function Di(e,n){return n.has(e)}import{AST_NODE_TYPES as ji,ESLintUtils as Li}from"@typescript-eslint/utils";import{z as Nt}from"zod/v4";var Mi=Li.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nr="no-call-with-explicit-generics",_i=Nt.object({functions:Nt.array(Nt.string())}),$i=Mi({name:nr,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[U(_i)]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Set(n.functions);return{CallExpression(t){let{callee:o}=t;o.type===ji.Identifier&&r.has(o.name)&&t.typeArguments&&e.report({node:t,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),Dt={name:nr,rule:$i};import{AST_NODE_TYPES as ut,ESLintUtils as Ui}from"@typescript-eslint/utils";var zi=Ui.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rr="no-call-with-inferred-generics",Wi=zi({name:rr,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Map(n.functions.map(t=>[t.name,t]));return{CallExpression(t){let{callee:o}=t;if(o.type!==ut.Identifier)return;let s=r.get(o.name);if(!s)return;let{minGenerics:i=1,allowAny:l,disallowTypes:c=n.disallowTypes}=s;(t.typeArguments?.params.length||0)<(i||0)&&e.report({node:t,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(l&&!c)&&t.typeArguments?.params.some(u=>!l&&u.type===ut.TSAnyKeyword||c&&u.type===ut.TSTypeReference&&u.typeName.type===ut.Identifier&&c.includes(u.typeName.name))&&e.report({node:t,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),jt={name:rr,rule:Wi};import{ESLintUtils as Ji}from"@typescript-eslint/utils";var Vi=Ji.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sr="no-commented-out-code",Xi=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],Bi=/^\s*return\s+/,Hi=/\w=("|'|`)/,Yi=/\w+:\s*('|"|`)/,qi=/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,Zi=/\w+-\w+:/,Gi=/\w+_\w+:/,Ki=/\?\s+\w/,Qi=/:\s+\w/,eo=/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,to=/^\s*\d+[,}]/,no=/^\s*\[[^\]]*\][,}]/,ro=/^\s*\{[^}]*\}[,}]/,io=/\.\w+\(/,oo=/\[\w+\]/,so=/^\s*(['"`]).+?\1\s*:/,ao=/^<[A-Z]\w*(\s|>|\/)/,lo=/^<[a-z]+(\s|>|\/)/,po=/<[A-Z]\w*(\s.*)?>/,co=/<\/[A-Z]\w*>/,uo=/<[a-z]+(\s.*)?>/,fo=/<\/[a-z]+>/,mo=/^\s*[*\s]*$/,yo=/^[a-zA-Z]/,go=/^[A-Z][A-Za-z]*(?:\s+\d+)?(?:\s+[a-z]+)*:\s+[A-Za-z]/,So=/```[\s\S]*?```/g,To=/`[^`]*`/g,ir=/[a-zA-Z0-9]/,ho=/\.[A-Za-z_][A-Za-z0-9_]*\(/,Eo=/[{}[\]()`=<>]/,bo=/:\s*(['"`[{(]|\w+\s*=>)/,xo=/\bif\s*\(|\belse\b|=>/,fe={returnStatement:Bi,stringAssignment:Hi,objectPropertyWithQuotes:Yi,computedPropertyAssignment:qi,kebabCaseProperty:Zi,snakeCaseProperty:Gi,ternaryOperator:Ki,colonWithWord:Qi,quotedString:eo,numberWithComma:to,arrayWithComma:no,objectWithComma:ro,methodCall:io,arrayAccess:oo,quotedPropertyKey:so,jsxSelfClosing:ao,jsxElement:lo,jsxOpeningTag:po,jsxClosingTag:co,htmlOpeningTag:uo,htmlClosingTag:fo,jsdocComment:mo};function Co(e){if(e.includes(":")){let r=e.split(":")[0]?.trim();if(r&&yo.test(r)&&r.includes(" "))return!0}let n=e.trim();return n.length===0||ho.test(n)||Eo.test(n)||bo.test(n)||xo.test(n)?!1:!!(n.includes(":")&&go.test(n))}var Io=[") {","return;",fe.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",fe.stringAssignment,");",fe.objectPropertyWithQuotes,fe.computedPropertyAssignment,fe.kebabCaseProperty,fe.snakeCaseProperty,"&&","||","()",fe.ternaryOperator,fe.colonWithWord,fe.quotedString,fe.numberWithComma,fe.arrayWithComma,fe.objectWithComma,fe.methodCall,fe.arrayAccess,"?.(","??","=>",fe.quotedPropertyKey],Ao=["/>","</",fe.jsxSelfClosing,fe.jsxElement,fe.jsxOpeningTag,fe.jsxClosingTag,fe.htmlOpeningTag,fe.htmlClosingTag],or=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],wo=Vi({name:sr,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function n(t,o){if(t.startsWith("/"))return!1;let s=t.trimStart();if(t.startsWith("*")||s.startsWith("eslint-disable")||t.includes("@deprecated")||t.includes("@example")||t.includes("@param")||t.includes("@returns")||t.includes("@throws")||t.includes("typescript-eslint")||t.includes("@ts-")||t.includes("prettier-ignore")||fe.jsdocComment.test(t))return!1;for(let i of or)if(s.startsWith(i))return!1;if(t.includes("https://")||Co(s))return!1;if(o==="Block"){for(let i of Ao)if(typeof i=="string"){if(t.includes(i))return{wrongPattern:i}}else if(i.test(t))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Xi)if(s.startsWith(i))return{wrongPattern:i};for(let i of Io)if(typeof i=="string"){if(t.includes(i))return{wrongPattern:i}}else if(i.test(t))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(t,o){let s=t,i=s.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return s;if(o==="Block"&&s.includes("```")){let a=s.split(So);a.some(f=>ir.test(f))&&(s=a.join(""))}if(!s.includes("`"))return s;let l=s.split(To);return l.some(a=>ir.test(a))?l.join(""):s}return{Program(){let o=e.sourceCode.getAllComments();for(let s of o){let i=r(s.value,s.type),l=n(i,s.type);l&&e.report({node:s,messageId:"commentedOutCode",data:{wrongPattern:l.wrongPattern,allowedPrefixes:or.join(", ")}})}}}}}),Lt={name:sr,rule:wo};import{ESLintUtils as Ro,TSESTree as Fo}from"@typescript-eslint/utils";var vo=Ro.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ar="no-default-export",ko=vo({name:ar,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(n){e.report({node:n,messageId:"noDefaultExport"})},ExportNamedDeclaration(n){for(let r of n.specifiers)r.exported.type===Fo.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:n,messageId:"noDefaultExport"})}}}}),Mt={name:ar,rule:ko};import{ESLintUtils as Po}from"@typescript-eslint/utils";var Oo=Po.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lr="no-leaked-text-in-jsx",No=[",",";","[","]","(",")"],Do=Oo({name:lr,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(n){let r=n.value.trim();if(!r)return;let t="";No.includes(r)?t=r:r.includes("&&")?t="&&":r.includes("||")?t="||":r.endsWith("? (")&&(t="? ("),t&&e.report({node:n,messageId:"leakedTextInJSX",data:{text:t}})}}}}),_t={name:lr,rule:Do};import{AST_NODE_TYPES as nt,ESLintUtils as jo}from"@typescript-eslint/utils";var Lo=jo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cr="no-non-camel-case-functions",Mo=/^(\$?[a-z][a-zA-Z0-9]*)$/;function pr(e){if(e.typeName.type!==nt.TSQualifiedName)return!1;let{left:n,right:r}=e.typeName;return n.type===nt.Identifier&&n.name==="JSX"&&r.name==="Element"}var _o=Lo({name:cr,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(n){if(n.id&&!Mo.test(n.id.name)){let r=n.returnType?.typeAnnotation;if(r&&(r.type===nt.TSTypeReference?pr(r):r.type===nt.TSUnionType&&r.types.some(o=>o.type===nt.TSTypeReference&&pr(o))))return;e.report({node:n.id,messageId:"nonCamelCaseFunction",data:{functionName:n.id.name}})}}}}}),$t={name:cr,rule:_o};import{ESLintUtils as $o,TSESTree as se}from"@typescript-eslint/utils";var Uo=$o.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ur="no-optional-root-props",zo=Uo({name:ur,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function n(t){let s=e.sourceCode.getDeclaredVariables(t)[0];if(!s||s.references.length!==1)return!1;let i=s.references[0];if(!i)return!1;for(let l of kt(i.identifier)){if("returnType"in l||l.type===se.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let c=l.parent;if(!c)return!1;if(c.type===se.AST_NODE_TYPES.TSTypeParameterInstantiation&&c.parent.type===se.AST_NODE_TYPES.TSTypeReference&&c.parent.typeName.type===se.AST_NODE_TYPES.Identifier&&c.parent.typeName.name==="FC"){let u=qe(c.parent.parent,se.AST_NODE_TYPES.VariableDeclaration,4);if(!u)return!1;let f=ft(u,e.sourceCode);return f?!(f.parent.type===se.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===se.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(l.type===se.AST_NODE_TYPES.AssignmentPattern)return!1;if(c.type===se.AST_NODE_TYPES.ArrowFunctionExpression){let a=qe(c,se.AST_NODE_TYPES.VariableDeclaration);return a?!!ft(a,e.sourceCode):!1}if(c.type===se.AST_NODE_TYPES.FunctionDeclaration)return!!ft(c,e.sourceCode)}return!1}function r(t){t.key.type!==se.AST_NODE_TYPES.Identifier||!t.optional||e.report({node:t.key,messageId:"optionalNotAllowed",data:{propertyName:t.key.name},suggest:[{messageId:"suggestion",fix:o=>{let s=qe(t,se.AST_NODE_TYPES.TSPropertySignature);if(!s)return null;let i=e.sourceCode.getText(s);return o.replaceText(s,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(t){if(t.typeAnnotation.type===se.AST_NODE_TYPES.TSTypeLiteral&&!(mt(t)||!n(t)))for(let o of t.typeAnnotation.members)o.type===se.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(t){if(!(mt(t)||!n(t)))for(let o of t.body.body)o.type===se.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(t){if(t.typeName.type!==se.AST_NODE_TYPES.Identifier||t.typeName.name!=="FC"||!t.typeArguments?.params[0])return;let o=t.typeArguments.params[0];if(o.type!==se.AST_NODE_TYPES.TSTypeLiteral)return;let s=qe(t.parent,se.AST_NODE_TYPES.VariableDeclaration,4);if(!s)return;let i=ft(s,e.sourceCode);if(!(!i||i.parent.type===se.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===se.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let c of o.members)c.type===se.AST_NODE_TYPES.TSPropertySignature&&r(c)}}}});function mt(e){return e?e.parent?.type===se.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===se.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function ft(e,n){if(mt(e))return;let r;if(e.type===se.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===se.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let t=n.getScope(e);e.type===se.AST_NODE_TYPES.FunctionDeclaration&&t.upper&&(t=t.upper);let o=t.variables.find(i=>i.identifiers.includes(r));if(!o)return;let s=o.references.filter(i=>i.identifier!==r);if(!(s.length!==1||!s[0])&&!mt(s[0].identifier.parent.parent))return s[0].identifier}var Ut={name:ur,rule:zo};import{AST_NODE_TYPES as yt}from"@typescript-eslint/utils";var rt=X({name:"no-reexport",meta:{type:"problem",docs:{description:"Disallow re-exports to prevent indirection"},schema:[],messages:{noReexport:"Re-exports are not allowed. Use direct exports only."}},defaultOptions:[],create(e){let n=new Set;function r(t){return t?t.type===yt.Identifier?n.has(t.name):t.type===yt.MemberExpression?r(t.object):!1:!1}return{ImportDeclaration(t){for(let o of t.specifiers)n.add(o.local.name)},ExportNamedDeclaration(t){if(t.source){e.report({node:t,messageId:"noReexport"});return}if(t.declaration?.type===yt.VariableDeclaration)for(let o of t.declaration.declarations)r(o.init)&&e.report({node:t,messageId:"noReexport"});t.specifiers.length>0&&e.report({node:t,messageId:"noReexport"})},ExportDefaultDeclaration(t){t.declaration.type===yt.Identifier&&n.has(t.declaration.name)&&e.report({node:t,messageId:"noReexport"})},ExportAllDeclaration(t){e.report({node:t,messageId:"noReexport"})}}}});import{ESLintUtils as Wo}from"@typescript-eslint/utils";import zt from"path";import{z as We}from"zod/v4";var Jo=Wo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fr="no-relative-imports",Vo=We.object({find:We.string(),replacement:We.string()}),Xo=We.object({aliases:We.array(Vo),rootDir:We.string().optional(),allowNotFoundAliases:We.boolean().optional(),_dev_simulateFileName:We.string().optional()}),Bo=Jo({name:fr,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[U(Xo)]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[n]){let r=n._dev_simulateFileName??e.filename;function t(i){return i.startsWith(".")||i.startsWith("..")}function o(i,l){let c=zt.dirname(l);return zt.resolve(c,i)}function s(i){let l=n.rootDir??process.cwd(),c=zt.relative(l,i);if(c.startsWith("."))return null;c.startsWith("/")||(c=`/${c}`);for(let{find:a,replacement:u}of n.aliases)if(c.startsWith(u)){let f=c.replace(u,a);return{alias:a,newPath:f}}return null}return{ImportDeclaration(i){let l=i.source.value;if(!t(l))return;let c=o(l,r),a=s(c);!a&&n.allowNotFoundAliases||e.report({node:i,messageId:a?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:a?.alias},fix:a?u=>u.replaceText(i.source,`'${a.newPath}'`):void 0})}}}}),Wt={name:fr,rule:Bo};import{AST_NODE_TYPES as me}from"@typescript-eslint/utils";import{z as mr}from"zod/v4";var Ho=mr.object({customMessage:mr.string().optional()}),Jt=X({name:"no-static-style-prop",meta:{type:"problem",docs:{description:"Prevent using static style props in JSX, only dynamic values should be allowed"},schema:[U(Ho)],messages:{noStaticStyleProp:"Static style props are not allowed use css instead.{{customMessage}}"}},defaultOptions:[{}],create(e,[n]){function r(t){switch(t.type){case me.Literal:return!0;case me.ObjectExpression:return t.properties.every(o=>o.type===me.Property?o.computed||o.value.type===me.Identifier&&o.key.type===me.Identifier&&o.key.name===o.value.name?!1:r(o.value):!1);case me.ArrayExpression:return t.elements.every(o=>o?o.type===me.SpreadElement?!1:r(o):!0);case me.TemplateLiteral:return t.expressions.length===0;case me.ConditionalExpression:case me.LogicalExpression:case me.BinaryExpression:case me.UnaryExpression:case me.CallExpression:case me.MemberExpression:case me.Identifier:case me.ArrowFunctionExpression:case me.FunctionExpression:return!1;default:return!1}}return{JSXAttribute(t){if(t.name.type===me.JSXIdentifier&&t.name.name==="style"&&t.value){let o=null;t.value.type===me.JSXExpressionContainer?t.value.expression.type!==me.JSXEmptyExpression&&(o=t.value.expression):t.value.type===me.Literal&&(o=t.value),o&&r(o)&&e.report({node:t,messageId:"noStaticStyleProp",data:{customMessage:n.customMessage?` ${n.customMessage}`:""}})}}}}});import{AST_NODE_TYPES as dt}from"@typescript-eslint/utils";import*as Xe from"zod/v4";var Yo=Xe.object({alternativeMsgs:Xe.object({inArrayFind:Xe.string().optional(),inArrayFilter:Xe.string().optional()}).optional(),__dev_simulateFileName:Xe.string().optional()});function qo(e){return e.typeAnnotation.type!==dt.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}var Zo=/(typeGuards|type-guards)\.(ts|tsx)$/;function Go(e){return Zo.test(e)}function Ko(e){let n=e.parent;for(;n;){if(n.type===dt.CallExpression&&n.callee.type===dt.MemberExpression&&n.callee.property.type===dt.Identifier){let r=n.callee.property.name;if(r==="filter"||r==="find")return{method:r}}n=n.parent}return null}var Vt=X({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Check if the type guard can be inferred by typescript, in most cases it can, e.g. `.filter((nullable) => nullable !== null)`. If not, type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[U(Yo)],hasSuggestions:!0},defaultOptions:[{}],create(e,[n]){let r=n.__dev_simulateFileName??e.filename;if(Go(r))return{};function t(o){if(!qo(o))return;let s=Ko(o);if(n.alternativeMsgs&&s){let i=s.method==="filter"?n.alternativeMsgs.inArrayFilter:n.alternativeMsgs.inArrayFind;if(i){let l=s.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:l,data:{message:i}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":t,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":t,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":t}}});import{AST_NODE_TYPES as Ge}from"@typescript-eslint/utils";var Qo="no-unnecessary-async-on-jsx-props";function es(e){if(e.body.type!==Ge.BlockStatement)return!1;let n=e.body.body;if(n.length!==1)return!1;let r=n[0];return!r||r.type!==Ge.ExpressionStatement?!1:r.expression.type===Ge.AwaitExpression}var Xt=X({name:Qo,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function n(r){es(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(t){let o=e.sourceCode,s=[],i=o.getFirstToken(r,c=>c.value==="async");if(i){let c=o.getTokenAfter(i);c?s.push(t.replaceTextRange([i.range[0],c.range[0]],"")):s.push(t.remove(i))}function l(c){if(c.type===Ge.AwaitExpression){let a=o.getFirstToken(c);if(a&&a.value==="await"){let u=o.getTokenAfter(a);u?s.push(t.replaceTextRange([a.range[0],u.range[0]],"")):s.push(t.remove(a))}}if(c.type===Ge.BlockStatement)for(let a of c.body)l(a);else c.type===Ge.ExpressionStatement&&l(c.expression)}return l(r.body),s}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":n,"JSXAttribute FunctionExpression[async=true]":n}}});import{AST_NODE_TYPES as it,ESLintUtils as dr}from"@typescript-eslint/utils";import*as Bt from"typescript";import ot from"zod/v4";var ts=dr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yr="no-unnecessary-casting",ns=ot.object({additionalCastFunctions:ot.array(ot.object({name:ot.string(),expectedType:ot.enum(["string","number"])})).optional()}),Ht={name:yr,rule:ts({name:yr,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[U(ns)],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],t=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=dr.getParserServices(e,!0),s=o.program?.getTypeChecker();if(!s||!o.program)throw new Error("TypeScript services or program not available");function i(u,f){switch(u.type){case it.Literal:return f==="number"?typeof u.value=="number":typeof u.value=="string";case it.TemplateLiteral:return f==="string";case it.UnaryExpression:return f==="number"?u.operator==="+"||u.operator==="-"||u.operator==="~":!1;default:return!1}}function l(u,f){return f==="number"?!!(u.flags&Bt.TypeFlags.NumberLike):!!(u.flags&Bt.TypeFlags.StringLike)}function c(u,f){return y=>y.replaceText(u,e.sourceCode.getText(f))}function a(u){if(!s||u.arguments.length!==1)return;let f=u.arguments[0];if(!f||f.type===it.SpreadElement)return;let{callee:y}=u;if(y.type!==it.Identifier)return;let C=y.name,m=t.find(x=>x.name===C);if(!m)return;if(i(f,m.expectedType)||l(s.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(f)),m.expectedType)){let x,S;C==="Number"?x="unnecessaryNumberCasting":C==="String"?x="unnecessaryStringCasting":(x="unnecessaryCustomCasting",S={name:m.name,type:m.expectedType}),e.report({node:u,messageId:x,...S?{data:S}:{},fix:c(u,f)})}}return{CallExpression:a}}})};import{AST_NODE_TYPES as Re}from"@typescript-eslint/utils";import*as gt from"zod/v4";var rs=gt.object({ignoreWithDescription:gt.string().optional()}),Yt=X({name:"no-unnecessary-describe",meta:{type:"suggestion",docs:{description:"Disallow unnecessary describe blocks that wrap all tests in a file"},messages:{unnecessaryDescribe:"Describe blocks that solely wrap all tests in the file are unnecessary, they just add unnecessary nesting to the code. The file itself should be enough to group tests. Remove it.",removeDescribe:"Remove the describe block"},hasSuggestions:!0,schema:[U(rs)]},defaultOptions:[{}],create(e,[n]){let r=e.getSourceCode(),t=r.ast;function o(c){let a=c.arguments[0];return a&&a.type===Re.Literal&&typeof a.value=="string"?a.value:null}function s(c){return!c||!n.ignoreWithDescription?!1:new RegExp(n.ignoreWithDescription).test(c)}function i(c){return c.length!==1?!1:t.body.filter(u=>{if(u.type===Re.ExpressionStatement){let f=u.expression;if(f.type===Re.CallExpression&&f.callee.type===Re.Identifier){let y=f.callee.name;return["test","it","beforeEach","afterEach","beforeAll","afterAll"].includes(y)}}return!1}).length===0}function l(c){let a=c.arguments[1];if(a&&(a.type===Re.FunctionExpression||a.type===Re.ArrowFunctionExpression)&&a.body.type===Re.BlockStatement){let u=a.body.body;return u.length===0?"":u.map(y=>r.text.slice(y.range[0],y.range[1])).join(`
16
16
 
17
- `)}return""}return{Program(){let c=[];for(let y of t.body)y.type===Re.ExpressionStatement&&y.expression.type===Re.CallExpression&&y.expression.callee.type===Re.Identifier&&y.expression.callee.name==="describe"&&y.expression.arguments.length===2&&c.push(y.expression);if(!i(c))return;let[a]=c;if(!a)return;let u=o(a);if(s(u))return;let m=t.body.find(y=>y.type===Re.ExpressionStatement&&y.expression===a);!m||m.type!==Re.ExpressionStatement||e.report({node:a,messageId:"unnecessaryDescribe",suggest:[{messageId:"removeDescribe",fix(y){let C=l(a);return C?y.replaceText(m,C):null}}]})}}}});import{AST_NODE_TYPES as gt}from"@typescript-eslint/utils";import*as Ne from"zod/v4";var ns=Ne.object({methods:Ne.union([Ne.array(Ne.string()),Ne.literal("array")])}),Yt=H({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[z(ns)]},defaultOptions:[{methods:"array"}],create(e,[n]){let r=n.methods,t=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(l){return Array.isArray(r)?r.includes(l):t.has(l)}function s(l){let{callee:c}=l;if(c.type===gt.MemberExpression){let a=c.property;if(a.type===gt.Identifier)return a.name}return null}function i(l,c){if(l.type!==gt.Identifier||!l.typeAnnotation)return;let a=c.parent;if(a.type===gt.CallExpression){let u=s(a);u&&o(u)&&a.arguments.indexOf(c)===0&&e.report({node:l.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(y){return l.typeAnnotation?y.remove(l.typeAnnotation):null}})}}return{ArrowFunctionExpression(l){for(let c of l.params)i(c,l)},FunctionExpression(l){for(let c of l.params)i(c,l)}}}});import{AST_NODE_TYPES as Ie}from"@typescript-eslint/utils";var qt=H({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(n){if(n.id.type===Ie.ObjectPattern||!n.init||n.init.type!==Ie.ObjectExpression||n.id.type===Ie.Identifier&&n.id.typeAnnotation||n.parent.parent.type===Ie.ExportNamedDeclaration)return;let r=new Map;for(let i of n.init.properties)i.type===Ie.Property&&i.key.type===Ie.Identifier&&r.set(i.key.name,i);if(r.size===0||n.id.type!==Ie.Identifier)return;let t=rs(n,e.sourceCode);if(t.length===0)return;let o=n.init.properties.some(i=>i.type!==Ie.Property?!1:i.value.type===Ie.FunctionExpression),s=new Set;for(let i of t){if(i.identifier.parent.type!==Ie.MemberExpression)return;let l=i.identifier.parent;if(l.object!==i.identifier)return;if(l.computed)if(l.property.type===Ie.Literal&&typeof l.property.value=="string")s.add(l.property.value);else return;else{if(l.property.type!==Ie.Identifier)return;s.add(l.property.name)}if(l.parent.type===Ie.CallExpression&&o)return}for(let[i,l]of r)s.has(i)||e.report({node:l,messageId:"unusedObjectProperty",data:{name:i}})}}}});function rs(e,n){let r=n.getDeclaredVariables(e);if(r.length!==1)return[];let t=r[0];return t?t.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as te}from"@typescript-eslint/utils";import{z as yr}from"zod/v4";var is=yr.object({ignoreArgsMatching:yr.string().optional()}),Zt=H({name:"no-unused-optional-args",meta:{type:"problem",docs:{description:"Detect unused optional function arguments in non-exported functions"},messages:{unusedOptionalArg:"Optional parameter '{{name}}' is never used",unusedOptionalProp:"Optional prop '{{name}}' is never provided"},schema:[z(is)]},defaultOptions:[{}],create(e,[n]){let r=[];function t(i){return n.ignoreArgsMatching?new RegExp(n.ignoreArgsMatching).test(i):!1}function o(i){return i.type===te.ExportNamedDeclaration||i.type===te.ExportDefaultDeclaration||i.parent?.type===te.ExportNamedDeclaration||i.parent?.type===te.ExportDefaultDeclaration}function s(i){let l=[];for(let c=0;c<i.length;c++){let a=i[c];if(!a||a.type!==te.Identifier)continue;let u=a.name;if(!t(u)){if(a.optional&&a.typeAnnotation&&a.typeAnnotation.typeAnnotation.type===te.TSTypeLiteral){let m=a.typeAnnotation.typeAnnotation,y=[];for(let C of m.members)C.type===te.TSPropertySignature&&C.key.type===te.Identifier&&y.push({name:C.key.name,optional:C.optional===!0});y.some(C=>C.optional)?l.push({param:a,index:c,name:u,isObjectParam:!0,objectProps:y}):l.push({param:a,index:c,name:u,isObjectParam:!1})}else if(a.optional)l.push({param:a,index:c,name:u,isObjectParam:!1});else if(a.typeAnnotation&&a.typeAnnotation.typeAnnotation.type===te.TSTypeLiteral){let m=a.typeAnnotation.typeAnnotation,y=[];for(let C of m.members)C.type===te.TSPropertySignature&&C.key.type===te.Identifier&&y.push({name:C.key.name,optional:C.optional===!0});y.some(C=>C.optional)&&l.push({param:a,index:c,name:u,isObjectParam:!0,objectProps:y})}}}return l}return{FunctionDeclaration(i){if(o(i))return;let l=s(i.params);l.length!==0&&r.push({node:i,declarationNode:i,optionalParams:l})},VariableDeclarator(i){if(i.id.type!==te.Identifier||!i.init||i.init.type!==te.ArrowFunctionExpression&&i.init.type!==te.FunctionExpression||o(i.parent.parent))return;let c=[...s(i.init.params)];if(i.id.typeAnnotation&&i.id.typeAnnotation.typeAnnotation.type===te.TSTypeReference){let a=i.id.typeAnnotation.typeAnnotation;if(a.typeName.type===te.Identifier&&a.typeName.name==="FC"){let u=a.typeArguments;if(u&&u.params.length===1){let m=u.params[0];if(m&&m.type===te.TSTypeLiteral){let y=[];for(let C of m.members)C.type===te.TSPropertySignature&&C.key.type===te.Identifier&&y.push({name:C.key.name,optional:C.optional===!0});y.some(C=>C.optional)&&c.push({param:i.id,index:0,name:"props",isObjectParam:!0,objectProps:y})}}}}c.length!==0&&r.push({node:i.init,declarationNode:i,optionalParams:c})},"Program:exit"(){for(let i of r){let c=e.sourceCode.getDeclaredVariables(i.declarationNode)[0];if(!c)continue;let a=c.references.filter(y=>y.identifier!==c.identifiers[0]);if(a.length===0)continue;let u=!1;for(let y of a){let C=y.identifier.parent;if(C.type===te.CallExpression&&y.identifier.type===te.Identifier&&C.arguments.includes(y.identifier)){u=!0;break}if(C.type===te.ReturnStatement){u=!0;break}if(C.type===te.Property&&C.parent.type===te.ObjectExpression&&C.parent.parent.type===te.ReturnStatement){u=!0;break}if(C.type===te.JSXExpressionContainer){u=!0;break}}if(u)continue;let m=[];for(let y of a){let C=y.identifier.parent;if(C.type===te.CallExpression&&C.callee===y.identifier){let f=C.arguments.length,E=C.arguments.some(S=>S.type===te.SpreadElement);if(E){u=!0;break}let x={argCount:f,hasSpread:E};for(let S of i.optionalParams)if(S.isObjectParam&&S.index<f){let I=C.arguments[S.index];if(I?.type===te.ObjectExpression){let A={};for(let T of I.properties)T.type===te.Property&&T.key.type===te.Identifier&&(A[T.key.name]=!0);x.objectArgs||(x.objectArgs=[]),x.objectArgs[S.index]=A}else if(I){u=!0;break}}m.push(x)}else if(C.type===te.JSXOpeningElement&&C.name===y.identifier){let f=C.attributes.some(x=>x.type===te.JSXSpreadAttribute);if(f){u=!0;break}let E={argCount:1,hasSpread:f};for(let x of i.optionalParams)if(x.isObjectParam&&x.index===0){let S={};for(let I of C.attributes)I.type===te.JSXAttribute&&I.name.type===te.JSXIdentifier&&(S[I.name.name]=!0);E.objectArgs||(E.objectArgs=[]),E.objectArgs[0]=S}m.push(E)}}if(!(u||m.length===0))for(let y of i.optionalParams)if(y.isObjectParam&&y.objectProps)for(let C of y.objectProps){if(!C.optional)continue;let f=!1;for(let E of m)if(E.objectArgs&&E.objectArgs[y.index]){let x=E.objectArgs[y.index];if(x&&x[C.name]){f=!0;break}}f||e.report({node:y.param,messageId:"unusedOptionalProp",data:{name:C.name}})}else{let C=!1;for(let f of m)if(f.argCount>y.index){C=!0;break}C||e.report({node:y.param,messageId:"unusedOptionalArg",data:{name:y.name}})}}}}}});import{AST_NODE_TYPES as le,ESLintUtils as os}from"@typescript-eslint/utils";import{z as Be}from"zod/v4";var ss=Be.object({selectors:Be.array(Be.object({name:Be.string(),selectorProp:Be.string().optional(),selectorArgPos:Be.number().optional(),returnProp:Be.string().optional()}))}),as=os.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dr="no-unused-selected-values",Gt={name:dr,rule:as({name:dr,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[z(ss)]},defaultOptions:[{selectors:[]}],create(e,[n]){let{selectors:r=[]}=n,t=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let s=null;if(o.init?.type===le.CallExpression&&(s=o.init),!s)return;let i=ps(s);if(!i)return;let l=t.get(i);if(!l)return;let c=ls(s,l.selectorArgPos??0,l.selectorProp);if(!c)return;let a=cs(c);if(!a)return;let u=gr(a.properties,void 0);if(!u)return;if(o.id.type===le.ObjectPattern){let C=gr(o.id.properties,l.returnProp);if(!C)return;for(let[f,E]of u)C.has(f)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:f}});return}if(o.id.type!==le.Identifier||l.returnProp)return;let m=us(o,e.sourceCode);if(m.length===0)return;let y=new Set;for(let C of m){if(C.identifier.parent.type!==le.MemberExpression)return;let f=C.identifier.parent.property;if(f.type!==le.Identifier)return;y.add(f.name)}for(let[C,f]of u)y.has(C)||e.report({node:f,messageId:"unusedSelectedValue",data:{name:C}})}}}})};function ls(e,n,r){let t=e.arguments[n];if(!t)return null;if(t.type===le.ArrowFunctionExpression||t.type===le.FunctionExpression)return t;if(r&&t.type===le.ObjectExpression){let o=t.properties.find(i=>i.type===le.Property&&i.key.type===le.Identifier&&i.key.name===r);if(o?.type!==le.Property)return null;let s=o.value;if(s.type===le.ArrowFunctionExpression||s.type===le.FunctionExpression)return s}return null}function ps(e){return e.callee.type===le.Identifier?e.callee.name:e.callee.type===le.MemberExpression&&e.callee.property.type===le.Identifier?e.callee.property.name:null}function cs(e){if(e.body.type===le.ObjectExpression)return e.body;if(e.body.type===le.BlockStatement){let n=e.body.body.filter(r=>r.type===le.ReturnStatement);return n.length!==1||!n[0]||n[0].argument?.type!==le.ObjectExpression?null:n[0].argument}return null}function gr(e,n){let r=e;if(n){let o=e.find(s=>s.type===le.Property&&s.key.type===le.Identifier&&s.key.name===n);if(o?.type!==le.Property||o.value.type!==le.ObjectPattern)return null;r=o.value.properties}let t=new Map;for(let o of r){if(o.type!==le.Property||o.key.type!==le.Identifier)return null;t.set(o.key.name,o)}return t.size>0?t:null}function us(e,n){let r=n.getDeclaredVariables(e);if(r.length!==1)return[];let t=r[0];return t?t.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as ae}from"@typescript-eslint/utils";var Kt=H({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(s=>s.type===ae.ImportDeclaration&&s.source.value==="t-state-form"))return{};let t=null,o=!1;return{CallExpression(s){if(o)return;if(!t){let l=fs(s);l&&(t=l);return}let i=ms(s,e.sourceCode);if(i){o=!0;for(let l of i)t.delete(l);if(t.size!==0)for(let[l,c]of t)e.report({node:c,messageId:"unusedField",data:{name:l}})}}}}});function fs(e){if(!(e.callee.type===ae.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==ae.ObjectExpression)return null;let t=kt(r.properties,s=>s.type!==ae.Property||s.key.type!==ae.Identifier||s.key.name!=="initialConfig"?null:s.value.type===ae.ObjectExpression?s.value:s.value.type===ae.ArrowFunctionExpression||s.value.type===ae.FunctionExpression?ys(s.value):null);if(!t)return null;let o=new Map;for(let s of t.properties)s.type===ae.Property&&s.key.type===ae.Identifier&&o.set(s.key.name,s);return o}function ms(e,n){if(!(e.callee.type===ae.Identifier&&e.callee.name==="useFormState")||e.parent.type!==ae.VariableDeclarator||e.parent.id.type!==ae.ObjectPattern||!kt(e.parent.id.properties,i=>i.type===ae.Property&&i.key.type===ae.Identifier&&i.key.name==="formFields"&&i))return null;let o=qn(e.parent,"formFields",n),s=new Set;for(let{identifier:i}of o){if(i.type!==ae.Identifier||i.parent.type===ae.Property&&i.parent.parent.type===ae.ObjectExpression&&i.parent.parent.parent.type===ae.ReturnStatement||i.parent.type===ae.ReturnStatement)return null;if(i.parent.type===ae.MemberExpression){if(i.parent.object.type!==ae.Identifier||i.parent.property.type!==ae.Identifier)return null;s.add(i.parent.property.name)}}return s}function ys(e){if(e.body.type===ae.ObjectExpression)return e.body;if(e.body.type===ae.BlockStatement){let n=e.body.body.filter(r=>r.type===ae.ReturnStatement);return n.length!==1||!n[0]||n[0].argument?.type!==ae.ObjectExpression?null:n[0].argument}return null}import{AST_NODE_TYPES as ie,ESLintUtils as ds}from"@typescript-eslint/utils";import{z as St}from"zod/v4";var gs=ds.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Sr(e){let n=[];for(let r of e.members)r.type===ie.TSPropertySignature&&r.key.type===ie.Identifier&&n.push([r.key.name,r]);return n}function Tr(e,...n){for(let r of n)e.set(...r);return e}var Ss=St.object({forceCheckOnFCPropTypesWithName:St.array(St.string()).optional(),alwaysCheckFunctionOptionTypes:St.boolean().optional()}),hr="no-unused-type-props-in-args",Qt=null,Ts=gs({name:hr,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[z(Ss)],fixable:"code"},defaultOptions:[{alwaysCheckFunctionOptionTypes:!0}],create(e,[n]){let{forceCheckOnFCPropTypesWithName:r,alwaysCheckFunctionOptionTypes:t=!0}=n;r&&!Qt&&(Qt=r.map(c=>new RegExp(c)));function o(c,a,u,m,y=!0,C=!1){let f=u.name,E=e.sourceCode.getScope(a).references.find(T=>T.identifier.name===f)?.resolved,x=c&&Qt?.some(T=>T.test(f)),S=C&&t;if(!E||!x&&E.references.filter(T=>T.isTypeReference).length>1||!E.defs[0])return;let I=E.defs[0].node,A=I.parent?.type===ie.ExportNamedDeclaration;if(!(y&&A&&!S)){if(I.type===ie.TSTypeAliasDeclaration){s(c,a,m,I.typeAnnotation,!0,C);return}if(I.type===ie.TSInterfaceDeclaration){s(c,a,m,I.body,!0,C);return}}}function s(c,a,u,m,y,C=!1){if(m.type===ie.TSInterfaceBody){for(let f of m.body)f.type===ie.TSPropertySignature&&f.key.type===ie.Identifier&&u.set(f.key.name,f);return}if(m.type===ie.TSTypeLiteral){Tr(u,...Sr(m));return}if(m.type===ie.TSIntersectionType){for(let f of m.types)s(c,a,u,f,!0,C);return}y||m.type===ie.TSTypeReference&&m.typeName.type===ie.Identifier&&o(c,a,m.typeName,u,!0,C)}function i(c,a,u,m=!1){for(let y of u)if(y.type===ie.ObjectPattern&&y.typeAnnotation){let C=new Map;if(s(c,a,C,y.typeAnnotation.typeAnnotation,!1,m),C.size===0)continue;l(y,C)}else y.type===ie.AssignmentPattern&&y.left.type===ie.ObjectPattern&&i(c,a,[y.left],m)}function l(c,a){let u=[];if(c.properties.at(-1)?.type===ie.RestElement)return;for(let f of c.properties)f.type===ie.Property&&f.key.type===ie.Identifier&&u.push(f.key.name);let y=[],C=[];for(let[f,E]of a)u.includes(f)||(C.push(f),y.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:f}}));for(let[f,E]of y.entries())e.report({...E,fix:f===y.length-1?x=>{let S=c.properties.at(-1),I=C.join(", ");return S?S.type===ie.RestElement?null:x.insertTextAfter(S,`, ${I}`):x.insertTextBeforeRange([c.range[0]+1,c.range[1]],I)}:void 0})}return{VariableDeclaration(c){let a=c.declarations[0],u=new Map,m=a.id.type===ie.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===ie.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===ie.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(m){if(m.type===ie.TSTypeReference&&m.typeName.type===ie.Identifier)o(!0,c,m.typeName,u,!1);else if(m.type===ie.TSTypeLiteral)Tr(u,...Sr(m));else if(m.type===ie.TSIntersectionType)for(let y of m.types)y.type===ie.TSTypeReference&&y.typeName.type===ie.Identifier?o(!0,c,y.typeName,u,!1):s(!0,c,u,y,!0);if(u.size!==0&&a.init?.type===ie.ArrowFunctionExpression){let y=a.init.params[0];if(!y){e.report({node:a.init,messageId:"missingComponentParam"});return}y.type===ie.ObjectPattern&&l(y,u)}}},FunctionDeclaration(c){i(!1,c,c.params,t)},ArrowFunctionExpression(c){i(!1,c,c.params,t)}}}}),en={name:hr,rule:Ts};import{AST_NODE_TYPES as Oe}from"@typescript-eslint/utils";var tn=H({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let n=new Set;function r(t){return t.callee.type===Oe.Identifier?n.has(t.callee.name):t.callee.type===Oe.MemberExpression&&t.callee.object.type===Oe.Identifier&&t.callee.property.type===Oe.Identifier?t.callee.property.name==="useRef":!1}return{ImportDeclaration(t){if(t.source.value==="react")for(let o of t.specifiers)o.type===Oe.ImportSpecifier&&o.imported.type===Oe.Identifier&&o.imported.name==="useRef"&&n.add(o.local.name)},VariableDeclarator(t){if(t.init&&t.init.type===Oe.CallExpression&&r(t.init)&&t.id.type===Oe.Identifier){let s=e.sourceCode.getScope(t).set.get(t.id.name);if(s){let i=!1;for(let l of s.references){let a=l.identifier.parent;if(a!==t&&!(a.type===Oe.JSXExpressionContainer&&a.parent.type===Oe.JSXAttribute&&a.parent.name.type===Oe.JSXIdentifier&&a.parent.name.name==="ref")){i=!0;break}}i||e.report({node:t.id,messageId:"refNotRead",data:{name:t.id.name}})}}}}}});import{AST_NODE_TYPES as nn,ESLintUtils as hs}from"@typescript-eslint/utils";var Es=hs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),br="prefer-named-functions",Er=new Map,bs=Es({name:br,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[n]){let r=null;if(n.ignoreRegex){let t=Er.get(n.ignoreRegex);t?r=t:(r=new RegExp(n.ignoreRegex),Er.set(n.ignoreRegex,r))}return{VariableDeclarator(t){if(t.init&&t.init.type===nn.ArrowFunctionExpression&&t.id.type===nn.Identifier){let o=t.id.name;if(t.id.typeAnnotation||r&&r.test(o)||!n.disallowArrowFnWithImplicitReturns&&t.init.body.type!==nn.BlockStatement)return;let s=t.parent,i=t.init.params,l=t.init.body,c=t.init;e.report({node:t.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:n.ignoreRegex},suggest:[{messageId:"suggestion",fix:a=>a.replaceText(s,`${c.async?"async ":""}function ${o}(${i.map(u=>e.sourceCode.getText(u)).join(", ")||""}) ${e.sourceCode.getText(l)}`)}]})}}}}}),rn={name:br,rule:bs};import{AST_NODE_TYPES as Q}from"@typescript-eslint/utils";import{z as _e}from"zod/v4";var xs=_e.object({disallowedFunctions:_e.array(_e.object({name:_e.string(),allowUsingWithArgs:_e.boolean().optional(),hookAlternative:_e.string().optional(),message:_e.string().optional(),allowUseInside:_e.array(_e.string()).optional()}))}),Cs=/^use[A-Z]/,Is=/^[A-Z]/;function Tt(e){return Cs.test(e)}function xr(e){return Is.test(e)}function As(e){return e.type===Q.Identifier?Tt(e.name):e.type===Q.MemberExpression&&e.property.type===Q.Identifier?Tt(e.property.name):!1}function Cr(e,n){return e.type===Q.Identifier?e.name===n:e.type===Q.MemberExpression&&e.object.type===Q.Identifier&&e.property.type===Q.Identifier?e.object.name==="React"&&e.property.name===n:!1}function Ir(e){return!!(e.parent&&e.parent.type===Q.CallExpression&&Cr(e.parent.callee,"forwardRef"))}function Ar(e){return!!(e.parent&&e.parent.type===Q.CallExpression&&Cr(e.parent.callee,"memo"))}function on(e){if(e.type===Q.FunctionDeclaration||e.type===Q.FunctionExpression&&e.id)return e.id||void 0;if(e.type===Q.FunctionExpression||e.type===Q.ArrowFunctionExpression){if(e.parent.type===Q.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===Q.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===Q.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===Q.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function ws(e){let n=e.parent,r=!1;for(;n;){if(n.type===Q.FunctionDeclaration||n.type===Q.FunctionExpression||n.type===Q.ArrowFunctionExpression){let t=on(n);if(t&&t.type===Q.Identifier){if(xr(t.name)||Tt(t.name))return!r;r=!0}else{if(Ir(n)||Ar(n))return!r;if(n.parent.type===Q.CallExpression){let o=n.parent;As(o.callee)||(r=!0)}else n.parent.type===Q.JSXExpressionContainer||(r=!0)}}n=n.parent}return!1}function wr(e){return e.callee.type===Q.Identifier?e.callee.name:e.callee.type===Q.MemberExpression&&e.callee.property.type===Q.Identifier?e.callee.property.name:null}function Rs(e,n){if(!n.length)return!1;let r=e.parent;for(;r;){if(r.type===Q.FunctionDeclaration||r.type===Q.FunctionExpression||r.type===Q.ArrowFunctionExpression){let t=on(r);if(t&&t.type===Q.Identifier&&n.includes(t.name))return!0}else if(r.type===Q.CallExpression){let t=wr(r);if(t&&n.includes(t))return!0}r=r.parent}return!1}function Fs(e){return e.arguments.length>0&&!e.arguments.every(n=>n.type===Q.Identifier&&n.name==="undefined")}function vs(e,n){let r=!1,t=e.parent;for(;t;){if(t.type===Q.FunctionDeclaration||t.type===Q.FunctionExpression||t.type===Q.ArrowFunctionExpression){let o=on(t);if(o&&o.type===Q.Identifier){if(xr(o.name)||Tt(o.name)){r=!0;break}}else if(Ir(t)||Ar(t)){r=!0;break}}t=t.parent}return r?n.length===0?ws(e):!Rs(e,n):!1}var sn=H({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react{{message}}."},schema:[z(xs)],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[n]){let{disallowedFunctions:r}=n,t=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let s=wr(o);if(!s)return;let i=t.get(s);if(!i||i.allowUsingWithArgs&&Fs(o))return;let l=i.allowUseInside||[];vs(o,l)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:c=>{let a=i.hookAlternative;return a?o.callee.type===Q.Identifier?c.replaceText(o.callee,a):o.callee.type===Q.MemberExpression&&o.callee.property.type===Q.Identifier?c.replaceText(o.callee.property,a):null:null}}]:[]})}}}});import{AST_NODE_TYPES as ye,AST_TOKEN_TYPES as Rr,ESLintUtils as ks}from"@typescript-eslint/utils";import an from"zod/v4";var Ps=ks.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vr="prefer-single-line-if",Os=an.object({maxLineLength:an.number().optional(),maxNonSimpleConditionLength:an.number().optional()}),Ns=Ps({name:vr,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[z(Os)]},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode;return{IfStatement(t){if(t.consequent.type!==ye.BlockStatement||t.loc.start.line===t.loc.end.line||r.getCommentsInside(t.consequent).length>0||t.alternate||t.consequent.body.length!==1)return;let s=t.consequent.body[0];if(!s)return;if(s.type===ye.ReturnStatement){if(!Pr(s))return}else if(!(s.type===ye.ContinueStatement||s.type===ye.BreakStatement))return;if(t.test.type===ye.LogicalExpression||t.test.type===ye.ConditionalExpression)return;let i;if(n.maxNonSimpleConditionLength){let m=Fr(t.test);if(!m&&t.test.type===ye.UnaryExpression&&t.test.operator==="!"){let y=t.test.argument;Fr(y)&&(m=!0)}if(m&&(i=r.getText(t.test),i.length>n.maxNonSimpleConditionLength))return}i||(i=r.getText(t.test));let l=r.getText(s);if(i.includes(`
18
- `))return;let c=r.getTokenAfter(t);if(c&&c.type===Rr.Punctuator&&c.value==="}"){let m=r.getTokenAfter(c);if(m&&m.type===Rr.Keyword&&(m.value==="else"||m.value==="catch"))return}let a=Ds(r,t),u=`if (${i}) ${l}`;n.maxLineLength&&u.length+a.length>n.maxLineLength||e.report({node:t,messageId:"noSingleLineCurly",fix:m=>m.replaceText(t,u)})}}}});function Fr(e){return e.type===ye.CallExpression||e.type===ye.BinaryExpression||e.type===ye.MemberExpression&&kr(e)}function kr(e){return e.object.type===ye.MemberExpression?kr(e.object):e.object.type!==ye.Identifier}function Ds(e,n){return e.text.slice(n.range[0]-n.loc.start.column,n.range[0])}function Pr(e){if(!e.argument)return!0;let n=e.argument;return n.type===ye.ArrayExpression&&n.elements.length===0||n.type===ye.ObjectExpression&&n.properties.length===0||n.type===ye.Literal||n.type===ye.Identifier||n.type===ye.TemplateLiteral||n.type===ye.TaggedTemplateExpression?!0:n.type===ye.CallExpression?n.arguments.length===0:n.type===ye.UnaryExpression?Pr(n):!1}var ln={name:vr,rule:Ns};import{AST_NODE_TYPES as W,ESLintUtils as js}from"@typescript-eslint/utils";import{z as Or}from"zod/v4";var Ls=js.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lr="react-compiler-extra",Ms=Or.object({runOnlyWithEnableCompilerDirective:Or.boolean().optional()}),_s=/eslint +react-compiler\/react-compiler: +\["error/;function Mr(e){return e.type===W.Identifier?e.name.startsWith("use"):!1}function $s(e){return e.type===W.Identifier?e.name.startsWith("use"):e.type===W.MemberExpression&&e.property.type===W.Identifier?e.property.name.startsWith("use"):!1}function De(e){if(!e)return!1;switch(e.type){case W.JSXElement:case W.JSXFragment:return!0;case W.ConditionalExpression:return De(e.consequent)||De(e.alternate);case W.LogicalExpression:return e.operator==="&&"?De(e.right):e.operator==="||"?De(e.left)||De(e.right):!1;case W.CallExpression:if(e.callee.type===W.MemberExpression&&e.callee.object.type===W.Identifier&&e.callee.object.name==="React"&&e.callee.property.type===W.Identifier&&e.callee.property.name==="createElement")return!0;for(let n of e.arguments)if(n.type!==W.SpreadElement&&De(n))return!0;return!1;default:return!1}}function Us(e){let n=e.typeAnnotation;if(n.type===W.TSTypeReference){if(n.typeName.type===W.Identifier)return n.typeName.name==="FC";if(n.typeName.type===W.TSQualifiedName&&n.typeName.left.type===W.Identifier&&n.typeName.right.type===W.Identifier)return n.typeName.left.name==="React"&&n.typeName.right.name==="FC"}return!1}var zs=/^[A-Z][a-zA-Z0-9]*$/;function st(e){return zs.test(e)}function cn(e){return e.startsWith("use")&&e.length>3}function un(e,n,r,t){if(r&&Us(r))return n?st(n.name):e.type===W.FunctionDeclaration&&e.id?st(e.id.name):!0;if(n&&cn(n.name)||e.type===W.FunctionDeclaration&&e.id&&cn(e.id.name))return!0;if(t){let o=n?.name||e.type===W.FunctionDeclaration&&e.id?.name;if(o&&st(o)&&_r(e.body,t).containsJSX)return!0}return!1}function ot(e){if(e.body.type===W.BlockStatement){for(let n of e.body.body)if(n.type===W.ExpressionStatement&&n.expression.type===W.Literal&&typeof n.expression.value=="string"&&n.expression.value==="use memo")return!0}return!1}function _r(e,n){let r={containsJSX:!1,containsHookCalls:!1};return Pe(e,t=>{if(r.containsJSX&&r.containsHookCalls)return!0;switch(t.type){case W.JSXElement:case W.JSXFragment:r.containsJSX=!0;break;case W.CallExpression:Mr(t.callee)&&(r.containsHookCalls=!0),De(t)&&(r.containsJSX=!0);break;case W.ReturnStatement:t.argument&&De(t.argument)&&(r.containsJSX=!0);break;case W.VariableDeclarator:t.init&&De(t.init)&&(r.containsJSX=!0);break;case W.AssignmentExpression:De(t.right)&&(r.containsJSX=!0);break}},n),r}function Nr(e,n){let r=e.body,t=_r(r,n);return t.containsJSX||t.containsHookCalls}var Ws=/\bthis[.[]/;function Dr(e){return Ws.test(e)}function Vs(e,n){let r={containsJSX:!1,containsHookCalls:!1};return Pe(e,t=>{if(r.containsHookCalls||(t.type===W.FunctionDeclaration||t.type===W.FunctionExpression||t.type===W.ArrowFunctionExpression)&&t!==e)return!0;t.type===W.CallExpression&&$s(t.callee)&&(r.containsHookCalls=!0)},n),r}function jr(e){return st(e)||cn(e)}function pn(e,n,r,t){if(!Vs(e.body,n).containsHookCalls)return!1;let s=un(e,r,t,n);if(!s&&t){let i=r?.name||e.type===W.FunctionDeclaration&&e.id?.name;i&&st(i)&&(s=!0)}return!s}var Js=Ls({name:Lr,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually.",fcComponentShouldReturnJsx:'React components and hooks should create JSX elements, call other hooks or use the "use memo" directive for optimal React compiler detection.',addUseMemoDirective:'Add "use memo" directive to opt into React compiler memoization',functionCallingHooksMustBeComponent:'Functions calling hooks must be React components (PascalCase with FC type) or hooks (start with "use").',useMemoDirectiveNaming:'Functions using "use memo" directive must follow React naming conventions (PascalCase for components or start with "use" for hooks).'},hasSuggestions:!0,schema:[z(Ms)]},defaultOptions:[{}],create(e,[n]){let r=!1;if(n.runOnlyWithEnableCompilerDirective){for(let s of e.sourceCode.getAllComments())if(_s.test(s.value)){r=!0;break}if(!r)return{}}function t(s){for(let i of s.properties)if(i.type===W.Property&&i.method&&i.value.type===W.FunctionExpression){let l=e.sourceCode,c=l.getText(i.key),a=i.value,u=l.getText(a.body);if(Dr(u))e.report({node:i,messageId:"thisKeywordInMethod"});else{let m=a.params.map(C=>l.getText(C)).join(", "),y="";a.generator?y=`${c}: function* (${m}) ${u}`:y=`${c}: (${m}) => ${u}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:C=>C.replaceText(i,y)})}}}function o(s){for(let i of s.properties)if(i.type===W.Property&&i.value.type===W.ObjectExpression){for(let l of i.value.properties)if(l.type===W.Property&&l.method&&l.value.type===W.FunctionExpression){let a=e.sourceCode.getText(l.value.body);Dr(a)&&e.report({node:l,messageId:"thisKeywordInMethod"})}}}return{CallExpression(s){if(Mr(s.callee))for(let i of s.arguments){if(i.type===W.ObjectExpression&&(t(i),o(i)),i.type===W.ArrowFunctionExpression&&(i.body.type===W.ObjectExpression&&(t(i.body),o(i.body)),i.body.type===W.BlockStatement))for(let l of i.body.body)l.type===W.ReturnStatement&&l.argument?.type===W.ObjectExpression&&(t(l.argument),o(l.argument));if(i.type===W.FunctionExpression)for(let l of i.body.body)l.type===W.ReturnStatement&&l.argument?.type===W.ObjectExpression&&(t(l.argument),o(l.argument))}},VariableDeclarator(s){if(s.id.type===W.Identifier&&s.init&&(s.init.type===W.ArrowFunctionExpression||s.init.type===W.FunctionExpression)){let i=s.init,l=s.id,c=s.id.typeAnnotation;if(ot(i)&&!jr(l.name)){e.report({node:i,messageId:"useMemoDirectiveNaming"});return}if(pn(i,e.sourceCode,l,c)){e.report({node:i,messageId:"functionCallingHooksMustBeComponent"});return}if(un(i,l,c,e.sourceCode)){let a=Nr(i,e.sourceCode),u=ot(i);!a&&!u&&e.report({node:i,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(m){if(i.body.type===W.BlockStatement){let y=i.body.range[0]+1;return m.insertTextAfterRange([y,y],`
17
+ `)}return""}return{Program(){let c=[];for(let y of t.body)y.type===Re.ExpressionStatement&&y.expression.type===Re.CallExpression&&y.expression.callee.type===Re.Identifier&&y.expression.callee.name==="describe"&&y.expression.arguments.length===2&&c.push(y.expression);if(!i(c))return;let[a]=c;if(!a)return;let u=o(a);if(s(u))return;let f=t.body.find(y=>y.type===Re.ExpressionStatement&&y.expression===a);!f||f.type!==Re.ExpressionStatement||e.report({node:a,messageId:"unnecessaryDescribe",suggest:[{messageId:"removeDescribe",fix(y){let C=l(a);return C?y.replaceText(f,C):null}}]})}}}});import{AST_NODE_TYPES as St}from"@typescript-eslint/utils";import*as De from"zod/v4";var is=De.object({methods:De.union([De.array(De.string()),De.literal("array")])}),qt=X({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[U(is)]},defaultOptions:[{methods:"array"}],create(e,[n]){let r=n.methods,t=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(l){return Array.isArray(r)?r.includes(l):t.has(l)}function s(l){let{callee:c}=l;if(c.type===St.MemberExpression){let a=c.property;if(a.type===St.Identifier)return a.name}return null}function i(l,c){if(l.type!==St.Identifier||!l.typeAnnotation)return;let a=c.parent;if(a.type===St.CallExpression){let u=s(a);u&&o(u)&&a.arguments.indexOf(c)===0&&e.report({node:l.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(y){return l.typeAnnotation?y.remove(l.typeAnnotation):null}})}}return{ArrowFunctionExpression(l){for(let c of l.params)i(c,l)},FunctionExpression(l){for(let c of l.params)i(c,l)}}}});import{AST_NODE_TYPES as Ie}from"@typescript-eslint/utils";var Zt=X({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(n){if(n.id.type===Ie.ObjectPattern||!n.init||n.init.type!==Ie.ObjectExpression||n.id.type===Ie.Identifier&&n.id.typeAnnotation||n.parent.parent.type===Ie.ExportNamedDeclaration)return;let r=new Map;for(let i of n.init.properties)i.type===Ie.Property&&i.key.type===Ie.Identifier&&r.set(i.key.name,i);if(r.size===0||n.id.type!==Ie.Identifier)return;let t=os(n,e.sourceCode);if(t.length===0)return;let o=n.init.properties.some(i=>i.type!==Ie.Property?!1:i.value.type===Ie.FunctionExpression),s=new Set;for(let i of t){if(i.identifier.parent.type!==Ie.MemberExpression)return;let l=i.identifier.parent;if(l.object!==i.identifier)return;if(l.computed)if(l.property.type===Ie.Literal&&typeof l.property.value=="string")s.add(l.property.value);else return;else{if(l.property.type!==Ie.Identifier)return;s.add(l.property.name)}if(l.parent.type===Ie.CallExpression&&o)return}for(let[i,l]of r)s.has(i)||e.report({node:l,messageId:"unusedObjectProperty",data:{name:i}})}}}});function os(e,n){let r=n.getDeclaredVariables(e);if(r.length!==1)return[];let t=r[0];return t?t.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as te}from"@typescript-eslint/utils";import{z as gr}from"zod/v4";var ss=gr.object({ignoreArgsMatching:gr.string().optional()}),Gt=X({name:"no-unused-optional-args",meta:{type:"problem",docs:{description:"Detect unused optional function arguments in non-exported functions"},messages:{unusedOptionalArg:"Optional parameter '{{name}}' is never used",unusedOptionalProp:"Optional prop '{{name}}' is never provided"},schema:[U(ss)]},defaultOptions:[{}],create(e,[n]){let r=[];function t(i){return n.ignoreArgsMatching?new RegExp(n.ignoreArgsMatching).test(i):!1}function o(i){return i.type===te.ExportNamedDeclaration||i.type===te.ExportDefaultDeclaration||i.parent?.type===te.ExportNamedDeclaration||i.parent?.type===te.ExportDefaultDeclaration}function s(i){let l=[];for(let c=0;c<i.length;c++){let a=i[c];if(!a||a.type!==te.Identifier)continue;let u=a.name;if(!t(u)){if(a.optional&&a.typeAnnotation&&a.typeAnnotation.typeAnnotation.type===te.TSTypeLiteral){let f=a.typeAnnotation.typeAnnotation,y=[];for(let C of f.members)C.type===te.TSPropertySignature&&C.key.type===te.Identifier&&y.push({name:C.key.name,optional:C.optional===!0});y.some(C=>C.optional)?l.push({param:a,index:c,name:u,isObjectParam:!0,objectProps:y}):l.push({param:a,index:c,name:u,isObjectParam:!1})}else if(a.optional)l.push({param:a,index:c,name:u,isObjectParam:!1});else if(a.typeAnnotation&&a.typeAnnotation.typeAnnotation.type===te.TSTypeLiteral){let f=a.typeAnnotation.typeAnnotation,y=[];for(let C of f.members)C.type===te.TSPropertySignature&&C.key.type===te.Identifier&&y.push({name:C.key.name,optional:C.optional===!0});y.some(C=>C.optional)&&l.push({param:a,index:c,name:u,isObjectParam:!0,objectProps:y})}}}return l}return{FunctionDeclaration(i){if(o(i))return;let l=s(i.params);l.length!==0&&r.push({node:i,declarationNode:i,optionalParams:l})},VariableDeclarator(i){if(i.id.type!==te.Identifier||!i.init||i.init.type!==te.ArrowFunctionExpression&&i.init.type!==te.FunctionExpression||o(i.parent.parent))return;let c=[...s(i.init.params)];if(i.id.typeAnnotation&&i.id.typeAnnotation.typeAnnotation.type===te.TSTypeReference){let a=i.id.typeAnnotation.typeAnnotation;if(a.typeName.type===te.Identifier&&a.typeName.name==="FC"){let u=a.typeArguments;if(u&&u.params.length===1){let f=u.params[0];if(f&&f.type===te.TSTypeLiteral){let y=[];for(let C of f.members)C.type===te.TSPropertySignature&&C.key.type===te.Identifier&&y.push({name:C.key.name,optional:C.optional===!0});y.some(C=>C.optional)&&c.push({param:i.id,index:0,name:"props",isObjectParam:!0,objectProps:y})}}}}c.length!==0&&r.push({node:i.init,declarationNode:i,optionalParams:c})},"Program:exit"(){for(let i of r){let c=e.sourceCode.getDeclaredVariables(i.declarationNode)[0];if(!c)continue;let a=c.references.filter(y=>y.identifier!==c.identifiers[0]);if(a.length===0)continue;let u=!1;for(let y of a){let C=y.identifier.parent;if(C.type===te.CallExpression&&y.identifier.type===te.Identifier&&C.arguments.includes(y.identifier)){u=!0;break}if(C.type===te.ReturnStatement){u=!0;break}if(C.type===te.Property&&C.parent.type===te.ObjectExpression&&C.parent.parent.type===te.ReturnStatement){u=!0;break}if(C.type===te.JSXExpressionContainer){u=!0;break}}if(u)continue;let f=[];for(let y of a){let C=y.identifier.parent;if(C.type===te.CallExpression&&C.callee===y.identifier){let m=C.arguments.length,E=C.arguments.some(S=>S.type===te.SpreadElement);if(E){u=!0;break}let x={argCount:m,hasSpread:E};for(let S of i.optionalParams)if(S.isObjectParam&&S.index<m){let I=C.arguments[S.index];if(I?.type===te.ObjectExpression){let A={};for(let T of I.properties)T.type===te.Property&&T.key.type===te.Identifier&&(A[T.key.name]=!0);x.objectArgs||(x.objectArgs=[]),x.objectArgs[S.index]=A}else if(I){u=!0;break}}f.push(x)}else if(C.type===te.JSXOpeningElement&&C.name===y.identifier){let m=C.attributes.some(x=>x.type===te.JSXSpreadAttribute);if(m){u=!0;break}let E={argCount:1,hasSpread:m};for(let x of i.optionalParams)if(x.isObjectParam&&x.index===0){let S={};for(let I of C.attributes)I.type===te.JSXAttribute&&I.name.type===te.JSXIdentifier&&(S[I.name.name]=!0);E.objectArgs||(E.objectArgs=[]),E.objectArgs[0]=S}f.push(E)}}if(!(u||f.length===0))for(let y of i.optionalParams)if(y.isObjectParam&&y.objectProps)for(let C of y.objectProps){if(!C.optional)continue;let m=!1;for(let E of f)if(E.objectArgs&&E.objectArgs[y.index]){let x=E.objectArgs[y.index];if(x&&x[C.name]){m=!0;break}}m||e.report({node:y.param,messageId:"unusedOptionalProp",data:{name:C.name}})}else{let C=!1;for(let m of f)if(m.argCount>y.index){C=!0;break}C||e.report({node:y.param,messageId:"unusedOptionalArg",data:{name:y.name}})}}}}}});import{AST_NODE_TYPES as le,ESLintUtils as as}from"@typescript-eslint/utils";import{z as Be}from"zod/v4";var ls=Be.object({selectors:Be.array(Be.object({name:Be.string(),selectorProp:Be.string().optional(),selectorArgPos:Be.number().optional(),returnProp:Be.string().optional()}))}),ps=as.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sr="no-unused-selected-values",Kt={name:Sr,rule:ps({name:Sr,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[U(ls)]},defaultOptions:[{selectors:[]}],create(e,[n]){let{selectors:r=[]}=n,t=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let s=null;if(o.init?.type===le.CallExpression&&(s=o.init),!s)return;let i=us(s);if(!i)return;let l=t.get(i);if(!l)return;let c=cs(s,l.selectorArgPos??0,l.selectorProp);if(!c)return;let a=fs(c);if(!a)return;let u=Tr(a.properties,void 0);if(!u)return;if(o.id.type===le.ObjectPattern){let C=Tr(o.id.properties,l.returnProp);if(!C)return;for(let[m,E]of u)C.has(m)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:m}});return}if(o.id.type!==le.Identifier||l.returnProp)return;let f=ms(o,e.sourceCode);if(f.length===0)return;let y=new Set;for(let C of f){if(C.identifier.parent.type!==le.MemberExpression)return;let m=C.identifier.parent.property;if(m.type!==le.Identifier)return;y.add(m.name)}for(let[C,m]of u)y.has(C)||e.report({node:m,messageId:"unusedSelectedValue",data:{name:C}})}}}})};function cs(e,n,r){let t=e.arguments[n];if(!t)return null;if(t.type===le.ArrowFunctionExpression||t.type===le.FunctionExpression)return t;if(r&&t.type===le.ObjectExpression){let o=t.properties.find(i=>i.type===le.Property&&i.key.type===le.Identifier&&i.key.name===r);if(o?.type!==le.Property)return null;let s=o.value;if(s.type===le.ArrowFunctionExpression||s.type===le.FunctionExpression)return s}return null}function us(e){return e.callee.type===le.Identifier?e.callee.name:e.callee.type===le.MemberExpression&&e.callee.property.type===le.Identifier?e.callee.property.name:null}function fs(e){if(e.body.type===le.ObjectExpression)return e.body;if(e.body.type===le.BlockStatement){let n=e.body.body.filter(r=>r.type===le.ReturnStatement);return n.length!==1||!n[0]||n[0].argument?.type!==le.ObjectExpression?null:n[0].argument}return null}function Tr(e,n){let r=e;if(n){let o=e.find(s=>s.type===le.Property&&s.key.type===le.Identifier&&s.key.name===n);if(o?.type!==le.Property||o.value.type!==le.ObjectPattern)return null;r=o.value.properties}let t=new Map;for(let o of r){if(o.type!==le.Property||o.key.type!==le.Identifier)return null;t.set(o.key.name,o)}return t.size>0?t:null}function ms(e,n){let r=n.getDeclaredVariables(e);if(r.length!==1)return[];let t=r[0];return t?t.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as ae}from"@typescript-eslint/utils";var Qt=X({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(s=>s.type===ae.ImportDeclaration&&s.source.value==="t-state-form"))return{};let t=null,o=!1;return{CallExpression(s){if(o)return;if(!t){let l=ys(s);l&&(t=l);return}let i=ds(s,e.sourceCode);if(i){o=!0;for(let l of i)t.delete(l);if(t.size!==0)for(let[l,c]of t)e.report({node:c,messageId:"unusedField",data:{name:l}})}}}}});function ys(e){if(!(e.callee.type===ae.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==ae.ObjectExpression)return null;let t=Pt(r.properties,s=>s.type!==ae.Property||s.key.type!==ae.Identifier||s.key.name!=="initialConfig"?null:s.value.type===ae.ObjectExpression?s.value:s.value.type===ae.ArrowFunctionExpression||s.value.type===ae.FunctionExpression?gs(s.value):null);if(!t)return null;let o=new Map;for(let s of t.properties)s.type===ae.Property&&s.key.type===ae.Identifier&&o.set(s.key.name,s);return o}function ds(e,n){if(!(e.callee.type===ae.Identifier&&e.callee.name==="useFormState")||e.parent.type!==ae.VariableDeclarator||e.parent.id.type!==ae.ObjectPattern||!Pt(e.parent.id.properties,i=>i.type===ae.Property&&i.key.type===ae.Identifier&&i.key.name==="formFields"&&i))return null;let o=Gn(e.parent,"formFields",n),s=new Set;for(let{identifier:i}of o){if(i.type!==ae.Identifier||i.parent.type===ae.Property&&i.parent.parent.type===ae.ObjectExpression&&i.parent.parent.parent.type===ae.ReturnStatement||i.parent.type===ae.ReturnStatement)return null;if(i.parent.type===ae.MemberExpression){if(i.parent.object.type!==ae.Identifier||i.parent.property.type!==ae.Identifier)return null;s.add(i.parent.property.name)}}return s}function gs(e){if(e.body.type===ae.ObjectExpression)return e.body;if(e.body.type===ae.BlockStatement){let n=e.body.body.filter(r=>r.type===ae.ReturnStatement);return n.length!==1||!n[0]||n[0].argument?.type!==ae.ObjectExpression?null:n[0].argument}return null}import{AST_NODE_TYPES as ie,ESLintUtils as Ss}from"@typescript-eslint/utils";import{z as Tt}from"zod/v4";var Ts=Ss.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function hr(e){let n=[];for(let r of e.members)r.type===ie.TSPropertySignature&&r.key.type===ie.Identifier&&n.push([r.key.name,r]);return n}function Er(e,...n){for(let r of n)e.set(...r);return e}var hs=Tt.object({forceCheckOnFCPropTypesWithName:Tt.array(Tt.string()).optional(),alwaysCheckFunctionOptionTypes:Tt.boolean().optional()}),br="no-unused-type-props-in-args",en=null,Es=Ts({name:br,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[U(hs)],fixable:"code"},defaultOptions:[{alwaysCheckFunctionOptionTypes:!0}],create(e,[n]){let{forceCheckOnFCPropTypesWithName:r,alwaysCheckFunctionOptionTypes:t=!0}=n;r&&!en&&(en=r.map(c=>new RegExp(c)));function o(c,a,u,f,y=!0,C=!1){let m=u.name,E=e.sourceCode.getScope(a).references.find(T=>T.identifier.name===m)?.resolved,x=c&&en?.some(T=>T.test(m)),S=C&&t;if(!E||!x&&E.references.filter(T=>T.isTypeReference).length>1||!E.defs[0])return;let I=E.defs[0].node,A=I.parent?.type===ie.ExportNamedDeclaration;if(!(y&&A&&!S)){if(I.type===ie.TSTypeAliasDeclaration){s(c,a,f,I.typeAnnotation,!0,C);return}if(I.type===ie.TSInterfaceDeclaration){s(c,a,f,I.body,!0,C);return}}}function s(c,a,u,f,y,C=!1){if(f.type===ie.TSInterfaceBody){for(let m of f.body)m.type===ie.TSPropertySignature&&m.key.type===ie.Identifier&&u.set(m.key.name,m);return}if(f.type===ie.TSTypeLiteral){Er(u,...hr(f));return}if(f.type===ie.TSIntersectionType){for(let m of f.types)s(c,a,u,m,!0,C);return}y||f.type===ie.TSTypeReference&&f.typeName.type===ie.Identifier&&o(c,a,f.typeName,u,!0,C)}function i(c,a,u,f=!1){for(let y of u)if(y.type===ie.ObjectPattern&&y.typeAnnotation){let C=new Map;if(s(c,a,C,y.typeAnnotation.typeAnnotation,!1,f),C.size===0)continue;l(y,C)}else y.type===ie.AssignmentPattern&&y.left.type===ie.ObjectPattern&&i(c,a,[y.left],f)}function l(c,a){let u=[];if(c.properties.at(-1)?.type===ie.RestElement)return;for(let m of c.properties)m.type===ie.Property&&m.key.type===ie.Identifier&&u.push(m.key.name);let y=[],C=[];for(let[m,E]of a)u.includes(m)||(C.push(m),y.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:m}}));for(let[m,E]of y.entries())e.report({...E,fix:m===y.length-1?x=>{let S=c.properties.at(-1),I=C.join(", ");return S?S.type===ie.RestElement?null:x.insertTextAfter(S,`, ${I}`):x.insertTextBeforeRange([c.range[0]+1,c.range[1]],I)}:void 0})}return{VariableDeclaration(c){let a=c.declarations[0],u=new Map,f=a.id.type===ie.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===ie.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===ie.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(f){if(f.type===ie.TSTypeReference&&f.typeName.type===ie.Identifier)o(!0,c,f.typeName,u,!1);else if(f.type===ie.TSTypeLiteral)Er(u,...hr(f));else if(f.type===ie.TSIntersectionType)for(let y of f.types)y.type===ie.TSTypeReference&&y.typeName.type===ie.Identifier?o(!0,c,y.typeName,u,!1):s(!0,c,u,y,!0);if(u.size!==0&&a.init?.type===ie.ArrowFunctionExpression){let y=a.init.params[0];if(!y){e.report({node:a.init,messageId:"missingComponentParam"});return}y.type===ie.ObjectPattern&&l(y,u)}}},FunctionDeclaration(c){i(!1,c,c.params,t)},ArrowFunctionExpression(c){i(!1,c,c.params,t)}}}}),tn={name:br,rule:Es};import{AST_NODE_TYPES as Oe}from"@typescript-eslint/utils";var nn=X({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let n=new Set;function r(t){return t.callee.type===Oe.Identifier?n.has(t.callee.name):t.callee.type===Oe.MemberExpression&&t.callee.object.type===Oe.Identifier&&t.callee.property.type===Oe.Identifier?t.callee.property.name==="useRef":!1}return{ImportDeclaration(t){if(t.source.value==="react")for(let o of t.specifiers)o.type===Oe.ImportSpecifier&&o.imported.type===Oe.Identifier&&o.imported.name==="useRef"&&n.add(o.local.name)},VariableDeclarator(t){if(t.init&&t.init.type===Oe.CallExpression&&r(t.init)&&t.id.type===Oe.Identifier){let s=e.sourceCode.getScope(t).set.get(t.id.name);if(s){let i=!1;for(let l of s.references){let a=l.identifier.parent;if(a!==t&&!(a.type===Oe.JSXExpressionContainer&&a.parent.type===Oe.JSXAttribute&&a.parent.name.type===Oe.JSXIdentifier&&a.parent.name.name==="ref")){i=!0;break}}i||e.report({node:t.id,messageId:"refNotRead",data:{name:t.id.name}})}}}}}});import{AST_NODE_TYPES as rn,ESLintUtils as bs}from"@typescript-eslint/utils";var xs=bs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cr="prefer-named-functions",xr=new Map,Cs=xs({name:Cr,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[n]){let r=null;if(n.ignoreRegex){let t=xr.get(n.ignoreRegex);t?r=t:(r=new RegExp(n.ignoreRegex),xr.set(n.ignoreRegex,r))}return{VariableDeclarator(t){if(t.init&&t.init.type===rn.ArrowFunctionExpression&&t.id.type===rn.Identifier){let o=t.id.name;if(t.id.typeAnnotation||r&&r.test(o)||!n.disallowArrowFnWithImplicitReturns&&t.init.body.type!==rn.BlockStatement)return;let s=t.parent,i=t.init.params,l=t.init.body,c=t.init;e.report({node:t.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:n.ignoreRegex},suggest:[{messageId:"suggestion",fix:a=>a.replaceText(s,`${c.async?"async ":""}function ${o}(${i.map(u=>e.sourceCode.getText(u)).join(", ")||""}) ${e.sourceCode.getText(l)}`)}]})}}}}}),on={name:Cr,rule:Cs};import{AST_NODE_TYPES as Q}from"@typescript-eslint/utils";import{z as _e}from"zod/v4";var Is=_e.object({disallowedFunctions:_e.array(_e.object({name:_e.string(),allowUsingWithArgs:_e.boolean().optional(),hookAlternative:_e.string().optional(),message:_e.string().optional(),allowUseInside:_e.array(_e.string()).optional()}))}),As=/^use[A-Z]/,ws=/^[A-Z]/;function ht(e){return As.test(e)}function Ir(e){return ws.test(e)}function Rs(e){return e.type===Q.Identifier?ht(e.name):e.type===Q.MemberExpression&&e.property.type===Q.Identifier?ht(e.property.name):!1}function Ar(e,n){return e.type===Q.Identifier?e.name===n:e.type===Q.MemberExpression&&e.object.type===Q.Identifier&&e.property.type===Q.Identifier?e.object.name==="React"&&e.property.name===n:!1}function wr(e){return!!(e.parent&&e.parent.type===Q.CallExpression&&Ar(e.parent.callee,"forwardRef"))}function Rr(e){return!!(e.parent&&e.parent.type===Q.CallExpression&&Ar(e.parent.callee,"memo"))}function sn(e){if(e.type===Q.FunctionDeclaration||e.type===Q.FunctionExpression&&e.id)return e.id||void 0;if(e.type===Q.FunctionExpression||e.type===Q.ArrowFunctionExpression){if(e.parent.type===Q.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===Q.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===Q.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===Q.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Fs(e){let n=e.parent,r=!1;for(;n;){if(n.type===Q.FunctionDeclaration||n.type===Q.FunctionExpression||n.type===Q.ArrowFunctionExpression){let t=sn(n);if(t&&t.type===Q.Identifier){if(Ir(t.name)||ht(t.name))return!r;r=!0}else{if(wr(n)||Rr(n))return!r;if(n.parent.type===Q.CallExpression){let o=n.parent;Rs(o.callee)||(r=!0)}else n.parent.type===Q.JSXExpressionContainer||(r=!0)}}n=n.parent}return!1}function Fr(e){return e.callee.type===Q.Identifier?e.callee.name:e.callee.type===Q.MemberExpression&&e.callee.property.type===Q.Identifier?e.callee.property.name:null}function vs(e,n){if(!n.length)return!1;let r=e.parent;for(;r;){if(r.type===Q.FunctionDeclaration||r.type===Q.FunctionExpression||r.type===Q.ArrowFunctionExpression){let t=sn(r);if(t&&t.type===Q.Identifier&&n.includes(t.name))return!0}else if(r.type===Q.CallExpression){let t=Fr(r);if(t&&n.includes(t))return!0}r=r.parent}return!1}function ks(e){return e.arguments.length>0&&!e.arguments.every(n=>n.type===Q.Identifier&&n.name==="undefined")}function Ps(e,n){let r=!1,t=e.parent;for(;t;){if(t.type===Q.FunctionDeclaration||t.type===Q.FunctionExpression||t.type===Q.ArrowFunctionExpression){let o=sn(t);if(o&&o.type===Q.Identifier){if(Ir(o.name)||ht(o.name)){r=!0;break}}else if(wr(t)||Rr(t)){r=!0;break}}t=t.parent}return r?n.length===0?Fs(e):!vs(e,n):!1}var an=X({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react{{message}}."},schema:[U(Is)],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[n]){let{disallowedFunctions:r}=n,t=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let s=Fr(o);if(!s)return;let i=t.get(s);if(!i||i.allowUsingWithArgs&&ks(o))return;let l=i.allowUseInside||[];Ps(o,l)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:c=>{let a=i.hookAlternative;return a?o.callee.type===Q.Identifier?c.replaceText(o.callee,a):o.callee.type===Q.MemberExpression&&o.callee.property.type===Q.Identifier?c.replaceText(o.callee.property,a):null:null}}]:[]})}}}});import{AST_NODE_TYPES as ye,AST_TOKEN_TYPES as vr,ESLintUtils as Os}from"@typescript-eslint/utils";import ln from"zod/v4";var Ns=Os.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pr="prefer-single-line-if",Ds=ln.object({maxLineLength:ln.number().optional(),maxNonSimpleConditionLength:ln.number().optional()}),js=Ns({name:Pr,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[U(Ds)]},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode;return{IfStatement(t){if(t.consequent.type!==ye.BlockStatement||t.loc.start.line===t.loc.end.line||r.getCommentsInside(t.consequent).length>0||t.alternate||t.consequent.body.length!==1)return;let s=t.consequent.body[0];if(!s)return;if(s.type===ye.ReturnStatement){if(!Nr(s))return}else if(!(s.type===ye.ContinueStatement||s.type===ye.BreakStatement))return;if(t.test.type===ye.LogicalExpression||t.test.type===ye.ConditionalExpression)return;let i;if(n.maxNonSimpleConditionLength){let f=kr(t.test);if(!f&&t.test.type===ye.UnaryExpression&&t.test.operator==="!"){let y=t.test.argument;kr(y)&&(f=!0)}if(f&&(i=r.getText(t.test),i.length>n.maxNonSimpleConditionLength))return}i||(i=r.getText(t.test));let l=r.getText(s);if(i.includes(`
18
+ `))return;let c=r.getTokenAfter(t);if(c&&c.type===vr.Punctuator&&c.value==="}"){let f=r.getTokenAfter(c);if(f&&f.type===vr.Keyword&&(f.value==="else"||f.value==="catch"))return}let a=Ls(r,t),u=`if (${i}) ${l}`;n.maxLineLength&&u.length+a.length>n.maxLineLength||e.report({node:t,messageId:"noSingleLineCurly",fix:f=>f.replaceText(t,u)})}}}});function kr(e){return e.type===ye.CallExpression||e.type===ye.BinaryExpression||e.type===ye.MemberExpression&&Or(e)}function Or(e){return e.object.type===ye.MemberExpression?Or(e.object):e.object.type!==ye.Identifier}function Ls(e,n){return e.text.slice(n.range[0]-n.loc.start.column,n.range[0])}function Nr(e){if(!e.argument)return!0;let n=e.argument;return n.type===ye.ArrayExpression&&n.elements.length===0||n.type===ye.ObjectExpression&&n.properties.length===0||n.type===ye.Literal||n.type===ye.Identifier||n.type===ye.TemplateLiteral||n.type===ye.TaggedTemplateExpression?!0:n.type===ye.CallExpression?n.arguments.length===0:n.type===ye.UnaryExpression?Nr(n):!1}var pn={name:Pr,rule:js};import{AST_NODE_TYPES as W,ESLintUtils as Ms}from"@typescript-eslint/utils";import{z as Dr}from"zod/v4";var _s=Ms.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_r="react-compiler-extra",$s=Dr.object({runOnlyWithEnableCompilerDirective:Dr.boolean().optional()}),Us=/eslint +react-compiler\/react-compiler: +\["error/;function $r(e){return e.type===W.Identifier?e.name.startsWith("use"):!1}function zs(e){return e.type===W.Identifier?e.name.startsWith("use"):e.type===W.MemberExpression&&e.property.type===W.Identifier?e.property.name.startsWith("use"):!1}function je(e){if(!e)return!1;switch(e.type){case W.JSXElement:case W.JSXFragment:return!0;case W.ConditionalExpression:return je(e.consequent)||je(e.alternate);case W.LogicalExpression:return e.operator==="&&"?je(e.right):e.operator==="||"?je(e.left)||je(e.right):!1;case W.CallExpression:if(e.callee.type===W.MemberExpression&&e.callee.object.type===W.Identifier&&e.callee.object.name==="React"&&e.callee.property.type===W.Identifier&&e.callee.property.name==="createElement")return!0;for(let n of e.arguments)if(n.type!==W.SpreadElement&&je(n))return!0;return!1;default:return!1}}function Ws(e){let n=e.typeAnnotation;if(n.type===W.TSTypeReference){if(n.typeName.type===W.Identifier)return n.typeName.name==="FC";if(n.typeName.type===W.TSQualifiedName&&n.typeName.left.type===W.Identifier&&n.typeName.right.type===W.Identifier)return n.typeName.left.name==="React"&&n.typeName.right.name==="FC"}return!1}var Js=/^[A-Z][a-zA-Z0-9]*$/;function at(e){return Js.test(e)}function un(e){return e.startsWith("use")&&e.length>3}function fn(e,n,r,t){if(r&&Ws(r))return n?at(n.name):e.type===W.FunctionDeclaration&&e.id?at(e.id.name):!0;if(n&&un(n.name)||e.type===W.FunctionDeclaration&&e.id&&un(e.id.name))return!0;if(t){let o=n?.name||e.type===W.FunctionDeclaration&&e.id?.name;if(o&&at(o)&&Ur(e.body,t).containsJSX)return!0}return!1}function st(e){if(e.body.type===W.BlockStatement){for(let n of e.body.body)if(n.type===W.ExpressionStatement&&n.expression.type===W.Literal&&typeof n.expression.value=="string"&&n.expression.value==="use memo")return!0}return!1}function Ur(e,n){let r={containsJSX:!1,containsHookCalls:!1};return Pe(e,t=>{if(r.containsJSX&&r.containsHookCalls)return!0;switch(t.type){case W.JSXElement:case W.JSXFragment:r.containsJSX=!0;break;case W.CallExpression:$r(t.callee)&&(r.containsHookCalls=!0),je(t)&&(r.containsJSX=!0);break;case W.ReturnStatement:t.argument&&je(t.argument)&&(r.containsJSX=!0);break;case W.VariableDeclarator:t.init&&je(t.init)&&(r.containsJSX=!0);break;case W.AssignmentExpression:je(t.right)&&(r.containsJSX=!0);break}},n),r}function jr(e,n){let r=e.body,t=Ur(r,n);return t.containsJSX||t.containsHookCalls}var Vs=/\bthis[.[]/;function Lr(e){return Vs.test(e)}function Xs(e,n){let r={containsJSX:!1,containsHookCalls:!1};return Pe(e,t=>{if(r.containsHookCalls||(t.type===W.FunctionDeclaration||t.type===W.FunctionExpression||t.type===W.ArrowFunctionExpression)&&t!==e)return!0;t.type===W.CallExpression&&zs(t.callee)&&(r.containsHookCalls=!0)},n),r}function Mr(e){return at(e)||un(e)}function cn(e,n,r,t){if(!Xs(e.body,n).containsHookCalls)return!1;let s=fn(e,r,t,n);if(!s&&t){let i=r?.name||e.type===W.FunctionDeclaration&&e.id?.name;i&&at(i)&&(s=!0)}return!s}var Bs=_s({name:_r,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually.",fcComponentShouldReturnJsx:'React components and hooks should create JSX elements, call other hooks or use the "use memo" directive for optimal React compiler detection.',addUseMemoDirective:'Add "use memo" directive to opt into React compiler memoization',functionCallingHooksMustBeComponent:'Functions calling hooks must be React components (PascalCase with FC type) or hooks (start with "use").',useMemoDirectiveNaming:'Functions using "use memo" directive must follow React naming conventions (PascalCase for components or start with "use" for hooks).'},hasSuggestions:!0,schema:[U($s)]},defaultOptions:[{}],create(e,[n]){let r=!1;if(n.runOnlyWithEnableCompilerDirective){for(let s of e.sourceCode.getAllComments())if(Us.test(s.value)){r=!0;break}if(!r)return{}}function t(s){for(let i of s.properties)if(i.type===W.Property&&i.method&&i.value.type===W.FunctionExpression){let l=e.sourceCode,c=l.getText(i.key),a=i.value,u=l.getText(a.body);if(Lr(u))e.report({node:i,messageId:"thisKeywordInMethod"});else{let f=a.params.map(C=>l.getText(C)).join(", "),y="";a.generator?y=`${c}: function* (${f}) ${u}`:y=`${c}: (${f}) => ${u}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:C=>C.replaceText(i,y)})}}}function o(s){for(let i of s.properties)if(i.type===W.Property&&i.value.type===W.ObjectExpression){for(let l of i.value.properties)if(l.type===W.Property&&l.method&&l.value.type===W.FunctionExpression){let a=e.sourceCode.getText(l.value.body);Lr(a)&&e.report({node:l,messageId:"thisKeywordInMethod"})}}}return{CallExpression(s){if($r(s.callee))for(let i of s.arguments){if(i.type===W.ObjectExpression&&(t(i),o(i)),i.type===W.ArrowFunctionExpression&&(i.body.type===W.ObjectExpression&&(t(i.body),o(i.body)),i.body.type===W.BlockStatement))for(let l of i.body.body)l.type===W.ReturnStatement&&l.argument?.type===W.ObjectExpression&&(t(l.argument),o(l.argument));if(i.type===W.FunctionExpression)for(let l of i.body.body)l.type===W.ReturnStatement&&l.argument?.type===W.ObjectExpression&&(t(l.argument),o(l.argument))}},VariableDeclarator(s){if(s.id.type===W.Identifier&&s.init&&(s.init.type===W.ArrowFunctionExpression||s.init.type===W.FunctionExpression)){let i=s.init,l=s.id,c=s.id.typeAnnotation;if(st(i)&&!Mr(l.name)){e.report({node:i,messageId:"useMemoDirectiveNaming"});return}if(cn(i,e.sourceCode,l,c)){e.report({node:i,messageId:"functionCallingHooksMustBeComponent"});return}if(fn(i,l,c,e.sourceCode)){let a=jr(i,e.sourceCode),u=st(i);!a&&!u&&e.report({node:i,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(f){if(i.body.type===W.BlockStatement){let y=i.body.range[0]+1;return f.insertTextAfterRange([y,y],`
19
19
  "use memo"
20
- `)}return null}}]})}}},FunctionDeclaration(s){if(s.id&&ot(s)&&!jr(s.id.name)){e.report({node:s,messageId:"useMemoDirectiveNaming"});return}if(pn(s,e.sourceCode)){e.report({node:s,messageId:"functionCallingHooksMustBeComponent"});return}if(un(s,void 0,void 0,e.sourceCode)){let i=Nr(s,e.sourceCode),l=ot(s);!i&&!l&&e.report({node:s,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(c){let a=s.body.range[0]+1;return c.insertTextAfterRange([a,a],`
20
+ `)}return null}}]})}}},FunctionDeclaration(s){if(s.id&&st(s)&&!Mr(s.id.name)){e.report({node:s,messageId:"useMemoDirectiveNaming"});return}if(cn(s,e.sourceCode)){e.report({node:s,messageId:"functionCallingHooksMustBeComponent"});return}if(fn(s,void 0,void 0,e.sourceCode)){let i=jr(s,e.sourceCode),l=st(s);!i&&!l&&e.report({node:s,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(c){let a=s.body.range[0]+1;return c.insertTextAfterRange([a,a],`
21
21
  "use memo"
22
- `)}}]})}},FunctionExpression(s){if(ot(s)){e.report({node:s,messageId:"useMemoDirectiveNaming"});return}pn(s,e.sourceCode)&&e.report({node:s,messageId:"functionCallingHooksMustBeComponent"})}}}}),fn={name:Lr,rule:Js};import{AST_NODE_TYPES as Fe,ESLintUtils as Xs}from"@typescript-eslint/utils";import{z as je}from"zod/v4";var Bs=Xs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$r="react-compiler-migration",Hs=je.object({disallowHooks:je.array(je.object({name:je.string(),replacement:je.string()})).optional(),disallowMethods:je.array(je.object({name:je.string(),replacement:je.string().optional(),requireTrueProp:je.string().optional()})).optional()}),Ys=/eslint +react-compiler\/react-compiler: +\["error/;function qs(e){return e.type===Fe.Identifier?e.name.startsWith("use"):e.type===Fe.MemberExpression&&e.property.type===Fe.Identifier?e.property.name.startsWith("use"):!1}var Zs=Bs({name:$r,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[z(Hs)]},defaultOptions:[{disallowHooks:[],disallowMethods:[]}],create(e,[n]){let r=!1;for(let t of e.sourceCode.getAllComments())if(Ys.test(t.value)){r=!0;break}return r?{CallExpression(t){if(n.disallowHooks?.length){let o=null,s=null;if(t.callee.type===Fe.Identifier?(o=t.callee.name,s=t.callee):t.callee.type===Fe.MemberExpression&&t.callee.property.type===Fe.Identifier&&(o=t.callee.property.name,s=t.callee.property),o){let i=n.disallowHooks.find(l=>l.name===o);i&&s&&e.report({node:t,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(s,i.replacement)}]})}}if(n.disallowMethods?.length&&qs(t.callee)){for(let o of t.arguments)if(o.type===Fe.ObjectExpression){for(let s of o.properties)if(s.type===Fe.Property&&s.key.type===Fe.Identifier){let i=s.key.name,l=n.disallowMethods.find(c=>c.name===i);if(l){if(l.requireTrueProp){let c=l.requireTrueProp,a=!1;for(let u of o.properties)if(u.type===Fe.Property&&u.key.type===Fe.Identifier&&u.key.name===c&&u.value.type===Fe.Literal&&u.value.value===!0){a=!0;break}if(!a){e.report({node:s,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:l.name,requireTrueProp:c}});continue}}l.replacement&&e.report({node:s,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:l.name,replacement:l.replacement},suggest:[{messageId:"replace",data:{replacement:l.replacement},fix:c=>l.replacement?c.replaceText(s.key,l.replacement):null}]})}}}}}}:{}}}),mn={name:$r,rule:Zs};import{AST_NODE_TYPES as $}from"@typescript-eslint/utils";import{z as Ur}from"zod";var Gs=Ur.object({runOnlyWithEnableCompilerDirective:Ur.boolean().optional()}),Ks=/eslint +react-compiler\/react-compiler: +\["error/,Qs=/^\d+$/,ea=/[\s_-]+/,ta=/[a-z][A-Z]/,na=/^(.+?)([A-Z][a-z]+s?)$/,ra=/^[a-z][a-zA-Z]*$/;function zr(e,n){let r=[];if(e.type===$.JSXElement){for(let t of e.openingElement.attributes)if(t.type===$.JSXAttribute&&t.name.type===$.JSXIdentifier&&t.value?.type===$.JSXExpressionContainer&&t.value.expression.type!==$.JSXEmptyExpression){let o=t.name.name,s=t.value.expression,i=!1;Pe(s,l=>{switch(l.type){case $.ObjectExpression:case $.ArrowFunctionExpression:case $.FunctionExpression:case $.ArrayExpression:return i=!0,!0}return!1},n),i&&r.push(o)}}return{hasUnstable:r.length>0,problematicProps:r}}function ia(e){if(e.body.type===$.JSXElement||e.body.type===$.JSXFragment)return!0;if(e.body.type===$.BlockStatement){for(let n of e.body.body)if(n.type===$.ReturnStatement&&n.argument&&(n.argument.type===$.JSXElement||n.argument.type===$.JSXFragment))return!0}return!1}function oa(e,n){let r=e.callee;if(r.type===$.MemberExpression){let t=r.object;if(t.type===$.Identifier){let o=t.name,s=sa(o);if(s!==o)return dn(s)}}if(n.length>0){let t=n[0];if(t&&t.type===$.Identifier)return dn(t.name)}return"ListItem"}function sa(e){let r={people:"person",children:"child",feet:"foot",teeth:"tooth",mice:"mouse",men:"man",women:"woman"}[e.toLowerCase()];if(r)return r;if(e.match(ta)){let t=e.match(na);if(t){let o=t[1],s=t[2];if(!o||!s)return yn(e);let i=yn(s);if(i!==s)return o+i}}return yn(e)}function yn(e){return e.endsWith("ies")?`${e.slice(0,-3)}y`:e.endsWith("es")&&e.length>3?e.slice(0,-2):e.endsWith("s")&&e.length>1?e.slice(0,-1):e}function dn(e){return e.match(ra)?e.charAt(0).toUpperCase()+e.slice(1):e.split(ea).map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join("")}function Wr(e,n,r){let t=[],o=new Set,s=new Set(["console","document","window","Math","Object","Array","String","Number","Boolean","undefined","null"]);Pe(e,i=>{if(i.type===$.Identifier&&!n.includes(i.name)&&!s.has(i.name)&&!Qs.test(i.name)){let l=i.parent;if(l.type===$.Property&&l.key===i||l.type===$.MemberExpression&&l.property===i&&!l.computed||l.type===$.JSXOpeningElement||l.type===$.JSXClosingElement||l.type===$.JSXAttribute&&l.name.type===$.JSXIdentifier&&l.name.name===i.name)return!1;o.add(i.name)}return!1},r);for(let i of o)n.includes(i)||t.push({name:i,type:"unknown"});return t}function Vr(e,n,r,t,o){let i=[...r.map(m=>m.type===$.Identifier?m.name:"item").map((m,y)=>({name:m,type:y===0?`${e}Type`:y===1?"number":"unknown"})),...t],l=i.map(m=>{let y=m.type;return m.name.includes("on")&&y==="any"&&(y="unknown"),` ${m.name}: ${y};`}).join(`
23
- `),c=i.map(m=>m.name).join(", "),a=o.getText(n),u=`${e}Props`;return`type ${u} = {
22
+ `)}}]})}},FunctionExpression(s){if(st(s)){e.report({node:s,messageId:"useMemoDirectiveNaming"});return}cn(s,e.sourceCode)&&e.report({node:s,messageId:"functionCallingHooksMustBeComponent"})}}}}),mn={name:_r,rule:Bs};import{AST_NODE_TYPES as Fe,ESLintUtils as Hs}from"@typescript-eslint/utils";import{z as Ne}from"zod/v4";var Ys=Hs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zr="react-compiler-migration",qs=Ne.object({disallowHooks:Ne.array(Ne.object({name:Ne.string(),replacement:Ne.string()})).optional(),disallowMethods:Ne.array(Ne.object({name:Ne.string(),replacement:Ne.string().optional(),requireTrueProp:Ne.string().optional()})).optional(),runOnlyWithEnableCompilerDirective:Ne.boolean()}),Zs=/eslint +react-compiler\/react-compiler: +\["error/;function Gs(e){return e.type===Fe.Identifier?e.name.startsWith("use"):e.type===Fe.MemberExpression&&e.property.type===Fe.Identifier?e.property.name.startsWith("use"):!1}var Ks=Ys({name:zr,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[U(qs)]},defaultOptions:[{disallowHooks:[],disallowMethods:[],runOnlyWithEnableCompilerDirective:!1}],create(e,[n]){let r=!0;if(n.runOnlyWithEnableCompilerDirective){r=!1;for(let t of e.sourceCode.getAllComments())if(Zs.test(t.value)){r=!0;break}}return r?{CallExpression(t){if(n.disallowHooks?.length){let o=null,s=null;if(t.callee.type===Fe.Identifier?(o=t.callee.name,s=t.callee):t.callee.type===Fe.MemberExpression&&t.callee.property.type===Fe.Identifier&&(o=t.callee.property.name,s=t.callee.property),o){let i=n.disallowHooks.find(l=>l.name===o);i&&s&&e.report({node:t,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(s,i.replacement)}]})}}if(n.disallowMethods?.length&&Gs(t.callee)){for(let o of t.arguments)if(o.type===Fe.ObjectExpression){for(let s of o.properties)if(s.type===Fe.Property&&s.key.type===Fe.Identifier){let i=s.key.name,l=n.disallowMethods.find(c=>c.name===i);if(l){if(l.requireTrueProp){let c=l.requireTrueProp,a=!1;for(let u of o.properties)if(u.type===Fe.Property&&u.key.type===Fe.Identifier&&u.key.name===c&&u.value.type===Fe.Literal&&u.value.value===!0){a=!0;break}if(!a){e.report({node:s,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:l.name,requireTrueProp:c}});continue}}l.replacement&&e.report({node:s,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:l.name,replacement:l.replacement},suggest:[{messageId:"replace",data:{replacement:l.replacement},fix:c=>l.replacement?c.replaceText(s.key,l.replacement):null}]})}}}}}}:{}}}),yn={name:zr,rule:Ks};import{AST_NODE_TYPES as $}from"@typescript-eslint/utils";import{z as Wr}from"zod";var Qs=Wr.object({runOnlyWithEnableCompilerDirective:Wr.boolean().optional()}),ea=/eslint +react-compiler\/react-compiler: +\["error/,ta=/^\d+$/,na=/[\s_-]+/,ra=/[a-z][A-Z]/,ia=/^(.+?)([A-Z][a-z]+s?)$/,oa=/^[a-z][a-zA-Z]*$/;function Jr(e,n){let r=[];if(e.type===$.JSXElement){for(let t of e.openingElement.attributes)if(t.type===$.JSXAttribute&&t.name.type===$.JSXIdentifier&&t.value?.type===$.JSXExpressionContainer&&t.value.expression.type!==$.JSXEmptyExpression){let o=t.name.name,s=t.value.expression,i=!1;Pe(s,l=>{switch(l.type){case $.ObjectExpression:case $.ArrowFunctionExpression:case $.FunctionExpression:case $.ArrayExpression:return i=!0,!0}return!1},n),i&&r.push(o)}}return{hasUnstable:r.length>0,problematicProps:r}}function sa(e){if(e.body.type===$.JSXElement||e.body.type===$.JSXFragment)return!0;if(e.body.type===$.BlockStatement){for(let n of e.body.body)if(n.type===$.ReturnStatement&&n.argument&&(n.argument.type===$.JSXElement||n.argument.type===$.JSXFragment))return!0}return!1}function aa(e,n){let r=e.callee;if(r.type===$.MemberExpression){let t=r.object;if(t.type===$.Identifier){let o=t.name,s=la(o);if(s!==o)return gn(s)}}if(n.length>0){let t=n[0];if(t&&t.type===$.Identifier)return gn(t.name)}return"ListItem"}function la(e){let r={people:"person",children:"child",feet:"foot",teeth:"tooth",mice:"mouse",men:"man",women:"woman"}[e.toLowerCase()];if(r)return r;if(e.match(ra)){let t=e.match(ia);if(t){let o=t[1],s=t[2];if(!o||!s)return dn(e);let i=dn(s);if(i!==s)return o+i}}return dn(e)}function dn(e){return e.endsWith("ies")?`${e.slice(0,-3)}y`:e.endsWith("es")&&e.length>3?e.slice(0,-2):e.endsWith("s")&&e.length>1?e.slice(0,-1):e}function gn(e){return e.match(oa)?e.charAt(0).toUpperCase()+e.slice(1):e.split(na).map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join("")}function Vr(e,n,r){let t=[],o=new Set,s=new Set(["console","document","window","Math","Object","Array","String","Number","Boolean","undefined","null"]);Pe(e,i=>{if(i.type===$.Identifier&&!n.includes(i.name)&&!s.has(i.name)&&!ta.test(i.name)){let l=i.parent;if(l.type===$.Property&&l.key===i||l.type===$.MemberExpression&&l.property===i&&!l.computed||l.type===$.JSXOpeningElement||l.type===$.JSXClosingElement||l.type===$.JSXAttribute&&l.name.type===$.JSXIdentifier&&l.name.name===i.name)return!1;o.add(i.name)}return!1},r);for(let i of o)n.includes(i)||t.push({name:i,type:"unknown"});return t}function Xr(e,n,r,t,o){let i=[...r.map(f=>f.type===$.Identifier?f.name:"item").map((f,y)=>({name:f,type:y===0?`${e}Type`:y===1?"number":"unknown"})),...t],l=i.map(f=>{let y=f.type;return f.name.includes("on")&&y==="any"&&(y="unknown"),` ${f.name}: ${y};`}).join(`
23
+ `),c=i.map(f=>f.name).join(", "),a=o.getText(n),u=`${e}Props`;return`type ${u} = {
24
24
  ${l}
25
25
  };
26
26
 
@@ -28,28 +28,28 @@ const ${e}: FC<${u}> = ({ ${c} }) => {
28
28
  return (
29
29
  ${a}
30
30
  );
31
- };`}function aa(e,n,r,t){let o=n.map(i=>i.type===$.Identifier?i.name:"item"),s=[t?`key={${t}}`:`key={${o[0]}.id}`,...o.map(i=>`${i}={${i}}`),...r.map(i=>`${i.name}={${i.name}}`)].filter(Boolean);return`<${e} ${s.join(" ")} />`}function la(e){if(e.type===$.JSXElement&&e.openingElement.name.type===$.JSXIdentifier){let n=e.openingElement.name.name;if(n!=="div"&&n!=="span")return dn(n)}return"ListItem"}function pa(e,n,r){let t=[r?`key={${r}}`:"",...n.map(o=>`${o.name}={${o.name}}`)].filter(Boolean);return`<${e}${t.length>0?` ${t.join(" ")}`:""} />`}function Jr(e,n){for(let r of e.openingElement.attributes)if(r.type===$.JSXAttribute&&r.name.type===$.JSXIdentifier&&r.name.name==="key"&&r.value&&r.value.type===$.JSXExpressionContainer&&r.value.expression.type!==$.JSXEmptyExpression)return n.getText(r.value.expression);return null}var gn=H({name:"react-optimized-collections",meta:{type:"suggestion",docs:{description:"Detect unstable values in map renders that prevent React Compiler optimization"},messages:{unstableValueInMap:"Unstable values in {{problematicProps}} prevent React Compiler from optimizing individual list items. Extract the problematic props to outside the loop or extract the item to a separate component.",extractComponent:"Extract to {{componentName}} component"},schema:[z(Gs)],hasSuggestions:!0},defaultOptions:[{runOnlyWithEnableCompilerDirective:!1}],create(e,[n]){let{sourceCode:r}=e;if(n.runOnlyWithEnableCompilerDirective){let t=!1;for(let o of r.getAllComments())if(Ks.test(o.value)){t=!0;break}if(!t)return{}}return{CallExpression(t){t.callee.type===$.MemberExpression&&t.callee.property.type===$.Identifier&&(t.callee.property.name==="map"||t.callee.property.name==="push")&&(t.callee.property.name==="map"?ca(t,r,e):ua(t,r,e))}}}});function ca(e,n,r){let t=e.arguments[0];if(!t||t.type!==$.ArrowFunctionExpression&&t.type!==$.FunctionExpression||!ia(t))return;let o=null;if(t.body.type===$.JSXElement||t.body.type===$.JSXFragment?o=t.body:t.body.type===$.BlockStatement&&t.body.body[0]?.type===$.ReturnStatement&&t.body.body[0].argument&&(t.body.body[0].argument.type===$.JSXElement||t.body.body[0].argument.type===$.JSXFragment)&&(o=t.body.body[0].argument),!o)return;let s=zr(o,n);if(!s.hasUnstable)return;let i=oa(e,t.params),l=t.params.map(m=>m.type===$.Identifier?m.name:"item"),c=Wr(o,l,n),a=o.type===$.JSXElement?Jr(o,n):null,u=s.problematicProps.length===1?`prop "${s.problematicProps[0]}"`:`props "${s.problematicProps.join('", "')}"`;r.report({node:o,messageId:"unstableValueInMap",data:{problematicProps:u},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:m=>{let y=Vr(i,o,t.params,c,n),C=aa(i,t.params,c,a),f=e;for(;f.parent.type!==$.Program&&!(f.type===$.FunctionDeclaration||f.type===$.VariableDeclarator&&f.init&&(f.init.type===$.ArrowFunctionExpression||f.init.type===$.FunctionExpression));)f=f.parent;let E=[];return E.push(m.insertTextAfter(f,`
31
+ };`}function pa(e,n,r,t){let o=n.map(i=>i.type===$.Identifier?i.name:"item"),s=[t?`key={${t}}`:`key={${o[0]}.id}`,...o.map(i=>`${i}={${i}}`),...r.map(i=>`${i.name}={${i.name}}`)].filter(Boolean);return`<${e} ${s.join(" ")} />`}function ca(e){if(e.type===$.JSXElement&&e.openingElement.name.type===$.JSXIdentifier){let n=e.openingElement.name.name;if(n!=="div"&&n!=="span")return gn(n)}return"ListItem"}function ua(e,n,r){let t=[r?`key={${r}}`:"",...n.map(o=>`${o.name}={${o.name}}`)].filter(Boolean);return`<${e}${t.length>0?` ${t.join(" ")}`:""} />`}function Br(e,n){for(let r of e.openingElement.attributes)if(r.type===$.JSXAttribute&&r.name.type===$.JSXIdentifier&&r.name.name==="key"&&r.value&&r.value.type===$.JSXExpressionContainer&&r.value.expression.type!==$.JSXEmptyExpression)return n.getText(r.value.expression);return null}var Sn=X({name:"react-optimized-collections",meta:{type:"suggestion",docs:{description:"Detect unstable values in map renders that prevent React Compiler optimization"},messages:{unstableValueInMap:"Unstable values in {{problematicProps}} prevent React Compiler from optimizing individual list items. Extract the problematic props to outside the loop or extract the item to a separate component.",extractComponent:"Extract to {{componentName}} component"},schema:[U(Qs)],hasSuggestions:!0},defaultOptions:[{runOnlyWithEnableCompilerDirective:!1}],create(e,[n]){let{sourceCode:r}=e;if(n.runOnlyWithEnableCompilerDirective){let t=!1;for(let o of r.getAllComments())if(ea.test(o.value)){t=!0;break}if(!t)return{}}return{CallExpression(t){t.callee.type===$.MemberExpression&&t.callee.property.type===$.Identifier&&(t.callee.property.name==="map"||t.callee.property.name==="push")&&(t.callee.property.name==="map"?fa(t,r,e):ma(t,r,e))}}}});function fa(e,n,r){let t=e.arguments[0];if(!t||t.type!==$.ArrowFunctionExpression&&t.type!==$.FunctionExpression||!sa(t))return;let o=null;if(t.body.type===$.JSXElement||t.body.type===$.JSXFragment?o=t.body:t.body.type===$.BlockStatement&&t.body.body[0]?.type===$.ReturnStatement&&t.body.body[0].argument&&(t.body.body[0].argument.type===$.JSXElement||t.body.body[0].argument.type===$.JSXFragment)&&(o=t.body.body[0].argument),!o)return;let s=Jr(o,n);if(!s.hasUnstable)return;let i=aa(e,t.params),l=t.params.map(f=>f.type===$.Identifier?f.name:"item"),c=Vr(o,l,n),a=o.type===$.JSXElement?Br(o,n):null,u=s.problematicProps.length===1?`prop "${s.problematicProps[0]}"`:`props "${s.problematicProps.join('", "')}"`;r.report({node:o,messageId:"unstableValueInMap",data:{problematicProps:u},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:f=>{let y=Xr(i,o,t.params,c,n),C=pa(i,t.params,c,a),m=e;for(;m.parent.type!==$.Program&&!(m.type===$.FunctionDeclaration||m.type===$.VariableDeclarator&&m.init&&(m.init.type===$.ArrowFunctionExpression||m.init.type===$.FunctionExpression));)m=m.parent;let E=[];return E.push(f.insertTextAfter(m,`
32
32
 
33
- ${y}`)),E.push(m.replaceText(o,C)),E}}]})}function ua(e,n,r){let t=e.arguments[0];if(!t||t.type!==$.JSXElement&&t.type!==$.JSXFragment)return;let o=t,s=zr(o,n);if(!s.hasUnstable)return;let i=la(o),l=Wr(o,[],n),c=o.type===$.JSXElement?Jr(o,n):null,a=s.problematicProps.length===1?`prop "${s.problematicProps[0]}"`:`props "${s.problematicProps.join('", "')}"`;r.report({node:o,messageId:"unstableValueInMap",data:{problematicProps:a},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:u=>{let m=Vr(i,o,[],l,n),y=pa(i,l,c),C=e;for(;C.parent.type!==$.Program&&!(C.type===$.FunctionDeclaration||C.type===$.VariableDeclarator&&C.init&&(C.init.type===$.ArrowFunctionExpression||C.init.type===$.FunctionExpression));)C=C.parent;let f=[];return f.push(u.insertTextAfter(C,`
33
+ ${y}`)),E.push(f.replaceText(o,C)),E}}]})}function ma(e,n,r){let t=e.arguments[0];if(!t||t.type!==$.JSXElement&&t.type!==$.JSXFragment)return;let o=t,s=Jr(o,n);if(!s.hasUnstable)return;let i=ca(o),l=Vr(o,[],n),c=o.type===$.JSXElement?Br(o,n):null,a=s.problematicProps.length===1?`prop "${s.problematicProps[0]}"`:`props "${s.problematicProps.join('", "')}"`;r.report({node:o,messageId:"unstableValueInMap",data:{problematicProps:a},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:u=>{let f=Xr(i,o,[],l,n),y=ua(i,l,c),C=e;for(;C.parent.type!==$.Program&&!(C.type===$.FunctionDeclaration||C.type===$.VariableDeclarator&&C.init&&(C.init.type===$.ArrowFunctionExpression||C.init.type===$.FunctionExpression));)C=C.parent;let m=[];return m.push(u.insertTextAfter(C,`
34
34
 
35
- ${m}`)),f.push(u.replaceText(o,y)),f}}]})}import{ESLintUtils as fa,TSESTree as ma}from"@typescript-eslint/utils";var ya=fa.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xr="require-description",da=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ga=/^eslint-disable-(next-)?line$/u,Sa=ya({name:Xr,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[n]){let r=e.sourceCode,t=new Set(n.ignore||[]);return{Program(){for(let o of r.getAllComments()){let s=Ta(o);s!=null&&(t.has(s.kind)||s.description||e.report({loc:ba(o.loc),messageId:"missingDescription"}))}}}}}),Br={name:Xr,rule:Sa};function Ta(e){let{text:n,description:r}=Ea(e.value);if(!n)return null;let t=da.exec(n);if(!t)return null;let o=t[1];if(!o)return null;let s=ga.test(o);if(e.type===ma.AST_TOKEN_TYPES.Line&&!s||s&&e.loc.start.line!==e.loc.end.line)return null;let i=n.slice(t.index+o.length);return{kind:o,value:i.trim(),description:r}}var ha=/\s-{2,}\s/u;function Ea(e){let n=e.split(ha);return{text:n[0]?.trim(),description:n.length>1?n[1]?.trim()??null:null}}function ba(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as ne}from"@typescript-eslint/utils";import{z as $e}from"zod/v4";var xa=$e.object({varsToCheck:$e.array($e.object({selector:$e.string().optional(),fromFnCall:$e.string().optional(),prop:$e.string().or($e.array($e.string())),errorMsg:$e.string().optional()}))}),Sn=H({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[z(xa)]},defaultOptions:[{varsToCheck:[]}],create(e,[n]){let r=new Map;function t(i,l,c,a){let u=new Set;for(let y of i.properties)y.type===ne.Property&&y.key.type===ne.Identifier&&u.add(y.key.name);let m=l.filter(y=>!u.has(y));if(m.length>0)if(m.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:m[0],fnName:a,customMsg:c||""}});else{let y=m.map(C=>`"${C}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:a,customMsg:c||""}})}}function o(i){if(i.init?.type===ne.CallExpression){if(i.init.callee.type===ne.Identifier)return i.init.callee.name;if(i.init.callee.type===ne.MemberExpression&&i.init.callee.property.type===ne.Identifier)return i.init.callee.object.type===ne.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let s={};for(let i of n.varsToCheck)i.selector&&(s[i.selector]=l=>{if(l.type===ne.VariableDeclarator&&l.id.type===ne.Identifier&&r.set(l.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:l.id,fnName:o(l)}),l.type===ne.VariableDeclarator&&l.id.type===ne.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];t(l.id,c,i.errorMsg,o(l))}});for(let i of n.varsToCheck)if(i.fromFnCall){let l=i.fromFnCall;if(l.startsWith("*.")){let a=`VariableDeclarator > CallExpression > MemberExpression[property.name="${l.slice(2)}"]`;s[a]=u=>{if(u.type!==ne.MemberExpression||u.parent.type!==ne.CallExpression)return;let m=u.parent;if(m.parent.type!==ne.VariableDeclarator)return;let y=m.parent;if(y.id.type===ne.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===ne.ObjectPattern){let C=Array.isArray(i.prop)?i.prop:[i.prop];t(y.id,C,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(l.includes(".")){let[c,a]=l.split("."),u=`VariableDeclarator > CallExpression > MemberExpression[object.name="${c}"][property.name="${a}"]`;s[u]=m=>{if(m.type!==ne.MemberExpression||m.parent.type!==ne.CallExpression)return;let y=m.parent;if(y.parent.type!==ne.VariableDeclarator)return;let C=y.parent;if(C.id.type===ne.Identifier)r.set(C.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:C.id,fnName:i.fromFnCall||"unknown function"});else if(C.id.type===ne.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];t(C.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let c=`VariableDeclarator > CallExpression > Identifier[name="${l}"]`;s[c]=a=>{if(a.type!==ne.Identifier||a.parent.type!==ne.CallExpression)return;let u=a.parent;if(u.parent.type!==ne.VariableDeclarator)return;let m=u.parent;if(m.id.type===ne.Identifier)r.set(m.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:m.id,fnName:i.fromFnCall||"unknown function"});else if(m.id.type===ne.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];t(m.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...s,"Program:exit"(){for(let[i,{props:l,errorMsg:c,node:a,fnName:u}]of r){let y=e.sourceCode.getScope(a).set.get(i);if(y){let C=new Set(l);for(let f of y.references){let E=f.identifier,x=E.parent;if(!(x.type===ne.VariableDeclarator&&x.id===E)){if(x.type===ne.MemberExpression&&x.object===E&&x.property.type===ne.Identifier&&C.has(x.property.name)){if(C.delete(x.property.name),C.size===0)break;continue}if(x.type===ne.VariableDeclarator&&x.init===E&&x.id.type===ne.ObjectPattern){for(let S of x.id.properties)S.type===ne.Property&&S.key.type===ne.Identifier&&C.has(S.key.name)&&C.delete(S.key.name);if(C.size===0)break;continue}if(!(x.type===ne.MemberExpression&&x.object===E&&x.property.type===ne.Identifier&&!l.includes(x.property.name))){C.clear();break}}}if(C.size>0){let f=Array.from(C);if(f.length===1)e.report({node:a,messageId:"propNotRead",data:{prop:f[0],fnName:u,customMsg:c||""}});else{let E=f.map(x=>`"${x}"`).join(", ");e.report({node:a,messageId:"propsNotRead",data:{props:E,fnName:u,customMsg:c||""}})}}}}}}}});function qr(e){return/^use[A-Z0-9]/.test(e)}function ht(e){return e.type==="Identifier"?qr(e.name):e.type==="MemberExpression"&&!e.computed&&ht(e.property)?e.object.type==="Identifier":!1}function Zr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Gr(e,n){return e.name===n||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===n}function Kr(e){return!!(e.parent&&e.parent.callee&&Gr(e.parent.callee,"forwardRef"))}function Qr(e){return!!(e.parent&&e.parent.callee&&Gr(e.parent.callee,"memo"))}function Tn(e){for(;e;){let n=ti(e);if(n&&(Zr(n)||ht(n))||Kr(e)||Qr(e))return!0;e=e.parent}return!1}function Hr(e){return!1}function hn(e){return!1}var Ca=/eslint +react-compiler\/react-compiler: +\["error/,ei={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"},reactCompilerIsEnabled:{type:"boolean"}}}]},create(e){let n=!!e.options[0]?.reactCompilerIsEnabled;if(n)return{CallExpression(a){let u=null;a.callee.name==="useMemo"?u="useMemo":a.callee.name==="useCallback"&&(u="useCallback"),u&&e.report({node:a,message:`"${u}" is not necessary when using React Compiler.`})}};if(e.options[0]?.ignoreIfReactCompilerIsEnabled||n){for(let a of e.sourceCode.getAllComments())if(Ca.test(a.value))return{CallExpression(u){let m=null;u.callee.name==="useMemo"?m="useMemo":u.callee.name==="useCallback"&&(m="useCallback"),m&&e.report({node:u,message:`"${m}" is not necessary when using React Compiler.`})}}}let r=typeof e.getSource=="function"?a=>r(a):a=>e.sourceCode.getText(a),t=typeof e.getScope=="function"?()=>t():a=>e.sourceCode.getScope(a),o=null,s=[],i=[],l=new WeakSet;function c(a){for(let u of a.references){let m=u.identifier.parent;if(m.type==="VariableDeclarator"&&m.init&&m.init.type==="CallExpression"&&m.init.callee&&Hr(m.init.callee))for(let y of u.resolved.references)y!==u&&l.add(y.identifier)}}return{onCodePathSegmentStart:a=>i.push(a),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(a,u){let m=s.pop();if(m.size===0)return;let y=new Set;function C(h,b){let{cache:w}=C,k=w.get(h.id),N=new Set(b);if(N.has(h.id)){let p=[...N],R=p.slice(p.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),k!==void 0)return k;if(a.thrownSegments.includes(h))k=BigInt("0");else if(h.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let p of h.prevSegments)k+=C(p,N)}return h.reachable&&k===BigInt("0")?w.delete(h.id):w.set(h.id,k),k}function f(h,b){let{cache:w}=f,k=w.get(h.id),N=new Set(b);if(N.has(h.id)){let p=Array.from(N),R=p.slice(p.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),k!==void 0)return k;if(a.thrownSegments.includes(h))k=BigInt("0");else if(h.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let p of h.nextSegments)k+=f(p,N)}return w.set(h.id,k),k}function E(h){let{cache:b}=E,w=b.get(h.id);if(w===null)return 1/0;if(w!==void 0)return w;if(b.set(h.id,null),h.prevSegments.length===0)w=1;else{w=1/0;for(let k of h.prevSegments){let N=E(k);N<w&&(w=N)}w+=1}return b.set(h.id,w),w}C.cache=new Map,f.cache=new Map,E.cache=new Map;let x=f(a.initialSegment),S=ti(u),I=Tn(u),A=S?Zr(S)||ht(S):Kr(u)||Qr(u),T=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let b=E(h);b<T&&(T=b)}for(let[h,b]of m){if(!h.reachable)continue;let w=h.nextSegments.length===0?T<=E(h):T<E(h),k=C(h)*f(h),N=y.has(h.id);for(let p of b)if(N&&!hn(p)&&e.report({node:p,message:`React Hook "${r(p)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(u.async&&e.report({node:p,message:`React Hook "${r(p)}" cannot be called in an async function.`}),!N&&k!==x&&!hn(p)){let d=`React Hook "${r(p)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(w?" Did you accidentally call a React Hook after an early return?":"");e.report({node:p,message:d})}}else if(u.parent&&(u.parent.type==="MethodDefinition"||u.parent.type==="ClassProperty")&&u.parent.value===u){let R=`React Hook "${r(p)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:p,message:R})}else if(S){let R=`React Hook "${r(p)}" is called in function "${r(S)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:p,message:R})}else if(u.type==="Program"){let R=`React Hook "${r(p)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:p,message:R})}else if(I&&!hn(p)){if(u.parent.type==="CallExpression"&&u.parent.callee.type==="Identifier"&&u.parent.callee.name==="useCallback"){let d=u.parent;if(d.parent.type==="VariableDeclarator"&&qr(d.parent.id.name))return}let R=`React Hook "${r(p)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:p,message:R})}}},CallExpression(a){if(ht(a.callee)){let u=Yr(s),m=Yr(i),y=u.get(m);y||(y=[],u.set(m,y)),y.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Hr(a.callee))&&a.arguments.length>0&&(o=a)},Identifier(a){o==null&&l.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${r(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===o&&(o=null)},FunctionDeclaration(a){Tn(a)&&c(t(a))},ArrowFunctionExpression(a){Tn(a)&&c(t(a))}}}};function ti(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function Yr(e){return e[e.length-1]}import{AST_NODE_TYPES as Se,AST_TOKEN_TYPES as Ia}from"@typescript-eslint/utils";import*as be from"zod/v4";var Aa=/^\s+$/,En=/\r?\n/,wa=/^(\s*)/,Ra=/^(\s*)\S/,Fa=/\r?\n/,va=be.object({indent:be.union([be.string().regex(Aa),be.number().int().min(1)]).optional(),tags:be.array(be.string()).optional(),functions:be.array(be.string()).optional(),comments:be.array(be.string()).optional()}),bn=H({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[z(va)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let n=e.sourceCode,{comments:r=["HTML","indent"],functions:t=["dedent","stripIndent"],tags:o=["outdent","dedent","gql","sql","html","styled"],indent:s}=e.options[0],i=r.map(S=>S.toLowerCase());function l(S){let I=S.split(En),A=I.filter(h=>h.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let h of A){let b=h.match(wa);b&&(T=Math.min(T,b[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(h=>h.slice(T)).join(`
36
- `)}function c(S,I,A){return S.split(En).map(h=>h.trim()===""?h:A.repeat(I)+h).join(`
37
- `)}function a(S){if(S.type===Se.Identifier)return S.name;if(S.type===Se.MemberExpression){let I=S.object.type===Se.Identifier?S.object.name:null,A=S.property.type===Se.Identifier?S.property.name:null;return I&&A?`${I}.${A}`:A}return null}function u(S,I){if(!S)return!1;for(let A of I)if(A.includes(".")){let T=A.split(".");if(S.type===Se.MemberExpression&&S.object.type===Se.Identifier&&S.property.type===Se.Identifier&&S.object.name===T[0]&&S.property.name===T[1])return!0}else if(S.type===Se.Identifier&&S.name===A)return!0;return!1}function m(S,I){let A=S.parent;if(A.type!==Se.TaggedTemplateExpression)return!1;let T=a(A.tag);return T?I.includes(T):!1}function y(S,I){if(!S||S.type!==Se.CallExpression)return!1;let{method:A,argumentsLength:T,optionalCall:h=!0,optionalMember:b=!0}=I;return T!==void 0&&S.arguments.length!==T||!h&&S.optional||S.callee.type!==Se.MemberExpression||!b&&S.callee.optional||S.callee.property.type!==Se.Identifier?!1:S.callee.property.name===A}function C(S,I){if(!S||S.type!==Se.CallExpression)return!1;let{name:A,argumentsLength:T,optionalCall:h=!0}=I;return T!==void 0&&S.arguments.length!==T||!h&&S.optional||S.callee.type!==Se.Identifier?!1:S.callee.name===A}function f(S){return y(S.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&S.parent.type===Se.CallExpression&&S.parent.arguments[0]===S&&C(S.parent.callee.type===Se.MemberExpression?S.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function E(S){if(i.length>0){let I=n.getTokenBefore(S,{includeComments:!0});if(I?.type===Ia.Block&&i.includes(I.value.trim().toLowerCase()))return!0}return!!(f(S)||o.length>0&&m(S,o)||t.length>0&&S.parent.type===Se.CallExpression&&S.parent.arguments.includes(S)&&u(S.parent.callee,t))}function x(S){let I=`__PLACEHOLDER__${Math.random()}`,A=S.quasis.map(j=>n.getText(j).slice(1,j.tail?-1:-2)).join(I),T=A.match(Fa);if(!T)return;let h=T[0],b=n.lines[n.getLocFromIndex(S.range[0]).line-1];if(!b)return;let k=b.match(Ra)?.[1]??"",N;typeof s=="string"?N=s:typeof s=="number"?N=" ".repeat(s):N=k.startsWith(" ")?" ":" ";let R=l(A).replace(new RegExp(`^${h}|${h}[ ]*$`,"g"),""),d=h+c(R,1,k+N)+h+k,g=A.includes(`\r
35
+ ${f}`)),m.push(u.replaceText(o,y)),m}}]})}import{ESLintUtils as ya,TSESTree as da}from"@typescript-eslint/utils";var ga=ya.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Hr="require-description",Sa=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Ta=/^eslint-disable-(next-)?line$/u,ha=ga({name:Hr,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[n]){let r=e.sourceCode,t=new Set(n.ignore||[]);return{Program(){for(let o of r.getAllComments()){let s=Ea(o);s!=null&&(t.has(s.kind)||s.description||e.report({loc:Ca(o.loc),messageId:"missingDescription"}))}}}}}),Yr={name:Hr,rule:ha};function Ea(e){let{text:n,description:r}=xa(e.value);if(!n)return null;let t=Sa.exec(n);if(!t)return null;let o=t[1];if(!o)return null;let s=Ta.test(o);if(e.type===da.AST_TOKEN_TYPES.Line&&!s||s&&e.loc.start.line!==e.loc.end.line)return null;let i=n.slice(t.index+o.length);return{kind:o,value:i.trim(),description:r}}var ba=/\s-{2,}\s/u;function xa(e){let n=e.split(ba);return{text:n[0]?.trim(),description:n.length>1?n[1]?.trim()??null:null}}function Ca(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as ne}from"@typescript-eslint/utils";import{z as $e}from"zod/v4";var Ia=$e.object({varsToCheck:$e.array($e.object({selector:$e.string().optional(),fromFnCall:$e.string().optional(),prop:$e.string().or($e.array($e.string())),errorMsg:$e.string().optional()}))}),Tn=X({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[U(Ia)]},defaultOptions:[{varsToCheck:[]}],create(e,[n]){let r=new Map;function t(i,l,c,a){let u=new Set;for(let y of i.properties)y.type===ne.Property&&y.key.type===ne.Identifier&&u.add(y.key.name);let f=l.filter(y=>!u.has(y));if(f.length>0)if(f.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:f[0],fnName:a,customMsg:c||""}});else{let y=f.map(C=>`"${C}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:a,customMsg:c||""}})}}function o(i){if(i.init?.type===ne.CallExpression){if(i.init.callee.type===ne.Identifier)return i.init.callee.name;if(i.init.callee.type===ne.MemberExpression&&i.init.callee.property.type===ne.Identifier)return i.init.callee.object.type===ne.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let s={};for(let i of n.varsToCheck)i.selector&&(s[i.selector]=l=>{if(l.type===ne.VariableDeclarator&&l.id.type===ne.Identifier&&r.set(l.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:l.id,fnName:o(l)}),l.type===ne.VariableDeclarator&&l.id.type===ne.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];t(l.id,c,i.errorMsg,o(l))}});for(let i of n.varsToCheck)if(i.fromFnCall){let l=i.fromFnCall;if(l.startsWith("*.")){let a=`VariableDeclarator > CallExpression > MemberExpression[property.name="${l.slice(2)}"]`;s[a]=u=>{if(u.type!==ne.MemberExpression||u.parent.type!==ne.CallExpression)return;let f=u.parent;if(f.parent.type!==ne.VariableDeclarator)return;let y=f.parent;if(y.id.type===ne.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===ne.ObjectPattern){let C=Array.isArray(i.prop)?i.prop:[i.prop];t(y.id,C,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(l.includes(".")){let[c,a]=l.split("."),u=`VariableDeclarator > CallExpression > MemberExpression[object.name="${c}"][property.name="${a}"]`;s[u]=f=>{if(f.type!==ne.MemberExpression||f.parent.type!==ne.CallExpression)return;let y=f.parent;if(y.parent.type!==ne.VariableDeclarator)return;let C=y.parent;if(C.id.type===ne.Identifier)r.set(C.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:C.id,fnName:i.fromFnCall||"unknown function"});else if(C.id.type===ne.ObjectPattern){let m=Array.isArray(i.prop)?i.prop:[i.prop];t(C.id,m,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let c=`VariableDeclarator > CallExpression > Identifier[name="${l}"]`;s[c]=a=>{if(a.type!==ne.Identifier||a.parent.type!==ne.CallExpression)return;let u=a.parent;if(u.parent.type!==ne.VariableDeclarator)return;let f=u.parent;if(f.id.type===ne.Identifier)r.set(f.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:f.id,fnName:i.fromFnCall||"unknown function"});else if(f.id.type===ne.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];t(f.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...s,"Program:exit"(){for(let[i,{props:l,errorMsg:c,node:a,fnName:u}]of r){let y=e.sourceCode.getScope(a).set.get(i);if(y){let C=new Set(l);for(let m of y.references){let E=m.identifier,x=E.parent;if(!(x.type===ne.VariableDeclarator&&x.id===E)){if(x.type===ne.MemberExpression&&x.object===E&&x.property.type===ne.Identifier&&C.has(x.property.name)){if(C.delete(x.property.name),C.size===0)break;continue}if(x.type===ne.VariableDeclarator&&x.init===E&&x.id.type===ne.ObjectPattern){for(let S of x.id.properties)S.type===ne.Property&&S.key.type===ne.Identifier&&C.has(S.key.name)&&C.delete(S.key.name);if(C.size===0)break;continue}if(!(x.type===ne.MemberExpression&&x.object===E&&x.property.type===ne.Identifier&&!l.includes(x.property.name))){C.clear();break}}}if(C.size>0){let m=Array.from(C);if(m.length===1)e.report({node:a,messageId:"propNotRead",data:{prop:m[0],fnName:u,customMsg:c||""}});else{let E=m.map(x=>`"${x}"`).join(", ");e.report({node:a,messageId:"propsNotRead",data:{props:E,fnName:u,customMsg:c||""}})}}}}}}}});function Gr(e){return/^use[A-Z0-9]/.test(e)}function Et(e){return e.type==="Identifier"?Gr(e.name):e.type==="MemberExpression"&&!e.computed&&Et(e.property)?e.object.type==="Identifier":!1}function Kr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Qr(e,n){return e.name===n||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===n}function ei(e){return!!(e.parent&&e.parent.callee&&Qr(e.parent.callee,"forwardRef"))}function ti(e){return!!(e.parent&&e.parent.callee&&Qr(e.parent.callee,"memo"))}function hn(e){for(;e;){let n=ri(e);if(n&&(Kr(n)||Et(n))||ei(e)||ti(e))return!0;e=e.parent}return!1}function qr(e){return!1}function En(e){return!1}var Aa=/eslint +react-compiler\/react-compiler: +\["error/,ni={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"},reactCompilerIsEnabled:{type:"boolean"}}}]},create(e){let n=!!e.options[0]?.reactCompilerIsEnabled;if(n)return{CallExpression(a){let u=null;a.callee.name==="useMemo"?u="useMemo":a.callee.name==="useCallback"&&(u="useCallback"),u&&e.report({node:a,message:`"${u}" is not necessary when using React Compiler.`})}};if(e.options[0]?.ignoreIfReactCompilerIsEnabled||n){for(let a of e.sourceCode.getAllComments())if(Aa.test(a.value))return{CallExpression(u){let f=null;u.callee.name==="useMemo"?f="useMemo":u.callee.name==="useCallback"&&(f="useCallback"),f&&e.report({node:u,message:`"${f}" is not necessary when using React Compiler.`})}}}let r=typeof e.getSource=="function"?a=>r(a):a=>e.sourceCode.getText(a),t=typeof e.getScope=="function"?()=>t():a=>e.sourceCode.getScope(a),o=null,s=[],i=[],l=new WeakSet;function c(a){for(let u of a.references){let f=u.identifier.parent;if(f.type==="VariableDeclarator"&&f.init&&f.init.type==="CallExpression"&&f.init.callee&&qr(f.init.callee))for(let y of u.resolved.references)y!==u&&l.add(y.identifier)}}return{onCodePathSegmentStart:a=>i.push(a),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(a,u){let f=s.pop();if(f.size===0)return;let y=new Set;function C(h,b){let{cache:w}=C,k=w.get(h.id),N=new Set(b);if(N.has(h.id)){let p=[...N],R=p.slice(p.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),k!==void 0)return k;if(a.thrownSegments.includes(h))k=BigInt("0");else if(h.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let p of h.prevSegments)k+=C(p,N)}return h.reachable&&k===BigInt("0")?w.delete(h.id):w.set(h.id,k),k}function m(h,b){let{cache:w}=m,k=w.get(h.id),N=new Set(b);if(N.has(h.id)){let p=Array.from(N),R=p.slice(p.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),k!==void 0)return k;if(a.thrownSegments.includes(h))k=BigInt("0");else if(h.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let p of h.nextSegments)k+=m(p,N)}return w.set(h.id,k),k}function E(h){let{cache:b}=E,w=b.get(h.id);if(w===null)return 1/0;if(w!==void 0)return w;if(b.set(h.id,null),h.prevSegments.length===0)w=1;else{w=1/0;for(let k of h.prevSegments){let N=E(k);N<w&&(w=N)}w+=1}return b.set(h.id,w),w}C.cache=new Map,m.cache=new Map,E.cache=new Map;let x=m(a.initialSegment),S=ri(u),I=hn(u),A=S?Kr(S)||Et(S):ei(u)||ti(u),T=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let b=E(h);b<T&&(T=b)}for(let[h,b]of f){if(!h.reachable)continue;let w=h.nextSegments.length===0?T<=E(h):T<E(h),k=C(h)*m(h),N=y.has(h.id);for(let p of b)if(N&&!En(p)&&e.report({node:p,message:`React Hook "${r(p)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(u.async&&e.report({node:p,message:`React Hook "${r(p)}" cannot be called in an async function.`}),!N&&k!==x&&!En(p)){let d=`React Hook "${r(p)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(w?" Did you accidentally call a React Hook after an early return?":"");e.report({node:p,message:d})}}else if(u.parent&&(u.parent.type==="MethodDefinition"||u.parent.type==="ClassProperty")&&u.parent.value===u){let R=`React Hook "${r(p)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:p,message:R})}else if(S){let R=`React Hook "${r(p)}" is called in function "${r(S)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:p,message:R})}else if(u.type==="Program"){let R=`React Hook "${r(p)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:p,message:R})}else if(I&&!En(p)){if(u.parent.type==="CallExpression"&&u.parent.callee.type==="Identifier"&&u.parent.callee.name==="useCallback"){let d=u.parent;if(d.parent.type==="VariableDeclarator"&&Gr(d.parent.id.name))return}let R=`React Hook "${r(p)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:p,message:R})}}},CallExpression(a){if(Et(a.callee)){let u=Zr(s),f=Zr(i),y=u.get(f);y||(y=[],u.set(f,y)),y.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||qr(a.callee))&&a.arguments.length>0&&(o=a)},Identifier(a){o==null&&l.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${r(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===o&&(o=null)},FunctionDeclaration(a){hn(a)&&c(t(a))},ArrowFunctionExpression(a){hn(a)&&c(t(a))}}}};function ri(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function Zr(e){return e[e.length-1]}import{AST_NODE_TYPES as Se,AST_TOKEN_TYPES as wa}from"@typescript-eslint/utils";import*as be from"zod/v4";var Ra=/^\s+$/,bn=/\r?\n/,Fa=/^(\s*)/,va=/^(\s*)\S/,ka=/\r?\n/,Pa=be.object({indent:be.union([be.string().regex(Ra),be.number().int().min(1)]).optional(),tags:be.array(be.string()).optional(),functions:be.array(be.string()).optional(),comments:be.array(be.string()).optional()}),xn=X({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[U(Pa)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let n=e.sourceCode,{comments:r=["HTML","indent"],functions:t=["dedent","stripIndent"],tags:o=["outdent","dedent","gql","sql","html","styled"],indent:s}=e.options[0],i=r.map(S=>S.toLowerCase());function l(S){let I=S.split(bn),A=I.filter(h=>h.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let h of A){let b=h.match(Fa);b&&(T=Math.min(T,b[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(h=>h.slice(T)).join(`
36
+ `)}function c(S,I,A){return S.split(bn).map(h=>h.trim()===""?h:A.repeat(I)+h).join(`
37
+ `)}function a(S){if(S.type===Se.Identifier)return S.name;if(S.type===Se.MemberExpression){let I=S.object.type===Se.Identifier?S.object.name:null,A=S.property.type===Se.Identifier?S.property.name:null;return I&&A?`${I}.${A}`:A}return null}function u(S,I){if(!S)return!1;for(let A of I)if(A.includes(".")){let T=A.split(".");if(S.type===Se.MemberExpression&&S.object.type===Se.Identifier&&S.property.type===Se.Identifier&&S.object.name===T[0]&&S.property.name===T[1])return!0}else if(S.type===Se.Identifier&&S.name===A)return!0;return!1}function f(S,I){let A=S.parent;if(A.type!==Se.TaggedTemplateExpression)return!1;let T=a(A.tag);return T?I.includes(T):!1}function y(S,I){if(!S||S.type!==Se.CallExpression)return!1;let{method:A,argumentsLength:T,optionalCall:h=!0,optionalMember:b=!0}=I;return T!==void 0&&S.arguments.length!==T||!h&&S.optional||S.callee.type!==Se.MemberExpression||!b&&S.callee.optional||S.callee.property.type!==Se.Identifier?!1:S.callee.property.name===A}function C(S,I){if(!S||S.type!==Se.CallExpression)return!1;let{name:A,argumentsLength:T,optionalCall:h=!0}=I;return T!==void 0&&S.arguments.length!==T||!h&&S.optional||S.callee.type!==Se.Identifier?!1:S.callee.name===A}function m(S){return y(S.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&S.parent.type===Se.CallExpression&&S.parent.arguments[0]===S&&C(S.parent.callee.type===Se.MemberExpression?S.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function E(S){if(i.length>0){let I=n.getTokenBefore(S,{includeComments:!0});if(I?.type===wa.Block&&i.includes(I.value.trim().toLowerCase()))return!0}return!!(m(S)||o.length>0&&f(S,o)||t.length>0&&S.parent.type===Se.CallExpression&&S.parent.arguments.includes(S)&&u(S.parent.callee,t))}function x(S){let I=`__PLACEHOLDER__${Math.random()}`,A=S.quasis.map(j=>n.getText(j).slice(1,j.tail?-1:-2)).join(I),T=A.match(ka);if(!T)return;let h=T[0],b=n.lines[n.getLocFromIndex(S.range[0]).line-1];if(!b)return;let k=b.match(va)?.[1]??"",N;typeof s=="string"?N=s:typeof s=="number"?N=" ".repeat(s):N=k.startsWith(" ")?" ":" ";let R=l(A).replace(new RegExp(`^${h}|${h}[ ]*$`,"g"),""),d=h+c(R,1,k+N)+h+k,g=A.includes(`\r
38
38
  `)?`\r
39
39
  `:`
40
- `,F=A.split(En),P=F.map((j,J)=>J!==F.length-1&&j===N+k?"":j).join(g);if(d!==P)return{node:S,messageId:"improperlyIndented",fix:j=>d.split(I).map((J,G)=>{let Y=S.quasis[G];return Y?j.replaceTextRange([Y.range[0]+1,Y.range[1]-(Y.tail?1:2)],J):[]}).flat()}}return{TemplateLiteral(S){if(!E(S))return;let I=x(S);if(I)return e.report(I)}}}});import{AST_NODE_TYPES as ni}from"@typescript-eslint/utils";function ka(e){if(!("regex"in e))return!1;let n=e.regex.flags;return n.includes("g")||n.includes("y")}function Pa(e){let n=e.parent;return n?.type===ni.NewExpression&&n.callee.type===ni.Identifier&&n.callee.name==="RegExp"}var xn=H({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function n(r){ka(r)||Pa(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":n}}});import{AST_NODE_TYPES as Te}from"@typescript-eslint/utils";import{z as at}from"zod/v4";var Oa=at.object({checkOnly:at.array(at.enum(["function-args","FC","generic-args-at-fn-calls"])).optional(),checkTypesFromSelectors:at.array(at.string()).optional()}),Cn=H({name:"use-types-directly-above-usage",meta:{type:"suggestion",docs:{description:"Require type definitions to be placed directly above their first usage for better readability"},fixable:"code",schema:[z(Oa)],messages:{moveTypeAboveUsage:"Type definition should be placed directly above its first usage."}},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=new Map,o=[];function s(f){for(let E of o)if(f.range[0]>=E.range[0]&&f.range[1]<=E.range[1])return E;return null}function i(f){let E=f.parent;for(;E;){if(E.type===Te.FunctionDeclaration||E.type===Te.FunctionExpression||E.type===Te.ArrowFunctionExpression){let x=E.params;for(let S of x)if(f.range[0]>=S.range[0]&&f.range[1]<=S.range[1])return!0;break}E=E.parent}return!1}function l(f){let E=f.parent;for(;E;){if(E.type===Te.TSTypeParameterInstantiation){let x=E.parent;if(x.type===Te.TSTypeReference&&x.typeName.type===Te.Identifier&&(x.typeName.name==="FC"||x.typeName.name==="React.FC")||x.type===Te.TSTypeReference&&x.typeName.type===Te.TSQualifiedName&&x.typeName.right.name==="FC")return!0}E=E.parent}return!1}function c(f){let E=f.parent;for(;E;){if(E.type===Te.TSTypeParameterInstantiation){let x=E.parent;if(x.type===Te.CallExpression||x.type===Te.NewExpression)return!0}E=E.parent}return!1}function a(f){let E=f.parent;for(;E;){if(E.type===Te.TSTypeAliasDeclaration||E.type===Te.TSInterfaceDeclaration)return!0;E=E.parent}return!1}function u(f){return f.parent.type===Te.TSIndexedAccessType&&f.parent.objectType===f}let m=[];function y(f){let E=[],x=new Map;for(let{typeName:I,firstUsage:A}of f){let T=x.get(A)||[];T.push(I),x.set(A,T)}for(let{typeName:I,firstUsage:A,firstUsagePosition:T,firstUsageInFunctionArgs:h}of f){let b=t.get(I);if(!b||b.statement===A)continue;let w=o.indexOf(b.statement),k=o.indexOf(A);if(w===-1||k===-1)continue;let N=!!(n.checkOnly&&n.checkOnly.includes("function-args")&&h),R=(x.get(A)||[]).length>1;(N||R?w>k:w>k||w!==k-1)&&E.push({typeName:I,typeDef:b,targetStatement:A,firstUsagePosition:T})}if(E.length===0)return;E.sort((I,A)=>{let T=I.firstUsagePosition-A.firstUsagePosition;if(T!==0)return T;let h=o.indexOf(I.typeDef.statement),b=o.indexOf(A.typeDef.statement);return h-b});let S=E[0];S&&e.report({node:S.typeDef.node,messageId:"moveTypeAboveUsage",fix:C(E)})}function C(f){return function*(E){let x=new Map;for(let S of f){let I=x.get(S.targetStatement)||[];I.push(S),x.set(S.targetStatement,I)}for(let[,S]of x)S.sort((I,A)=>{let T=I.firstUsagePosition-A.firstUsagePosition;if(T!==0)return T;let h=o.indexOf(I.typeDef.statement),b=o.indexOf(A.typeDef.statement);return h-b});for(let S of f){let{typeDef:I}=S,A=I.statement,T=r.getCommentsBefore(A),h=A.range[0],b=A.range[1];T.length>0&&T[0]&&(h=T[0].range[0]),yield E.removeRange([h,b])}for(let[S,I]of x){let A=r.getCommentsBefore(S),T=A.length>0&&A[0]?A[0].range[0]:S.range[0],h=[];for(let b of I){let w=b.typeDef.statement,k=r.getText(w),N=r.getCommentsBefore(w),p=k;N.length>0&&(p=`${N.map(d=>r.getText(d)).join(`
40
+ `,F=A.split(bn),P=F.map((j,V)=>V!==F.length-1&&j===N+k?"":j).join(g);if(d!==P)return{node:S,messageId:"improperlyIndented",fix:j=>d.split(I).map((V,G)=>{let Y=S.quasis[G];return Y?j.replaceTextRange([Y.range[0]+1,Y.range[1]-(Y.tail?1:2)],V):[]}).flat()}}return{TemplateLiteral(S){if(!E(S))return;let I=x(S);if(I)return e.report(I)}}}});import{AST_NODE_TYPES as ii}from"@typescript-eslint/utils";function Oa(e){if(!("regex"in e))return!1;let n=e.regex.flags;return n.includes("g")||n.includes("y")}function Na(e){let n=e.parent;return n?.type===ii.NewExpression&&n.callee.type===ii.Identifier&&n.callee.name==="RegExp"}var Cn=X({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function n(r){Oa(r)||Na(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":n}}});import{AST_NODE_TYPES as Te}from"@typescript-eslint/utils";import{z as lt}from"zod/v4";var Da=lt.object({checkOnly:lt.array(lt.enum(["function-args","FC","generic-args-at-fn-calls"])).optional(),checkTypesFromSelectors:lt.array(lt.string()).optional()}),In=X({name:"use-types-directly-above-usage",meta:{type:"suggestion",docs:{description:"Require type definitions to be placed directly above their first usage for better readability"},fixable:"code",schema:[U(Da)],messages:{moveTypeAboveUsage:"Type definition should be placed directly above its first usage."}},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=new Map,o=[];function s(m){for(let E of o)if(m.range[0]>=E.range[0]&&m.range[1]<=E.range[1])return E;return null}function i(m){let E=m.parent;for(;E;){if(E.type===Te.FunctionDeclaration||E.type===Te.FunctionExpression||E.type===Te.ArrowFunctionExpression){let x=E.params;for(let S of x)if(m.range[0]>=S.range[0]&&m.range[1]<=S.range[1])return!0;break}E=E.parent}return!1}function l(m){let E=m.parent;for(;E;){if(E.type===Te.TSTypeParameterInstantiation){let x=E.parent;if(x.type===Te.TSTypeReference&&x.typeName.type===Te.Identifier&&(x.typeName.name==="FC"||x.typeName.name==="React.FC")||x.type===Te.TSTypeReference&&x.typeName.type===Te.TSQualifiedName&&x.typeName.right.name==="FC")return!0}E=E.parent}return!1}function c(m){let E=m.parent;for(;E;){if(E.type===Te.TSTypeParameterInstantiation){let x=E.parent;if(x.type===Te.CallExpression||x.type===Te.NewExpression)return!0}E=E.parent}return!1}function a(m){let E=m.parent;for(;E;){if(E.type===Te.TSTypeAliasDeclaration||E.type===Te.TSInterfaceDeclaration)return!0;E=E.parent}return!1}function u(m){return m.parent.type===Te.TSIndexedAccessType&&m.parent.objectType===m}let f=[];function y(m){let E=[],x=new Map;for(let{typeName:I,firstUsage:A}of m){let T=x.get(A)||[];T.push(I),x.set(A,T)}for(let{typeName:I,firstUsage:A,firstUsagePosition:T,firstUsageInFunctionArgs:h}of m){let b=t.get(I);if(!b||b.statement===A)continue;let w=o.indexOf(b.statement),k=o.indexOf(A);if(w===-1||k===-1)continue;let N=!!(n.checkOnly&&n.checkOnly.includes("function-args")&&h),R=(x.get(A)||[]).length>1;(N||R?w>k:w>k||w!==k-1)&&E.push({typeName:I,typeDef:b,targetStatement:A,firstUsagePosition:T})}if(E.length===0)return;E.sort((I,A)=>{let T=I.firstUsagePosition-A.firstUsagePosition;if(T!==0)return T;let h=o.indexOf(I.typeDef.statement),b=o.indexOf(A.typeDef.statement);return h-b});let S=E[0];S&&e.report({node:S.typeDef.node,messageId:"moveTypeAboveUsage",fix:C(E)})}function C(m){return function*(E){let x=new Map;for(let S of m){let I=x.get(S.targetStatement)||[];I.push(S),x.set(S.targetStatement,I)}for(let[,S]of x)S.sort((I,A)=>{let T=I.firstUsagePosition-A.firstUsagePosition;if(T!==0)return T;let h=o.indexOf(I.typeDef.statement),b=o.indexOf(A.typeDef.statement);return h-b});for(let S of m){let{typeDef:I}=S,A=I.statement,T=r.getCommentsBefore(A),h=A.range[0],b=A.range[1];T.length>0&&T[0]&&(h=T[0].range[0]),yield E.removeRange([h,b])}for(let[S,I]of x){let A=r.getCommentsBefore(S),T=A.length>0&&A[0]?A[0].range[0]:S.range[0],h=[];for(let b of I){let w=b.typeDef.statement,k=r.getText(w),N=r.getCommentsBefore(w),p=k;N.length>0&&(p=`${N.map(d=>r.getText(d)).join(`
41
41
  `)}
42
42
  ${k}`),h.push(p)}yield E.insertTextBeforeRange([T,T],`${h.join(`
43
43
 
44
44
  `)}
45
45
 
46
- `)}}}return{Program(f){o.push(...f.body)},TSTypeAliasDeclaration(f){if(o.some(x=>x.type===Te.ExportNamedDeclaration&&x.declaration===f?!0:x===f)){let x=s(f);x&&t.set(f.id.name,{node:f,name:f.id.name,statement:x})}},TSInterfaceDeclaration(f){if(o.some(x=>x.type===Te.ExportNamedDeclaration&&x.declaration===f?!0:x===f)){let x=s(f);x&&t.set(f.id.name,{node:f,name:f.id.name,statement:x})}},TSTypeReference(f){if(f.typeName.type===Te.Identifier){if(u(f))return;let E=i(f),x=l(f),S=c(f);m.push({typeName:f.typeName.name,node:f,inFunctionArgs:E,inFCProps:x,inGenericArgAtFunctionCall:S,usagePosition:f.range[0]})}},"Program:exit"(){let f=new Map;function E(S){if(!n.checkOnly||n.checkOnly.length===0)return!0;for(let I of n.checkOnly)if(I==="function-args"&&S.inFunctionArgs||I==="FC"&&S.inFCProps||I==="generic-args-at-fn-calls"&&S.inGenericArgAtFunctionCall)return!0;return!1}for(let S of m){let{typeName:I,node:A}=S;if(!t.has(I)||!E(S))continue;let T=s(A),h=t.get(I);if(!T||!h||T===h.statement)continue;f.has(I)||f.set(I,[]);let b=f.get(I);if(!b)return;b.includes(T)||b.push(T)}let x=[];for(let[S,I]of f)if(I.length>0){if(I.length===0)continue;let A=I[0];if(!A)continue;let T=Number.MAX_SAFE_INTEGER,h=!1;for(let w of I)w.range[0]<A.range[0]&&(A=w);for(let w of m)E(w)&&w.typeName===S&&s(w.node)===A&&w.usagePosition<T&&(T=w.usagePosition,h=w.inFunctionArgs);if(!!(n.checkOnly&&n.checkOnly.length>0)){let w=Number.MAX_SAFE_INTEGER;for(let N of m){if(N.typeName!==S)continue;let p=s(N.node);if(!p)continue;let R=o.indexOf(p);R!==-1&&R<w&&(w=R)}let k=o.indexOf(A);if(w!==Number.MAX_SAFE_INTEGER&&k!==-1&&w<k)continue}else{let w=Number.MAX_SAFE_INTEGER;for(let N of m){if(N.typeName!==S||a(N.node))continue;let p=s(N.node);if(!p)continue;let R=o.indexOf(p);R!==-1&&R<w&&(w=R)}let k=o.indexOf(A);if(w!==Number.MAX_SAFE_INTEGER&&k!==-1&&w<k)continue}x.push({typeName:S,firstUsage:A,firstUsagePosition:T,firstUsageInFunctionArgs:h})}x.length>0&&y(x)}}}});import{AST_NODE_TYPES as re}from"@typescript-eslint/utils";import*as Ge from"zod/v4";var Na=["tsx"],Da=/^[A-Z][A-Za-z0-9]*$/,ja=Ge.object({extensions:Ge.array(Ge.string()).optional()}),In=H({name:"react-single-export",meta:{type:"problem",docs:{description:"Enforces only one export per React component file to support fast refresh"},messages:{multipleExports:"React component files should have only one export to support fast refresh, if you want to export multiple components, use a separate file for each component. Type-only exports are allowed."},schema:[z(ja)]},defaultOptions:[{}],create(e,[n]){let r=e.getFilename(),t=n.extensions??Na,o=!1;for(let T of t)if(r.endsWith(T)){o=!0;break}if(!o)return{};let s=e.sourceCode,i=new Set,l=new Map;function c(T){return Da.test(T)}function a(T){if(T.type!==re.CallExpression)return!1;let h=T.callee;return h.type===re.Identifier?h.name==="memo"||h.name==="forwardRef":h.type===re.MemberExpression&&h.property.type===re.Identifier?h.property.name==="memo"||h.property.name==="forwardRef":!1}function u(T){if(T.type===re.JSXElement||T.type===re.JSXFragment)return!0;if(T.type===re.ArrayExpression){for(let h of T.elements)if(h&&(h.type===re.JSXElement||h.type===re.JSXFragment))return!0}return!1}function m(T){if(T.type!==re.ArrowFunctionExpression)return!1;let h=T.body;if(h.type===re.ArrowFunctionExpression){let b=h.body;if(u(b))return!0}return!1}function y(T){if(T.id.type!==re.Identifier)return;let h=T.id.name,b=T.init;if(b){if(c(h)&&(b.type===re.ArrowFunctionExpression||b.type===re.FunctionExpression||a(b))){i.add(h);return}b.type===re.Identifier&&l.set(h,b.name),c(h)||m(b)&&i.add(h)}}function C(T){if(T.type===re.VariableDeclaration){for(let h of T.declarations)y(h);return}if(T.type===re.FunctionDeclaration&&T.id){c(T.id.name)&&i.add(T.id.name);return}if(T.type===re.ExportNamedDeclaration&&T.declaration){let h=T.declaration;if(h.type===re.VariableDeclaration){for(let b of h.declarations)y(b);return}if(h.type===re.FunctionDeclaration&&h.id){c(h.id.name)&&i.add(h.id.name);return}}}for(let T of s.ast.body)C(T);function f(T,h=new Set){if(i.has(T))return!0;if(h.has(T))return!1;h.add(T);let b=l.get(T);return b?f(b,h):!1}let E=[];function x(T,h,b){E.push({node:T,isType:h,isComponent:b})}for(let T of s.ast.body){if(T.type===re.ExportNamedDeclaration){let h=T.exportKind==="type";if(T.declaration){let b=T.declaration;if(b.type===re.TSTypeAliasDeclaration||b.type===re.TSInterfaceDeclaration){x(b,!0,!1);continue}if(b.type===re.VariableDeclaration){for(let w of b.declarations){if(w.id.type!==re.Identifier)continue;let k=w.id.name,N=f(k);x(w,h,N)}continue}if(b.type===re.FunctionDeclaration){let w=b.id?.name,k=w?f(w)||c(w):!1;x(b,h,k);continue}x(b,h,!1);continue}if(T.specifiers.length>0)for(let b of T.specifiers){if(b.local.type!==re.Identifier)continue;let w=b.local.name,k=f(w);x(b,h,k)}continue}if(T.type===re.ExportDefaultDeclaration){let h=T.declaration;if(h.type===re.Identifier){let b=f(h.name)||c(h.name);x(T,!1,b);continue}if(h.type===re.FunctionDeclaration||h.type===re.ArrowFunctionExpression||h.type===re.FunctionExpression||h.type===re.CallExpression){x(T,!1,!0);continue}x(T,!1,!1);continue}}let S=!1;for(let T of E)if(!T.isType&&T.isComponent){S=!0;break}if(!S)return{};let I=[];for(let T of E)T.isType||I.push(T);let A=-1;for(let[T,h]of I.entries())if(h.isComponent){A=T;break}if(A===-1)return{};for(let[T,h]of I.entries())if(T!==A){e.report({node:h.node,messageId:"multipleExports"});break}return{}}});import{AST_NODE_TYPES as Ve}from"@typescript-eslint/utils";import{z as An}from"zod/v4";function Et(e){return e.charAt(0).toUpperCase()+e.slice(1)}function La(e){return e.callee.type===Ve.Identifier?e.callee.name==="useState":e.callee.type===Ve.MemberExpression&&e.callee.object.type===Ve.Identifier&&e.callee.property.type===Ve.Identifier?e.callee.object.name==="React"&&e.callee.property.name==="useState":!1}var Ma=An.object({ignorePrefixes:An.array(An.string()).optional()});function ri(e,n){for(let r of n)if(e.startsWith(r))return e.slice(r.length);return e}function _a(e){return`set${Et(e)}`}var wn=H({name:"use-state-setter-naming",meta:{type:"problem",docs:{description:"Enforce consistent naming convention for useState destructuring where setter should be set{Value}"},messages:{incorrectSetterName:'useState setter should follow the pattern "set{{expectedName}}" with a "set" prefix but got "{{actualName}}"',useSuggestedName:'Use "{{expectedSetterName}}" instead'},hasSuggestions:!0,schema:[z(Ma)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[n]){return{VariableDeclarator(r){if(!r.init||r.init.type!==Ve.CallExpression||!La(r.init)||r.id.type!==Ve.ArrayPattern||r.id.elements.length!==2)return;let[t,o]=r.id.elements;if(!t||!o||t.type!==Ve.Identifier||o.type!==Ve.Identifier)return;let s=t.name,i=o.name,l=n.ignorePrefixes||[],c=ri(s,l),a=ri(i,l);if(c===""){if(!a.startsWith("set")){let m=`set${Et(s)}`;e.report({node:o,messageId:"incorrectSetterName",data:{expectedName:Et(s),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:m},fix:y=>y.replaceText(o,m)}]})}return}let u=_a(c);a!==u&&e.report({node:o,messageId:"incorrectSetterName",data:{expectedName:Et(c),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:u},fix:m=>m.replaceText(o,u)}]})}}}});import{AST_NODE_TYPES as de}from"@typescript-eslint/utils";import{z as Ke}from"zod/v4";var $a=Ke.object({name:Ke.string(),defaults:Ke.array(Ke.unknown())}),Ua=Ke.object({functions:Ke.array($a)});function bt(e,n){if(e===n)return!0;if(e===null||n===null||e===void 0||n===void 0)return e===n;if(typeof e!=typeof n||typeof e!="object"||Array.isArray(e)!==Array.isArray(n))return!1;if(Array.isArray(e)&&Array.isArray(n))return e.length!==n.length?!1:e.every((o,s)=>bt(o,n[s]));let r=Object.keys(e),t=Object.keys(n);if(r.length!==t.length)return!1;for(let o of r){if(!t.includes(o))return!1;let s=Object.getOwnPropertyDescriptor(e,o),i=Object.getOwnPropertyDescriptor(n,o);if(!s||!i)return!1;let l=s.value,c=i.value;if(!bt(l,c))return!1}return!0}function za(e,n){let r=new Set;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return r;for(let t in e){if(!(t in n))continue;let o=Object.getOwnPropertyDescriptor(e,t),s=Object.getOwnPropertyDescriptor(n,t);o&&s&&bt(o.value,s.value)&&r.add(t)}return r}function ii(e){if(e.type===de.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case de.Literal:return e.value;case de.ObjectExpression:{let n={};for(let r of e.properties)r.type===de.Property&&r.key.type===de.Identifier&&!r.computed&&(r.value.type===de.Literal?n[r.key.name]=r.value.value:r.value.type===de.ObjectExpression?n[r.key.name]=ii(r.value):n[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return n}case de.ArrayExpression:return e.elements.map(n=>{if(!(!n||n.type===de.SpreadElement))return n.type===de.Literal?n.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function Wa(e){return e.type===de.Identifier?e.name:e.type===de.MemberExpression&&e.property.type===de.Identifier&&!e.computed?e.property.name:null}var Rn=H({name:"no-redundant-function-params",meta:{type:"suggestion",docs:{description:"Disallow calling functions with redundant default parameters"},messages:{redundantParams:"Function call has redundant parameters matching its default values and can be removed: {{details}}"},fixable:"code",schema:[z(Ua)]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Map;for(let t of n.functions)r.set(t.name,t.defaults);return{CallExpression(t){let o=Wa(t.callee);if(!o)return;let s=r.get(o);if(!s)return;let i=t.arguments;if(i.length===0)return;let l=-1,c=!1,a=new Map,u=new Set,m=new Map,y=[];for(let f=0;f<i.length;f++){if(f>=s.length){l=f;continue}let E=s[f],x=i[f];if(!x||x.type===de.SpreadElement){l=f;continue}let S=ii(x);if(E===void 0){l=f;continue}if(bt(S,E)){x.type===de.ObjectExpression?(u.add(f),y.push({type:"object",position:f+1})):(m.set(f,S),y.push({type:"simple",position:f+1,value:S}));continue}if(x.type===de.ObjectExpression&&x.properties.length===0&&typeof E=="object"&&E!==null&&Object.keys(E).length>0){u.add(f),y.push({type:"object",position:f+1});continue}let I=za(S,E);if(I.size>0){let A=typeof E=="object"&&E!==null?Object.keys(E).length:0;if(x.type===de.ObjectExpression&&x.properties.length===I.size&&x.properties.length===A){u.add(f),y.push({type:"object",position:f+1});continue}else c=!0,a.set(f,I),y.push({type:"partialObject",position:f+1,redundantProperties:Array.from(I)}),l=f}else l=f}if(l<i.length-1||c||u.size>0){let f=function(){let x=[];for(let S of y)if(S.type==="simple")x.push(`Param ${S.position} with value ${JSON.stringify(S.value)}`);else if(S.type==="object")x.push(`Param ${S.position} (object)`);else{let I=S.redundantProperties||[],A=s?s[S.position-1]:void 0;if(typeof A=="object"&&A!==null){let T=A;for(let h of I)if(h in T){let b=Object.getOwnPropertyDescriptor(T,h);b&&x.push(`Param ${S.position} property "${h}" with value ${JSON.stringify(b.value)}`)}}}return{messageId:"redundantParams",data:{details:x.join(", ")}}};var C=f;let E=f();e.report({node:t,messageId:E.messageId,data:E.data,fix(x){let S=[];if(c)for(let[A,T]of a){let h=i[A];if(h&&h.type===de.ObjectExpression){let b=[];for(let k of h.properties)k.type===de.Property&&k.key.type===de.Identifier&&!k.computed&&T.has(k.key.name)||b.push(k);let w=b.map(k=>e.sourceCode.getText(k));S.push(x.replaceText(h,`{ ${w.join(", ")} }`))}}let I=-1;for(let A=i.length-1;A>=0;A--)if(!u.has(A)&&A<=l){I=A;break}if(I<i.length-1)if(I===-1){let A=e.sourceCode.getTokenAfter(t.callee),T=e.sourceCode.getLastToken(t);A&&T&&S.push(x.replaceTextRange([A.range[1],T.range[0]],""))}else{let A=i[I],T=e.sourceCode.getLastToken(t);T&&A&&S.push(x.replaceTextRange([A.range[1],T.range[0]],""))}return S.length>0?S:null}})}}}}});import{AST_NODE_TYPES as ve}from"@typescript-eslint/utils";function Va(e){let n=e.parent;for(;n;){if(n.type===ve.AwaitExpression||n.type===ve.MemberExpression&&n.object===e&&n.property.type===ve.Identifier&&n.property.name==="then"||n.type===ve.ArrowFunctionExpression&&n.body===e)return!0;if(n.type===ve.ArrayExpression&&n.parent.type===ve.CallExpression){let r=n.parent;if(r.callee.type===ve.MemberExpression&&r.callee.object.type===ve.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===ve.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(n.parent)n=n.parent;else break}return!1}function Ja(e){let{callee:n}=e;return n.type===ve.Identifier&&n.name==="require"||n.type===ve.MemberExpression&&n.object.type===ve.Identifier&&n.object.name==="require"}var Fn=H({name:"no-sync-dynamic-import",meta:{type:"problem",docs:{description:"Disallow synchronous dynamic imports and require statements, only allow async dynamic imports with await"},messages:{syncDynamicImport:"Synchronous dynamic import() is not allowed. Use regular import statement or await import() for dynamic imports.",requireNotAllowed:"require() statements are not allowed. Use ES6 import statements instead."},schema:[]},defaultOptions:[],create(e){return{ImportExpression(n){Va(n)||e.report({node:n,messageId:"syncDynamicImport"})},TSImportType(n){e.report({node:n,messageId:"syncDynamicImport"})},CallExpression(n){Ja(n)&&e.report({node:n,messageId:"requireNotAllowed"})}}}});import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";import{z as vn}from"zod/v4";var Xa=vn.object({mainComponentRegex:vn.string().optional(),mainComponentSelector:vn.string().optional()}),Ba=/^[A-Z][A-Za-z0-9]*$/,kn=H({name:"sort-react-components-and-styles",meta:{type:"suggestion",docs:{description:"Sort React components and styles with styles placed above their first usage"},fixable:"code",schema:[z(Xa)],messages:{stylesShouldBeAboveUsage:"Style definitions should be placed above the first component that uses them",mainComponentShouldBeFirst:"Main component should be placed before other components"}},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=n.mainComponentRegex?new RegExp(n.mainComponentRegex):void 0,o=n.mainComponentSelector;if(!e.filename.endsWith(".tsx"))return{};let i=new Set,l=new Map,c=[],a=[],u=new Set;function m(d){let g=d.node;if(g.type===L.VariableDeclaration){for(let F of g.declarations)if(F.id.type===L.Identifier&&F.id.name===d.name&&F.init)return F.init}if(g.type===L.ExportNamedDeclaration){let F=g.declaration;if(F&&F.type===L.VariableDeclaration){for(let P of F.declarations)if(P.id.type===L.Identifier&&P.id.name===d.name&&P.init)return P.init}}return null}function y(d){let g=new Set;return Pe(d,F=>(F.type===L.Identifier&&F.name!=="styled"&&F.name!=="css"&&g.add(F.name),!1),r),g}function C(d){return Ba.test(d)}function f(d){if(d.type!==L.CallExpression)return!1;let g=d.callee;return g.type===L.Identifier?g.name==="memo"||g.name==="forwardRef":g.type===L.MemberExpression&&g.property.type===L.Identifier?g.property.name==="memo"||g.property.name==="forwardRef":!1}function E(d){if(d.type===L.JSXElement||d.type===L.JSXFragment)return!0;if(d.type===L.BlockStatement){for(let g of d.body)if(g.type===L.ReturnStatement&&g.argument)return E(g.argument)}if(d.type===L.ArrayExpression){for(let g of d.elements)if(g&&(g.type===L.JSXElement||g.type===L.JSXFragment))return!0}return!1}function x(d){if(d.type!==L.ArrowFunctionExpression)return!1;let g=d.body;if(g.type===L.ArrowFunctionExpression){let F=g.body;if(E(F))return!0}return!1}function S(d){if(d.type===L.TaggedTemplateExpression){let g=d.tag;if(g.type===L.MemberExpression&&g.object.type===L.Identifier&&g.object.name==="styled")return!0;if(g.type===L.CallExpression){let F=g.callee;if(F.type===L.Identifier&&F.name==="styled")return!0}}return!1}function I(d){if(d.type===L.TaggedTemplateExpression){let g=d.tag;if(g.type===L.Identifier&&g.name==="css")return!0}return!1}function A(d,g){if(d.id.type!==L.Identifier)return;let F=d.id.name,P=d.init;if(P){if(S(P)||I(P)){a.push({node:g,name:F});return}if((C(F)||P.type===L.ArrowFunctionExpression)&&(P.type===L.ArrowFunctionExpression||P.type===L.FunctionExpression||f(P))){if(P.type===L.ArrowFunctionExpression||P.type===L.FunctionExpression){if(E(P.body)){i.add(F);return}}else if(f(P)){i.add(F);return}}P.type===L.Identifier&&l.set(F,P.name),C(F)||x(P)&&i.add(F)}}function T(d){return d.type===L.ExportDefaultDeclaration||d.type===L.ExportNamedDeclaration}function h(d){if(d.type===L.FunctionDeclaration)return d.id?d.id.name:null;if(d.type===L.VariableDeclaration){let g=d.declarations[0];if(g&&g.id.type===L.Identifier)return g.id.name}if(d.type===L.ExportDefaultDeclaration){let g=d.declaration;if(g.type===L.FunctionDeclaration)return g.id?g.id.name:"default";if(g.type===L.Identifier)return g.name}if(d.type===L.ExportNamedDeclaration){let g=d.declaration;if(g&&g.type===L.FunctionDeclaration)return g.id?g.id.name:null;if(g&&g.type===L.VariableDeclaration){let F=g.declarations[0];if(F&&F.id.type===L.Identifier)return F.id.name}}return null}function b(d,g){return o?u.has(d):t?t.test(g):T(d)}function w(d){let g=new Set;Pe(d.node,F=>{if(F.type===L.Identifier)for(let P of a)P.name===F.name&&(g.add(P.name),(P.firstUsagePosition===void 0||F.range[0]<P.firstUsagePosition)&&(P.firstUsagePosition=F.range[0]));if(F.type===L.JSXElement){let P=F.openingElement;if(P.name.type===L.JSXIdentifier)for(let j of a)j.name===P.name.name&&(g.add(j.name),(j.firstUsagePosition===void 0||P.name.range[0]<j.firstUsagePosition)&&(j.firstUsagePosition=P.name.range[0]))}return!1},r),d.usedStyles=g}function k(d){if(d.type===L.VariableDeclaration){for(let g of d.declarations)A(g,d);return}if(d.type===L.FunctionDeclaration){C(d.id.name)&&E(d.body)&&i.add(d.id.name);return}if(d.type===L.ExportNamedDeclaration&&d.declaration){let g=d.declaration;if(g.type===L.VariableDeclaration){for(let F of g.declarations)A(F,d);return}if(g.type===L.FunctionDeclaration&&g.id){C(g.id.name)&&E(g.body)&&i.add(g.id.name);return}}if(d.type===L.ExportDefaultDeclaration){let g=d.declaration;g.type===L.Identifier&&i.add(g.name),(g.type===L.FunctionDeclaration||g.type===L.ArrowFunctionExpression||g.type===L.FunctionExpression)&&(g.type===L.FunctionDeclaration?g.id?i.add(g.id.name):i.add("default"):E(g.body)&&i.add("default"))}}function N(d,g=new Set){if(i.has(d))return!0;if(g.has(d))return!1;g.add(d);let F=l.get(d);return F?N(F,g):!1}let p={};return o&&(p[o]=d=>{let g=d;for(;g.parent&&g.parent.type!==L.Program;)g=g.parent;g.parent&&(g.type===L.VariableDeclaration||g.type===L.FunctionDeclaration||g.type===L.ExportNamedDeclaration||g.type===L.ExportDefaultDeclaration)&&u.add(g)}),p["Program:exit"]=d=>{let g=0;for(let D of d.body){if(D.type===L.ImportDeclaration){g+=1;continue}break}for(let D of d.body)k(D);for(let D of d.body){let Z=h(D);if(Z&&N(Z)){let q=b(D,Z);c.push({node:D,name:Z,isMainComponent:q,usedStyles:new Set,isExported:T(D)})}}if(!o&&t&&!c.some(D=>D.isMainComponent))for(let D of c)D.isExported&&(D.isMainComponent=!0);for(let D of c)w(D);let F=new Set;for(let D of a)F.add(D.name);let P=new Map;for(let D=0;D<d.body.length;D+=1){let Z=d.body[D];for(let q of a)q.node===Z&&P.set(q.name,D)}let j=new Map;for(let D of a){let Z=m(D),q=new Set;if(Z){let ce=y(Z);for(let ue of ce)F.has(ue)&&ue!==D.name&&q.add(ue)}j.set(D.name,q)}let J=new Map;for(let D of a){let Z=j.get(D.name);if(!Z)continue;let q=P.get(D.name);if(q!==void 0)for(let ce of Z){let ue=J.get(ce);(ue===void 0||q<ue)&&J.set(ce,q)}}let G=[];for(let D of a){if(D.firstUsagePosition===void 0)continue;let Z=d.body.indexOf(D.node),q=-1;for(let Ee of c){if(!Ee.usedStyles.has(D.name))continue;let xe=d.body.indexOf(Ee.node);(q===-1||xe<q)&&(q=xe)}let ce=J.get(D.name);if(ce!==void 0&&(q===-1||ce<q)&&(q=ce),q===-1)continue;let ue=-1;for(let Ee of c){let xe=d.body.indexOf(Ee.node);xe<q&&xe>ue&&(ue=xe)}let Ae=Z<q,Ue=Z>ue,ge=-1,et=j.get(D.name);if(et)for(let Ee of et){let xe=P.get(Ee);xe!==void 0&&xe>ge&&(ge=xe)}let He=Z>ge;if(!(Ae&&Ue&&He)){let Ee=ue+1;if(ge+1>Ee&&(Ee=ge+1),Ee<g&&(Ee=g),Ee>q)continue;G.push({style:D,targetPosition:Ee})}}let Y=null;if(c.length>1){let D=c.map(q=>({c:q,idx:d.body.indexOf(q.node)})).sort((q,ce)=>q.idx-ce.idx)[0]?.c,Z=c.find(q=>q.isMainComponent)||null;D&&Z&&D.node!==Z.node&&(Y={component:Z,targetBefore:D.node})}if(G.length>0||Y){let D=G[0]?.style.node||Y?.component.node||d,Z=G.length>0?"stylesShouldBeAboveUsage":"mainComponentShouldBeFirst";e.report({node:D,messageId:Z,fix:R(G,Y,d.body)})}},p;function R(d,g,F){return function*(P){d.sort((J,G)=>J.targetPosition-G.targetPosition);for(let{style:J}of d){let G=r.getCommentsBefore(J.node),Y=J.node.range[0],D=J.node.range[1];G.length>0&&G[0]&&(Y=G[0].range[0]),Y===J.node.range[0]&&r.text.slice(0,Y).trim().length===0&&(Y=0),yield P.removeRange([Y,D])}let j=new Map;for(let J of d){let G=j.get(J.targetPosition)||[];G.push(J),j.set(J.targetPosition,G)}for(let[J,G]of j){let Y=F[J];if(!Y)continue;let D=r.getCommentsBefore(Y),Z=D.length>0&&D[0]?D[0].range[0]:Y.range[0],q=[];for(let{style:ce}of G){let ue=r.getCommentsBefore(ce.node),Ae=r.getText(ce.node);ue.length>0&&(Ae=`${ue.map(ge=>r.getText(ge)).join(`
46
+ `)}}}return{Program(m){o.push(...m.body)},TSTypeAliasDeclaration(m){if(o.some(x=>x.type===Te.ExportNamedDeclaration&&x.declaration===m?!0:x===m)){let x=s(m);x&&t.set(m.id.name,{node:m,name:m.id.name,statement:x})}},TSInterfaceDeclaration(m){if(o.some(x=>x.type===Te.ExportNamedDeclaration&&x.declaration===m?!0:x===m)){let x=s(m);x&&t.set(m.id.name,{node:m,name:m.id.name,statement:x})}},TSTypeReference(m){if(m.typeName.type===Te.Identifier){if(u(m))return;let E=i(m),x=l(m),S=c(m);f.push({typeName:m.typeName.name,node:m,inFunctionArgs:E,inFCProps:x,inGenericArgAtFunctionCall:S,usagePosition:m.range[0]})}},"Program:exit"(){let m=new Map;function E(S){if(!n.checkOnly||n.checkOnly.length===0)return!0;for(let I of n.checkOnly)if(I==="function-args"&&S.inFunctionArgs||I==="FC"&&S.inFCProps||I==="generic-args-at-fn-calls"&&S.inGenericArgAtFunctionCall)return!0;return!1}for(let S of f){let{typeName:I,node:A}=S;if(!t.has(I)||!E(S))continue;let T=s(A),h=t.get(I);if(!T||!h||T===h.statement)continue;m.has(I)||m.set(I,[]);let b=m.get(I);if(!b)return;b.includes(T)||b.push(T)}let x=[];for(let[S,I]of m)if(I.length>0){if(I.length===0)continue;let A=I[0];if(!A)continue;let T=Number.MAX_SAFE_INTEGER,h=!1;for(let w of I)w.range[0]<A.range[0]&&(A=w);for(let w of f)E(w)&&w.typeName===S&&s(w.node)===A&&w.usagePosition<T&&(T=w.usagePosition,h=w.inFunctionArgs);if(!!(n.checkOnly&&n.checkOnly.length>0)){let w=Number.MAX_SAFE_INTEGER;for(let N of f){if(N.typeName!==S)continue;let p=s(N.node);if(!p)continue;let R=o.indexOf(p);R!==-1&&R<w&&(w=R)}let k=o.indexOf(A);if(w!==Number.MAX_SAFE_INTEGER&&k!==-1&&w<k)continue}else{let w=Number.MAX_SAFE_INTEGER;for(let N of f){if(N.typeName!==S||a(N.node))continue;let p=s(N.node);if(!p)continue;let R=o.indexOf(p);R!==-1&&R<w&&(w=R)}let k=o.indexOf(A);if(w!==Number.MAX_SAFE_INTEGER&&k!==-1&&w<k)continue}x.push({typeName:S,firstUsage:A,firstUsagePosition:T,firstUsageInFunctionArgs:h})}x.length>0&&y(x)}}}});import{AST_NODE_TYPES as re}from"@typescript-eslint/utils";import*as Ke from"zod/v4";var ja=["tsx"],La=/^[A-Z][A-Za-z0-9]*$/,Ma=Ke.object({extensions:Ke.array(Ke.string()).optional()}),An=X({name:"react-single-export",meta:{type:"problem",docs:{description:"Enforces only one export per React component file to support fast refresh"},messages:{multipleExports:"React component files should have only one export to support fast refresh, if you want to export multiple components, use a separate file for each component. Type-only exports are allowed."},schema:[U(Ma)]},defaultOptions:[{}],create(e,[n]){let r=e.getFilename(),t=n.extensions??ja,o=!1;for(let T of t)if(r.endsWith(T)){o=!0;break}if(!o)return{};let s=e.sourceCode,i=new Set,l=new Map;function c(T){return La.test(T)}function a(T){if(T.type!==re.CallExpression)return!1;let h=T.callee;return h.type===re.Identifier?h.name==="memo"||h.name==="forwardRef":h.type===re.MemberExpression&&h.property.type===re.Identifier?h.property.name==="memo"||h.property.name==="forwardRef":!1}function u(T){if(T.type===re.JSXElement||T.type===re.JSXFragment)return!0;if(T.type===re.ArrayExpression){for(let h of T.elements)if(h&&(h.type===re.JSXElement||h.type===re.JSXFragment))return!0}return!1}function f(T){if(T.type!==re.ArrowFunctionExpression)return!1;let h=T.body;if(h.type===re.ArrowFunctionExpression){let b=h.body;if(u(b))return!0}return!1}function y(T){if(T.id.type!==re.Identifier)return;let h=T.id.name,b=T.init;if(b){if(c(h)&&(b.type===re.ArrowFunctionExpression||b.type===re.FunctionExpression||a(b))){i.add(h);return}b.type===re.Identifier&&l.set(h,b.name),c(h)||f(b)&&i.add(h)}}function C(T){if(T.type===re.VariableDeclaration){for(let h of T.declarations)y(h);return}if(T.type===re.FunctionDeclaration&&T.id){c(T.id.name)&&i.add(T.id.name);return}if(T.type===re.ExportNamedDeclaration&&T.declaration){let h=T.declaration;if(h.type===re.VariableDeclaration){for(let b of h.declarations)y(b);return}if(h.type===re.FunctionDeclaration&&h.id){c(h.id.name)&&i.add(h.id.name);return}}}for(let T of s.ast.body)C(T);function m(T,h=new Set){if(i.has(T))return!0;if(h.has(T))return!1;h.add(T);let b=l.get(T);return b?m(b,h):!1}let E=[];function x(T,h,b){E.push({node:T,isType:h,isComponent:b})}for(let T of s.ast.body){if(T.type===re.ExportNamedDeclaration){let h=T.exportKind==="type";if(T.declaration){let b=T.declaration;if(b.type===re.TSTypeAliasDeclaration||b.type===re.TSInterfaceDeclaration){x(b,!0,!1);continue}if(b.type===re.VariableDeclaration){for(let w of b.declarations){if(w.id.type!==re.Identifier)continue;let k=w.id.name,N=m(k);x(w,h,N)}continue}if(b.type===re.FunctionDeclaration){let w=b.id?.name,k=w?m(w)||c(w):!1;x(b,h,k);continue}x(b,h,!1);continue}if(T.specifiers.length>0)for(let b of T.specifiers){if(b.local.type!==re.Identifier)continue;let w=b.local.name,k=m(w);x(b,h,k)}continue}if(T.type===re.ExportDefaultDeclaration){let h=T.declaration;if(h.type===re.Identifier){let b=m(h.name)||c(h.name);x(T,!1,b);continue}if(h.type===re.FunctionDeclaration||h.type===re.ArrowFunctionExpression||h.type===re.FunctionExpression||h.type===re.CallExpression){x(T,!1,!0);continue}x(T,!1,!1);continue}}let S=!1;for(let T of E)if(!T.isType&&T.isComponent){S=!0;break}if(!S)return{};let I=[];for(let T of E)T.isType||I.push(T);let A=-1;for(let[T,h]of I.entries())if(h.isComponent){A=T;break}if(A===-1)return{};for(let[T,h]of I.entries())if(T!==A){e.report({node:h.node,messageId:"multipleExports"});break}return{}}});import{AST_NODE_TYPES as Je}from"@typescript-eslint/utils";import{z as wn}from"zod/v4";function bt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function _a(e){return e.callee.type===Je.Identifier?e.callee.name==="useState":e.callee.type===Je.MemberExpression&&e.callee.object.type===Je.Identifier&&e.callee.property.type===Je.Identifier?e.callee.object.name==="React"&&e.callee.property.name==="useState":!1}var $a=wn.object({ignorePrefixes:wn.array(wn.string()).optional()});function oi(e,n){for(let r of n)if(e.startsWith(r))return e.slice(r.length);return e}function Ua(e){return`set${bt(e)}`}var Rn=X({name:"use-state-setter-naming",meta:{type:"problem",docs:{description:"Enforce consistent naming convention for useState destructuring where setter should be set{Value}"},messages:{incorrectSetterName:'useState setter should follow the pattern "set{{expectedName}}" with a "set" prefix but got "{{actualName}}"',useSuggestedName:'Use "{{expectedSetterName}}" instead'},hasSuggestions:!0,schema:[U($a)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[n]){return{VariableDeclarator(r){if(!r.init||r.init.type!==Je.CallExpression||!_a(r.init)||r.id.type!==Je.ArrayPattern||r.id.elements.length!==2)return;let[t,o]=r.id.elements;if(!t||!o||t.type!==Je.Identifier||o.type!==Je.Identifier)return;let s=t.name,i=o.name,l=n.ignorePrefixes||[],c=oi(s,l),a=oi(i,l);if(c===""){if(!a.startsWith("set")){let f=`set${bt(s)}`;e.report({node:o,messageId:"incorrectSetterName",data:{expectedName:bt(s),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:f},fix:y=>y.replaceText(o,f)}]})}return}let u=Ua(c);a!==u&&e.report({node:o,messageId:"incorrectSetterName",data:{expectedName:bt(c),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:u},fix:f=>f.replaceText(o,u)}]})}}}});import{AST_NODE_TYPES as de}from"@typescript-eslint/utils";import{z as Qe}from"zod/v4";var za=Qe.object({name:Qe.string(),defaults:Qe.array(Qe.unknown())}),Wa=Qe.object({functions:Qe.array(za)});function xt(e,n){if(e===n)return!0;if(e===null||n===null||e===void 0||n===void 0)return e===n;if(typeof e!=typeof n||typeof e!="object"||Array.isArray(e)!==Array.isArray(n))return!1;if(Array.isArray(e)&&Array.isArray(n))return e.length!==n.length?!1:e.every((o,s)=>xt(o,n[s]));let r=Object.keys(e),t=Object.keys(n);if(r.length!==t.length)return!1;for(let o of r){if(!t.includes(o))return!1;let s=Object.getOwnPropertyDescriptor(e,o),i=Object.getOwnPropertyDescriptor(n,o);if(!s||!i)return!1;let l=s.value,c=i.value;if(!xt(l,c))return!1}return!0}function Ja(e,n){let r=new Set;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return r;for(let t in e){if(!(t in n))continue;let o=Object.getOwnPropertyDescriptor(e,t),s=Object.getOwnPropertyDescriptor(n,t);o&&s&&xt(o.value,s.value)&&r.add(t)}return r}function si(e){if(e.type===de.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case de.Literal:return e.value;case de.ObjectExpression:{let n={};for(let r of e.properties)r.type===de.Property&&r.key.type===de.Identifier&&!r.computed&&(r.value.type===de.Literal?n[r.key.name]=r.value.value:r.value.type===de.ObjectExpression?n[r.key.name]=si(r.value):n[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return n}case de.ArrayExpression:return e.elements.map(n=>{if(!(!n||n.type===de.SpreadElement))return n.type===de.Literal?n.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function Va(e){return e.type===de.Identifier?e.name:e.type===de.MemberExpression&&e.property.type===de.Identifier&&!e.computed?e.property.name:null}var Fn=X({name:"no-redundant-function-params",meta:{type:"suggestion",docs:{description:"Disallow calling functions with redundant default parameters"},messages:{redundantParams:"Function call has redundant parameters matching its default values and can be removed: {{details}}"},fixable:"code",schema:[U(Wa)]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Map;for(let t of n.functions)r.set(t.name,t.defaults);return{CallExpression(t){let o=Va(t.callee);if(!o)return;let s=r.get(o);if(!s)return;let i=t.arguments;if(i.length===0)return;let l=-1,c=!1,a=new Map,u=new Set,f=new Map,y=[];for(let m=0;m<i.length;m++){if(m>=s.length){l=m;continue}let E=s[m],x=i[m];if(!x||x.type===de.SpreadElement){l=m;continue}let S=si(x);if(E===void 0){l=m;continue}if(xt(S,E)){x.type===de.ObjectExpression?(u.add(m),y.push({type:"object",position:m+1})):(f.set(m,S),y.push({type:"simple",position:m+1,value:S}));continue}if(x.type===de.ObjectExpression&&x.properties.length===0&&typeof E=="object"&&E!==null&&Object.keys(E).length>0){u.add(m),y.push({type:"object",position:m+1});continue}let I=Ja(S,E);if(I.size>0){let A=typeof E=="object"&&E!==null?Object.keys(E).length:0;if(x.type===de.ObjectExpression&&x.properties.length===I.size&&x.properties.length===A){u.add(m),y.push({type:"object",position:m+1});continue}else c=!0,a.set(m,I),y.push({type:"partialObject",position:m+1,redundantProperties:Array.from(I)}),l=m}else l=m}if(l<i.length-1||c||u.size>0){let m=function(){let x=[];for(let S of y)if(S.type==="simple")x.push(`Param ${S.position} with value ${JSON.stringify(S.value)}`);else if(S.type==="object")x.push(`Param ${S.position} (object)`);else{let I=S.redundantProperties||[],A=s?s[S.position-1]:void 0;if(typeof A=="object"&&A!==null){let T=A;for(let h of I)if(h in T){let b=Object.getOwnPropertyDescriptor(T,h);b&&x.push(`Param ${S.position} property "${h}" with value ${JSON.stringify(b.value)}`)}}}return{messageId:"redundantParams",data:{details:x.join(", ")}}};var C=m;let E=m();e.report({node:t,messageId:E.messageId,data:E.data,fix(x){let S=[];if(c)for(let[A,T]of a){let h=i[A];if(h&&h.type===de.ObjectExpression){let b=[];for(let k of h.properties)k.type===de.Property&&k.key.type===de.Identifier&&!k.computed&&T.has(k.key.name)||b.push(k);let w=b.map(k=>e.sourceCode.getText(k));S.push(x.replaceText(h,`{ ${w.join(", ")} }`))}}let I=-1;for(let A=i.length-1;A>=0;A--)if(!u.has(A)&&A<=l){I=A;break}if(I<i.length-1)if(I===-1){let A=e.sourceCode.getTokenAfter(t.callee),T=e.sourceCode.getLastToken(t);A&&T&&S.push(x.replaceTextRange([A.range[1],T.range[0]],""))}else{let A=i[I],T=e.sourceCode.getLastToken(t);T&&A&&S.push(x.replaceTextRange([A.range[1],T.range[0]],""))}return S.length>0?S:null}})}}}}});import{AST_NODE_TYPES as ve}from"@typescript-eslint/utils";function Xa(e){let n=e.parent;for(;n;){if(n.type===ve.AwaitExpression||n.type===ve.MemberExpression&&n.object===e&&n.property.type===ve.Identifier&&n.property.name==="then"||n.type===ve.ArrowFunctionExpression&&n.body===e)return!0;if(n.type===ve.ArrayExpression&&n.parent.type===ve.CallExpression){let r=n.parent;if(r.callee.type===ve.MemberExpression&&r.callee.object.type===ve.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===ve.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(n.parent)n=n.parent;else break}return!1}function Ba(e){let{callee:n}=e;return n.type===ve.Identifier&&n.name==="require"||n.type===ve.MemberExpression&&n.object.type===ve.Identifier&&n.object.name==="require"}var vn=X({name:"no-sync-dynamic-import",meta:{type:"problem",docs:{description:"Disallow synchronous dynamic imports and require statements, only allow async dynamic imports with await"},messages:{syncDynamicImport:"Synchronous dynamic import() is not allowed. Use regular import statement or await import() for dynamic imports.",requireNotAllowed:"require() statements are not allowed. Use ES6 import statements instead."},schema:[]},defaultOptions:[],create(e){return{ImportExpression(n){Xa(n)||e.report({node:n,messageId:"syncDynamicImport"})},TSImportType(n){e.report({node:n,messageId:"syncDynamicImport"})},CallExpression(n){Ba(n)&&e.report({node:n,messageId:"requireNotAllowed"})}}}});import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";import{z as kn}from"zod/v4";var Ha=kn.object({mainComponentRegex:kn.string().optional(),mainComponentSelector:kn.string().optional()}),Ya=/^[A-Z][A-Za-z0-9]*$/,Pn=X({name:"sort-react-components-and-styles",meta:{type:"suggestion",docs:{description:"Sort React components and styles with styles placed above their first usage"},fixable:"code",schema:[U(Ha)],messages:{stylesShouldBeAboveUsage:"Style definitions should be placed above the first component that uses them",mainComponentShouldBeFirst:"Main component should be placed before other components"}},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=n.mainComponentRegex?new RegExp(n.mainComponentRegex):void 0,o=n.mainComponentSelector;if(!e.filename.endsWith(".tsx"))return{};let i=new Set,l=new Map,c=[],a=[],u=new Set;function f(d){let g=d.node;if(g.type===L.VariableDeclaration){for(let F of g.declarations)if(F.id.type===L.Identifier&&F.id.name===d.name&&F.init)return F.init}if(g.type===L.ExportNamedDeclaration){let F=g.declaration;if(F&&F.type===L.VariableDeclaration){for(let P of F.declarations)if(P.id.type===L.Identifier&&P.id.name===d.name&&P.init)return P.init}}return null}function y(d){let g=new Set;return Pe(d,F=>(F.type===L.Identifier&&F.name!=="styled"&&F.name!=="css"&&g.add(F.name),!1),r),g}function C(d){return Ya.test(d)}function m(d){if(d.type!==L.CallExpression)return!1;let g=d.callee;return g.type===L.Identifier?g.name==="memo"||g.name==="forwardRef":g.type===L.MemberExpression&&g.property.type===L.Identifier?g.property.name==="memo"||g.property.name==="forwardRef":!1}function E(d){if(d.type===L.JSXElement||d.type===L.JSXFragment)return!0;if(d.type===L.BlockStatement){for(let g of d.body)if(g.type===L.ReturnStatement&&g.argument)return E(g.argument)}if(d.type===L.ArrayExpression){for(let g of d.elements)if(g&&(g.type===L.JSXElement||g.type===L.JSXFragment))return!0}return!1}function x(d){if(d.type!==L.ArrowFunctionExpression)return!1;let g=d.body;if(g.type===L.ArrowFunctionExpression){let F=g.body;if(E(F))return!0}return!1}function S(d){if(d.type===L.TaggedTemplateExpression){let g=d.tag;if(g.type===L.MemberExpression&&g.object.type===L.Identifier&&g.object.name==="styled")return!0;if(g.type===L.CallExpression){let F=g.callee;if(F.type===L.Identifier&&F.name==="styled")return!0}}return!1}function I(d){if(d.type===L.TaggedTemplateExpression){let g=d.tag;if(g.type===L.Identifier&&g.name==="css")return!0}return!1}function A(d,g){if(d.id.type!==L.Identifier)return;let F=d.id.name,P=d.init;if(P){if(S(P)||I(P)){a.push({node:g,name:F});return}if((C(F)||P.type===L.ArrowFunctionExpression)&&(P.type===L.ArrowFunctionExpression||P.type===L.FunctionExpression||m(P))){if(P.type===L.ArrowFunctionExpression||P.type===L.FunctionExpression){if(E(P.body)){i.add(F);return}}else if(m(P)){i.add(F);return}}P.type===L.Identifier&&l.set(F,P.name),C(F)||x(P)&&i.add(F)}}function T(d){return d.type===L.ExportDefaultDeclaration||d.type===L.ExportNamedDeclaration}function h(d){if(d.type===L.FunctionDeclaration)return d.id?d.id.name:null;if(d.type===L.VariableDeclaration){let g=d.declarations[0];if(g&&g.id.type===L.Identifier)return g.id.name}if(d.type===L.ExportDefaultDeclaration){let g=d.declaration;if(g.type===L.FunctionDeclaration)return g.id?g.id.name:"default";if(g.type===L.Identifier)return g.name}if(d.type===L.ExportNamedDeclaration){let g=d.declaration;if(g&&g.type===L.FunctionDeclaration)return g.id?g.id.name:null;if(g&&g.type===L.VariableDeclaration){let F=g.declarations[0];if(F&&F.id.type===L.Identifier)return F.id.name}}return null}function b(d,g){return o?u.has(d):t?t.test(g):T(d)}function w(d){let g=new Set;Pe(d.node,F=>{if(F.type===L.Identifier)for(let P of a)P.name===F.name&&(g.add(P.name),(P.firstUsagePosition===void 0||F.range[0]<P.firstUsagePosition)&&(P.firstUsagePosition=F.range[0]));if(F.type===L.JSXElement){let P=F.openingElement;if(P.name.type===L.JSXIdentifier)for(let j of a)j.name===P.name.name&&(g.add(j.name),(j.firstUsagePosition===void 0||P.name.range[0]<j.firstUsagePosition)&&(j.firstUsagePosition=P.name.range[0]))}return!1},r),d.usedStyles=g}function k(d){if(d.type===L.VariableDeclaration){for(let g of d.declarations)A(g,d);return}if(d.type===L.FunctionDeclaration){C(d.id.name)&&E(d.body)&&i.add(d.id.name);return}if(d.type===L.ExportNamedDeclaration&&d.declaration){let g=d.declaration;if(g.type===L.VariableDeclaration){for(let F of g.declarations)A(F,d);return}if(g.type===L.FunctionDeclaration&&g.id){C(g.id.name)&&E(g.body)&&i.add(g.id.name);return}}if(d.type===L.ExportDefaultDeclaration){let g=d.declaration;g.type===L.Identifier&&i.add(g.name),(g.type===L.FunctionDeclaration||g.type===L.ArrowFunctionExpression||g.type===L.FunctionExpression)&&(g.type===L.FunctionDeclaration?g.id?i.add(g.id.name):i.add("default"):E(g.body)&&i.add("default"))}}function N(d,g=new Set){if(i.has(d))return!0;if(g.has(d))return!1;g.add(d);let F=l.get(d);return F?N(F,g):!1}let p={};return o&&(p[o]=d=>{let g=d;for(;g.parent&&g.parent.type!==L.Program;)g=g.parent;g.parent&&(g.type===L.VariableDeclaration||g.type===L.FunctionDeclaration||g.type===L.ExportNamedDeclaration||g.type===L.ExportDefaultDeclaration)&&u.add(g)}),p["Program:exit"]=d=>{let g=0;for(let D of d.body){if(D.type===L.ImportDeclaration){g+=1;continue}break}for(let D of d.body)k(D);for(let D of d.body){let Z=h(D);if(Z&&N(Z)){let q=b(D,Z);c.push({node:D,name:Z,isMainComponent:q,usedStyles:new Set,isExported:T(D)})}}if(!o&&t&&!c.some(D=>D.isMainComponent))for(let D of c)D.isExported&&(D.isMainComponent=!0);for(let D of c)w(D);let F=new Set;for(let D of a)F.add(D.name);let P=new Map;for(let D=0;D<d.body.length;D+=1){let Z=d.body[D];for(let q of a)q.node===Z&&P.set(q.name,D)}let j=new Map;for(let D of a){let Z=f(D),q=new Set;if(Z){let ce=y(Z);for(let ue of ce)F.has(ue)&&ue!==D.name&&q.add(ue)}j.set(D.name,q)}let V=new Map;for(let D of a){let Z=j.get(D.name);if(!Z)continue;let q=P.get(D.name);if(q!==void 0)for(let ce of Z){let ue=V.get(ce);(ue===void 0||q<ue)&&V.set(ce,q)}}let G=[];for(let D of a){if(D.firstUsagePosition===void 0)continue;let Z=d.body.indexOf(D.node),q=-1;for(let Ee of c){if(!Ee.usedStyles.has(D.name))continue;let xe=d.body.indexOf(Ee.node);(q===-1||xe<q)&&(q=xe)}let ce=V.get(D.name);if(ce!==void 0&&(q===-1||ce<q)&&(q=ce),q===-1)continue;let ue=-1;for(let Ee of c){let xe=d.body.indexOf(Ee.node);xe<q&&xe>ue&&(ue=xe)}let Ae=Z<q,Ue=Z>ue,ge=-1,tt=j.get(D.name);if(tt)for(let Ee of tt){let xe=P.get(Ee);xe!==void 0&&xe>ge&&(ge=xe)}let Ye=Z>ge;if(!(Ae&&Ue&&Ye)){let Ee=ue+1;if(ge+1>Ee&&(Ee=ge+1),Ee<g&&(Ee=g),Ee>q)continue;G.push({style:D,targetPosition:Ee})}}let Y=null;if(c.length>1){let D=c.map(q=>({c:q,idx:d.body.indexOf(q.node)})).sort((q,ce)=>q.idx-ce.idx)[0]?.c,Z=c.find(q=>q.isMainComponent)||null;D&&Z&&D.node!==Z.node&&(Y={component:Z,targetBefore:D.node})}if(G.length>0||Y){let D=G[0]?.style.node||Y?.component.node||d,Z=G.length>0?"stylesShouldBeAboveUsage":"mainComponentShouldBeFirst";e.report({node:D,messageId:Z,fix:R(G,Y,d.body)})}},p;function R(d,g,F){return function*(P){d.sort((V,G)=>V.targetPosition-G.targetPosition);for(let{style:V}of d){let G=r.getCommentsBefore(V.node),Y=V.node.range[0],D=V.node.range[1];G.length>0&&G[0]&&(Y=G[0].range[0]),Y===V.node.range[0]&&r.text.slice(0,Y).trim().length===0&&(Y=0),yield P.removeRange([Y,D])}let j=new Map;for(let V of d){let G=j.get(V.targetPosition)||[];G.push(V),j.set(V.targetPosition,G)}for(let[V,G]of j){let Y=F[V];if(!Y)continue;let D=r.getCommentsBefore(Y),Z=D.length>0&&D[0]?D[0].range[0]:Y.range[0],q=[];for(let{style:ce}of G){let ue=r.getCommentsBefore(ce.node),Ae=r.getText(ce.node);ue.length>0&&(Ae=`${ue.map(ge=>r.getText(ge)).join(`
47
47
  `)}
48
48
  ${Ae}`),q.push(Ae)}yield P.insertTextBeforeRange([Z,Z],`${q.join(`
49
49
 
50
50
  `)}
51
51
 
52
- `)}if(g){let{component:J,targetBefore:G}=g,Y=r.getCommentsBefore(J.node),D=J.node.range[0],Z=J.node.range[1];Y.length>0&&Y[0]&&(D=Y[0].range[0]),D===J.node.range[0]&&r.text.slice(0,D).trim().length===0&&(D=0);let q=r.getCommentsBefore(G),ce=q.length>0&&q[0]?q[0].range[0]:G.range[0],ue=(()=>{let Ae=r.getText(J.node);return Y.length>0&&(Ae=`${Y.map(ge=>r.getText(ge)).join(`
52
+ `)}if(g){let{component:V,targetBefore:G}=g,Y=r.getCommentsBefore(V.node),D=V.node.range[0],Z=V.node.range[1];Y.length>0&&Y[0]&&(D=Y[0].range[0]),D===V.node.range[0]&&r.text.slice(0,D).trim().length===0&&(D=0);let q=r.getCommentsBefore(G),ce=q.length>0&&q[0]?q[0].range[0]:G.range[0],ue=(()=>{let Ae=r.getText(V.node);return Y.length>0&&(Ae=`${Y.map(ge=>r.getText(ge)).join(`
53
53
  `)}
54
54
  ${Ae}`),Ae})();yield P.removeRange([D,Z]),yield P.insertTextBeforeRange([ce,ce],`${ue}
55
- `)}}}}});import{AST_NODE_TYPES as Ha,ESLintUtils as Ya}from"@typescript-eslint/utils";import oi from"typescript";import{z as qa}from"zod/v4";var Za=qa.object({}),Pn=H({name:"no-unnecessary-void-on-promise",meta:{type:"suggestion",docs:{description:"Disallow void operator on non-Promise function calls to avoid unnecessary void keywords added by no-floating-promises"},messages:{unnecessaryVoid:"Unnecessary void operator on non-Promise function call",removeVoid:"Remove void operator"},hasSuggestions:!0,schema:[z(Za)]},defaultOptions:[{}],create(e){let n=Ya.getParserServices(e,!0),r=n.program?.getTypeChecker();if(!r||!n.program)throw new Error("TypeScript services or program not available");function t(o,s){if(o.flags&oi.TypeFlags.Any||o.flags&oi.TypeFlags.Unknown)return!1;let i=o.getProperty("then");return i?s.getTypeOfSymbol(i).getCallSignatures().length>0:!1}return{UnaryExpression(o){if(o.operator!=="void"||o.argument.type!==Ha.CallExpression)return;let s=n.esTreeNodeToTSNodeMap.get(o.argument),i=r.getTypeAtLocation(s);if(!t(i,r)){let c=e.sourceCode.getText(o.argument);e.report({node:o,messageId:"unnecessaryVoid",suggest:[{messageId:"removeVoid",fix(a){return a.replaceText(o,c)}}]})}}}}});import{AST_NODE_TYPES as Ce}from"@typescript-eslint/utils";import{z as lt}from"zod/v4";var Ga=lt.object({functions:lt.array(lt.string()).optional(),selectors:lt.array(lt.string()).optional()});function si(e){let n=e.parent;for(;n;){if(n.type===Ce.FunctionDeclaration||n.type===Ce.FunctionExpression||n.type===Ce.ArrowFunctionExpression)return!0;n=n.parent}return!1}function ai(e){if(e.type===Ce.TaggedTemplateExpression){let{tag:r}=e;return r.type===Ce.Identifier?r.name:r.type===Ce.MemberExpression&&r.property.type===Ce.Identifier?r.property.name:null}let{callee:n}=e;return n.type===Ce.Identifier?n.name:n.type===Ce.MemberExpression&&n.property.type===Ce.Identifier?n.property.name:null}var On=H({name:"require-lazy-execution",meta:{type:"problem",docs:{description:"Require certain function calls to be executed lazily (inside functions, not at module level)"},messages:{moduleLevel:'Function "{{ functionName }}" must only be called inside functions or getters, not at module level'},schema:[z(Ga)]},defaultOptions:[{functions:[],selectors:[]}],create(e){let[n]=e.options,r=new Set(n.functions??[]),t=n.selectors??[];function o(i){if(si(i))return;let l=ai(i);l&&r.has(l)&&e.report({node:i,messageId:"moduleLevel",data:{functionName:l}})}let s={CallExpression(i){i.type===Ce.CallExpression&&o(i)},TaggedTemplateExpression(i){i.type===Ce.TaggedTemplateExpression&&o(i)}};for(let i of t)s[i]=l=>{if(l.type!==Ce.CallExpression&&l.type!==Ce.TaggedTemplateExpression||si(l))return;let c=ai(l);c&&e.report({node:l,messageId:"moduleLevel",data:{functionName:c}})};return s}});import{AST_NODE_TYPES as Qe}from"@typescript-eslint/utils";function Ka(e,n){let{body:r}=e;if(r.type!==Qe.BlockStatement)return n.getText(r);let t=r.body[0];return!t||t.type!==Qe.ReturnStatement?"":t.argument?n.getText(t.argument):"undefined"}var Nn=H({name:"no-unnecessary-iife",meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary immediately invoked function expressions"},messages:{unnecessaryIife:"Unnecessary IIFE. Can be simplified to the returned expression."},schema:[]},defaultOptions:[],create(e){let n=e.sourceCode;return{CallExpression(r){let{callee:t,arguments:o}=r;if(o.length>0||t.type!==Qe.FunctionExpression&&t.type!==Qe.ArrowFunctionExpression||t.async||t.params.length>0)return;let{body:s}=t;if(s.type===Qe.BlockStatement){if(s.body.length!==1)return;let c=s.body[0];if(!c||c.type!==Qe.ReturnStatement)return}if(n.getCommentsInside(t).length>0)return;let l=Ka(t,n);e.report({node:r,messageId:"unnecessaryIife",fix:c=>c.replaceText(r,l)})}}}});var li={[en.name]:en.rule,[jt.name]:jt.rule,[Dt.name]:Dt.rule,"rules-of-hooks":ei,"exhaustive-deps":Vn,"require-description":Br.rule,[Lt.name]:Lt.rule,[_t.name]:_t.rule,[rn.name]:rn.rule,[Ct.name]:Ct.rule,[Nt.name]:Nt.rule,[zt.name]:zt.rule,[nt.name]:nt.rule,[ln.name]:ln.rule,[$t.name]:$t.rule,[Mt.name]:Mt.rule,[Wt.name]:Wt.rule,[At.name]:At.rule,[mn.name]:mn.rule,[fn.name]:fn.rule,[gn.name]:gn.rule,[Pt.name]:Pt.rule,[Bt.name]:Bt.rule,[Ht.name]:Ht.rule,[Yt.name]:Yt.rule,[Gt.name]:Gt.rule,[Kt.name]:Kt.rule,[qt.name]:qt.rule,[Zt.name]:Zt.rule,[sn.name]:sn.rule,[Jt.name]:Jt.rule,[Vt.name]:Vt.rule,[xn.name]:xn.rule,[tn.name]:tn.rule,[Sn.name]:Sn.rule,[bn.name]:bn.rule,[Cn.name]:Cn.rule,[In.name]:In.rule,[wn.name]:wn.rule,[Rn.name]:Rn.rule,[Fn.name]:Fn.rule,[kn.name]:kn.rule,[Pn.name]:Pn.rule,[On.name]:On.rule,[nt.name]:nt.rule,[Nn.name]:Nn.rule};var _f={rules:li};export{_f as extendedLintPlugin};
55
+ `)}}}}});import{AST_NODE_TYPES as qa,ESLintUtils as Za}from"@typescript-eslint/utils";import ai from"typescript";import{z as Ga}from"zod/v4";var Ka=Ga.object({}),On=X({name:"no-unnecessary-void-on-promise",meta:{type:"suggestion",docs:{description:"Disallow void operator on non-Promise function calls to avoid unnecessary void keywords added by no-floating-promises"},messages:{unnecessaryVoid:"Unnecessary void operator on non-Promise function call",removeVoid:"Remove void operator"},hasSuggestions:!0,schema:[U(Ka)]},defaultOptions:[{}],create(e){let n=Za.getParserServices(e,!0),r=n.program?.getTypeChecker();if(!r||!n.program)throw new Error("TypeScript services or program not available");function t(o,s){if(o.flags&ai.TypeFlags.Any||o.flags&ai.TypeFlags.Unknown)return!1;let i=o.getProperty("then");return i?s.getTypeOfSymbol(i).getCallSignatures().length>0:!1}return{UnaryExpression(o){if(o.operator!=="void"||o.argument.type!==qa.CallExpression)return;let s=n.esTreeNodeToTSNodeMap.get(o.argument),i=r.getTypeAtLocation(s);if(!t(i,r)){let c=e.sourceCode.getText(o.argument);e.report({node:o,messageId:"unnecessaryVoid",suggest:[{messageId:"removeVoid",fix(a){return a.replaceText(o,c)}}]})}}}}});import{AST_NODE_TYPES as Ce}from"@typescript-eslint/utils";import{z as pt}from"zod/v4";var Qa=pt.object({functions:pt.array(pt.string()).optional(),selectors:pt.array(pt.string()).optional()});function li(e){let n=e.parent;for(;n;){if(n.type===Ce.FunctionDeclaration||n.type===Ce.FunctionExpression||n.type===Ce.ArrowFunctionExpression)return!0;n=n.parent}return!1}function pi(e){if(e.type===Ce.TaggedTemplateExpression){let{tag:r}=e;return r.type===Ce.Identifier?r.name:r.type===Ce.MemberExpression&&r.property.type===Ce.Identifier?r.property.name:null}let{callee:n}=e;return n.type===Ce.Identifier?n.name:n.type===Ce.MemberExpression&&n.property.type===Ce.Identifier?n.property.name:null}var Nn=X({name:"require-lazy-execution",meta:{type:"problem",docs:{description:"Require certain function calls to be executed lazily (inside functions, not at module level)"},messages:{moduleLevel:'Function "{{ functionName }}" must only be called inside functions or getters, not at module level'},schema:[U(Qa)]},defaultOptions:[{functions:[],selectors:[]}],create(e){let[n]=e.options,r=new Set(n.functions??[]),t=n.selectors??[];function o(i){if(li(i))return;let l=pi(i);l&&r.has(l)&&e.report({node:i,messageId:"moduleLevel",data:{functionName:l}})}let s={CallExpression(i){i.type===Ce.CallExpression&&o(i)},TaggedTemplateExpression(i){i.type===Ce.TaggedTemplateExpression&&o(i)}};for(let i of t)s[i]=l=>{if(l.type!==Ce.CallExpression&&l.type!==Ce.TaggedTemplateExpression||li(l))return;let c=pi(l);c&&e.report({node:l,messageId:"moduleLevel",data:{functionName:c}})};return s}});import{AST_NODE_TYPES as et}from"@typescript-eslint/utils";function el(e,n){let{body:r}=e;if(r.type!==et.BlockStatement)return n.getText(r);let t=r.body[0];return!t||t.type!==et.ReturnStatement?"":t.argument?n.getText(t.argument):"undefined"}var Dn=X({name:"no-unnecessary-iife",meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary immediately invoked function expressions"},messages:{unnecessaryIife:"Unnecessary IIFE. Can be simplified to the returned expression."},schema:[]},defaultOptions:[],create(e){let n=e.sourceCode;return{CallExpression(r){let{callee:t,arguments:o}=r;if(o.length>0||t.type!==et.FunctionExpression&&t.type!==et.ArrowFunctionExpression||t.async||t.params.length>0)return;let{body:s}=t;if(s.type===et.BlockStatement){if(s.body.length!==1)return;let c=s.body[0];if(!c||c.type!==et.ReturnStatement)return}if(n.getCommentsInside(t).length>0)return;let l=el(t,n);e.report({node:r,messageId:"unnecessaryIife",fix:c=>c.replaceText(r,l)})}}}});import{z as He}from"zod/v4";var tl="no-restricted-comments",nl=He.object({regex:He.string().optional(),includes:He.string().optional(),message:He.string().optional(),autoFix:He.boolean().optional()}),rl=He.object({patterns:He.array(nl)}),jn=X({name:tl,meta:{type:"problem",docs:{description:"Disallow comments matching specific patterns"},fixable:"code",hasSuggestions:!0,schema:[U(rl)],messages:{restrictedComment:"Comment matches restricted pattern '{{pattern}}'",restrictedCommentWithMessage:"{{message}}",removeComment:"Remove this comment"}},defaultOptions:[{patterns:[]}],create(e,[n]){let r=e.sourceCode,t=new Map;function o(i){let l=t.get(i);return l||(l=new RegExp(i),t.set(i,l)),l}function s(i,l){return l.regex?o(l.regex).test(i):l.includes?i.includes(l.includes):!1}return{Program(){let i=r.getAllComments();for(let c of i)for(let a of n.patterns)if(s(c.value,a)){let f=function(y){return y.remove(c)};var l=f;let u=a.regex??a.includes??"";a.message?e.report({loc:c.loc,messageId:"restrictedCommentWithMessage",data:{message:a.message},fix:a.autoFix?f:void 0,suggest:a.autoFix?void 0:[{messageId:"removeComment",fix:f}]}):e.report({loc:c.loc,messageId:"restrictedComment",data:{pattern:u},fix:a.autoFix?f:void 0,suggest:a.autoFix?void 0:[{messageId:"removeComment",fix:f}]});break}}}}});var ci={[tn.name]:tn.rule,[Lt.name]:Lt.rule,[jt.name]:jt.rule,"rules-of-hooks":ni,"exhaustive-deps":Xn,"require-description":Yr.rule,[Mt.name]:Mt.rule,[$t.name]:$t.rule,[on.name]:on.rule,[It.name]:It.rule,[Dt.name]:Dt.rule,[Wt.name]:Wt.rule,[rt.name]:rt.rule,[pn.name]:pn.rule,[Ut.name]:Ut.rule,[_t.name]:_t.rule,[Jt.name]:Jt.rule,[wt.name]:wt.rule,[yn.name]:yn.rule,[mn.name]:mn.rule,[Sn.name]:Sn.rule,[Ot.name]:Ot.rule,[Ht.name]:Ht.rule,[Yt.name]:Yt.rule,[qt.name]:qt.rule,[Kt.name]:Kt.rule,[Qt.name]:Qt.rule,[Zt.name]:Zt.rule,[Gt.name]:Gt.rule,[an.name]:an.rule,[Xt.name]:Xt.rule,[Vt.name]:Vt.rule,[Cn.name]:Cn.rule,[nn.name]:nn.rule,[Tn.name]:Tn.rule,[xn.name]:xn.rule,[In.name]:In.rule,[An.name]:An.rule,[Rn.name]:Rn.rule,[Fn.name]:Fn.rule,[vn.name]:vn.rule,[Pn.name]:Pn.rule,[On.name]:On.rule,[Nn.name]:Nn.rule,[rt.name]:rt.rule,[Dn.name]:Dn.rule,[jn.name]:jn.rule};var Hf={rules:ci};export{Hf as extendedLintPlugin};