@ls-stack/extended-lint 0.72.0 → 0.73.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 ue}from"@typescript-eslint/utils";import{z as F}from"zod/v4";import{ESLintUtils as Qr}from"@typescript-eslint/utils";import*as wn from"zod/v4";function _(e){let r=Qr.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function $(e){return wn.toJSONSchema(e)}var ei=F.object({disallow:F.array(F.object({selector:F.string(),message:F.string(),replace:F.optional(F.union([F.string(),F.object({regex:F.string(),with:F.string()})])),replaceType:F.optional(F.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:F.optional(F.array(F.object({fn:F.string(),withArgs:F.optional(F.array(F.object({atIndex:F.number(),value:F.union([F.string(),F.number(),F.boolean()])}))),message:F.string(),replaceWith:F.optional(F.string()),ignoreRegex:F.optional(F.string())}))),__dev_simulateFileName:F.optional(F.string()),mustMatchSyntax:F.optional(F.array(F.object({includeRegex:F.string(),mustCallFn:F.optional(F.array(F.object({anyCall:F.array(F.object({fn:F.string(),withArgs:F.array(F.object({atIndex:F.number(),literal:F.union([F.string(),F.number(),F.boolean()])}))})),message:F.optional(F.string())}))),mustMatchSelector:F.optional(F.array(F.object({selector:F.string(),message:F.string()}))),mustHaveExport:F.optional(F.array(F.object({name:F.string(),type:F.enum(["function","variable","any"]).default("any"),message:F.string()})))})))}),gt=_({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[$(ei)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:s,disallow:o,disallowFnCalls:i}=t,p=s??e.filename,a=[],c=new Map,g=new Set,S=new Map,l=new Set,E=new Map;function f(u){for(let d of u.specifiers)d.type===ue.ImportSpecifier&&d.imported.type===ue.Identifier&&d.imported.name!==d.local.name&&E.set(d.local.name,d.imported.name)}function h(u){if(u.declaration){if(u.declaration.type===ue.FunctionDeclaration&&u.declaration.id){let d=u.declaration.id.name;for(let A of Array.from(l)){let[I,R]=A.split(":");I===d&&(R==="function"||R==="any")&&l.delete(A)}}else if(u.declaration.type===ue.VariableDeclaration){for(let d of u.declaration.declarations)if(d.id.type===ue.Identifier){let A=d.id.name;for(let I of Array.from(l)){let[R,v]=I.split(":");R===A&&(v==="variable"||v==="any")&&l.delete(I)}}}}for(let d of u.specifiers)if(d.exported.type===ue.Identifier){let A=d.exported.name;for(let I of Array.from(l)){let[R,v]=I.split(":");R===A&&v==="any"&&l.delete(I)}}}function T(u){u.id.type===ue.Identifier&&u.init?.type===ue.Identifier&&E.set(u.id.name,u.init.name)}function m(u){return E.get(u)??u}function b(u,d){return m(u)===d||u===d}for(let{includeRegex:u,mustCallFn:d,mustMatchSelector:A,mustHaveExport:I}of n??[]){let v=function(J){let Y=J;for(let{name:te,value:ee}of R??[])Y=Y.replaceAll(te,ee);return Y};var x=v;let R=ti(p,new RegExp(u));if(R){for(let{anyCall:J,message:Y}of d??[]){let te=`Expected file to call the function: ${J.map(({fn:ee})=>ee).join(" or ")}`;g.add(te),a.push(ee=>{let{callee:V}=ee;if(V.type===ue.Identifier){for(let{fn:me,withArgs:xe}of J)if(V.name===me){g.delete(te);for(let ce of xe){let Ce=ee.arguments[ce.atIndex],de=typeof ce.literal=="string"?v(ce.literal):ce.literal;if(!Ce){e.report({node:ee,messageId:"default",data:{message:`Missing argument with value "${de}" at index ${ce.atIndex}${Y?`: ${v(Y)}`:""}`}});continue}if(Ce.type!==ue.Literal){e.report({node:Ce,messageId:"default",data:{message:`Argument at position ${ce.atIndex} should the literal "${de}"${Y?`: ${v(Y)}`:""}`}});continue}Ce.value!==de&&e.report({node:Ce,messageId:"default",data:{message:`Argument should have the value "${de}"${Y?`: ${v(Y)}`:""}`},fix:Le=>Le.replaceText(Ce,typeof de=="string"?`'${de}'`:String(de))})}break}}})}for(let{selector:J,message:Y}of A??[])S.set(J,v(Y)),c.set(v(J),()=>{S.delete(J)});for(let{name:J,type:Y,message:te}of I??[]){let ee=v(J),V=v(te);l.add(`${ee}:${Y}:${V}`)}}}for(let{fn:u,withArgs:d,message:A,replaceWith:I,ignoreRegex:R}of i??[])R&&new RegExp(R).test(p)||a.push(v=>{let{callee:J}=v;if(J.type!==ue.Identifier||!b(J.name,u))return;if(d)for(let te of d){let ee=v.arguments[te.atIndex];if(!ee){e.report({node:v,messageId:"default",data:{message:`Missing argument with value "${te.value}" at index ${te.atIndex}: ${A}`}});return}if(ee.type!==ue.Literal||ee.value!==te.value)return}let Y=te=>I?te.replaceText(v,I):null;e.report({node:v,messageId:"default",data:{message:A},suggest:I?[{messageId:"default",data:{message:`Replace with "${I}"`},fix:Y}]:void 0})});function C(u,d){let A=r[u];A?r[u]=I=>{A(I),d(I)}:r[u]=d}for(let{selector:u,message:d,replace:A,replaceType:I="suggestion"}of o??[]){if(u==="CallExpression"){a.push(R=>{y(A,R,d,I)});continue}r[u]=R=>{y(A,R,d,I)}}if(c.size>0)for(let[u,d]of c)C(u,d);return a.length>0&&(r.CallExpression=u=>{if(u.type===ue.CallExpression)for(let d of a)d(u)}),r.ImportDeclaration=u=>{u.type===ue.ImportDeclaration&&f(u)},r.ExportNamedDeclaration=u=>{u.type===ue.ExportNamedDeclaration&&h(u)},r.VariableDeclarator=u=>{u.type===ue.VariableDeclarator&&T(u)},r["Program:exit"]=u=>{for(let d of g)e.report({node:u,messageId:"default",data:{message:d}});for(let[,d]of S)e.report({node:u,messageId:"default",data:{message:d}});for(let d of l){let[A,I,R]=d.split(":");e.report({node:u,messageId:"default",data:{message:`Missing required export "${A}" of type ${I}: ${R}`}})}},r;function y(u,d,A,I){let R=v=>{if(!u)return null;if(typeof u=="string")return v.replaceText(d,u);{let J=new RegExp(u.regex),Y=e.sourceCode.getText(d);return v.replaceText(d,Y.replace(J,u.with))}};e.report({node:d,messageId:"default",data:{message:A},fix:u&&I==="autofix"?R:void 0,suggest:u&&I==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof u=="string"?u:u.with}"`},fix:R}]:void 0})}}});function ti(e,t){let r=[],n=t.exec(e);if(!n)return null;let[s,...o]=n;r.push({name:"$0_lowercase",value:s.toLowerCase()}),r.push({name:"$0_capitalize",value:Rn(s)}),r.push({name:"$0_uncapitalize",value:Pn(s)}),r.push({name:"$0",value:s});for(let i=0;i<o.length;i++){let p=`$${i+1}`,a=o[i];a!==void 0&&(r.push({name:`${p}_lowercase`,value:a.toLowerCase()}),r.push({name:`${p}_capitalize`,value:Rn(a)}),r.push({name:`${p}_uncapitalize`,value:Pn(a)}),r.push({name:p,value:a}))}return r}function Rn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Pn(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as Z,AST_TOKEN_TYPES as vn,ESLintUtils as ni}from"@typescript-eslint/utils";import{z as Me}from"zod/v4";var ri=ni.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kn="collapse-simple-objs-in-one-line",ii=Me.object({maxLineLength:Me.number().optional(),maxProperties:Me.number().optional(),nestedObjMaxLineLength:Me.number().optional(),nestedObjMaxProperties:Me.number().optional(),ignoreTypesWithSuffix:Me.array(Me.string()).optional()}),si=ri({name:kn,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:[$(ii)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,o=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function p(c){if(c.type===Z.ObjectExpression){let g=c.parent.type===Z.Property,S=g?i:s,l=c.properties.length;if(l>S)return!1;if(l===1){let f=c.properties[0];return!f||f.type===Z.Property&&f.value.type===Z.ObjectExpression||f.type===Z.Property&&f.value.type===Z.ArrayExpression&&!f.value.elements.every(T=>T&&St(T))?!1:{text:r.getText(f),isNested:g,propsSize:l}}let E=[];for(let f of c.properties){if(f.type===Z.Property&&!St(f.value))return!1;E.push(r.getText(f))}return{text:E.join(", "),isNested:g,propsSize:l}}else{let g=c.parent.parent?.type===Z.TSPropertySignature,S=g?i:s,l=c.members.length;if(l>S)return!1;if(n.length>0&&c.parent.type===Z.TSTypeAliasDeclaration){let f=c.parent.id.name;if(n.some(h=>f.endsWith(h)))return!1}if(l===1){let f=c.members[0];return!f||f.type===Z.TSPropertySignature&&f.typeAnnotation?.typeAnnotation.type===Z.TSTypeLiteral?!1:{text:r.getText(f),isNested:g,propsSize:1}}if(c.parent.type===Z.TSIntersectionType||c.parent.type===Z.TSUnionType&&c.parent.types[0]!==c)return!1;let E=[];for(let f of c.members){if(f.type!==Z.TSPropertySignature)return!1;let h=f.typeAnnotation?.typeAnnotation;if(!h||h.type===Z.TSTypeLiteral||!Fn(h))return!1;if(h.type===Z.TSTypeReference&&h.typeArguments){if(h.typeArguments.params.length>1)return!1;let m=h.typeArguments.params[0];if(!m||!Fn(m))return!1}let T=r.getText(f).trim();(T.endsWith(";")||T.endsWith(","))&&(T=T.slice(0,-1)),E.push(T)}return{text:E.join("; "),isNested:g,propsSize:l}}}function a(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==Z.JSXExpressionContainer){let h=0,T=!1,m=r.getTokenAfter(c,{filter:C=>C.type!==vn.Punctuator||T?!0:C.value===","?(h++,!1):C.value===";"?(h++,T=!0,!1):C.value===")"||C.value==="}"?(h++,!1):!0});if(h>4)return;let b=m?.type===vn.Template&&m.value.startsWith(`}
2
- `);if(m?.loc.start.line===c.loc.end.line&&!b)return}let g=p(c);if(!g)return;let S=g.text;if(S.includes(`
3
- `)||r.getCommentsInside(c).length>0)return;S.endsWith(";")&&(S=S.slice(0,-1));let l=`{ ${S} }`,E=ai(r,c),f=g.isNested&&g.propsSize>2?o:t.maxLineLength;f&&l.length+E.length+oi(c,r)>f||e.report({node:c,messageId:"singleLineProp",fix:h=>h.replaceText(c,l)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function Fn(e){return e.type===Z.TSLiteralType||e.type===Z.TSTypeReference||e.type===Z.TSNumberKeyword||e.type===Z.TSStringKeyword||e.type===Z.TSBooleanKeyword||e.type===Z.TSNullKeyword||e.type===Z.TSUndefinedKeyword}function St(e,t){return!!(e.type===Z.Literal||e.type===Z.Identifier||e.type===Z.TemplateLiteral||e.type===Z.TaggedTemplateExpression||!t&&e.type===Z.ArrayExpression&&e.elements.every(r=>r&&St(r,!0)))}function oi(e,t){let r=t.getLastToken(e);if(!r)return 0;let n=t.text.indexOf(`
4
- `,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function ai(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Tt={name:kn,rule:si};var li=/eslint +react-compiler\/react-compiler: +\["error/,Nn={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"}}}]},create(e){let t=!1,r=typeof e.getSource=="function"?m=>r(m):m=>e.sourceCode.getText(m),n=typeof e.getScope=="function"?()=>n():m=>e.sourceCode.getScope(m),s=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,o=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:s,enableDangerousAutofixThisMayCauseInfiniteLoops:o};function p(m){o&&Array.isArray(m.suggest)&&m.suggest.length>0&&(m.fix=m.suggest[0].fix),e.report(m)}let a=e.getSourceCode().scopeManager,c=new WeakMap,g=new WeakSet,S=new WeakMap,l=new WeakMap,E=new WeakSet;function f(m,b){return function(C){if(b.has(C))return b.get(C);let y=m(C);return b.set(C,y),y}}function h(m,b,C,y,x){x&&m.async&&p({node:m,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ import{AST_NODE_TYPES as ge}from"@typescript-eslint/utils";import{z as D}from"zod/v4";import{ESLintUtils as ti}from"@typescript-eslint/utils";import*as Fn from"zod/v4";function B(e){let r=ti.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function V(e){return Fn.toJSONSchema(e)}var ni=D.object({disallow:D.array(D.object({selector:D.string(),message:D.string(),replace:D.optional(D.union([D.string(),D.object({regex:D.string(),with:D.string()})])),replaceType:D.optional(D.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:D.optional(D.array(D.object({fn:D.string(),withArgs:D.optional(D.array(D.object({atIndex:D.number(),value:D.union([D.string(),D.number(),D.boolean()])}))),message:D.string(),replaceWith:D.optional(D.string()),ignoreRegex:D.optional(D.string())}))),__dev_simulateFileName:D.optional(D.string()),mustMatchSyntax:D.optional(D.array(D.object({includeRegex:D.string(),mustCallFn:D.optional(D.array(D.object({anyCall:D.array(D.object({fn:D.string(),withArgs:D.array(D.object({atIndex:D.number(),literal:D.union([D.string(),D.number(),D.boolean()])}))})),message:D.optional(D.string())}))),mustMatchSelector:D.optional(D.array(D.object({selector:D.string(),message:D.string()}))),mustHaveExport:D.optional(D.array(D.object({name:D.string(),type:D.enum(["function","variable","any"]).default("any"),message:D.string()})))})))}),Et=B({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[V(ni)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:s,disallow:a,disallowFnCalls:i}=t,p=s??e.filename,l=[],c=new Map,d=new Set,y=new Map,g=new Set,b=new Map;function f(u){for(let T of u.specifiers)T.type===ge.ImportSpecifier&&T.imported.type===ge.Identifier&&T.imported.name!==T.local.name&&b.set(T.local.name,T.imported.name)}function E(u){if(u.declaration){if(u.declaration.type===ge.FunctionDeclaration&&u.declaration.id){let T=u.declaration.id.name;for(let w of Array.from(g)){let[R,v]=w.split(":");R===T&&(v==="function"||v==="any")&&g.delete(w)}}else if(u.declaration.type===ge.VariableDeclaration){for(let T of u.declaration.declarations)if(T.id.type===ge.Identifier){let w=T.id.name;for(let R of Array.from(g)){let[v,x]=R.split(":");v===w&&(x==="variable"||x==="any")&&g.delete(R)}}}}for(let T of u.specifiers)if(T.exported.type===ge.Identifier){let w=T.exported.name;for(let R of Array.from(g)){let[v,x]=R.split(":");v===w&&x==="any"&&g.delete(R)}}}function h(u){u.id.type===ge.Identifier&&u.init?.type===ge.Identifier&&b.set(u.id.name,u.init.name)}function m(u){return b.get(u)??u}function A(u,T){return m(u)===T||u===T}for(let{includeRegex:u,mustCallFn:T,mustMatchSelector:w,mustHaveExport:R}of n??[]){let x=function(C){let F=C;for(let{name:O,value:G}of v??[])F=F.replaceAll(O,G);return F};var S=x;let v=ri(p,new RegExp(u));if(v){for(let{anyCall:C,message:F}of T??[]){let O=`Expected file to call the function: ${C.map(({fn:G})=>G).join(" or ")}`;d.add(O),l.push(G=>{let{callee:_}=G;if(_.type===ge.Identifier){for(let{fn:te,withArgs:M}of C)if(_.name===te){d.delete(O);for(let W of M){let X=G.arguments[W.atIndex],ne=typeof W.literal=="string"?x(W.literal):W.literal;if(!X){e.report({node:G,messageId:"default",data:{message:`Missing argument with value "${ne}" at index ${W.atIndex}${F?`: ${x(F)}`:""}`}});continue}if(X.type!==ge.Literal){e.report({node:X,messageId:"default",data:{message:`Argument at position ${W.atIndex} should the literal "${ne}"${F?`: ${x(F)}`:""}`}});continue}X.value!==ne&&e.report({node:X,messageId:"default",data:{message:`Argument should have the value "${ne}"${F?`: ${x(F)}`:""}`},fix:le=>le.replaceText(X,typeof ne=="string"?`'${ne}'`:String(ne))})}break}}})}for(let{selector:C,message:F}of w??[])y.set(C,x(F)),c.set(x(C),()=>{y.delete(C)});for(let{name:C,type:F,message:O}of R??[]){let G=x(C),_=x(O);g.add(`${G}:${F}:${_}`)}}}for(let{fn:u,withArgs:T,message:w,replaceWith:R,ignoreRegex:v}of i??[])v&&new RegExp(v).test(p)||l.push(x=>{let{callee:C}=x;if(C.type!==ge.Identifier||!A(C.name,u))return;if(T)for(let O of T){let G=x.arguments[O.atIndex];if(!G){e.report({node:x,messageId:"default",data:{message:`Missing argument with value "${O.value}" at index ${O.atIndex}: ${w}`}});return}if(G.type!==ge.Literal||G.value!==O.value)return}let F=O=>R?O.replaceText(x,R):null;e.report({node:x,messageId:"default",data:{message:w},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:F}]:void 0})});function I(u,T){let w=r[u];w?r[u]=R=>{w(R),T(R)}:r[u]=T}for(let{selector:u,message:T,replace:w,replaceType:R="suggestion"}of a??[]){if(u==="CallExpression"){l.push(v=>{o(w,v,T,R)});continue}r[u]=v=>{o(w,v,T,R)}}if(c.size>0)for(let[u,T]of c)I(u,T);return l.length>0&&(r.CallExpression=u=>{if(u.type===ge.CallExpression)for(let T of l)T(u)}),r.ImportDeclaration=u=>{u.type===ge.ImportDeclaration&&f(u)},r.ExportNamedDeclaration=u=>{u.type===ge.ExportNamedDeclaration&&E(u)},r.VariableDeclarator=u=>{u.type===ge.VariableDeclarator&&h(u)},r["Program:exit"]=u=>{for(let T of d)e.report({node:u,messageId:"default",data:{message:T}});for(let[,T]of y)e.report({node:u,messageId:"default",data:{message:T}});for(let T of g){let[w,R,v]=T.split(":");e.report({node:u,messageId:"default",data:{message:`Missing required export "${w}" of type ${R}: ${v}`}})}},r;function o(u,T,w,R){let v=x=>{if(!u)return null;if(typeof u=="string")return x.replaceText(T,u);{let C=new RegExp(u.regex),F=e.sourceCode.getText(T);return x.replaceText(T,F.replace(C,u.with))}};e.report({node:T,messageId:"default",data:{message:w},fix:u&&R==="autofix"?v:void 0,suggest:u&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof u=="string"?u:u.with}"`},fix:v}]:void 0})}}});function ri(e,t){let r=[],n=t.exec(e);if(!n)return null;let[s,...a]=n;r.push({name:"$0_lowercase",value:s.toLowerCase()}),r.push({name:"$0_capitalize",value:kn(s)}),r.push({name:"$0_uncapitalize",value:On(s)}),r.push({name:"$0",value:s});for(let i=0;i<a.length;i++){let p=`$${i+1}`,l=a[i];l!==void 0&&(r.push({name:`${p}_lowercase`,value:l.toLowerCase()}),r.push({name:`${p}_capitalize`,value:kn(l)}),r.push({name:`${p}_uncapitalize`,value:On(l)}),r.push({name:p,value:l}))}return r}function kn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function On(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as ie,AST_TOKEN_TYPES as Nn,ESLintUtils as ii}from"@typescript-eslint/utils";import{z as We}from"zod/v4";var oi=ii.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jn="collapse-simple-objs-in-one-line",si=We.object({maxLineLength:We.number().optional(),maxProperties:We.number().optional(),nestedObjMaxLineLength:We.number().optional(),nestedObjMaxProperties:We.number().optional(),ignoreTypesWithSuffix:We.array(We.string()).optional()}),ai=oi({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:[V(si)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function p(c){if(c.type===ie.ObjectExpression){let d=c.parent.type===ie.Property,y=d?i:s,g=c.properties.length;if(g>y)return!1;if(g===1){let f=c.properties[0];return!f||f.type===ie.Property&&f.value.type===ie.ObjectExpression||f.type===ie.Property&&f.value.type===ie.ArrayExpression&&!f.value.elements.every(h=>h&&bt(h))?!1:{text:r.getText(f),isNested:d,propsSize:g}}let b=[];for(let f of c.properties){if(f.type===ie.Property&&!bt(f.value))return!1;b.push(r.getText(f))}return{text:b.join(", "),isNested:d,propsSize:g}}else{let d=c.parent.parent?.type===ie.TSPropertySignature,y=d?i:s,g=c.members.length;if(g>y)return!1;if(n.length>0&&c.parent.type===ie.TSTypeAliasDeclaration){let f=c.parent.id.name;if(n.some(E=>f.endsWith(E)))return!1}if(g===1){let f=c.members[0];return!f||f.type===ie.TSPropertySignature&&f.typeAnnotation?.typeAnnotation.type===ie.TSTypeLiteral?!1:{text:r.getText(f),isNested:d,propsSize:1}}if(c.parent.type===ie.TSIntersectionType||c.parent.type===ie.TSUnionType&&c.parent.types[0]!==c)return!1;let b=[];for(let f of c.members){if(f.type!==ie.TSPropertySignature)return!1;let E=f.typeAnnotation?.typeAnnotation;if(!E||E.type===ie.TSTypeLiteral||!Dn(E))return!1;if(E.type===ie.TSTypeReference&&E.typeArguments){if(E.typeArguments.params.length>1)return!1;let m=E.typeArguments.params[0];if(!m||!Dn(m))return!1}let h=r.getText(f).trim();(h.endsWith(";")||h.endsWith(","))&&(h=h.slice(0,-1)),b.push(h)}return{text:b.join("; "),isNested:d,propsSize:g}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==ie.JSXExpressionContainer){let E=0,h=!1,m=r.getTokenAfter(c,{filter:I=>I.type!==Nn.Punctuator||h?!0:I.value===","?(E++,!1):I.value===";"?(E++,h=!0,!1):I.value===")"||I.value==="}"?(E++,!1):!0});if(E>4)return;let A=m?.type===Nn.Template&&m.value.startsWith(`}
2
+ `);if(m?.loc.start.line===c.loc.end.line&&!A)return}let d=p(c);if(!d)return;let y=d.text;if(y.includes(`
3
+ `)||r.getCommentsInside(c).length>0)return;y.endsWith(";")&&(y=y.slice(0,-1));let g=`{ ${y} }`,b=pi(r,c),f=d.isNested&&d.propsSize>2?a:t.maxLineLength;f&&g.length+b.length+li(c,r)>f||e.report({node:c,messageId:"singleLineProp",fix:E=>E.replaceText(c,g)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function Dn(e){return e.type===ie.TSLiteralType||e.type===ie.TSTypeReference||e.type===ie.TSNumberKeyword||e.type===ie.TSStringKeyword||e.type===ie.TSBooleanKeyword||e.type===ie.TSNullKeyword||e.type===ie.TSUndefinedKeyword}function bt(e,t){return!!(e.type===ie.Literal||e.type===ie.Identifier||e.type===ie.TemplateLiteral||e.type===ie.TaggedTemplateExpression||!t&&e.type===ie.ArrayExpression&&e.elements.every(r=>r&&bt(r,!0)))}function li(e,t){let r=t.getLastToken(e);if(!r)return 0;let n=t.text.indexOf(`
4
+ `,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function pi(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var xt={name:jn,rule:ai};var ci=/eslint +react-compiler\/react-compiler: +\["error/,Mn={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"}}}]},create(e){let t=!1,r=typeof e.getSource=="function"?m=>r(m):m=>e.sourceCode.getText(m),n=typeof e.getScope=="function"?()=>n():m=>e.sourceCode.getScope(m),s=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,a=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:s,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function p(m){a&&Array.isArray(m.suggest)&&m.suggest.length>0&&(m.fix=m.suggest[0].fix),e.report(m)}let l=e.getSourceCode().scopeManager,c=new WeakMap,d=new WeakSet,y=new WeakMap,g=new WeakMap,b=new WeakSet;function f(m,A){return function(I){if(A.has(I))return A.get(I);let o=m(I);return A.set(I,o),o}}function E(m,A,I,o,S){S&&m.async&&p({node:m,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,41 +12,44 @@ 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 u=a.acquire(m),d=new Set,A=null;{let w=u.upper;for(;w&&(d.add(w),w.type!=="function");)w=w.upper;if(!w)return;A=w}let I=Array.isArray;function R(w){if(!I(w.defs))return!1;let P=w.defs[0];if(P==null||P.node.type!=="VariableDeclarator")return!1;let k=P.node.init;if(k==null)return!1;for(;k.type==="TSAsExpression";)k=k.expression;let N=P.node.parent;if(N==null&&(bt(A.block,P.node.id),N=P.node.parent,N==null))return!1;if(N.kind==="const"&&k.type==="Literal"&&(typeof k.value=="string"||typeof k.value=="number"||k.value===null))return!0;if(k.type!=="CallExpression")return!1;let M=k.callee;if(M.type==="MemberExpression"&&M.object.name==="React"&&M.property!=null&&!M.computed&&(M=M.property),M.type!=="Identifier")return!1;let j=P.node.id,{name:U}=M;if(U==="useRef"&&j.type==="Identifier")return!0;if(mi(M)&&j.type==="Identifier"){for(let W of w.references)W!==j&&E.add(W.identifier);return!0}else if(U==="useState"||U==="useReducer"){if(j.type==="ArrayPattern"&&j.elements.length===2&&I(w.identifiers)){if(j.elements[1]===w.identifiers[0]){if(U==="useState"){let W=w.references,ge=0;for(let Pe=0;Pe<W.length;Pe++){if(W[Pe].isWrite()&&ge++,ge>1)return!1;c.set(W[Pe].identifier,j.elements[0])}}return!0}else if(j.elements[0]===w.identifiers[0]){if(U==="useState"){let W=w.references;for(let ge=0;ge<W.length;ge++)g.add(W[ge].identifier)}return!1}}}else if(U==="useTransition"&&j.type==="ArrayPattern"&&j.elements.length===2&&Array.isArray(w.identifiers)&&j.elements[1]===w.identifiers[0])return!0;return!1}function v(w){if(!I(w.defs))return!1;let P=w.defs[0];if(P==null||P.node==null||P.node.id==null)return!1;let k=P.node,N=A.childScopes,M=null,j;for(j=0;j<N.length;j++){let U=N[j],W=U.block;if(k.type==="FunctionDeclaration"&&W===k||k.type==="VariableDeclarator"&&W.parent===k){M=U;break}}if(M==null)return!1;for(j=0;j<M.through.length;j++){let U=M.through[j];if(U.resolved!=null&&d.has(U.resolved.scope)&&!J(U.resolved))return!1}return!0}let J=f(R,S),Y=f(v,l),te=new Map;function ee(w){let P=w.from,k=!1;for(;P.block!==m;)P.type==="function"&&(k=P.block.parent!=null&&P.block.parent.type==="ReturnStatement"),P=P.upper;return k}let V=new Map,me=new Map;xe(u);function xe(w){for(let P of w.references){if(!P.resolved||!d.has(P.resolved.scope))continue;let k=bt(m,P.identifier),N=Dn(k),M=ve(N,me);if(x&&N.type==="Identifier"&&(N.parent.type==="MemberExpression"||N.parent.type==="OptionalMemberExpression")&&!N.parent.computed&&N.parent.property.type==="Identifier"&&N.parent.property.name==="current"&&ee(P)&&te.set(M,{reference:P,dependencyNode:N}),N.parent.type==="TSTypeQuery"||N.parent.type==="TSTypeReference")continue;let j=P.resolved.defs[0];if(j!=null&&!(j.node!=null&&j.node.init===m.parent)&&j.type!=="TypeParameter")if(V.has(M))V.get(M).references.push(P);else{let U=P.resolved,W=J(U)||Y(U);V.set(M,{isStable:W,references:[P]})}}for(let P of w.childScopes)xe(P)}te.forEach(({reference:w,dependencyNode:P},k)=>{let N=w.resolved.references,M=!1;for(let j=0;j<N.length;j++){let{identifier:U}=N[j],{parent:W}=U;if(W!=null&&W.type==="MemberExpression"&&!W.computed&&W.property.type==="Identifier"&&W.property.name==="current"&&W.parent.type==="AssignmentExpression"&&W.parent.left===W){M=!0;break}}M||p({node:P.parent.property,message:`The ref value '${k}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${k}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ce=new Set;function Ce(w,P){ce.has(P)||(ce.add(P),p({node:w,message:`Assignments to the '${P}' variable from inside React Hook ${r(C)} 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(C)}.`}))}let de=new Set;if(V.forEach(({isStable:w,references:P},k)=>{w&&de.add(k),P.forEach(N=>{N.writeExpr&&Ce(N.writeExpr,k)})}),ce.size>0)return;if(!b){let w=null;if(V.forEach(({isStable:P,references:k},N)=>{w||k.forEach(M=>{if(w)return;let j=M.identifier;if(!c.has(j))return;let W=M.from;for(;W.type!=="function";)W=W.upper;W.block===m&&(w=N)})}),w){let{suggestedDependencies:P}=ht({dependencies:V,declaredDependencies:[],stableDependencies:de,externalDependencies:new Set,isEffect:!0});p({node:C,message:`React Hook ${y} contains a call to '${w}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+P.join(", ")+`] as a second argument to the ${y} Hook.`,suggest:[{desc:`Add dependencies array: [${P.join(", ")}]`,fix(k){return k.insertTextAfter(m,`, [${P.join(", ")}]`)}}]})}return}let Le=[],Xe=new Set;b.type!=="ArrayExpression"?p({node:b,message:`React Hook ${r(C)} 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.`}):b.elements.forEach(w=>{if(w===null)return;if(w.type==="SpreadElement"){p({node:w,message:`React Hook ${r(C)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}E.has(w)&&p({node:w,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(w)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(w)}\``,fix(M){return M.removeRange(w.range)}}]});let P;try{P=ve(w,me)}catch(M){if(/Unsupported node type/.test(M.message)){w.type==="Literal"?V.has(w.value)?p({node:w,message:`The ${w.raw} literal is not a valid dependency because it never changes. Did you mean to include ${w.value} in the array instead?`}):p({node:w,message:`The ${w.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):p({node:w,message:`React Hook ${r(C)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw M}let k=w;for(;k.type==="MemberExpression"||k.type==="OptionalMemberExpression"||k.type==="ChainExpression";)k=k.object||k.expression.object;let N=!A.through.some(M=>M.identifier===k);Le.push({key:P,node:w}),N||Xe.add(P)});let{suggestedDependencies:qr,unnecessaryDependencies:Qe,missingDependencies:Oe,duplicateDependencies:Cn}=ht({dependencies:V,declaredDependencies:Le,stableDependencies:de,externalDependencies:Xe,isEffect:x}),et=qr;if(Cn.size+Oe.size+Qe.size===0){if(t)return;pi({declaredDependencies:Le,declaredDependenciesNode:b,componentScope:A,scope:u}).forEach(({construction:P,isUsedOutsideOfHook:k,depType:N})=>{let M=N==="function"?"useCallback":"useMemo",j=N==="function"?"definition":"initialization",U=`wrap the ${j} of '${P.name.name}' in its own ${M}() Hook.`,W=k?`To fix this, ${U}`:`Move it inside the ${y} callback. Alternatively, ${U}`,ge=N==="conditional"||N==="logical expression"?"could make":"makes",Pe=`The '${P.name.name}' ${N} ${ge} the dependencies of ${y} Hook (at line ${b.loc.start.line}) change on every render. ${W}`,An;k&&P.type==="Variable"&&N==="function"&&(An=[{desc:`Wrap the ${j} of '${P.name.name}' in its own ${M}() Hook.`,fix(In){let[Gr,Kr]=M==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[In.insertTextBefore(P.node.init,Gr),In.insertTextAfter(P.node.init,Kr)]}}]),p({node:P.node,message:Pe,suggest:An})});return}!x&&Oe.size>0&&(et=ht({dependencies:V,declaredDependencies:[],stableDependencies:de,externalDependencies:Xe,isEffect:x}).suggestedDependencies);function Zr(){if(Le.length===0)return!0;let w=Le.map(k=>k.key),P=w.slice().sort();return w.join(",")===P.join(",")}Zr()&&et.sort();function yt(w){let P=w.split("."),k="";for(let N=0;N<P.length;N++){if(N!==0){let M=P.slice(0,N+1).join("."),j=me.get(M)===!0;k+=j?"?.":"."}k+=P[N]}return k}function dt(w,P,k,N){return w.size===0?null:(w.size>1?"":P+" ")+k+" "+(w.size>1?"dependencies":"dependency")+": "+ui(Array.from(w).sort().map(M=>"'"+yt(M)+"'"))+`. Either ${N} ${w.size>1?"them":"it"} or remove the dependency array.`}let Ee="";if(Qe.size>0){let w=null;if(Array.from(Qe.keys()).forEach(P=>{w===null&&P.endsWith(".current")&&(w=P)}),w!==null)Ee=` Mutable values like '${w}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Xe.size>0){let P=Array.from(Xe)[0];u.set.has(P)||(Ee=` Outer scope values like '${P}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!Ee&&Oe.has("props")){let w=V.get("props");if(w==null)return;let P=w.references;if(!Array.isArray(P))return;let k=!0;for(let N=0;N<P.length;N++){let M=P[N],j=bt(A.block,M.identifier);if(!j){k=!1;break}let U=j.parent;if(U==null){k=!1;break}if(U.type!=="MemberExpression"&&U.type!=="OptionalMemberExpression"){k=!1;break}}k&&(Ee=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${y} call and refer to those specific props inside ${r(C)}.`)}if(!Ee&&Oe.size>0){let w=null;Oe.forEach(P=>{if(w)return;let k=A.set.get(P),N=V.get(P);if(N.references[0].resolved!==k)return;let M=k.defs[0];if(M==null||M.name==null||M.type!=="Parameter")return;let j=!1,U;for(let W=0;W<N.references.length;W++)if(U=N.references[W].identifier,U!=null&&U.parent!=null&&(U.parent.type==="CallExpression"||U.parent.type==="OptionalCallExpression")&&U.parent.callee===U){j=!0;break}j&&(w=P)}),w!==null&&(Ee=` If '${w}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!Ee&&Oe.size>0){let w=null;if(Oe.forEach(P=>{if(w!==null)return;let N=V.get(P).references,M,j;for(let U=0;U<N.length;U++){for(M=N[U].identifier,j=M.parent;j!=null&&j!==A.block;){if(j.type==="CallExpression"){let W=c.get(j.callee);if(W!=null){if(W.name===P)w={missingDep:P,setter:j.callee.name,form:"updater"};else if(g.has(M))w={missingDep:P,setter:j.callee.name,form:"reducer"};else{let ge=N[U].resolved;if(ge!=null){let Pe=ge.defs[0];Pe!=null&&Pe.type==="Parameter"&&(w={missingDep:P,setter:j.callee.name,form:"inlineReducer"})}}break}}j=j.parent}if(w!==null)break}}),w!==null)switch(w.form){case"reducer":Ee=` You can also replace multiple useState variables with useReducer if '${w.setter}' needs the current value of '${w.missingDep}'.`;break;case"inlineReducer":Ee=` If '${w.setter}' needs the current value of '${w.missingDep}', you can also switch to useReducer instead of useState and read '${w.missingDep}' in the reducer.`;break;case"updater":Ee=` You can also do a functional update '${w.setter}(${w.missingDep.slice(0,1)} => ...)' if you only need '${w.missingDep}' in the '${w.setter}' call.`;break;default:throw new Error("Unknown case.")}}p({node:b,message:`React Hook ${r(C)} has `+(dt(Oe,"a","missing","include")||dt(Qe,"an","unnecessary","exclude")||dt(Cn,"a","duplicate","omit"))+Ee,suggest:[{desc:`Update the dependencies array to be: [${et.map(yt).join(", ")}]`,fix(w){return w.replaceText(b,`[${et.map(yt).join(", ")}]`)}}]})}function T(m){let b=ci(m.callee,i);if(b===-1)return;let C=m.arguments[b],y=m.callee,x=jn(y).name,u=m.arguments[b+1],d=/Effect($|[^a-z])/g.test(x);if(!C){p({node:y,message:`React Hook ${x} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!d)){if(!u&&!d){(x==="useMemo"||x==="useCallback")&&p({node:y,message:`React Hook ${x} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(C.type){case"FunctionExpression":case"ArrowFunctionExpression":h(C,u,y,x,d);return;case"Identifier":if(!u||u.elements&&u.elements.some(R=>R&&R.type==="Identifier"&&R.name===C.name))return;let A=n(m).set.get(C.name);if(A==null||A.defs==null)return;let I=A.defs[0];if(!I||!I.node||I.type!=="Variable"&&I.type!=="FunctionName")break;switch(I.node.type){case"FunctionDeclaration":h(I.node,u,y,x,d);return;case"VariableDeclarator":let R=I.node.init;if(!R)break;switch(R.type){case"ArrowFunctionExpression":case"FunctionExpression":h(R,u,y,x,d);return}break}break;default:p({node:y,message:`React Hook ${x} received a function whose dependencies are unknown. Pass an inline function instead.`});return}p({node:y,message:`React Hook ${x} has a missing dependency: '${C.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${C.name}]`,fix(A){return A.replaceText(u,`[${C.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let m of e.sourceCode.getAllComments())if(li.test(m.value))return t=!0,{CallExpression:b=>T(b,!0)}}return{CallExpression:m=>T(m)}}};function ht({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:s}){let o=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((h,T)=>{let m=p(o,T);m.isUsed=!0,a(o,T,b=>{b.isSubtreeUsed=!0})}),t.forEach(({key:h})=>{let T=p(o,h);T.isSatisfiedRecursively=!0}),r.forEach(h=>{let T=p(o,h);T.isSatisfiedRecursively=!0});function p(h,T){let m=T.split("."),b=h;for(let C of m){let y=b.children.get(C);y||(y=i(),b.children.set(C,y)),b=y}return b}function a(h,T,m){let b=T.split("."),C=h;for(let y of b){let x=C.children.get(y);if(!x)return;m(x),C=x}}let c=new Set,g=new Set;S(o,c,g,h=>h);function S(h,T,m,b){h.children.forEach((C,y)=>{let x=b(y);if(C.isSatisfiedRecursively){C.isSubtreeUsed&&m.add(x);return}if(C.isUsed){T.add(x);return}S(C,T,m,u=>x+"."+u)})}let l=[],E=new Set,f=new Set;return t.forEach(({key:h})=>{g.has(h)?l.indexOf(h)===-1?l.push(h):f.add(h):E.add(h)}),c.forEach(h=>{l.push(h)}),{suggestedDependencies:l,unnecessaryDependencies:E,duplicateDependencies:f,missingDependencies:c}}function Ne(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 Ne(e.consequent)!=null||Ne(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Ne(e.left)!=null||Ne(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Ne(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Ne(e.expression);case"TSAsExpression":return Ne(e.expression)}return null}function pi({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let s=e.map(({key:i})=>{let p=r.variables.find(c=>c.name===i);if(p==null)return null;let a=p.defs[0];if(a==null)return null;if(a.type==="Variable"&&a.node.type==="VariableDeclarator"&&a.node.id.type==="Identifier"&&a.node.init!=null){let c=Ne(a.node.init);if(c!=null)return[p,c]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[p,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[p,"class"]:null}).filter(Boolean);function o(i){let p=!1;for(let a=0;a<i.references.length;a++){let c=i.references[a];if(c.writeExpr){if(p)return!0;p=!0;continue}let g=c.from;for(;g!==n&&g!=null;)g=g.upper;if(g!==n&&!Ln(t,c.identifier))return!0}return!1}return s.map(([i,p])=>({construction:i.defs[0],depType:p,isUsedOutsideOfHook:o(i)}))}function Dn(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)?Dn(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Et(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function ve(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=ve(e.object,t),n=ve(e.property,null),s=`${r}.${n}`;return Et(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=ve(e.object,t),n=ve(e.property,null),s=`${r}.${n}`;return Et(e,t,s),s}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=ve(r.object,t),s=ve(r.property,null),o=`${n}.${s}`;return Et(r,t,o),o}else throw new Error(`Unsupported node type: ${e.type}`)}function jn(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function ci(e,t){let r=jn(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&&t&&t.additionalHooks){let n;try{n=ve(r,null)}catch(s){if(/Unsupported node type/.test(s.message))return 0;throw s}return t.additionalHooks.test(n)?0:-1}else return-1}}function bt(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),fi(n,t))return n;if(Ln(n,t))for(let[s,o]of Object.entries(n))s!=="parent"&&(On(o)?(o.parent=n,r.push(o)):Array.isArray(o)&&o.forEach(i=>{On(i)&&(i.parent=n,r.push(i))}))}return null}function ui(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function On(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function fi(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function Ln(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function mi(e){return!1}import{AST_NODE_TYPES as ae,ESLintUtils as zn}from"@typescript-eslint/utils";import oe from"typescript";import{z as di}from"zod/v4";import{AST_NODE_TYPES as Mn}from"@typescript-eslint/utils";function Ue(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Ue(e.parent,t,r===1/0?r:r-1)}function*xt(e){yield e,e.parent&&(yield*xt(e.parent))}function Ct(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function _n(e,t,r){let s=r.getDeclaredVariables(e).find(o=>o.name===t||o.identifiers[0]?.parent.type===Mn.Property&&o.identifiers[0].parent.key.type===Mn.Identifier&&o.identifiers[0].parent.key.name===t);return s?s.references.filter(o=>!o.init):[]}function $n(e){return e===null||typeof e!="object"||!("type"in e)?!1:typeof e.type=="string"}function yi(e,t){return e[t]}function Ae(e,t,r){let n=r.visitorKeys,s=new Set;function o(i){if(s.has(i))return!1;if(s.add(i),t(i)===!0)return!0;let a=n[i.type];if(a)for(let c of a){let g=yi(i,c);if(g){if(Array.isArray(g)){for(let S of g)if($n(S)&&o(S))return!0}else if($n(g)&&o(g))return!0}}return!1}o(e)}var gi=zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Un="improved-no-unnecessary-condition",Si=di.object({}),Ti=["string","number","bigint","boolean","symbol","undefined","object","function","never"],hi=new Set(Ti),At={name:Un,rule:gi({name:Un,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.",unnecessaryLengthCondition:"This length comparison is unnecessary as it always evaluates to true.",alwaysFalseLengthCondition:"This length comparison will always be false."},schema:[$(Si)]},defaultOptions:[{}],create(e){let t=zn.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(l){return l.type===ae.UnaryExpression&&l.operator==="typeof"}function s(l){return l.flags&oe.TypeFlags.Any||l.flags&oe.TypeFlags.Unknown?null:l.flags&oe.TypeFlags.StringLike?["string"]:l.flags&oe.TypeFlags.NumberLike?["number"]:l.flags&oe.TypeFlags.BigIntLike?["bigint"]:l.flags&oe.TypeFlags.BooleanLike?["boolean"]:l.flags&oe.TypeFlags.ESSymbolLike?["symbol"]:l.flags&oe.TypeFlags.Undefined||l.flags&oe.TypeFlags.Void?["undefined"]:l.flags&oe.TypeFlags.Null?["object"]:l.getCallSignatures().length>0?["function"]:l.flags&oe.TypeFlags.Object?l.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:l.flags&oe.TypeFlags.NonPrimitive?["object"]:l.flags&oe.TypeFlags.Never?["never"]:null}function o(l){if(!r)return null;let E=t.esTreeNodeToTSNodeMap.get(l),f=r.getTypeAtLocation(E.expression);if(f.flags&oe.TypeFlags.Any||f.flags&oe.TypeFlags.Unknown)return null;let h=[];if(f.isUnion()){for(let m of f.types){let b=s(m);if(b)h.push(...b);else return null}return h}let T=s(f);return T?(h.push(...T),h):null}function i(l){if(!(l.operator==="==="||l.operator==="!=="))return;let f=null,h=null;if(n(l.left)?(f=l.left,h=l.right.type===ae.Literal&&typeof l.right.value=="string"?l.right.value:null):n(l.right)&&(f=l.right,h=l.left.type===ae.Literal&&typeof l.left.value=="string"?l.left.value:null),!f||!h||!Ei(h,hi))return;let T=o(f);if(!T)return;let m=l.operator==="!==",b=T.includes(h);T.length===1?b&&!m?e.report({node:l,messageId:"unnecessaryTypeofCondition",data:{name:ze(f,e),type:h}}):!b&&m?e.report({node:l,messageId:"unnecessaryTypeofCondition",data:{name:ze(f,e),type:Array.from(T)[0]}}):!b&&!m?e.report({node:l,messageId:"alwaysFalseTypeofCondition",data:{name:ze(f,e),actualType:tt(T),conditionType:h}}):b&&m&&e.report({node:l,messageId:"alwaysFalseTypeofCondition",data:{name:ze(f,e),actualType:tt(T),conditionType:h}}):!b&&!m?e.report({node:l,messageId:"alwaysFalseTypeofCondition",data:{name:ze(f,e),actualType:tt(T),conditionType:h}}):!b&&m&&e.report({node:l,messageId:"unnecessaryTypeofCondition",data:{name:ze(f,e),type:tt(T)}})}function p(l){if(l.flags&oe.TypeFlags.Any||l.flags&oe.TypeFlags.Unknown)return null;if(l.isUnion()){let E=[];for(let f of l.types)if(f.flags&oe.TypeFlags.StringLiteral){let h=f.value;E.push(h)}else return null;return E}return l.flags&oe.TypeFlags.StringLiteral?[l.value]:null}function a(l){if(!r)return null;let E=t.esTreeNodeToTSNodeMap.get(l),f=r.getTypeAtLocation(E),h=p(f);if(h)return h;let T=r.getSymbolAtLocation(E);if(T){let m=r.getTypeOfSymbolAtLocation(T,E),b=p(m);if(b)return b}return null}function c(l){let E=e.sourceCode.ast,f=null;return Ae(E,h=>{if(h.type===ae.VariableDeclarator&&h.id.type===ae.Identifier&&h.id.name===l.name&&h.id.typeAnnotation){let T=h.id.typeAnnotation.typeAnnotation;if(T.type===ae.TSUnionType){let m=[];for(let b of T.types)if(b.type===ae.TSLiteralType&&b.literal.type===ae.Literal&&typeof b.literal.value=="string")m.push(b.literal.value);else return!0;return f=m,!0}if(T.type===ae.TSLiteralType&&T.literal.type===ae.Literal&&typeof T.literal.value=="string")return f=[T.literal.value],!0}return!1},e.sourceCode),f}function g(l){if(l.callee.type!==ae.MemberExpression||l.callee.property.type!==ae.Identifier||l.callee.computed)return;let E=l.callee.property.name;if(E!=="startsWith"&&E!=="endsWith"&&E!=="includes"||l.arguments.length!==1)return;let[f]=l.arguments;if(!f||f.type!==ae.Literal||typeof f.value!="string")return;let h=l.callee.object,T=a(h);if(!T&&h.type===ae.Identifier&&(T=c(h)),!T||T.length===0)return;let m=f.value;if(E==="includes"&&T.length>1)return;let b=0,C=0;for(let y of T)if((E==="startsWith"?y.startsWith(m):E==="endsWith"?y.endsWith(m):y.includes(m))?b++:C++,b>0&&C>0)return;if(b>0&&C===0){let y=E==="startsWith"?"unnecessaryStartsWithCondition":E==="endsWith"?"unnecessaryEndsWithCondition":"unnecessaryIncludesCondition";e.report({node:l,messageId:y})}else if(C>0&&b===0){let y=E==="startsWith"?"alwaysFalseStartsWithCondition":E==="endsWith"?"alwaysFalseEndsWithCondition":"alwaysFalseIncludesCondition";e.report({node:l,messageId:y})}}function S(l){if(!new Set(["===","!==",">",">=","<","<="]).has(l.operator))return;function f(x){if(x.type!==ae.MemberExpression||x.computed||x.property.type!==ae.Identifier||x.property.name!=="length")return null;let u=x.object,d=a(u);if(!d||d.length===0)return null;let A=[];for(let I of d)A.push(I.length);return{values:A}}let h=f(l.left),T=f(l.right),m=null,b=null;if(h?l.right.type===ae.Literal&&typeof l.right.value=="number"&&(m=h.values,b=l.right.value):T&&l.left.type===ae.Literal&&typeof l.left.value=="number"&&(m=T.values,b=l.left.value),!m||b===null)return;let C=0,y=0;for(let x of m){let u=!1;if(l.operator==="==="?u=x===b:l.operator==="!=="?u=x!==b:l.operator===">"?u=x>b:l.operator===">="?u=x>=b:l.operator==="<"?u=x<b:l.operator==="<="&&(u=x<=b),u?C++:y++,C>0&&y>0)return}C>0&&y===0?e.report({node:l,messageId:"unnecessaryLengthCondition"}):y>0&&C===0&&e.report({node:l,messageId:"alwaysFalseLengthCondition"})}return{BinaryExpression(l){i(l),S(l)},CallExpression:g}}})};function tt(e){return Array.from(new Set(e)).join(" | ")||"never"}function ze(e,t){let r=e.argument;return r.type===ae.Identifier?r.name:t.sourceCode.getText(r)}function Ei(e,t){return t.has(e)}import{AST_NODE_TYPES as bi,ESLintUtils as xi}from"@typescript-eslint/utils";import{z as It}from"zod/v4";var Ci=xi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wn="no-call-with-explicit-generics",Ai=It.object({functions:It.array(It.string())}),Ii=Ci({name:Wn,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:[$(Ai)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:s}=n;s.type===bi.Identifier&&r.has(s.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),wt={name:Wn,rule:Ii};import{AST_NODE_TYPES as nt,ESLintUtils as wi}from"@typescript-eslint/utils";var Ri=wi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jn="no-call-with-inferred-generics",Pi=Ri({name:Jn,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,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:s}=n;if(s.type!==nt.Identifier)return;let o=r.get(s.name);if(!o)return;let{minGenerics:i=1,allowAny:p,disallowTypes:a=t.disallowTypes}=o;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:i||0}}),!(p&&!a)&&n.typeArguments?.params.some(g=>!p&&g.type===nt.TSAnyKeyword||a&&g.type===nt.TSTypeReference&&g.typeName.type===nt.Identifier&&a.includes(g.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),Rt={name:Jn,rule:Pi};import{ESLintUtils as vi}from"@typescript-eslint/utils";var Fi=vi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Hn="no-commented-out-code",ki=["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:"],Oi=/^\s*return\s+/,Ni=/\w=("|'|`)/,Di=/\w+:\s*('|"|`)/,ji=/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,Li=/\w+-\w+:/,Mi=/\w+_\w+:/,$i=/\?\s+\w/,_i=/:\s+\w/,Ui=/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,zi=/^\s*\d+[,}]/,Wi=/^\s*\[[^\]]*\][,}]/,Ji=/^\s*\{[^}]*\}[,}]/,Vi=/\.\w+\(/,Xi=/\[\w+\]/,Hi=/^\s*(['"`]).+?\1\s*:/,Bi=/^<[A-Z]\w*(\s|>|\/)/,Yi=/^<[a-z]+(\s|>|\/)/,qi=/<[A-Z]\w*(\s.*)?>/,Zi=/<\/[A-Z]\w*>/,Gi=/<[a-z]+(\s.*)?>/,Ki=/<\/[a-z]+>/,Qi=/^\s*[*\s]*$/,es=/^[a-zA-Z]/,ts=/^[A-Z][A-Za-z]*(?:\s+\d+)?(?:\s+[a-z]+)*:\s+[A-Za-z]/,ns=/```[\s\S]*?```/g,rs=/`[^`]*`/g,Vn=/[a-zA-Z0-9]/,is=/\.[A-Za-z_][A-Za-z0-9_]*\(/,ss=/[{}[\]()`=<>]/,os=/:\s*(['"`[{(]|\w+\s*=>)/,as=/\bif\s*\(|\belse\b|=>/,ne={returnStatement:Oi,stringAssignment:Ni,objectPropertyWithQuotes:Di,computedPropertyAssignment:ji,kebabCaseProperty:Li,snakeCaseProperty:Mi,ternaryOperator:$i,colonWithWord:_i,quotedString:Ui,numberWithComma:zi,arrayWithComma:Wi,objectWithComma:Ji,methodCall:Vi,arrayAccess:Xi,quotedPropertyKey:Hi,jsxSelfClosing:Bi,jsxElement:Yi,jsxOpeningTag:qi,jsxClosingTag:Zi,htmlOpeningTag:Gi,htmlClosingTag:Ki,jsdocComment:Qi};function ls(e){if(e.includes(":")){let r=e.split(":")[0]?.trim();if(r&&es.test(r)&&r.includes(" "))return!0}let t=e.trim();return t.length===0||is.test(t)||ss.test(t)||os.test(t)||as.test(t)?!1:!!(t.includes(":")&&ts.test(t))}var ps=[") {","return;",ne.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",ne.stringAssignment,");",ne.objectPropertyWithQuotes,ne.computedPropertyAssignment,ne.kebabCaseProperty,ne.snakeCaseProperty,"&&","||","()",ne.ternaryOperator,ne.colonWithWord,ne.quotedString,ne.numberWithComma,ne.arrayWithComma,ne.objectWithComma,ne.methodCall,ne.arrayAccess,"?.(","??","=>",ne.quotedPropertyKey],cs=["/>","</",ne.jsxSelfClosing,ne.jsxElement,ne.jsxOpeningTag,ne.jsxClosingTag,ne.htmlOpeningTag,ne.htmlClosingTag],Xn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],us=Fi({name:Hn,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 t(n,s){if(n.startsWith("/"))return!1;let o=n.trimStart();if(n.startsWith("*")||o.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||ne.jsdocComment.test(n))return!1;for(let i of Xn)if(o.startsWith(i))return!1;if(n.includes("https://")||ls(o))return!1;if(s==="Block"){for(let i of cs)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of ki)if(o.startsWith(i))return{wrongPattern:i};for(let i of ps)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,s){let o=n,i=o.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return o;if(s==="Block"&&o.includes("```")){let c=o.split(ns);c.some(S=>Vn.test(S))&&(o=c.join(""))}if(!o.includes("`"))return o;let p=o.split(rs);return p.some(c=>Vn.test(c))?p.join(""):o}return{Program(){let s=e.sourceCode.getAllComments();for(let o of s){let i=r(o.value,o.type),p=t(i,o.type);p&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:p.wrongPattern,allowedPrefixes:Xn.join(", ")}})}}}}}),Pt={name:Hn,rule:us};import{ESLintUtils as fs,TSESTree as ms}from"@typescript-eslint/utils";var ys=fs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bn="no-default-export",ds=ys({name:Bn,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(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.type===ms.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),vt={name:Bn,rule:ds};import{ESLintUtils as gs}from"@typescript-eslint/utils";var Ss=gs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yn="no-leaked-text-in-jsx",Ts=[",",";","[","]","(",")"],hs=Ss({name:Yn,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(t){let r=t.value.trim();if(!r)return;let n="";Ts.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),Ft={name:Yn,rule:hs};import{AST_NODE_TYPES as He,ESLintUtils as Es}from"@typescript-eslint/utils";var bs=Es.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zn="no-non-camel-case-functions",xs=/^(\$?[a-z][a-zA-Z0-9]*)$/;function qn(e){if(e.typeName.type!==He.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===He.Identifier&&t.name==="JSX"&&r.name==="Element"}var Cs=bs({name:Zn,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(t){if(t.id&&!xs.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===He.TSTypeReference?qn(r):r.type===He.TSUnionType&&r.types.some(s=>s.type===He.TSTypeReference&&qn(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),kt={name:Zn,rule:Cs};import{ESLintUtils as As,TSESTree as G}from"@typescript-eslint/utils";var Is=As.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gn="no-optional-root-props",ws=Is({name:Gn,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 t(n){let o=e.sourceCode.getDeclaredVariables(n)[0];if(!o||o.references.length!==1)return!1;let i=o.references[0];if(!i)return!1;for(let p of xt(i.identifier)){if("returnType"in p||p.type===G.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let a=p.parent;if(!a)return!1;if(a.type===G.AST_NODE_TYPES.TSTypeParameterInstantiation&&a.parent.type===G.AST_NODE_TYPES.TSTypeReference&&a.parent.typeName.type===G.AST_NODE_TYPES.Identifier&&a.parent.typeName.name==="FC"){let g=Ue(a.parent.parent,G.AST_NODE_TYPES.VariableDeclaration,4);if(!g)return!1;let S=rt(g,e.sourceCode);return S?!(S.parent.type===G.AST_NODE_TYPES.CallExpression&&S.parent.callee.type===G.AST_NODE_TYPES.Identifier&&S.parent.callee.name==="memo"):!1}if(p.type===G.AST_NODE_TYPES.AssignmentPattern)return!1;if(a.type===G.AST_NODE_TYPES.ArrowFunctionExpression){let c=Ue(a,G.AST_NODE_TYPES.VariableDeclaration);return c?!!rt(c,e.sourceCode):!1}if(a.type===G.AST_NODE_TYPES.FunctionDeclaration)return!!rt(a,e.sourceCode)}return!1}function r(n){n.key.type!==G.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:s=>{let o=Ue(n,G.AST_NODE_TYPES.TSPropertySignature);if(!o)return null;let i=e.sourceCode.getText(o);return s.replaceText(o,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===G.AST_NODE_TYPES.TSTypeLiteral&&!(it(n)||!t(n)))for(let s of n.typeAnnotation.members)s.type===G.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSInterfaceDeclaration(n){if(!(it(n)||!t(n)))for(let s of n.body.body)s.type===G.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSTypeReference(n){if(n.typeName.type!==G.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let s=n.typeArguments.params[0];if(s.type!==G.AST_NODE_TYPES.TSTypeLiteral)return;let o=Ue(n.parent,G.AST_NODE_TYPES.VariableDeclaration,4);if(!o)return;let i=rt(o,e.sourceCode);if(!(!i||i.parent.type===G.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===G.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let a of s.members)a.type===G.AST_NODE_TYPES.TSPropertySignature&&r(a)}}}});function it(e){return e?e.parent?.type===G.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===G.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function rt(e,t){if(it(e))return;let r;if(e.type===G.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===G.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===G.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let s=n.variables.find(i=>i.identifiers.includes(r));if(!s)return;let o=s.references.filter(i=>i.identifier!==r);if(!(o.length!==1||!o[0])&&!it(o[0].identifier.parent.parent))return o[0].identifier}var Ot={name:Gn,rule:ws};import{AST_NODE_TYPES as st}from"@typescript-eslint/utils";var Be=_({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 t=new Set;function r(n){return n?n.type===st.Identifier?t.has(n.name):n.type===st.MemberExpression?r(n.object):!1:!1}return{ImportDeclaration(n){for(let s of n.specifiers)t.add(s.local.name)},ExportNamedDeclaration(n){if(n.source){e.report({node:n,messageId:"noReexport"});return}if(n.declaration?.type===st.VariableDeclaration)for(let s of n.declaration.declarations)r(s.init)&&e.report({node:n,messageId:"noReexport"});n.specifiers.length>0&&e.report({node:n,messageId:"noReexport"})},ExportDefaultDeclaration(n){n.declaration.type===st.Identifier&&t.has(n.declaration.name)&&e.report({node:n,messageId:"noReexport"})},ExportAllDeclaration(n){e.report({node:n,messageId:"noReexport"})}}}});import{ESLintUtils as Rs}from"@typescript-eslint/utils";import Nt from"path";import{z as De}from"zod/v4";var Ps=Rs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kn="no-relative-imports",vs=De.object({find:De.string(),replacement:De.string()}),Fs=De.object({aliases:De.array(vs),rootDir:De.string().optional(),allowNotFoundAliases:De.boolean().optional(),_dev_simulateFileName:De.string().optional()}),ks=Ps({name:Kn,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:[$(Fs)]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function s(i,p){let a=Nt.dirname(p);return Nt.resolve(a,i)}function o(i){let p=t.rootDir??process.cwd(),a=Nt.relative(p,i);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:c,replacement:g}of t.aliases)if(a.startsWith(g)){let S=a.replace(g,c);return{alias:c,newPath:S}}return null}return{ImportDeclaration(i){let p=i.source.value;if(!n(p))return;let a=s(p,r),c=o(a);!c&&t.allowNotFoundAliases||e.report({node:i,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?g=>g.replaceText(i.source,`'${c.newPath}'`):void 0})}}}}),Dt={name:Kn,rule:ks};import{AST_NODE_TYPES as re}from"@typescript-eslint/utils";import{z as Qn}from"zod/v4";var Os=Qn.object({customMessage:Qn.string().optional()}),jt=_({name:"no-static-style-prop",meta:{type:"problem",docs:{description:"Prevent using static style props in JSX, only dynamic values should be allowed"},schema:[$(Os)],messages:{noStaticStyleProp:"Static style props are not allowed use css instead.{{customMessage}}"}},defaultOptions:[{}],create(e,[t]){function r(n){switch(n.type){case re.Literal:return!0;case re.ObjectExpression:return n.properties.every(s=>s.type===re.Property?s.computed||s.value.type===re.Identifier&&s.key.type===re.Identifier&&s.key.name===s.value.name?!1:r(s.value):!1);case re.ArrayExpression:return n.elements.every(s=>s?s.type===re.SpreadElement?!1:r(s):!0);case re.TemplateLiteral:return n.expressions.length===0;case re.ConditionalExpression:case re.LogicalExpression:case re.BinaryExpression:case re.UnaryExpression:case re.CallExpression:case re.MemberExpression:case re.Identifier:case re.ArrowFunctionExpression:case re.FunctionExpression:return!1;default:return!1}}return{JSXAttribute(n){if(n.name.type===re.JSXIdentifier&&n.name.name==="style"&&n.value){let s=null;n.value.type===re.JSXExpressionContainer?n.value.expression.type!==re.JSXEmptyExpression&&(s=n.value.expression):n.value.type===re.Literal&&(s=n.value),s&&r(s)&&e.report({node:n,messageId:"noStaticStyleProp",data:{customMessage:t.customMessage?` ${t.customMessage}`:""}})}}}}});import{AST_NODE_TYPES as ot}from"@typescript-eslint/utils";import*as $e from"zod/v4";var Ns=$e.object({alternativeMsgs:$e.object({inArrayFind:$e.string().optional(),inArrayFilter:$e.string().optional()}).optional(),__dev_simulateFileName:$e.string().optional()});function Ds(e){return e.typeAnnotation.type!==ot.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}var js=/(typeGuards|type-guards)\.(ts|tsx)$/;function Ls(e){return js.test(e)}function Ms(e){let t=e.parent;for(;t;){if(t.type===ot.CallExpression&&t.callee.type===ot.MemberExpression&&t.callee.property.type===ot.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var Lt=_({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:[$(Ns)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(Ls(r))return{};function n(s){if(!Ds(s))return;let o=Ms(s);if(t.alternativeMsgs&&o){let i=o.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let p=o.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:s,messageId:p,data:{message:i}});return}}e.report({node:s,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as We}from"@typescript-eslint/utils";var $s="no-unnecessary-async-on-jsx-props";function _s(e){if(e.body.type!==We.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==We.ExpressionStatement?!1:r.expression.type===We.AwaitExpression}var Mt=_({name:$s,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 t(r){_s(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let s=e.sourceCode,o=[],i=s.getFirstToken(r,a=>a.value==="async");if(i){let a=s.getTokenAfter(i);a?o.push(n.replaceTextRange([i.range[0],a.range[0]],"")):o.push(n.remove(i))}function p(a){if(a.type===We.AwaitExpression){let c=s.getFirstToken(a);if(c&&c.value==="await"){let g=s.getTokenAfter(c);g?o.push(n.replaceTextRange([c.range[0],g.range[0]],"")):o.push(n.remove(c))}}if(a.type===We.BlockStatement)for(let c of a.body)p(c);else a.type===We.ExpressionStatement&&p(a.expression)}return p(r.body),o}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as Ye,ESLintUtils as tr}from"@typescript-eslint/utils";import*as $t from"typescript";import qe from"zod/v4";var Us=tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),er="no-unnecessary-casting",zs=qe.object({additionalCastFunctions:qe.array(qe.object({name:qe.string(),expectedType:qe.enum(["string","number"])})).optional()}),_t={name:er,rule:Us({name:er,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:[$(zs)],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],s=tr.getParserServices(e,!0),o=s.program?.getTypeChecker();if(!o||!s.program)throw new Error("TypeScript services or program not available");function i(g,S){switch(g.type){case Ye.Literal:return S==="number"?typeof g.value=="number":typeof g.value=="string";case Ye.TemplateLiteral:return S==="string";case Ye.UnaryExpression:return S==="number"?g.operator==="+"||g.operator==="-"||g.operator==="~":!1;default:return!1}}function p(g,S){return S==="number"?!!(g.flags&$t.TypeFlags.NumberLike):!!(g.flags&$t.TypeFlags.StringLike)}function a(g,S){return l=>l.replaceText(g,e.sourceCode.getText(S))}function c(g){if(!o||g.arguments.length!==1)return;let S=g.arguments[0];if(!S||S.type===Ye.SpreadElement)return;let{callee:l}=g;if(l.type!==Ye.Identifier)return;let E=l.name,f=n.find(T=>T.name===E);if(!f)return;if(i(S,f.expectedType)||p(o.getTypeAtLocation(s.esTreeNodeToTSNodeMap.get(S)),f.expectedType)){let T,m;E==="Number"?T="unnecessaryNumberCasting":E==="String"?T="unnecessaryStringCasting":(T="unnecessaryCustomCasting",m={name:f.name,type:f.expectedType}),e.report({node:g,messageId:T,...m?{data:m}:{},fix:a(g,S)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as Se}from"@typescript-eslint/utils";import*as at from"zod/v4";var Ws=at.object({ignoreWithDescription:at.string().optional()}),Ut=_({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:[$(Ws)]},defaultOptions:[{}],create(e,[t]){let r=e.getSourceCode(),n=r.ast;function s(a){let c=a.arguments[0];return c&&c.type===Se.Literal&&typeof c.value=="string"?c.value:null}function o(a){return!a||!t.ignoreWithDescription?!1:new RegExp(t.ignoreWithDescription).test(a)}function i(a){return a.length!==1?!1:n.body.filter(g=>{if(g.type===Se.ExpressionStatement){let S=g.expression;if(S.type===Se.CallExpression&&S.callee.type===Se.Identifier){let l=S.callee.name;return["test","it","beforeEach","afterEach","beforeAll","afterAll"].includes(l)}}return!1}).length===0}function p(a){let c=a.arguments[1];if(c&&(c.type===Se.FunctionExpression||c.type===Se.ArrowFunctionExpression)&&c.body.type===Se.BlockStatement){let g=c.body.body;return g.length===0?"":g.map(l=>r.text.slice(l.range[0],l.range[1])).join(`
15
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let u=l.acquire(m),T=new Set,w=null;{let P=u.upper;for(;P&&(T.add(P),P.type!=="function");)P=P.upper;if(!P)return;w=P}let R=Array.isArray;function v(P){if(!R(P.defs))return!1;let k=P.defs[0];if(k==null||k.node.type!=="VariableDeclarator")return!1;let j=k.node.init;if(j==null)return!1;for(;j.type==="TSAsExpression";)j=j.expression;let $=k.node.parent;if($==null&&(At(w.block,k.node.id),$=k.node.parent,$==null))return!1;if($.kind==="const"&&j.type==="Literal"&&(typeof j.value=="string"||typeof j.value=="number"||j.value===null))return!0;if(j.type!=="CallExpression")return!1;let J=j.callee;if(J.type==="MemberExpression"&&J.object.name==="React"&&J.property!=null&&!J.computed&&(J=J.property),J.type!=="Identifier")return!1;let z=k.node.id,{name:H}=J;if(H==="useRef"&&z.type==="Identifier")return!0;if(yi(J)&&z.type==="Identifier"){for(let Z of P.references)Z!==z&&b.add(Z.identifier);return!0}else if(H==="useState"||H==="useReducer"){if(z.type==="ArrayPattern"&&z.elements.length===2&&R(P.identifiers)){if(z.elements[1]===P.identifiers[0]){if(H==="useState"){let Z=P.references,Ae=0;for(let je=0;je<Z.length;je++){if(Z[je].isWrite()&&Ae++,Ae>1)return!1;c.set(Z[je].identifier,z.elements[0])}}return!0}else if(z.elements[0]===P.identifiers[0]){if(H==="useState"){let Z=P.references;for(let Ae=0;Ae<Z.length;Ae++)d.add(Z[Ae].identifier)}return!1}}}else if(H==="useTransition"&&z.type==="ArrayPattern"&&z.elements.length===2&&Array.isArray(P.identifiers)&&z.elements[1]===P.identifiers[0])return!0;return!1}function x(P){if(!R(P.defs))return!1;let k=P.defs[0];if(k==null||k.node==null||k.node.id==null)return!1;let j=k.node,$=w.childScopes,J=null,z;for(z=0;z<$.length;z++){let H=$[z],Z=H.block;if(j.type==="FunctionDeclaration"&&Z===j||j.type==="VariableDeclarator"&&Z.parent===j){J=H;break}}if(J==null)return!1;for(z=0;z<J.through.length;z++){let H=J.through[z];if(H.resolved!=null&&T.has(H.resolved.scope)&&!C(H.resolved))return!1}return!0}let C=f(v,y),F=f(x,g),O=new Map;function G(P){let k=P.from,j=!1;for(;k.block!==m;)k.type==="function"&&(j=k.block.parent!=null&&k.block.parent.type==="ReturnStatement"),k=k.upper;return j}let _=new Map,te=new Map;M(u);function M(P){for(let k of P.references){if(!k.resolved||!T.has(k.resolved.scope))continue;let j=At(m,k.identifier),$=$n(j),J=Le($,te);if(S&&$.type==="Identifier"&&($.parent.type==="MemberExpression"||$.parent.type==="OptionalMemberExpression")&&!$.parent.computed&&$.parent.property.type==="Identifier"&&$.parent.property.name==="current"&&G(k)&&O.set(J,{reference:k,dependencyNode:$}),$.parent.type==="TSTypeQuery"||$.parent.type==="TSTypeReference")continue;let z=k.resolved.defs[0];if(z!=null&&!(z.node!=null&&z.node.init===m.parent)&&z.type!=="TypeParameter")if(_.has(J))_.get(J).references.push(k);else{let H=k.resolved,Z=C(H)||F(H);_.set(J,{isStable:Z,references:[k]})}}for(let k of P.childScopes)M(k)}O.forEach(({reference:P,dependencyNode:k},j)=>{let $=P.resolved.references,J=!1;for(let z=0;z<$.length;z++){let{identifier:H}=$[z],{parent:Z}=H;if(Z!=null&&Z.type==="MemberExpression"&&!Z.computed&&Z.property.type==="Identifier"&&Z.property.name==="current"&&Z.parent.type==="AssignmentExpression"&&Z.parent.left===Z){J=!0;break}}J||p({node:k.parent.property,message:`The ref value '${j}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${j}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let W=new Set;function X(P,k){W.has(k)||(W.add(k),p({node:P,message:`Assignments to the '${k}' variable from inside React Hook ${r(I)} 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(I)}.`}))}let ne=new Set;if(_.forEach(({isStable:P,references:k},j)=>{P&&ne.add(j),k.forEach($=>{$.writeExpr&&X($.writeExpr,j)})}),W.size>0)return;if(!A){let P=null;if(_.forEach(({isStable:k,references:j},$)=>{P||j.forEach(J=>{if(P)return;let z=J.identifier;if(!c.has(z))return;let Z=J.from;for(;Z.type!=="function";)Z=Z.upper;Z.block===m&&(P=$)})}),P){let{suggestedDependencies:k}=Ct({dependencies:_,declaredDependencies:[],stableDependencies:ne,externalDependencies:new Set,isEffect:!0});p({node:I,message:`React Hook ${o} contains a call to '${P}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+k.join(", ")+`] as a second argument to the ${o} Hook.`,suggest:[{desc:`Add dependencies array: [${k.join(", ")}]`,fix(j){return j.insertTextAfter(m,`, [${k.join(", ")}]`)}}]})}return}let le=[],Ee=new Set;A.type!=="ArrayExpression"?p({node:A,message:`React Hook ${r(I)} 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(P=>{if(P===null)return;if(P.type==="SpreadElement"){p({node:P,message:`React Hook ${r(I)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}b.has(P)&&p({node:P,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(P)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(P)}\``,fix(J){return J.removeRange(P.range)}}]});let k;try{k=Le(P,te)}catch(J){if(/Unsupported node type/.test(J.message)){P.type==="Literal"?_.has(P.value)?p({node:P,message:`The ${P.raw} literal is not a valid dependency because it never changes. Did you mean to include ${P.value} in the array instead?`}):p({node:P,message:`The ${P.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):p({node:P,message:`React Hook ${r(I)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw J}let j=P;for(;j.type==="MemberExpression"||j.type==="OptionalMemberExpression"||j.type==="ChainExpression";)j=j.object||j.expression.object;let $=!w.through.some(J=>J.identifier===j);le.push({key:k,node:P}),$||Ee.add(k)});let{suggestedDependencies:be,unnecessaryDependencies:xe,missingDependencies:Se,duplicateDependencies:it}=Ct({dependencies:_,declaredDependencies:le,stableDependencies:ne,externalDependencies:Ee,isEffect:S}),Ze=be;if(it.size+Se.size+xe.size===0){if(t)return;ui({declaredDependencies:le,declaredDependenciesNode:A,componentScope:w,scope:u}).forEach(({construction:k,isUsedOutsideOfHook:j,depType:$})=>{let J=$==="function"?"useCallback":"useMemo",z=$==="function"?"definition":"initialization",H=`wrap the ${z} of '${k.name.name}' in its own ${J}() Hook.`,Z=j?`To fix this, ${H}`:`Move it inside the ${o} callback. Alternatively, ${H}`,Ae=$==="conditional"||$==="logical expression"?"could make":"makes",je=`The '${k.name.name}' ${$} ${Ae} the dependencies of ${o} Hook (at line ${A.loc.start.line}) change on every render. ${Z}`,Pn;j&&k.type==="Variable"&&$==="function"&&(Pn=[{desc:`Wrap the ${z} of '${k.name.name}' in its own ${J}() Hook.`,fix(vn){let[Qr,ei]=J==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[vn.insertTextBefore(k.node.init,Qr),vn.insertTextAfter(k.node.init,ei)]}}]),p({node:k.node,message:je,suggest:Pn})});return}!S&&Se.size>0&&(Ze=Ct({dependencies:_,declaredDependencies:[],stableDependencies:ne,externalDependencies:Ee,isEffect:S}).suggestedDependencies);function Ie(){if(le.length===0)return!0;let P=le.map(j=>j.key),k=P.slice().sort();return P.join(",")===k.join(",")}Ie()&&Ze.sort();function Tt(P){let k=P.split("."),j="";for(let $=0;$<k.length;$++){if($!==0){let J=k.slice(0,$+1).join("."),z=te.get(J)===!0;j+=z?"?.":"."}j+=k[$]}return j}function ht(P,k,j,$){return P.size===0?null:(P.size>1?"":k+" ")+j+" "+(P.size>1?"dependencies":"dependency")+": "+mi(Array.from(P).sort().map(J=>"'"+Tt(J)+"'"))+`. Either ${$} ${P.size>1?"them":"it"} or remove the dependency array.`}let ve="";if(xe.size>0){let P=null;if(Array.from(xe.keys()).forEach(k=>{P===null&&k.endsWith(".current")&&(P=k)}),P!==null)ve=` Mutable values like '${P}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Ee.size>0){let k=Array.from(Ee)[0];u.set.has(k)||(ve=` Outer scope values like '${k}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ve&&Se.has("props")){let P=_.get("props");if(P==null)return;let k=P.references;if(!Array.isArray(k))return;let j=!0;for(let $=0;$<k.length;$++){let J=k[$],z=At(w.block,J.identifier);if(!z){j=!1;break}let H=z.parent;if(H==null){j=!1;break}if(H.type!=="MemberExpression"&&H.type!=="OptionalMemberExpression"){j=!1;break}}j&&(ve=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${o} call and refer to those specific props inside ${r(I)}.`)}if(!ve&&Se.size>0){let P=null;Se.forEach(k=>{if(P)return;let j=w.set.get(k),$=_.get(k);if($.references[0].resolved!==j)return;let J=j.defs[0];if(J==null||J.name==null||J.type!=="Parameter")return;let z=!1,H;for(let Z=0;Z<$.references.length;Z++)if(H=$.references[Z].identifier,H!=null&&H.parent!=null&&(H.parent.type==="CallExpression"||H.parent.type==="OptionalCallExpression")&&H.parent.callee===H){z=!0;break}z&&(P=k)}),P!==null&&(ve=` If '${P}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ve&&Se.size>0){let P=null;if(Se.forEach(k=>{if(P!==null)return;let $=_.get(k).references,J,z;for(let H=0;H<$.length;H++){for(J=$[H].identifier,z=J.parent;z!=null&&z!==w.block;){if(z.type==="CallExpression"){let Z=c.get(z.callee);if(Z!=null){if(Z.name===k)P={missingDep:k,setter:z.callee.name,form:"updater"};else if(d.has(J))P={missingDep:k,setter:z.callee.name,form:"reducer"};else{let Ae=$[H].resolved;if(Ae!=null){let je=Ae.defs[0];je!=null&&je.type==="Parameter"&&(P={missingDep:k,setter:z.callee.name,form:"inlineReducer"})}}break}}z=z.parent}if(P!==null)break}}),P!==null)switch(P.form){case"reducer":ve=` You can also replace multiple useState variables with useReducer if '${P.setter}' needs the current value of '${P.missingDep}'.`;break;case"inlineReducer":ve=` If '${P.setter}' needs the current value of '${P.missingDep}', you can also switch to useReducer instead of useState and read '${P.missingDep}' in the reducer.`;break;case"updater":ve=` You can also do a functional update '${P.setter}(${P.missingDep.slice(0,1)} => ...)' if you only need '${P.missingDep}' in the '${P.setter}' call.`;break;default:throw new Error("Unknown case.")}}p({node:A,message:`React Hook ${r(I)} has `+(ht(Se,"a","missing","include")||ht(xe,"an","unnecessary","exclude")||ht(it,"a","duplicate","omit"))+ve,suggest:[{desc:`Update the dependencies array to be: [${Ze.map(Tt).join(", ")}]`,fix(P){return P.replaceText(A,`[${Ze.map(Tt).join(", ")}]`)}}]})}function h(m){let A=fi(m.callee,i);if(A===-1)return;let I=m.arguments[A],o=m.callee,S=_n(o).name,u=m.arguments[A+1],T=/Effect($|[^a-z])/g.test(S);if(!I){p({node:o,message:`React Hook ${S} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!T)){if(!u&&!T){(S==="useMemo"||S==="useCallback")&&p({node:o,message:`React Hook ${S} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(I.type){case"FunctionExpression":case"ArrowFunctionExpression":E(I,u,o,S,T);return;case"Identifier":if(!u||u.elements&&u.elements.some(v=>v&&v.type==="Identifier"&&v.name===I.name))return;let w=n(m).set.get(I.name);if(w==null||w.defs==null)return;let R=w.defs[0];if(!R||!R.node||R.type!=="Variable"&&R.type!=="FunctionName")break;switch(R.node.type){case"FunctionDeclaration":E(R.node,u,o,S,T);return;case"VariableDeclarator":let v=R.node.init;if(!v)break;switch(v.type){case"ArrowFunctionExpression":case"FunctionExpression":E(v,u,o,S,T);return}break}break;default:p({node:o,message:`React Hook ${S} received a function whose dependencies are unknown. Pass an inline function instead.`});return}p({node:o,message:`React Hook ${S} has a missing dependency: '${I.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${I.name}]`,fix(w){return w.replaceText(u,`[${I.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let m of e.sourceCode.getAllComments())if(ci.test(m.value))return t=!0,{CallExpression:A=>h(A,!0)}}return{CallExpression:m=>h(m)}}};function Ct({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:s}){let a=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,h)=>{let m=p(a,h);m.isUsed=!0,l(a,h,A=>{A.isSubtreeUsed=!0})}),t.forEach(({key:E})=>{let h=p(a,E);h.isSatisfiedRecursively=!0}),r.forEach(E=>{let h=p(a,E);h.isSatisfiedRecursively=!0});function p(E,h){let m=h.split("."),A=E;for(let I of m){let o=A.children.get(I);o||(o=i(),A.children.set(I,o)),A=o}return A}function l(E,h,m){let A=h.split("."),I=E;for(let o of A){let S=I.children.get(o);if(!S)return;m(S),I=S}}let c=new Set,d=new Set;y(a,c,d,E=>E);function y(E,h,m,A){E.children.forEach((I,o)=>{let S=A(o);if(I.isSatisfiedRecursively){I.isSubtreeUsed&&m.add(S);return}if(I.isUsed){h.add(S);return}y(I,h,m,u=>S+"."+u)})}let g=[],b=new Set,f=new Set;return t.forEach(({key:E})=>{d.has(E)?g.indexOf(E)===-1?g.push(E):f.add(E):b.add(E)}),c.forEach(E=>{g.push(E)}),{suggestedDependencies:g,unnecessaryDependencies:b,duplicateDependencies:f,missingDependencies:c}}function _e(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 _e(e.consequent)!=null||_e(e.alternate)!=null?"conditional":null;case"LogicalExpression":return _e(e.left)!=null||_e(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return _e(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return _e(e.expression);case"TSAsExpression":return _e(e.expression)}return null}function ui({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let s=e.map(({key:i})=>{let p=r.variables.find(c=>c.name===i);if(p==null)return null;let l=p.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=_e(l.node.init);if(c!=null)return[p,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[p,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[p,"class"]:null}).filter(Boolean);function a(i){let p=!1;for(let l=0;l<i.references.length;l++){let c=i.references[l];if(c.writeExpr){if(p)return!0;p=!0;continue}let d=c.from;for(;d!==n&&d!=null;)d=d.upper;if(d!==n&&!Un(t,c.identifier))return!0}return!1}return s.map(([i,p])=>({construction:i.defs[0],depType:p,isUsedOutsideOfHook:a(i)}))}function $n(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)?$n(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function It(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function Le(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=Le(e.object,t),n=Le(e.property,null),s=`${r}.${n}`;return It(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Le(e.object,t),n=Le(e.property,null),s=`${r}.${n}`;return It(e,t,s),s}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=Le(r.object,t),s=Le(r.property,null),a=`${n}.${s}`;return It(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function _n(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function fi(e,t){let r=_n(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&&t&&t.additionalHooks){let n;try{n=Le(r,null)}catch(s){if(/Unsupported node type/.test(s.message))return 0;throw s}return t.additionalHooks.test(n)?0:-1}else return-1}}function At(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),di(n,t))return n;if(Un(n,t))for(let[s,a]of Object.entries(n))s!=="parent"&&(Ln(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(i=>{Ln(i)&&(i.parent=n,r.push(i))}))}return null}function mi(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function Ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function di(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function Un(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function yi(e){return!1}import{AST_NODE_TYPES as ce,ESLintUtils as Bn}from"@typescript-eslint/utils";import Y from"typescript";import{z as Vn}from"zod/v4";import{AST_NODE_TYPES as zn}from"@typescript-eslint/utils";function Xe(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Xe(e.parent,t,r===1/0?r:r-1)}function*wt(e){yield e,e.parent&&(yield*wt(e.parent))}function Rt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function Jn(e,t,r){let s=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===zn.Property&&a.identifiers[0].parent.key.type===zn.Identifier&&a.identifiers[0].parent.key.name===t);return s?s.references.filter(a=>!a.init):[]}function Wn(e){return e===null||typeof e!="object"||!("type"in e)?!1:typeof e.type=="string"}function gi(e,t){return e[t]}function Fe(e,t,r){let n=r.visitorKeys,s=new Set;function a(i){if(s.has(i))return!1;if(s.add(i),t(i)===!0)return!0;let l=n[i.type];if(l)for(let c of l){let d=gi(i,c);if(d){if(Array.isArray(d)){for(let y of d)if(Wn(y)&&a(y))return!0}else if(Wn(d)&&a(d))return!0}}return!1}a(e)}var Si=Bn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xn="improved-no-unnecessary-condition",Ti=Vn.object({alternativeForInCondition:Vn.string().optional().describe("Alternative to appear in the error for `in` condition")}),hi=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Ei=new Set(hi),Pt={name:Xn,rule:Si({name:Xn,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.",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:[V(Ti)]},defaultOptions:[{}],create(e,[t]){let r=Bn.getParserServices(e,!0),n=r.program?.getTypeChecker();if(!n||!r.program)throw new Error("TypeScript services or program not available");function s(o){return o.type===ce.UnaryExpression&&o.operator==="typeof"}function a(o){return o.flags&Y.TypeFlags.Any||o.flags&Y.TypeFlags.Unknown?null:o.flags&Y.TypeFlags.StringLike?["string"]:o.flags&Y.TypeFlags.NumberLike?["number"]:o.flags&Y.TypeFlags.BigIntLike?["bigint"]:o.flags&Y.TypeFlags.BooleanLike?["boolean"]:o.flags&Y.TypeFlags.ESSymbolLike?["symbol"]:o.flags&Y.TypeFlags.Undefined||o.flags&Y.TypeFlags.Void?["undefined"]:o.flags&Y.TypeFlags.Null?["object"]:o.getCallSignatures().length>0?["function"]:o.flags&Y.TypeFlags.Object?o.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:o.flags&Y.TypeFlags.NonPrimitive?["object"]:o.flags&Y.TypeFlags.Never?["never"]:null}function i(o){if(!n)return null;let S=r.esTreeNodeToTSNodeMap.get(o),u=n.getTypeAtLocation(S.expression);if(u.flags&Y.TypeFlags.Any||u.flags&Y.TypeFlags.Unknown)return null;let T=[];if(u.isUnion()){for(let R of u.types){let v=a(R);if(v)T.push(...v);else return null}return T}let w=a(u);return w?(T.push(...w),T):null}function p(o){if(!(o.operator==="==="||o.operator==="!=="))return;let u=null,T=null;if(s(o.left)?(u=o.left,T=o.right.type===ce.Literal&&typeof o.right.value=="string"?o.right.value:null):s(o.right)&&(u=o.right,T=o.left.type===ce.Literal&&typeof o.left.value=="string"?o.left.value:null),!u||!T||!bi(T,Ei))return;let w=i(u);if(!w)return;let R=o.operator==="!==",v=w.includes(T);w.length===1?v&&!R?e.report({node:o,messageId:"unnecessaryTypeofCondition",data:{name:Be(u,e),type:T}}):!v&&R?e.report({node:o,messageId:"unnecessaryTypeofCondition",data:{name:Be(u,e),type:Array.from(w)[0]}}):!v&&!R?e.report({node:o,messageId:"alwaysFalseTypeofCondition",data:{name:Be(u,e),actualType:ot(w),conditionType:T}}):v&&R&&e.report({node:o,messageId:"alwaysFalseTypeofCondition",data:{name:Be(u,e),actualType:ot(w),conditionType:T}}):!v&&!R?e.report({node:o,messageId:"alwaysFalseTypeofCondition",data:{name:Be(u,e),actualType:ot(w),conditionType:T}}):!v&&R&&e.report({node:o,messageId:"unnecessaryTypeofCondition",data:{name:Be(u,e),type:ot(w)}})}function l(o){if(o.flags&Y.TypeFlags.Any||o.flags&Y.TypeFlags.Unknown)return null;if(o.isUnion()){let S=[];for(let u of o.types)if(u.flags&Y.TypeFlags.StringLiteral){let T=u.value;S.push(T)}else return null;return S}return o.flags&Y.TypeFlags.StringLiteral?[o.value]:null}function c(o){if(!n)return null;let S=r.esTreeNodeToTSNodeMap.get(o),u=n.getTypeAtLocation(S),T=l(u);if(T)return T;let w=n.getSymbolAtLocation(S);if(w){let R=n.getTypeOfSymbolAtLocation(w,S),v=l(R);if(v)return v}return null}function d(o){let S=e.sourceCode.ast,u=null;return Fe(S,T=>{if(T.type===ce.VariableDeclarator&&T.id.type===ce.Identifier&&T.id.name===o.name&&T.id.typeAnnotation){let w=T.id.typeAnnotation.typeAnnotation;if(w.type===ce.TSUnionType){let R=[];for(let v of w.types)if(v.type===ce.TSLiteralType&&v.literal.type===ce.Literal&&typeof v.literal.value=="string")R.push(v.literal.value);else return!0;return u=R,!0}if(w.type===ce.TSLiteralType&&w.literal.type===ce.Literal&&typeof w.literal.value=="string")return u=[w.literal.value],!0}return!1},e.sourceCode),u}function y(o){if(o.callee.type!==ce.MemberExpression||o.callee.property.type!==ce.Identifier||o.callee.computed)return;let S=o.callee.property.name;if(S!=="startsWith"&&S!=="endsWith"&&S!=="includes"||o.arguments.length!==1)return;let[u]=o.arguments;if(!u||u.type!==ce.Literal||typeof u.value!="string")return;let T=o.callee.object,w=c(T);if(!w&&T.type===ce.Identifier&&(w=d(T)),!w||w.length===0)return;let R=u.value;if(S==="includes"&&w.length>1)return;let v=0,x=0;for(let C of w)if((S==="startsWith"?C.startsWith(R):S==="endsWith"?C.endsWith(R):C.includes(R))?v++:x++,v>0&&x>0)return;if(v>0&&x===0){let C=S==="startsWith"?"unnecessaryStartsWithCondition":S==="endsWith"?"unnecessaryEndsWithCondition":"unnecessaryIncludesCondition";e.report({node:o,messageId:C})}else if(x>0&&v===0){let C=S==="startsWith"?"alwaysFalseStartsWithCondition":S==="endsWith"?"alwaysFalseEndsWithCondition":"alwaysFalseIncludesCondition";e.report({node:o,messageId:C})}}function g(o){if(!new Set(["===","!==",">",">=","<","<="]).has(o.operator))return;function u(F){if(F.type!==ce.MemberExpression||F.computed||F.property.type!==ce.Identifier||F.property.name!=="length")return null;let O=F.object,G=c(O);if(!G||G.length===0)return null;let _=[];for(let te of G)_.push(te.length);return{values:_}}let T=u(o.left),w=u(o.right),R=null,v=null;if(T?o.right.type===ce.Literal&&typeof o.right.value=="number"&&(R=T.values,v=o.right.value):w&&o.left.type===ce.Literal&&typeof o.left.value=="number"&&(R=w.values,v=o.left.value),!R||v===null)return;let x=0,C=0;for(let F of R){let O=!1;if(o.operator==="==="?O=F===v:o.operator==="!=="?O=F!==v:o.operator===">"?O=F>v:o.operator===">="?O=F>=v:o.operator==="<"?O=F<v:o.operator==="<="&&(O=F<=v),O?x++:C++,x>0&&C>0)return}x>0&&C===0?e.report({node:o,messageId:"unnecessaryLengthCondition"}):C>0&&x===0&&e.report({node:o,messageId:"alwaysFalseLengthCondition"})}function b(o){if(o.type===ce.Literal&&typeof o.value=="string")return o.value;let S=c(o);if(!S||S.length!==1)return null;let[u]=S;return u??null}function f(o){return(o.flags&Y.TypeFlags.Intersection)!==0}function E(o){return(o.flags&Y.TypeFlags.Object)!==0}function h(o){return!n||n.getIndexTypeOfType(o,Y.IndexKind.String)?!0:!!n.getIndexTypeOfType(o,Y.IndexKind.Number)}function m(o,S){if(!n||h(o)||o.getProperties().length===0)return"unknown";let u=n.getPropertyOfType(o,S);return u?u.flags&Y.SymbolFlags.Optional?"optional":"required":"absent"}function A(o,S){if(o.flags&Y.TypeFlags.Any||o.flags&Y.TypeFlags.Unknown||o.flags&Y.TypeFlags.Never||o.flags&Y.TypeFlags.TypeParameter||o.flags&Y.TypeFlags.IndexedAccess||o.flags&Y.TypeFlags.StringLike||o.flags&Y.TypeFlags.NumberLike||o.flags&Y.TypeFlags.BigIntLike||o.flags&Y.TypeFlags.BooleanLike||o.flags&Y.TypeFlags.EnumLike||o.flags&Y.TypeFlags.ESSymbolLike||o.flags&Y.TypeFlags.NonPrimitive||o.flags&Y.TypeFlags.Null||o.flags&Y.TypeFlags.Undefined||o.flags&Y.TypeFlags.Void)return"unknown";if(o.isUnion()){let u=!0,T=!0;for(let w of o.types){let R=A(w,S);if(R==="unknown"||(R!=="required"&&(u=!1),R!=="absent"&&(T=!1),R==="optional"))return"unknown"}return u?"required":T?"absent":"unknown"}if(f(o)){let u=o,T=!1,w=!1;for(let R of u.types){let v=A(R,S);if(v==="unknown")return"unknown";v==="required"?T=!0:v==="optional"&&(w=!0)}return T?"required":w?"optional":"absent"}return E(o)?m(o,S):"unknown"}function I(o){if(o.operator!=="in"||o.left.type===ce.PrivateIdentifier)return;let S=b(o.left);if(!S)return;let u=o.right,T=r.esTreeNodeToTSNodeMap.get(u);if(!n)return;let w=n.getTypeAtLocation(T),R=A(w,S);R==="required"?e.report({node:o,messageId:"unnecessaryInCondition",data:{property:S,type:n.typeToString(w),alternative:t.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${t.alternativeForInCondition}`:""}}):R==="absent"&&e.report({node:o,messageId:"alwaysFalseInCondition",data:{property:S,type:n.typeToString(w),alternative:t.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${t.alternativeForInCondition}`:""}})}return{BinaryExpression(o){p(o),g(o),I(o)},CallExpression:y}}})};function ot(e){return Array.from(new Set(e)).join(" | ")||"never"}function Be(e,t){let r=e.argument;return r.type===ce.Identifier?r.name:t.sourceCode.getText(r)}function bi(e,t){return t.has(e)}import{AST_NODE_TYPES as xi,ESLintUtils as Ci}from"@typescript-eslint/utils";import{z as vt}from"zod/v4";var Ii=Ci.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Hn="no-call-with-explicit-generics",Ai=vt.object({functions:vt.array(vt.string())}),wi=Ii({name:Hn,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:[V(Ai)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:s}=n;s.type===xi.Identifier&&r.has(s.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),Ft={name:Hn,rule:wi};import{AST_NODE_TYPES as st,ESLintUtils as Ri}from"@typescript-eslint/utils";var Pi=Ri.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yn="no-call-with-inferred-generics",vi=Pi({name:Yn,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,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:s}=n;if(s.type!==st.Identifier)return;let a=r.get(s.name);if(!a)return;let{minGenerics:i=1,allowAny:p,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:i||0}}),!(p&&!l)&&n.typeArguments?.params.some(d=>!p&&d.type===st.TSAnyKeyword||l&&d.type===st.TSTypeReference&&d.typeName.type===st.Identifier&&l.includes(d.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),kt={name:Yn,rule:vi};import{ESLintUtils as Fi}from"@typescript-eslint/utils";var ki=Fi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gn="no-commented-out-code",Oi=["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:"],Ni=/^\s*return\s+/,Di=/\w=("|'|`)/,ji=/\w+:\s*('|"|`)/,Li=/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,Mi=/\w+-\w+:/,$i=/\w+_\w+:/,_i=/\?\s+\w/,Ui=/:\s+\w/,zi=/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,Wi=/^\s*\d+[,}]/,Ji=/^\s*\[[^\]]*\][,}]/,Vi=/^\s*\{[^}]*\}[,}]/,Xi=/\.\w+\(/,Bi=/\[\w+\]/,Hi=/^\s*(['"`]).+?\1\s*:/,Yi=/^<[A-Z]\w*(\s|>|\/)/,qi=/^<[a-z]+(\s|>|\/)/,Zi=/<[A-Z]\w*(\s.*)?>/,Gi=/<\/[A-Z]\w*>/,Ki=/<[a-z]+(\s.*)?>/,Qi=/<\/[a-z]+>/,eo=/^\s*[*\s]*$/,to=/^[a-zA-Z]/,no=/^[A-Z][A-Za-z]*(?:\s+\d+)?(?:\s+[a-z]+)*:\s+[A-Za-z]/,ro=/```[\s\S]*?```/g,io=/`[^`]*`/g,qn=/[a-zA-Z0-9]/,oo=/\.[A-Za-z_][A-Za-z0-9_]*\(/,so=/[{}[\]()`=<>]/,ao=/:\s*(['"`[{(]|\w+\s*=>)/,lo=/\bif\s*\(|\belse\b|=>/,pe={returnStatement:Ni,stringAssignment:Di,objectPropertyWithQuotes:ji,computedPropertyAssignment:Li,kebabCaseProperty:Mi,snakeCaseProperty:$i,ternaryOperator:_i,colonWithWord:Ui,quotedString:zi,numberWithComma:Wi,arrayWithComma:Ji,objectWithComma:Vi,methodCall:Xi,arrayAccess:Bi,quotedPropertyKey:Hi,jsxSelfClosing:Yi,jsxElement:qi,jsxOpeningTag:Zi,jsxClosingTag:Gi,htmlOpeningTag:Ki,htmlClosingTag:Qi,jsdocComment:eo};function po(e){if(e.includes(":")){let r=e.split(":")[0]?.trim();if(r&&to.test(r)&&r.includes(" "))return!0}let t=e.trim();return t.length===0||oo.test(t)||so.test(t)||ao.test(t)||lo.test(t)?!1:!!(t.includes(":")&&no.test(t))}var co=[") {","return;",pe.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",pe.stringAssignment,");",pe.objectPropertyWithQuotes,pe.computedPropertyAssignment,pe.kebabCaseProperty,pe.snakeCaseProperty,"&&","||","()",pe.ternaryOperator,pe.colonWithWord,pe.quotedString,pe.numberWithComma,pe.arrayWithComma,pe.objectWithComma,pe.methodCall,pe.arrayAccess,"?.(","??","=>",pe.quotedPropertyKey],uo=["/>","</",pe.jsxSelfClosing,pe.jsxElement,pe.jsxOpeningTag,pe.jsxClosingTag,pe.htmlOpeningTag,pe.htmlClosingTag],Zn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],fo=ki({name:Gn,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 t(n,s){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||pe.jsdocComment.test(n))return!1;for(let i of Zn)if(a.startsWith(i))return!1;if(n.includes("https://")||po(a))return!1;if(s==="Block"){for(let i of uo)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Oi)if(a.startsWith(i))return{wrongPattern:i};for(let i of co)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,s){let a=n,i=a.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return a;if(s==="Block"&&a.includes("```")){let c=a.split(ro);c.some(y=>qn.test(y))&&(a=c.join(""))}if(!a.includes("`"))return a;let p=a.split(io);return p.some(c=>qn.test(c))?p.join(""):a}return{Program(){let s=e.sourceCode.getAllComments();for(let a of s){let i=r(a.value,a.type),p=t(i,a.type);p&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:p.wrongPattern,allowedPrefixes:Zn.join(", ")}})}}}}}),Ot={name:Gn,rule:fo};import{ESLintUtils as mo,TSESTree as yo}from"@typescript-eslint/utils";var go=mo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kn="no-default-export",So=go({name:Kn,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(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.type===yo.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Nt={name:Kn,rule:So};import{ESLintUtils as To}from"@typescript-eslint/utils";var ho=To.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qn="no-leaked-text-in-jsx",Eo=[",",";","[","]","(",")"],bo=ho({name:Qn,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(t){let r=t.value.trim();if(!r)return;let n="";Eo.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),Dt={name:Qn,rule:bo};import{AST_NODE_TYPES as Ge,ESLintUtils as xo}from"@typescript-eslint/utils";var Co=xo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tr="no-non-camel-case-functions",Io=/^(\$?[a-z][a-zA-Z0-9]*)$/;function er(e){if(e.typeName.type!==Ge.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Ge.Identifier&&t.name==="JSX"&&r.name==="Element"}var Ao=Co({name:tr,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(t){if(t.id&&!Io.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Ge.TSTypeReference?er(r):r.type===Ge.TSUnionType&&r.types.some(s=>s.type===Ge.TSTypeReference&&er(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),jt={name:tr,rule:Ao};import{ESLintUtils as wo,TSESTree as oe}from"@typescript-eslint/utils";var Ro=wo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nr="no-optional-root-props",Po=Ro({name:nr,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 t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let i=a.references[0];if(!i)return!1;for(let p of wt(i.identifier)){if("returnType"in p||p.type===oe.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=p.parent;if(!l)return!1;if(l.type===oe.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===oe.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===oe.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let d=Xe(l.parent.parent,oe.AST_NODE_TYPES.VariableDeclaration,4);if(!d)return!1;let y=at(d,e.sourceCode);return y?!(y.parent.type===oe.AST_NODE_TYPES.CallExpression&&y.parent.callee.type===oe.AST_NODE_TYPES.Identifier&&y.parent.callee.name==="memo"):!1}if(p.type===oe.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===oe.AST_NODE_TYPES.ArrowFunctionExpression){let c=Xe(l,oe.AST_NODE_TYPES.VariableDeclaration);return c?!!at(c,e.sourceCode):!1}if(l.type===oe.AST_NODE_TYPES.FunctionDeclaration)return!!at(l,e.sourceCode)}return!1}function r(n){n.key.type!==oe.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:s=>{let a=Xe(n,oe.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let i=e.sourceCode.getText(a);return s.replaceText(a,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===oe.AST_NODE_TYPES.TSTypeLiteral&&!(lt(n)||!t(n)))for(let s of n.typeAnnotation.members)s.type===oe.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSInterfaceDeclaration(n){if(!(lt(n)||!t(n)))for(let s of n.body.body)s.type===oe.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSTypeReference(n){if(n.typeName.type!==oe.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let s=n.typeArguments.params[0];if(s.type!==oe.AST_NODE_TYPES.TSTypeLiteral)return;let a=Xe(n.parent,oe.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let i=at(a,e.sourceCode);if(!(!i||i.parent.type===oe.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===oe.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of s.members)l.type===oe.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function lt(e){return e?e.parent?.type===oe.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===oe.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function at(e,t){if(lt(e))return;let r;if(e.type===oe.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===oe.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===oe.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let s=n.variables.find(i=>i.identifiers.includes(r));if(!s)return;let a=s.references.filter(i=>i.identifier!==r);if(!(a.length!==1||!a[0])&&!lt(a[0].identifier.parent.parent))return a[0].identifier}var Lt={name:nr,rule:Po};import{AST_NODE_TYPES as pt}from"@typescript-eslint/utils";var Ke=B({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 t=new Set;function r(n){return n?n.type===pt.Identifier?t.has(n.name):n.type===pt.MemberExpression?r(n.object):!1:!1}return{ImportDeclaration(n){for(let s of n.specifiers)t.add(s.local.name)},ExportNamedDeclaration(n){if(n.source){e.report({node:n,messageId:"noReexport"});return}if(n.declaration?.type===pt.VariableDeclaration)for(let s of n.declaration.declarations)r(s.init)&&e.report({node:n,messageId:"noReexport"});n.specifiers.length>0&&e.report({node:n,messageId:"noReexport"})},ExportDefaultDeclaration(n){n.declaration.type===pt.Identifier&&t.has(n.declaration.name)&&e.report({node:n,messageId:"noReexport"})},ExportAllDeclaration(n){e.report({node:n,messageId:"noReexport"})}}}});import{ESLintUtils as vo}from"@typescript-eslint/utils";import Mt from"path";import{z as Ue}from"zod/v4";var Fo=vo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rr="no-relative-imports",ko=Ue.object({find:Ue.string(),replacement:Ue.string()}),Oo=Ue.object({aliases:Ue.array(ko),rootDir:Ue.string().optional(),allowNotFoundAliases:Ue.boolean().optional(),_dev_simulateFileName:Ue.string().optional()}),No=Fo({name:rr,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:[V(Oo)]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function s(i,p){let l=Mt.dirname(p);return Mt.resolve(l,i)}function a(i){let p=t.rootDir??process.cwd(),l=Mt.relative(p,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:d}of t.aliases)if(l.startsWith(d)){let y=l.replace(d,c);return{alias:c,newPath:y}}return null}return{ImportDeclaration(i){let p=i.source.value;if(!n(p))return;let l=s(p,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:i,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?d=>d.replaceText(i.source,`'${c.newPath}'`):void 0})}}}}),$t={name:rr,rule:No};import{AST_NODE_TYPES as ue}from"@typescript-eslint/utils";import{z as ir}from"zod/v4";var Do=ir.object({customMessage:ir.string().optional()}),_t=B({name:"no-static-style-prop",meta:{type:"problem",docs:{description:"Prevent using static style props in JSX, only dynamic values should be allowed"},schema:[V(Do)],messages:{noStaticStyleProp:"Static style props are not allowed use css instead.{{customMessage}}"}},defaultOptions:[{}],create(e,[t]){function r(n){switch(n.type){case ue.Literal:return!0;case ue.ObjectExpression:return n.properties.every(s=>s.type===ue.Property?s.computed||s.value.type===ue.Identifier&&s.key.type===ue.Identifier&&s.key.name===s.value.name?!1:r(s.value):!1);case ue.ArrayExpression:return n.elements.every(s=>s?s.type===ue.SpreadElement?!1:r(s):!0);case ue.TemplateLiteral:return n.expressions.length===0;case ue.ConditionalExpression:case ue.LogicalExpression:case ue.BinaryExpression:case ue.UnaryExpression:case ue.CallExpression:case ue.MemberExpression:case ue.Identifier:case ue.ArrowFunctionExpression:case ue.FunctionExpression:return!1;default:return!1}}return{JSXAttribute(n){if(n.name.type===ue.JSXIdentifier&&n.name.name==="style"&&n.value){let s=null;n.value.type===ue.JSXExpressionContainer?n.value.expression.type!==ue.JSXEmptyExpression&&(s=n.value.expression):n.value.type===ue.Literal&&(s=n.value),s&&r(s)&&e.report({node:n,messageId:"noStaticStyleProp",data:{customMessage:t.customMessage?` ${t.customMessage}`:""}})}}}}});import{AST_NODE_TYPES as ct}from"@typescript-eslint/utils";import*as Je from"zod/v4";var jo=Je.object({alternativeMsgs:Je.object({inArrayFind:Je.string().optional(),inArrayFilter:Je.string().optional()}).optional(),__dev_simulateFileName:Je.string().optional()});function Lo(e){return e.typeAnnotation.type!==ct.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}var Mo=/(typeGuards|type-guards)\.(ts|tsx)$/;function $o(e){return Mo.test(e)}function _o(e){let t=e.parent;for(;t;){if(t.type===ct.CallExpression&&t.callee.type===ct.MemberExpression&&t.callee.property.type===ct.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var Ut=B({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:[V(jo)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if($o(r))return{};function n(s){if(!Lo(s))return;let a=_o(s);if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let p=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:s,messageId:p,data:{message:i}});return}}e.report({node:s,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as He}from"@typescript-eslint/utils";var Uo="no-unnecessary-async-on-jsx-props";function zo(e){if(e.body.type!==He.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==He.ExpressionStatement?!1:r.expression.type===He.AwaitExpression}var zt=B({name:Uo,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 t(r){zo(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let s=e.sourceCode,a=[],i=s.getFirstToken(r,l=>l.value==="async");if(i){let l=s.getTokenAfter(i);l?a.push(n.replaceTextRange([i.range[0],l.range[0]],"")):a.push(n.remove(i))}function p(l){if(l.type===He.AwaitExpression){let c=s.getFirstToken(l);if(c&&c.value==="await"){let d=s.getTokenAfter(c);d?a.push(n.replaceTextRange([c.range[0],d.range[0]],"")):a.push(n.remove(c))}}if(l.type===He.BlockStatement)for(let c of l.body)p(c);else l.type===He.ExpressionStatement&&p(l.expression)}return p(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as Qe,ESLintUtils as sr}from"@typescript-eslint/utils";import*as Wt from"typescript";import et from"zod/v4";var Wo=sr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),or="no-unnecessary-casting",Jo=et.object({additionalCastFunctions:et.array(et.object({name:et.string(),expectedType:et.enum(["string","number"])})).optional()}),Jt={name:or,rule:Wo({name:or,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:[V(Jo)],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],s=sr.getParserServices(e,!0),a=s.program?.getTypeChecker();if(!a||!s.program)throw new Error("TypeScript services or program not available");function i(d,y){switch(d.type){case Qe.Literal:return y==="number"?typeof d.value=="number":typeof d.value=="string";case Qe.TemplateLiteral:return y==="string";case Qe.UnaryExpression:return y==="number"?d.operator==="+"||d.operator==="-"||d.operator==="~":!1;default:return!1}}function p(d,y){return y==="number"?!!(d.flags&Wt.TypeFlags.NumberLike):!!(d.flags&Wt.TypeFlags.StringLike)}function l(d,y){return g=>g.replaceText(d,e.sourceCode.getText(y))}function c(d){if(!a||d.arguments.length!==1)return;let y=d.arguments[0];if(!y||y.type===Qe.SpreadElement)return;let{callee:g}=d;if(g.type!==Qe.Identifier)return;let b=g.name,f=n.find(h=>h.name===b);if(!f)return;if(i(y,f.expectedType)||p(a.getTypeAtLocation(s.esTreeNodeToTSNodeMap.get(y)),f.expectedType)){let h,m;b==="Number"?h="unnecessaryNumberCasting":b==="String"?h="unnecessaryStringCasting":(h="unnecessaryCustomCasting",m={name:f.name,type:f.expectedType}),e.report({node:d,messageId:h,...m?{data:m}:{},fix:l(d,y)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as we}from"@typescript-eslint/utils";import*as ut from"zod/v4";var Vo=ut.object({ignoreWithDescription:ut.string().optional()}),Vt=B({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:[V(Vo)]},defaultOptions:[{}],create(e,[t]){let r=e.getSourceCode(),n=r.ast;function s(l){let c=l.arguments[0];return c&&c.type===we.Literal&&typeof c.value=="string"?c.value:null}function a(l){return!l||!t.ignoreWithDescription?!1:new RegExp(t.ignoreWithDescription).test(l)}function i(l){return l.length!==1?!1:n.body.filter(d=>{if(d.type===we.ExpressionStatement){let y=d.expression;if(y.type===we.CallExpression&&y.callee.type===we.Identifier){let g=y.callee.name;return["test","it","beforeEach","afterEach","beforeAll","afterAll"].includes(g)}}return!1}).length===0}function p(l){let c=l.arguments[1];if(c&&(c.type===we.FunctionExpression||c.type===we.ArrowFunctionExpression)&&c.body.type===we.BlockStatement){let d=c.body.body;return d.length===0?"":d.map(g=>r.text.slice(g.range[0],g.range[1])).join(`
16
16
 
17
- `)}return""}return{Program(){let a=[];for(let l of n.body)l.type===Se.ExpressionStatement&&l.expression.type===Se.CallExpression&&l.expression.callee.type===Se.Identifier&&l.expression.callee.name==="describe"&&l.expression.arguments.length===2&&a.push(l.expression);if(!i(a))return;let[c]=a;if(!c)return;let g=s(c);if(o(g))return;let S=n.body.find(l=>l.type===Se.ExpressionStatement&&l.expression===c);!S||S.type!==Se.ExpressionStatement||e.report({node:c,messageId:"unnecessaryDescribe",suggest:[{messageId:"removeDescribe",fix(l){let E=p(c);return E?l.replaceText(S,E):null}}]})}}}});import{AST_NODE_TYPES as lt}from"@typescript-eslint/utils";import*as Ie from"zod/v4";var Js=Ie.object({methods:Ie.union([Ie.array(Ie.string()),Ie.literal("array")])}),zt=_({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:[$(Js)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function s(p){return Array.isArray(r)?r.includes(p):n.has(p)}function o(p){let{callee:a}=p;if(a.type===lt.MemberExpression){let c=a.property;if(c.type===lt.Identifier)return c.name}return null}function i(p,a){if(p.type!==lt.Identifier||!p.typeAnnotation)return;let c=a.parent;if(c.type===lt.CallExpression){let g=o(c);g&&s(g)&&c.arguments.indexOf(a)===0&&e.report({node:p.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(l){return p.typeAnnotation?l.remove(p.typeAnnotation):null}})}}return{ArrowFunctionExpression(p){for(let a of p.params)i(a,p)},FunctionExpression(p){for(let a of p.params)i(a,p)}}}});import{AST_NODE_TYPES as ye}from"@typescript-eslint/utils";var Wt=_({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(t){if(t.id.type===ye.ObjectPattern||!t.init||t.init.type!==ye.ObjectExpression||t.id.type===ye.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ye.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===ye.Property&&i.key.type===ye.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==ye.Identifier)return;let n=Vs(t,e.sourceCode);if(n.length===0)return;let s=t.init.properties.some(i=>i.type!==ye.Property?!1:i.value.type===ye.FunctionExpression),o=new Set;for(let i of n){if(i.identifier.parent.type!==ye.MemberExpression)return;let p=i.identifier.parent;if(p.object!==i.identifier)return;if(p.computed)if(p.property.type===ye.Literal&&typeof p.property.value=="string")o.add(p.property.value);else return;else{if(p.property.type!==ye.Identifier)return;o.add(p.property.name)}if(p.parent.type===ye.CallExpression&&s)return}for(let[i,p]of r)o.has(i)||e.report({node:p,messageId:"unusedObjectProperty",data:{name:i}})}}}});function Vs(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as X}from"@typescript-eslint/utils";import{z as nr}from"zod/v4";var Xs=nr.object({ignoreArgsMatching:nr.string().optional()}),Jt=_({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:[$(Xs)]},defaultOptions:[{}],create(e,[t]){let r=[];function n(i){return t.ignoreArgsMatching?new RegExp(t.ignoreArgsMatching).test(i):!1}function s(i){return i.type===X.ExportNamedDeclaration||i.type===X.ExportDefaultDeclaration||i.parent?.type===X.ExportNamedDeclaration||i.parent?.type===X.ExportDefaultDeclaration}function o(i){let p=[];for(let a=0;a<i.length;a++){let c=i[a];if(!c||c.type!==X.Identifier)continue;let g=c.name;if(!n(g)){if(c.optional&&c.typeAnnotation&&c.typeAnnotation.typeAnnotation.type===X.TSTypeLiteral){let S=c.typeAnnotation.typeAnnotation,l=[];for(let E of S.members)E.type===X.TSPropertySignature&&E.key.type===X.Identifier&&l.push({name:E.key.name,optional:E.optional===!0});l.some(E=>E.optional)?p.push({param:c,index:a,name:g,isObjectParam:!0,objectProps:l}):p.push({param:c,index:a,name:g,isObjectParam:!1})}else if(c.optional)p.push({param:c,index:a,name:g,isObjectParam:!1});else if(c.typeAnnotation&&c.typeAnnotation.typeAnnotation.type===X.TSTypeLiteral){let S=c.typeAnnotation.typeAnnotation,l=[];for(let E of S.members)E.type===X.TSPropertySignature&&E.key.type===X.Identifier&&l.push({name:E.key.name,optional:E.optional===!0});l.some(E=>E.optional)&&p.push({param:c,index:a,name:g,isObjectParam:!0,objectProps:l})}}}return p}return{FunctionDeclaration(i){if(s(i))return;let p=o(i.params);p.length!==0&&r.push({node:i,declarationNode:i,optionalParams:p})},VariableDeclarator(i){if(i.id.type!==X.Identifier||!i.init||i.init.type!==X.ArrowFunctionExpression&&i.init.type!==X.FunctionExpression||s(i.parent.parent))return;let a=[...o(i.init.params)];if(i.id.typeAnnotation&&i.id.typeAnnotation.typeAnnotation.type===X.TSTypeReference){let c=i.id.typeAnnotation.typeAnnotation;if(c.typeName.type===X.Identifier&&c.typeName.name==="FC"){let g=c.typeArguments;if(g&&g.params.length===1){let S=g.params[0];if(S&&S.type===X.TSTypeLiteral){let l=[];for(let E of S.members)E.type===X.TSPropertySignature&&E.key.type===X.Identifier&&l.push({name:E.key.name,optional:E.optional===!0});l.some(E=>E.optional)&&a.push({param:i.id,index:0,name:"props",isObjectParam:!0,objectProps:l})}}}}a.length!==0&&r.push({node:i.init,declarationNode:i,optionalParams:a})},"Program:exit"(){for(let i of r){let a=e.sourceCode.getDeclaredVariables(i.declarationNode)[0];if(!a)continue;let c=a.references.filter(l=>l.identifier!==a.identifiers[0]);if(c.length===0)continue;let g=!1;for(let l of c){let E=l.identifier.parent;if(E.type===X.CallExpression&&l.identifier.type===X.Identifier&&E.arguments.includes(l.identifier)){g=!0;break}if(E.type===X.ReturnStatement){g=!0;break}if(E.type===X.Property&&E.parent.type===X.ObjectExpression&&E.parent.parent.type===X.ReturnStatement){g=!0;break}if(E.type===X.JSXExpressionContainer){g=!0;break}}if(g)continue;let S=[];for(let l of c){let E=l.identifier.parent;if(E.type===X.CallExpression&&E.callee===l.identifier){let f=E.arguments.length,h=E.arguments.some(m=>m.type===X.SpreadElement);if(h){g=!0;break}let T={argCount:f,hasSpread:h};for(let m of i.optionalParams)if(m.isObjectParam&&m.index<f){let b=E.arguments[m.index];if(b?.type===X.ObjectExpression){let C={};for(let y of b.properties)y.type===X.Property&&y.key.type===X.Identifier&&(C[y.key.name]=!0);T.objectArgs||(T.objectArgs=[]),T.objectArgs[m.index]=C}else if(b){g=!0;break}}S.push(T)}else if(E.type===X.JSXOpeningElement&&E.name===l.identifier){let f=E.attributes.some(T=>T.type===X.JSXSpreadAttribute);if(f){g=!0;break}let h={argCount:1,hasSpread:f};for(let T of i.optionalParams)if(T.isObjectParam&&T.index===0){let m={};for(let b of E.attributes)b.type===X.JSXAttribute&&b.name.type===X.JSXIdentifier&&(m[b.name.name]=!0);h.objectArgs||(h.objectArgs=[]),h.objectArgs[0]=m}S.push(h)}}if(!(g||S.length===0))for(let l of i.optionalParams)if(l.isObjectParam&&l.objectProps)for(let E of l.objectProps){if(!E.optional)continue;let f=!1;for(let h of S)if(h.objectArgs&&h.objectArgs[l.index]){let T=h.objectArgs[l.index];if(T&&T[E.name]){f=!0;break}}f||e.report({node:l.param,messageId:"unusedOptionalProp",data:{name:E.name}})}else{let E=!1;for(let f of S)if(f.argCount>l.index){E=!0;break}E||e.report({node:l.param,messageId:"unusedOptionalArg",data:{name:l.name}})}}}}}});import{AST_NODE_TYPES as Q,ESLintUtils as Hs}from"@typescript-eslint/utils";import{z as _e}from"zod/v4";var Bs=_e.object({selectors:_e.array(_e.object({name:_e.string(),selectorProp:_e.string().optional(),selectorArgPos:_e.number().optional(),returnProp:_e.string().optional()}))}),Ys=Hs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rr="no-unused-selected-values",Vt={name:rr,rule:Ys({name:rr,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[$(Bs)]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(s=>[s.name,s]));return{VariableDeclarator(s){let o=null;if(s.init?.type===Q.CallExpression&&(o=s.init),!o)return;let i=Zs(o);if(!i)return;let p=n.get(i);if(!p)return;let a=qs(o,p.selectorArgPos??0,p.selectorProp);if(!a)return;let c=Gs(a);if(!c)return;let g=ir(c.properties,void 0);if(!g)return;if(s.id.type===Q.ObjectPattern){let E=ir(s.id.properties,p.returnProp);if(!E)return;for(let[f,h]of g)E.has(f)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:f}});return}if(s.id.type!==Q.Identifier||p.returnProp)return;let S=Ks(s,e.sourceCode);if(S.length===0)return;let l=new Set;for(let E of S){if(E.identifier.parent.type!==Q.MemberExpression)return;let f=E.identifier.parent.property;if(f.type!==Q.Identifier)return;l.add(f.name)}for(let[E,f]of g)l.has(E)||e.report({node:f,messageId:"unusedSelectedValue",data:{name:E}})}}}})};function qs(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===Q.ArrowFunctionExpression||n.type===Q.FunctionExpression)return n;if(r&&n.type===Q.ObjectExpression){let s=n.properties.find(i=>i.type===Q.Property&&i.key.type===Q.Identifier&&i.key.name===r);if(s?.type!==Q.Property)return null;let o=s.value;if(o.type===Q.ArrowFunctionExpression||o.type===Q.FunctionExpression)return o}return null}function Zs(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 Gs(e){if(e.body.type===Q.ObjectExpression)return e.body;if(e.body.type===Q.BlockStatement){let t=e.body.body.filter(r=>r.type===Q.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==Q.ObjectExpression?null:t[0].argument}return null}function ir(e,t){let r=e;if(t){let s=e.find(o=>o.type===Q.Property&&o.key.type===Q.Identifier&&o.key.name===t);if(s?.type!==Q.Property||s.value.type!==Q.ObjectPattern)return null;r=s.value.properties}let n=new Map;for(let s of r){if(s.type!==Q.Property||s.key.type!==Q.Identifier)return null;n.set(s.key.name,s)}return n.size>0?n:null}function Ks(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as K}from"@typescript-eslint/utils";var Xt=_({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(o=>o.type===K.ImportDeclaration&&o.source.value==="t-state-form"))return{};let n=null,s=!1;return{CallExpression(o){if(s)return;if(!n){let p=Qs(o);p&&(n=p);return}let i=eo(o,e.sourceCode);if(i){s=!0;for(let p of i)n.delete(p);if(n.size!==0)for(let[p,a]of n)e.report({node:a,messageId:"unusedField",data:{name:p}})}}}}});function Qs(e){if(!(e.callee.type===K.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==K.ObjectExpression)return null;let n=Ct(r.properties,o=>o.type!==K.Property||o.key.type!==K.Identifier||o.key.name!=="initialConfig"?null:o.value.type===K.ObjectExpression?o.value:o.value.type===K.ArrowFunctionExpression||o.value.type===K.FunctionExpression?to(o.value):null);if(!n)return null;let s=new Map;for(let o of n.properties)o.type===K.Property&&o.key.type===K.Identifier&&s.set(o.key.name,o);return s}function eo(e,t){if(!(e.callee.type===K.Identifier&&e.callee.name==="useFormState")||e.parent.type!==K.VariableDeclarator||e.parent.id.type!==K.ObjectPattern||!Ct(e.parent.id.properties,i=>i.type===K.Property&&i.key.type===K.Identifier&&i.key.name==="formFields"&&i))return null;let s=_n(e.parent,"formFields",t),o=new Set;for(let{identifier:i}of s){if(i.type!==K.Identifier||i.parent.type===K.Property&&i.parent.parent.type===K.ObjectExpression&&i.parent.parent.parent.type===K.ReturnStatement||i.parent.type===K.ReturnStatement)return null;if(i.parent.type===K.MemberExpression){if(i.parent.object.type!==K.Identifier||i.parent.property.type!==K.Identifier)return null;o.add(i.parent.property.name)}}return o}function to(e){if(e.body.type===K.ObjectExpression)return e.body;if(e.body.type===K.BlockStatement){let t=e.body.body.filter(r=>r.type===K.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==K.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as q,ESLintUtils as no}from"@typescript-eslint/utils";import{z as pt}from"zod/v4";var ro=no.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function sr(e){let t=[];for(let r of e.members)r.type===q.TSPropertySignature&&r.key.type===q.Identifier&&t.push([r.key.name,r]);return t}function or(e,...t){for(let r of t)e.set(...r);return e}var io=pt.object({forceCheckOnFCPropTypesWithName:pt.array(pt.string()).optional(),alwaysCheckFunctionOptionTypes:pt.boolean().optional()}),ar="no-unused-type-props-in-args",Ht=null,so=ro({name:ar,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:[$(io)],fixable:"code"},defaultOptions:[{alwaysCheckFunctionOptionTypes:!0}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r,alwaysCheckFunctionOptionTypes:n=!0}=t;r&&!Ht&&(Ht=r.map(a=>new RegExp(a)));function s(a,c,g,S,l=!0,E=!1){let f=g.name,h=e.sourceCode.getScope(c).references.find(y=>y.identifier.name===f)?.resolved,T=a&&Ht?.some(y=>y.test(f)),m=E&&n;if(!h||!T&&h.references.filter(y=>y.isTypeReference).length>1||!h.defs[0])return;let b=h.defs[0].node,C=b.parent?.type===q.ExportNamedDeclaration;if(!(l&&C&&!m)){if(b.type===q.TSTypeAliasDeclaration){o(a,c,S,b.typeAnnotation,!0,E);return}if(b.type===q.TSInterfaceDeclaration){o(a,c,S,b.body,!0,E);return}}}function o(a,c,g,S,l,E=!1){if(S.type===q.TSInterfaceBody){for(let f of S.body)f.type===q.TSPropertySignature&&f.key.type===q.Identifier&&g.set(f.key.name,f);return}if(S.type===q.TSTypeLiteral){or(g,...sr(S));return}if(S.type===q.TSIntersectionType){for(let f of S.types)o(a,c,g,f,!0,E);return}l||S.type===q.TSTypeReference&&S.typeName.type===q.Identifier&&s(a,c,S.typeName,g,!0,E)}function i(a,c,g,S=!1){for(let l of g)if(l.type===q.ObjectPattern&&l.typeAnnotation){let E=new Map;if(o(a,c,E,l.typeAnnotation.typeAnnotation,!1,S),E.size===0)continue;p(l,E)}else l.type===q.AssignmentPattern&&l.left.type===q.ObjectPattern&&i(a,c,[l.left],S)}function p(a,c){let g=[];if(a.properties.at(-1)?.type===q.RestElement)return;for(let f of a.properties)f.type===q.Property&&f.key.type===q.Identifier&&g.push(f.key.name);let l=[],E=[];for(let[f,h]of c)g.includes(f)||(E.push(f),l.push({node:h,messageId:"unusedObjectTypeProperty",data:{propertyName:f}}));for(let[f,h]of l.entries())e.report({...h,fix:f===l.length-1?T=>{let m=a.properties.at(-1),b=E.join(", ");return m?m.type===q.RestElement?null:T.insertTextAfter(m,`, ${b}`):T.insertTextBeforeRange([a.range[0]+1,a.range[1]],b)}:void 0})}return{VariableDeclaration(a){let c=a.declarations[0],g=new Map,S=c.id.type===q.Identifier&&c.id.typeAnnotation?.typeAnnotation.type===q.TSTypeReference&&c.id.typeAnnotation.typeAnnotation.typeName.type===q.Identifier&&c.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&c.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(S){if(S.type===q.TSTypeReference&&S.typeName.type===q.Identifier)s(!0,a,S.typeName,g,!1);else if(S.type===q.TSTypeLiteral)or(g,...sr(S));else if(S.type===q.TSIntersectionType)for(let l of S.types)l.type===q.TSTypeReference&&l.typeName.type===q.Identifier?s(!0,a,l.typeName,g,!1):o(!0,a,g,l,!0);if(g.size!==0&&c.init?.type===q.ArrowFunctionExpression){let l=c.init.params[0];if(!l){e.report({node:c.init,messageId:"missingComponentParam"});return}l.type===q.ObjectPattern&&p(l,g)}}},FunctionDeclaration(a){i(!1,a,a.params,n)},ArrowFunctionExpression(a){i(!1,a,a.params,n)}}}}),Bt={name:ar,rule:so};import{AST_NODE_TYPES as be}from"@typescript-eslint/utils";var Yt=_({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 t=new Set;function r(n){return n.callee.type===be.Identifier?t.has(n.callee.name):n.callee.type===be.MemberExpression&&n.callee.object.type===be.Identifier&&n.callee.property.type===be.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let s of n.specifiers)s.type===be.ImportSpecifier&&s.imported.type===be.Identifier&&s.imported.name==="useRef"&&t.add(s.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===be.CallExpression&&r(n.init)&&n.id.type===be.Identifier){let o=e.sourceCode.getScope(n).set.get(n.id.name);if(o){let i=!1;for(let p of o.references){let c=p.identifier.parent;if(c!==n&&!(c.type===be.JSXExpressionContainer&&c.parent.type===be.JSXAttribute&&c.parent.name.type===be.JSXIdentifier&&c.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});import{AST_NODE_TYPES as qt,ESLintUtils as oo}from"@typescript-eslint/utils";var ao=oo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pr="prefer-named-functions",lr=new Map,lo=ao({name:pr,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,[t]){let r=null;if(t.ignoreRegex){let n=lr.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),lr.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===qt.ArrowFunctionExpression&&n.id.type===qt.Identifier){let s=n.id.name;if(n.id.typeAnnotation||r&&r.test(s)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==qt.BlockStatement)return;let o=n.parent,i=n.init.params,p=n.init.body,a=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(o,`${a.async?"async ":""}function ${s}(${i.map(g=>e.sourceCode.getText(g)).join(", ")||""}) ${e.sourceCode.getText(p)}`)}]})}}}}}),Zt={name:pr,rule:lo};import{AST_NODE_TYPES as z}from"@typescript-eslint/utils";import{z as Fe}from"zod/v4";var po=Fe.object({disallowedFunctions:Fe.array(Fe.object({name:Fe.string(),allowUsingWithArgs:Fe.boolean().optional(),hookAlternative:Fe.string().optional(),message:Fe.string().optional(),allowUseInside:Fe.array(Fe.string()).optional()}))}),co=/^use[A-Z]/,uo=/^[A-Z]/;function ct(e){return co.test(e)}function cr(e){return uo.test(e)}function fo(e){return e.type===z.Identifier?ct(e.name):e.type===z.MemberExpression&&e.property.type===z.Identifier?ct(e.property.name):!1}function ur(e,t){return e.type===z.Identifier?e.name===t:e.type===z.MemberExpression&&e.object.type===z.Identifier&&e.property.type===z.Identifier?e.object.name==="React"&&e.property.name===t:!1}function fr(e){return!!(e.parent&&e.parent.type===z.CallExpression&&ur(e.parent.callee,"forwardRef"))}function mr(e){return!!(e.parent&&e.parent.type===z.CallExpression&&ur(e.parent.callee,"memo"))}function Gt(e){if(e.type===z.FunctionDeclaration||e.type===z.FunctionExpression&&e.id)return e.id||void 0;if(e.type===z.FunctionExpression||e.type===z.ArrowFunctionExpression){if(e.parent.type===z.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===z.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===z.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===z.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function mo(e){let t=e.parent,r=!1;for(;t;){if(t.type===z.FunctionDeclaration||t.type===z.FunctionExpression||t.type===z.ArrowFunctionExpression){let n=Gt(t);if(n&&n.type===z.Identifier){if(cr(n.name)||ct(n.name))return!r;r=!0}else{if(fr(t)||mr(t))return!r;if(t.parent.type===z.CallExpression){let s=t.parent;fo(s.callee)||(r=!0)}else t.parent.type===z.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function yr(e){return e.callee.type===z.Identifier?e.callee.name:e.callee.type===z.MemberExpression&&e.callee.property.type===z.Identifier?e.callee.property.name:null}function yo(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===z.FunctionDeclaration||r.type===z.FunctionExpression||r.type===z.ArrowFunctionExpression){let n=Gt(r);if(n&&n.type===z.Identifier&&t.includes(n.name))return!0}else if(r.type===z.CallExpression){let n=yr(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function go(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===z.Identifier&&t.name==="undefined")}function So(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===z.FunctionDeclaration||n.type===z.FunctionExpression||n.type===z.ArrowFunctionExpression){let s=Gt(n);if(s&&s.type===z.Identifier){if(cr(s.name)||ct(s.name)){r=!0;break}}else if(fr(n)||mr(n)){r=!0;break}}n=n.parent}return r?t.length===0?mo(e):!yo(e,t):!1}var Kt=_({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:[$(po)],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(s=>[s.name,s]));return{CallExpression(s){let o=yr(s);if(!o)return;let i=n.get(o);if(!i||i.allowUsingWithArgs&&go(s))return;let p=i.allowUseInside||[];So(s,p)&&e.report({node:s,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:a=>{let c=i.hookAlternative;return c?s.callee.type===z.Identifier?a.replaceText(s.callee,c):s.callee.type===z.MemberExpression&&s.callee.property.type===z.Identifier?a.replaceText(s.callee.property,c):null:null}}]:[]})}}}});import{AST_NODE_TYPES as ie,AST_TOKEN_TYPES as dr,ESLintUtils as To}from"@typescript-eslint/utils";import Qt from"zod/v4";var ho=To.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sr="prefer-single-line-if",Eo=Qt.object({maxLineLength:Qt.number().optional(),maxNonSimpleConditionLength:Qt.number().optional()}),bo=ho({name:Sr,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:[$(Eo)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==ie.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let o=n.consequent.body[0];if(!o)return;if(o.type===ie.ReturnStatement){if(!hr(o))return}else if(!(o.type===ie.ContinueStatement||o.type===ie.BreakStatement))return;if(n.test.type===ie.LogicalExpression||n.test.type===ie.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let S=gr(n.test);if(!S&&n.test.type===ie.UnaryExpression&&n.test.operator==="!"){let l=n.test.argument;gr(l)&&(S=!0)}if(S&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let p=r.getText(o);if(i.includes(`
18
- `))return;let a=r.getTokenAfter(n);if(a&&a.type===dr.Punctuator&&a.value==="}"){let S=r.getTokenAfter(a);if(S&&S.type===dr.Keyword&&(S.value==="else"||S.value==="catch"))return}let c=xo(r,n),g=`if (${i}) ${p}`;t.maxLineLength&&g.length+c.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:S=>S.replaceText(n,g)})}}}});function gr(e){return e.type===ie.CallExpression||e.type===ie.BinaryExpression||e.type===ie.MemberExpression&&Tr(e)}function Tr(e){return e.object.type===ie.MemberExpression?Tr(e.object):e.object.type!==ie.Identifier}function xo(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function hr(e){if(!e.argument)return!0;let t=e.argument;return t.type===ie.ArrayExpression&&t.elements.length===0||t.type===ie.ObjectExpression&&t.properties.length===0||t.type===ie.Literal||t.type===ie.Identifier||t.type===ie.TemplateLiteral||t.type===ie.TaggedTemplateExpression?!0:t.type===ie.CallExpression?t.arguments.length===0:t.type===ie.UnaryExpression?hr(t):!1}var en={name:Sr,rule:bo};import{AST_NODE_TYPES as D,ESLintUtils as Co}from"@typescript-eslint/utils";import{z as Er}from"zod/v4";var Ao=Co.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ar="react-compiler-extra",Io=Er.object({runOnlyWithEnableCompilerDirective:Er.boolean().optional()}),wo=/eslint +react-compiler\/react-compiler: +\["error/;function Ir(e){return e.type===D.Identifier?e.name.startsWith("use"):!1}function Ro(e){return e.type===D.Identifier?e.name.startsWith("use"):e.type===D.MemberExpression&&e.property.type===D.Identifier?e.property.name.startsWith("use"):!1}function we(e){if(!e)return!1;switch(e.type){case D.JSXElement:case D.JSXFragment:return!0;case D.ConditionalExpression:return we(e.consequent)||we(e.alternate);case D.LogicalExpression:return e.operator==="&&"?we(e.right):e.operator==="||"?we(e.left)||we(e.right):!1;case D.CallExpression:if(e.callee.type===D.MemberExpression&&e.callee.object.type===D.Identifier&&e.callee.object.name==="React"&&e.callee.property.type===D.Identifier&&e.callee.property.name==="createElement")return!0;for(let t of e.arguments)if(t.type!==D.SpreadElement&&we(t))return!0;return!1;default:return!1}}function Po(e){let t=e.typeAnnotation;if(t.type===D.TSTypeReference){if(t.typeName.type===D.Identifier)return t.typeName.name==="FC";if(t.typeName.type===D.TSQualifiedName&&t.typeName.left.type===D.Identifier&&t.typeName.right.type===D.Identifier)return t.typeName.left.name==="React"&&t.typeName.right.name==="FC"}return!1}var vo=/^[A-Z][a-zA-Z0-9]*$/;function Ge(e){return vo.test(e)}function nn(e){return e.startsWith("use")&&e.length>3}function rn(e,t,r,n){if(r&&Po(r))return t?Ge(t.name):e.type===D.FunctionDeclaration&&e.id?Ge(e.id.name):!0;if(t&&nn(t.name)||e.type===D.FunctionDeclaration&&e.id&&nn(e.id.name))return!0;if(n){let s=t?.name||e.type===D.FunctionDeclaration&&e.id?.name;if(s&&Ge(s)&&wr(e.body,n).containsJSX)return!0}return!1}function Ze(e){if(e.body.type===D.BlockStatement){for(let t of e.body.body)if(t.type===D.ExpressionStatement&&t.expression.type===D.Literal&&typeof t.expression.value=="string"&&t.expression.value==="use memo")return!0}return!1}function wr(e,t){let r={containsJSX:!1,containsHookCalls:!1};return Ae(e,n=>{if(r.containsJSX&&r.containsHookCalls)return!0;switch(n.type){case D.JSXElement:case D.JSXFragment:r.containsJSX=!0;break;case D.CallExpression:Ir(n.callee)&&(r.containsHookCalls=!0),we(n)&&(r.containsJSX=!0);break;case D.ReturnStatement:n.argument&&we(n.argument)&&(r.containsJSX=!0);break;case D.VariableDeclarator:n.init&&we(n.init)&&(r.containsJSX=!0);break;case D.AssignmentExpression:we(n.right)&&(r.containsJSX=!0);break}},t),r}function br(e,t){let r=e.body,n=wr(r,t);return n.containsJSX||n.containsHookCalls}var Fo=/\bthis[.[]/;function xr(e){return Fo.test(e)}function ko(e,t){let r={containsJSX:!1,containsHookCalls:!1};return Ae(e,n=>{if(r.containsHookCalls||(n.type===D.FunctionDeclaration||n.type===D.FunctionExpression||n.type===D.ArrowFunctionExpression)&&n!==e)return!0;n.type===D.CallExpression&&Ro(n.callee)&&(r.containsHookCalls=!0)},t),r}function Cr(e){return Ge(e)||nn(e)}function tn(e,t,r,n){if(!ko(e.body,t).containsHookCalls)return!1;let o=rn(e,r,n,t);if(!o&&n){let i=r?.name||e.type===D.FunctionDeclaration&&e.id?.name;i&&Ge(i)&&(o=!0)}return!o}var Oo=Ao({name:Ar,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:[$(Io)]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let o of e.sourceCode.getAllComments())if(wo.test(o.value)){r=!0;break}if(!r)return{}}function n(o){for(let i of o.properties)if(i.type===D.Property&&i.method&&i.value.type===D.FunctionExpression){let p=e.sourceCode,a=p.getText(i.key),c=i.value,g=p.getText(c.body);if(xr(g))e.report({node:i,messageId:"thisKeywordInMethod"});else{let S=c.params.map(E=>p.getText(E)).join(", "),l="";c.generator?l=`${a}: function* (${S}) ${g}`:l=`${a}: (${S}) => ${g}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:E=>E.replaceText(i,l)})}}}function s(o){for(let i of o.properties)if(i.type===D.Property&&i.value.type===D.ObjectExpression){for(let p of i.value.properties)if(p.type===D.Property&&p.method&&p.value.type===D.FunctionExpression){let c=e.sourceCode.getText(p.value.body);xr(c)&&e.report({node:p,messageId:"thisKeywordInMethod"})}}}return{CallExpression(o){if(Ir(o.callee))for(let i of o.arguments){if(i.type===D.ObjectExpression&&(n(i),s(i)),i.type===D.ArrowFunctionExpression&&(i.body.type===D.ObjectExpression&&(n(i.body),s(i.body)),i.body.type===D.BlockStatement))for(let p of i.body.body)p.type===D.ReturnStatement&&p.argument?.type===D.ObjectExpression&&(n(p.argument),s(p.argument));if(i.type===D.FunctionExpression)for(let p of i.body.body)p.type===D.ReturnStatement&&p.argument?.type===D.ObjectExpression&&(n(p.argument),s(p.argument))}},VariableDeclarator(o){if(o.id.type===D.Identifier&&o.init&&(o.init.type===D.ArrowFunctionExpression||o.init.type===D.FunctionExpression)){let i=o.init,p=o.id,a=o.id.typeAnnotation;if(Ze(i)&&!Cr(p.name)){e.report({node:i,messageId:"useMemoDirectiveNaming"});return}if(tn(i,e.sourceCode,p,a)){e.report({node:i,messageId:"functionCallingHooksMustBeComponent"});return}if(rn(i,p,a,e.sourceCode)){let c=br(i,e.sourceCode),g=Ze(i);!c&&!g&&e.report({node:i,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(S){if(i.body.type===D.BlockStatement){let l=i.body.range[0]+1;return S.insertTextAfterRange([l,l],`
17
+ `)}return""}return{Program(){let l=[];for(let g of n.body)g.type===we.ExpressionStatement&&g.expression.type===we.CallExpression&&g.expression.callee.type===we.Identifier&&g.expression.callee.name==="describe"&&g.expression.arguments.length===2&&l.push(g.expression);if(!i(l))return;let[c]=l;if(!c)return;let d=s(c);if(a(d))return;let y=n.body.find(g=>g.type===we.ExpressionStatement&&g.expression===c);!y||y.type!==we.ExpressionStatement||e.report({node:c,messageId:"unnecessaryDescribe",suggest:[{messageId:"removeDescribe",fix(g){let b=p(c);return b?g.replaceText(y,b):null}}]})}}}});import{AST_NODE_TYPES as ft}from"@typescript-eslint/utils";import*as Oe from"zod/v4";var Xo=Oe.object({methods:Oe.union([Oe.array(Oe.string()),Oe.literal("array")])}),Xt=B({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:[V(Xo)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function s(p){return Array.isArray(r)?r.includes(p):n.has(p)}function a(p){let{callee:l}=p;if(l.type===ft.MemberExpression){let c=l.property;if(c.type===ft.Identifier)return c.name}return null}function i(p,l){if(p.type!==ft.Identifier||!p.typeAnnotation)return;let c=l.parent;if(c.type===ft.CallExpression){let d=a(c);d&&s(d)&&c.arguments.indexOf(l)===0&&e.report({node:p.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(g){return p.typeAnnotation?g.remove(p.typeAnnotation):null}})}}return{ArrowFunctionExpression(p){for(let l of p.params)i(l,p)},FunctionExpression(p){for(let l of p.params)i(l,p)}}}});import{AST_NODE_TYPES as he}from"@typescript-eslint/utils";var Bt=B({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(t){if(t.id.type===he.ObjectPattern||!t.init||t.init.type!==he.ObjectExpression||t.id.type===he.Identifier&&t.id.typeAnnotation||t.parent.parent.type===he.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===he.Property&&i.key.type===he.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==he.Identifier)return;let n=Bo(t,e.sourceCode);if(n.length===0)return;let s=t.init.properties.some(i=>i.type!==he.Property?!1:i.value.type===he.FunctionExpression),a=new Set;for(let i of n){if(i.identifier.parent.type!==he.MemberExpression)return;let p=i.identifier.parent;if(p.object!==i.identifier)return;if(p.computed)if(p.property.type===he.Literal&&typeof p.property.value=="string")a.add(p.property.value);else return;else{if(p.property.type!==he.Identifier)return;a.add(p.property.name)}if(p.parent.type===he.CallExpression&&s)return}for(let[i,p]of r)a.has(i)||e.report({node:p,messageId:"unusedObjectProperty",data:{name:i}})}}}});function Bo(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as K}from"@typescript-eslint/utils";import{z as ar}from"zod/v4";var Ho=ar.object({ignoreArgsMatching:ar.string().optional()}),Ht=B({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:[V(Ho)]},defaultOptions:[{}],create(e,[t]){let r=[];function n(i){return t.ignoreArgsMatching?new RegExp(t.ignoreArgsMatching).test(i):!1}function s(i){return i.type===K.ExportNamedDeclaration||i.type===K.ExportDefaultDeclaration||i.parent?.type===K.ExportNamedDeclaration||i.parent?.type===K.ExportDefaultDeclaration}function a(i){let p=[];for(let l=0;l<i.length;l++){let c=i[l];if(!c||c.type!==K.Identifier)continue;let d=c.name;if(!n(d)){if(c.optional&&c.typeAnnotation&&c.typeAnnotation.typeAnnotation.type===K.TSTypeLiteral){let y=c.typeAnnotation.typeAnnotation,g=[];for(let b of y.members)b.type===K.TSPropertySignature&&b.key.type===K.Identifier&&g.push({name:b.key.name,optional:b.optional===!0});g.some(b=>b.optional)?p.push({param:c,index:l,name:d,isObjectParam:!0,objectProps:g}):p.push({param:c,index:l,name:d,isObjectParam:!1})}else if(c.optional)p.push({param:c,index:l,name:d,isObjectParam:!1});else if(c.typeAnnotation&&c.typeAnnotation.typeAnnotation.type===K.TSTypeLiteral){let y=c.typeAnnotation.typeAnnotation,g=[];for(let b of y.members)b.type===K.TSPropertySignature&&b.key.type===K.Identifier&&g.push({name:b.key.name,optional:b.optional===!0});g.some(b=>b.optional)&&p.push({param:c,index:l,name:d,isObjectParam:!0,objectProps:g})}}}return p}return{FunctionDeclaration(i){if(s(i))return;let p=a(i.params);p.length!==0&&r.push({node:i,declarationNode:i,optionalParams:p})},VariableDeclarator(i){if(i.id.type!==K.Identifier||!i.init||i.init.type!==K.ArrowFunctionExpression&&i.init.type!==K.FunctionExpression||s(i.parent.parent))return;let l=[...a(i.init.params)];if(i.id.typeAnnotation&&i.id.typeAnnotation.typeAnnotation.type===K.TSTypeReference){let c=i.id.typeAnnotation.typeAnnotation;if(c.typeName.type===K.Identifier&&c.typeName.name==="FC"){let d=c.typeArguments;if(d&&d.params.length===1){let y=d.params[0];if(y&&y.type===K.TSTypeLiteral){let g=[];for(let b of y.members)b.type===K.TSPropertySignature&&b.key.type===K.Identifier&&g.push({name:b.key.name,optional:b.optional===!0});g.some(b=>b.optional)&&l.push({param:i.id,index:0,name:"props",isObjectParam:!0,objectProps:g})}}}}l.length!==0&&r.push({node:i.init,declarationNode:i,optionalParams:l})},"Program:exit"(){for(let i of r){let l=e.sourceCode.getDeclaredVariables(i.declarationNode)[0];if(!l)continue;let c=l.references.filter(g=>g.identifier!==l.identifiers[0]);if(c.length===0)continue;let d=!1;for(let g of c){let b=g.identifier.parent;if(b.type===K.CallExpression&&g.identifier.type===K.Identifier&&b.arguments.includes(g.identifier)){d=!0;break}if(b.type===K.ReturnStatement){d=!0;break}if(b.type===K.Property&&b.parent.type===K.ObjectExpression&&b.parent.parent.type===K.ReturnStatement){d=!0;break}if(b.type===K.JSXExpressionContainer){d=!0;break}}if(d)continue;let y=[];for(let g of c){let b=g.identifier.parent;if(b.type===K.CallExpression&&b.callee===g.identifier){let f=b.arguments.length,E=b.arguments.some(m=>m.type===K.SpreadElement);if(E){d=!0;break}let h={argCount:f,hasSpread:E};for(let m of i.optionalParams)if(m.isObjectParam&&m.index<f){let A=b.arguments[m.index];if(A?.type===K.ObjectExpression){let I={};for(let o of A.properties)o.type===K.Property&&o.key.type===K.Identifier&&(I[o.key.name]=!0);h.objectArgs||(h.objectArgs=[]),h.objectArgs[m.index]=I}else if(A){d=!0;break}}y.push(h)}else if(b.type===K.JSXOpeningElement&&b.name===g.identifier){let f=b.attributes.some(h=>h.type===K.JSXSpreadAttribute);if(f){d=!0;break}let E={argCount:1,hasSpread:f};for(let h of i.optionalParams)if(h.isObjectParam&&h.index===0){let m={};for(let A of b.attributes)A.type===K.JSXAttribute&&A.name.type===K.JSXIdentifier&&(m[A.name.name]=!0);E.objectArgs||(E.objectArgs=[]),E.objectArgs[0]=m}y.push(E)}}if(!(d||y.length===0))for(let g of i.optionalParams)if(g.isObjectParam&&g.objectProps)for(let b of g.objectProps){if(!b.optional)continue;let f=!1;for(let E of y)if(E.objectArgs&&E.objectArgs[g.index]){let h=E.objectArgs[g.index];if(h&&h[b.name]){f=!0;break}}f||e.report({node:g.param,messageId:"unusedOptionalProp",data:{name:b.name}})}else{let b=!1;for(let f of y)if(f.argCount>g.index){b=!0;break}b||e.report({node:g.param,messageId:"unusedOptionalArg",data:{name:g.name}})}}}}}});import{AST_NODE_TYPES as ae,ESLintUtils as Yo}from"@typescript-eslint/utils";import{z as Ve}from"zod/v4";var qo=Ve.object({selectors:Ve.array(Ve.object({name:Ve.string(),selectorProp:Ve.string().optional(),selectorArgPos:Ve.number().optional(),returnProp:Ve.string().optional()}))}),Zo=Yo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lr="no-unused-selected-values",Yt={name:lr,rule:Zo({name:lr,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[V(qo)]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(s=>[s.name,s]));return{VariableDeclarator(s){let a=null;if(s.init?.type===ae.CallExpression&&(a=s.init),!a)return;let i=Ko(a);if(!i)return;let p=n.get(i);if(!p)return;let l=Go(a,p.selectorArgPos??0,p.selectorProp);if(!l)return;let c=Qo(l);if(!c)return;let d=pr(c.properties,void 0);if(!d)return;if(s.id.type===ae.ObjectPattern){let b=pr(s.id.properties,p.returnProp);if(!b)return;for(let[f,E]of d)b.has(f)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:f}});return}if(s.id.type!==ae.Identifier||p.returnProp)return;let y=es(s,e.sourceCode);if(y.length===0)return;let g=new Set;for(let b of y){if(b.identifier.parent.type!==ae.MemberExpression)return;let f=b.identifier.parent.property;if(f.type!==ae.Identifier)return;g.add(f.name)}for(let[b,f]of d)g.has(b)||e.report({node:f,messageId:"unusedSelectedValue",data:{name:b}})}}}})};function Go(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===ae.ArrowFunctionExpression||n.type===ae.FunctionExpression)return n;if(r&&n.type===ae.ObjectExpression){let s=n.properties.find(i=>i.type===ae.Property&&i.key.type===ae.Identifier&&i.key.name===r);if(s?.type!==ae.Property)return null;let a=s.value;if(a.type===ae.ArrowFunctionExpression||a.type===ae.FunctionExpression)return a}return null}function Ko(e){return e.callee.type===ae.Identifier?e.callee.name:e.callee.type===ae.MemberExpression&&e.callee.property.type===ae.Identifier?e.callee.property.name:null}function Qo(e){if(e.body.type===ae.ObjectExpression)return e.body;if(e.body.type===ae.BlockStatement){let t=e.body.body.filter(r=>r.type===ae.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==ae.ObjectExpression?null:t[0].argument}return null}function pr(e,t){let r=e;if(t){let s=e.find(a=>a.type===ae.Property&&a.key.type===ae.Identifier&&a.key.name===t);if(s?.type!==ae.Property||s.value.type!==ae.ObjectPattern)return null;r=s.value.properties}let n=new Map;for(let s of r){if(s.type!==ae.Property||s.key.type!==ae.Identifier)return null;n.set(s.key.name,s)}return n.size>0?n:null}function es(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as se}from"@typescript-eslint/utils";var qt=B({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(a=>a.type===se.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,s=!1;return{CallExpression(a){if(s)return;if(!n){let p=ts(a);p&&(n=p);return}let i=ns(a,e.sourceCode);if(i){s=!0;for(let p of i)n.delete(p);if(n.size!==0)for(let[p,l]of n)e.report({node:l,messageId:"unusedField",data:{name:p}})}}}}});function ts(e){if(!(e.callee.type===se.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==se.ObjectExpression)return null;let n=Rt(r.properties,a=>a.type!==se.Property||a.key.type!==se.Identifier||a.key.name!=="initialConfig"?null:a.value.type===se.ObjectExpression?a.value:a.value.type===se.ArrowFunctionExpression||a.value.type===se.FunctionExpression?rs(a.value):null);if(!n)return null;let s=new Map;for(let a of n.properties)a.type===se.Property&&a.key.type===se.Identifier&&s.set(a.key.name,a);return s}function ns(e,t){if(!(e.callee.type===se.Identifier&&e.callee.name==="useFormState")||e.parent.type!==se.VariableDeclarator||e.parent.id.type!==se.ObjectPattern||!Rt(e.parent.id.properties,i=>i.type===se.Property&&i.key.type===se.Identifier&&i.key.name==="formFields"&&i))return null;let s=Jn(e.parent,"formFields",t),a=new Set;for(let{identifier:i}of s){if(i.type!==se.Identifier||i.parent.type===se.Property&&i.parent.parent.type===se.ObjectExpression&&i.parent.parent.parent.type===se.ReturnStatement||i.parent.type===se.ReturnStatement)return null;if(i.parent.type===se.MemberExpression){if(i.parent.object.type!==se.Identifier||i.parent.property.type!==se.Identifier)return null;a.add(i.parent.property.name)}}return a}function rs(e){if(e.body.type===se.ObjectExpression)return e.body;if(e.body.type===se.BlockStatement){let t=e.body.body.filter(r=>r.type===se.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==se.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as re,ESLintUtils as is}from"@typescript-eslint/utils";import{z as mt}from"zod/v4";var os=is.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function cr(e){let t=[];for(let r of e.members)r.type===re.TSPropertySignature&&r.key.type===re.Identifier&&t.push([r.key.name,r]);return t}function ur(e,...t){for(let r of t)e.set(...r);return e}var ss=mt.object({forceCheckOnFCPropTypesWithName:mt.array(mt.string()).optional(),alwaysCheckFunctionOptionTypes:mt.boolean().optional()}),fr="no-unused-type-props-in-args",Zt=null,as=os({name:fr,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:[V(ss)],fixable:"code"},defaultOptions:[{alwaysCheckFunctionOptionTypes:!0}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r,alwaysCheckFunctionOptionTypes:n=!0}=t;r&&!Zt&&(Zt=r.map(l=>new RegExp(l)));function s(l,c,d,y,g=!0,b=!1){let f=d.name,E=e.sourceCode.getScope(c).references.find(o=>o.identifier.name===f)?.resolved,h=l&&Zt?.some(o=>o.test(f)),m=b&&n;if(!E||!h&&E.references.filter(o=>o.isTypeReference).length>1||!E.defs[0])return;let A=E.defs[0].node,I=A.parent?.type===re.ExportNamedDeclaration;if(!(g&&I&&!m)){if(A.type===re.TSTypeAliasDeclaration){a(l,c,y,A.typeAnnotation,!0,b);return}if(A.type===re.TSInterfaceDeclaration){a(l,c,y,A.body,!0,b);return}}}function a(l,c,d,y,g,b=!1){if(y.type===re.TSInterfaceBody){for(let f of y.body)f.type===re.TSPropertySignature&&f.key.type===re.Identifier&&d.set(f.key.name,f);return}if(y.type===re.TSTypeLiteral){ur(d,...cr(y));return}if(y.type===re.TSIntersectionType){for(let f of y.types)a(l,c,d,f,!0,b);return}g||y.type===re.TSTypeReference&&y.typeName.type===re.Identifier&&s(l,c,y.typeName,d,!0,b)}function i(l,c,d,y=!1){for(let g of d)if(g.type===re.ObjectPattern&&g.typeAnnotation){let b=new Map;if(a(l,c,b,g.typeAnnotation.typeAnnotation,!1,y),b.size===0)continue;p(g,b)}else g.type===re.AssignmentPattern&&g.left.type===re.ObjectPattern&&i(l,c,[g.left],y)}function p(l,c){let d=[];if(l.properties.at(-1)?.type===re.RestElement)return;for(let f of l.properties)f.type===re.Property&&f.key.type===re.Identifier&&d.push(f.key.name);let g=[],b=[];for(let[f,E]of c)d.includes(f)||(b.push(f),g.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:f}}));for(let[f,E]of g.entries())e.report({...E,fix:f===g.length-1?h=>{let m=l.properties.at(-1),A=b.join(", ");return m?m.type===re.RestElement?null:h.insertTextAfter(m,`, ${A}`):h.insertTextBeforeRange([l.range[0]+1,l.range[1]],A)}:void 0})}return{VariableDeclaration(l){let c=l.declarations[0],d=new Map,y=c.id.type===re.Identifier&&c.id.typeAnnotation?.typeAnnotation.type===re.TSTypeReference&&c.id.typeAnnotation.typeAnnotation.typeName.type===re.Identifier&&c.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&c.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(y){if(y.type===re.TSTypeReference&&y.typeName.type===re.Identifier)s(!0,l,y.typeName,d,!1);else if(y.type===re.TSTypeLiteral)ur(d,...cr(y));else if(y.type===re.TSIntersectionType)for(let g of y.types)g.type===re.TSTypeReference&&g.typeName.type===re.Identifier?s(!0,l,g.typeName,d,!1):a(!0,l,d,g,!0);if(d.size!==0&&c.init?.type===re.ArrowFunctionExpression){let g=c.init.params[0];if(!g){e.report({node:c.init,messageId:"missingComponentParam"});return}g.type===re.ObjectPattern&&p(g,d)}}},FunctionDeclaration(l){i(!1,l,l.params,n)},ArrowFunctionExpression(l){i(!1,l,l.params,n)}}}}),Gt={name:fr,rule:as};import{AST_NODE_TYPES as ke}from"@typescript-eslint/utils";var Kt=B({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 t=new Set;function r(n){return n.callee.type===ke.Identifier?t.has(n.callee.name):n.callee.type===ke.MemberExpression&&n.callee.object.type===ke.Identifier&&n.callee.property.type===ke.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let s of n.specifiers)s.type===ke.ImportSpecifier&&s.imported.type===ke.Identifier&&s.imported.name==="useRef"&&t.add(s.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===ke.CallExpression&&r(n.init)&&n.id.type===ke.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let i=!1;for(let p of a.references){let c=p.identifier.parent;if(c!==n&&!(c.type===ke.JSXExpressionContainer&&c.parent.type===ke.JSXAttribute&&c.parent.name.type===ke.JSXIdentifier&&c.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});import{AST_NODE_TYPES as Qt,ESLintUtils as ls}from"@typescript-eslint/utils";var ps=ls.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dr="prefer-named-functions",mr=new Map,cs=ps({name:dr,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,[t]){let r=null;if(t.ignoreRegex){let n=mr.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),mr.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Qt.ArrowFunctionExpression&&n.id.type===Qt.Identifier){let s=n.id.name;if(n.id.typeAnnotation||r&&r.test(s)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Qt.BlockStatement)return;let a=n.parent,i=n.init.params,p=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(a,`${l.async?"async ":""}function ${s}(${i.map(d=>e.sourceCode.getText(d)).join(", ")||""}) ${e.sourceCode.getText(p)}`)}]})}}}}}),en={name:dr,rule:cs};import{AST_NODE_TYPES as q}from"@typescript-eslint/utils";import{z as Me}from"zod/v4";var us=Me.object({disallowedFunctions:Me.array(Me.object({name:Me.string(),allowUsingWithArgs:Me.boolean().optional(),hookAlternative:Me.string().optional(),message:Me.string().optional(),allowUseInside:Me.array(Me.string()).optional()}))}),fs=/^use[A-Z]/,ms=/^[A-Z]/;function dt(e){return fs.test(e)}function yr(e){return ms.test(e)}function ds(e){return e.type===q.Identifier?dt(e.name):e.type===q.MemberExpression&&e.property.type===q.Identifier?dt(e.property.name):!1}function gr(e,t){return e.type===q.Identifier?e.name===t:e.type===q.MemberExpression&&e.object.type===q.Identifier&&e.property.type===q.Identifier?e.object.name==="React"&&e.property.name===t:!1}function Sr(e){return!!(e.parent&&e.parent.type===q.CallExpression&&gr(e.parent.callee,"forwardRef"))}function Tr(e){return!!(e.parent&&e.parent.type===q.CallExpression&&gr(e.parent.callee,"memo"))}function tn(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 ys(e){let t=e.parent,r=!1;for(;t;){if(t.type===q.FunctionDeclaration||t.type===q.FunctionExpression||t.type===q.ArrowFunctionExpression){let n=tn(t);if(n&&n.type===q.Identifier){if(yr(n.name)||dt(n.name))return!r;r=!0}else{if(Sr(t)||Tr(t))return!r;if(t.parent.type===q.CallExpression){let s=t.parent;ds(s.callee)||(r=!0)}else t.parent.type===q.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function hr(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 gs(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===q.FunctionDeclaration||r.type===q.FunctionExpression||r.type===q.ArrowFunctionExpression){let n=tn(r);if(n&&n.type===q.Identifier&&t.includes(n.name))return!0}else if(r.type===q.CallExpression){let n=hr(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Ss(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===q.Identifier&&t.name==="undefined")}function Ts(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===q.FunctionDeclaration||n.type===q.FunctionExpression||n.type===q.ArrowFunctionExpression){let s=tn(n);if(s&&s.type===q.Identifier){if(yr(s.name)||dt(s.name)){r=!0;break}}else if(Sr(n)||Tr(n)){r=!0;break}}n=n.parent}return r?t.length===0?ys(e):!gs(e,t):!1}var nn=B({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:[V(us)],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(s=>[s.name,s]));return{CallExpression(s){let a=hr(s);if(!a)return;let i=n.get(a);if(!i||i.allowUsingWithArgs&&Ss(s))return;let p=i.allowUseInside||[];Ts(s,p)&&e.report({node:s,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:l=>{let c=i.hookAlternative;return c?s.callee.type===q.Identifier?l.replaceText(s.callee,c):s.callee.type===q.MemberExpression&&s.callee.property.type===q.Identifier?l.replaceText(s.callee.property,c):null:null}}]:[]})}}}});import{AST_NODE_TYPES as fe,AST_TOKEN_TYPES as Er,ESLintUtils as hs}from"@typescript-eslint/utils";import rn from"zod/v4";var Es=hs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xr="prefer-single-line-if",bs=rn.object({maxLineLength:rn.number().optional(),maxNonSimpleConditionLength:rn.number().optional()}),xs=Es({name:xr,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:[V(bs)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==fe.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(!a)return;if(a.type===fe.ReturnStatement){if(!Ir(a))return}else if(!(a.type===fe.ContinueStatement||a.type===fe.BreakStatement))return;if(n.test.type===fe.LogicalExpression||n.test.type===fe.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let y=br(n.test);if(!y&&n.test.type===fe.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;br(g)&&(y=!0)}if(y&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let p=r.getText(a);if(i.includes(`
18
+ `))return;let l=r.getTokenAfter(n);if(l&&l.type===Er.Punctuator&&l.value==="}"){let y=r.getTokenAfter(l);if(y&&y.type===Er.Keyword&&(y.value==="else"||y.value==="catch"))return}let c=Cs(r,n),d=`if (${i}) ${p}`;t.maxLineLength&&d.length+c.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:y=>y.replaceText(n,d)})}}}});function br(e){return e.type===fe.CallExpression||e.type===fe.BinaryExpression||e.type===fe.MemberExpression&&Cr(e)}function Cr(e){return e.object.type===fe.MemberExpression?Cr(e.object):e.object.type!==fe.Identifier}function Cs(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Ir(e){if(!e.argument)return!0;let t=e.argument;return t.type===fe.ArrayExpression&&t.elements.length===0||t.type===fe.ObjectExpression&&t.properties.length===0||t.type===fe.Literal||t.type===fe.Identifier||t.type===fe.TemplateLiteral||t.type===fe.TaggedTemplateExpression?!0:t.type===fe.CallExpression?t.arguments.length===0:t.type===fe.UnaryExpression?Ir(t):!1}var on={name:xr,rule:xs};import{AST_NODE_TYPES as U,ESLintUtils as Is}from"@typescript-eslint/utils";import{z as Ar}from"zod/v4";var As=Is.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vr="react-compiler-extra",ws=Ar.object({runOnlyWithEnableCompilerDirective:Ar.boolean().optional()}),Rs=/eslint +react-compiler\/react-compiler: +\["error/;function Fr(e){return e.type===U.Identifier?e.name.startsWith("use"):!1}function Ps(e){return e.type===U.Identifier?e.name.startsWith("use"):e.type===U.MemberExpression&&e.property.type===U.Identifier?e.property.name.startsWith("use"):!1}function Ne(e){if(!e)return!1;switch(e.type){case U.JSXElement:case U.JSXFragment:return!0;case U.ConditionalExpression:return Ne(e.consequent)||Ne(e.alternate);case U.LogicalExpression:return e.operator==="&&"?Ne(e.right):e.operator==="||"?Ne(e.left)||Ne(e.right):!1;case U.CallExpression:if(e.callee.type===U.MemberExpression&&e.callee.object.type===U.Identifier&&e.callee.object.name==="React"&&e.callee.property.type===U.Identifier&&e.callee.property.name==="createElement")return!0;for(let t of e.arguments)if(t.type!==U.SpreadElement&&Ne(t))return!0;return!1;default:return!1}}function vs(e){let t=e.typeAnnotation;if(t.type===U.TSTypeReference){if(t.typeName.type===U.Identifier)return t.typeName.name==="FC";if(t.typeName.type===U.TSQualifiedName&&t.typeName.left.type===U.Identifier&&t.typeName.right.type===U.Identifier)return t.typeName.left.name==="React"&&t.typeName.right.name==="FC"}return!1}var Fs=/^[A-Z][a-zA-Z0-9]*$/;function nt(e){return Fs.test(e)}function an(e){return e.startsWith("use")&&e.length>3}function ln(e,t,r,n){if(r&&vs(r))return t?nt(t.name):e.type===U.FunctionDeclaration&&e.id?nt(e.id.name):!0;if(t&&an(t.name)||e.type===U.FunctionDeclaration&&e.id&&an(e.id.name))return!0;if(n){let s=t?.name||e.type===U.FunctionDeclaration&&e.id?.name;if(s&&nt(s)&&kr(e.body,n).containsJSX)return!0}return!1}function tt(e){if(e.body.type===U.BlockStatement){for(let t of e.body.body)if(t.type===U.ExpressionStatement&&t.expression.type===U.Literal&&typeof t.expression.value=="string"&&t.expression.value==="use memo")return!0}return!1}function kr(e,t){let r={containsJSX:!1,containsHookCalls:!1};return Fe(e,n=>{if(r.containsJSX&&r.containsHookCalls)return!0;switch(n.type){case U.JSXElement:case U.JSXFragment:r.containsJSX=!0;break;case U.CallExpression:Fr(n.callee)&&(r.containsHookCalls=!0),Ne(n)&&(r.containsJSX=!0);break;case U.ReturnStatement:n.argument&&Ne(n.argument)&&(r.containsJSX=!0);break;case U.VariableDeclarator:n.init&&Ne(n.init)&&(r.containsJSX=!0);break;case U.AssignmentExpression:Ne(n.right)&&(r.containsJSX=!0);break}},t),r}function wr(e,t){let r=e.body,n=kr(r,t);return n.containsJSX||n.containsHookCalls}var ks=/\bthis[.[]/;function Rr(e){return ks.test(e)}function Os(e,t){let r={containsJSX:!1,containsHookCalls:!1};return Fe(e,n=>{if(r.containsHookCalls||(n.type===U.FunctionDeclaration||n.type===U.FunctionExpression||n.type===U.ArrowFunctionExpression)&&n!==e)return!0;n.type===U.CallExpression&&Ps(n.callee)&&(r.containsHookCalls=!0)},t),r}function Pr(e){return nt(e)||an(e)}function sn(e,t,r,n){if(!Os(e.body,t).containsHookCalls)return!1;let a=ln(e,r,n,t);if(!a&&n){let i=r?.name||e.type===U.FunctionDeclaration&&e.id?.name;i&&nt(i)&&(a=!0)}return!a}var Ns=As({name:vr,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:[V(ws)]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(Rs.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let i of a.properties)if(i.type===U.Property&&i.method&&i.value.type===U.FunctionExpression){let p=e.sourceCode,l=p.getText(i.key),c=i.value,d=p.getText(c.body);if(Rr(d))e.report({node:i,messageId:"thisKeywordInMethod"});else{let y=c.params.map(b=>p.getText(b)).join(", "),g="";c.generator?g=`${l}: function* (${y}) ${d}`:g=`${l}: (${y}) => ${d}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:b=>b.replaceText(i,g)})}}}function s(a){for(let i of a.properties)if(i.type===U.Property&&i.value.type===U.ObjectExpression){for(let p of i.value.properties)if(p.type===U.Property&&p.method&&p.value.type===U.FunctionExpression){let c=e.sourceCode.getText(p.value.body);Rr(c)&&e.report({node:p,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Fr(a.callee))for(let i of a.arguments){if(i.type===U.ObjectExpression&&(n(i),s(i)),i.type===U.ArrowFunctionExpression&&(i.body.type===U.ObjectExpression&&(n(i.body),s(i.body)),i.body.type===U.BlockStatement))for(let p of i.body.body)p.type===U.ReturnStatement&&p.argument?.type===U.ObjectExpression&&(n(p.argument),s(p.argument));if(i.type===U.FunctionExpression)for(let p of i.body.body)p.type===U.ReturnStatement&&p.argument?.type===U.ObjectExpression&&(n(p.argument),s(p.argument))}},VariableDeclarator(a){if(a.id.type===U.Identifier&&a.init&&(a.init.type===U.ArrowFunctionExpression||a.init.type===U.FunctionExpression)){let i=a.init,p=a.id,l=a.id.typeAnnotation;if(tt(i)&&!Pr(p.name)){e.report({node:i,messageId:"useMemoDirectiveNaming"});return}if(sn(i,e.sourceCode,p,l)){e.report({node:i,messageId:"functionCallingHooksMustBeComponent"});return}if(ln(i,p,l,e.sourceCode)){let c=wr(i,e.sourceCode),d=tt(i);!c&&!d&&e.report({node:i,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(y){if(i.body.type===U.BlockStatement){let g=i.body.range[0]+1;return y.insertTextAfterRange([g,g],`
19
19
  "use memo"
20
- `)}return null}}]})}}},FunctionDeclaration(o){if(o.id&&Ze(o)&&!Cr(o.id.name)){e.report({node:o,messageId:"useMemoDirectiveNaming"});return}if(tn(o,e.sourceCode)){e.report({node:o,messageId:"functionCallingHooksMustBeComponent"});return}if(rn(o,void 0,void 0,e.sourceCode)){let i=br(o,e.sourceCode),p=Ze(o);!i&&!p&&e.report({node:o,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(a){let c=o.body.range[0]+1;return a.insertTextAfterRange([c,c],`
20
+ `)}return null}}]})}}},FunctionDeclaration(a){if(a.id&&tt(a)&&!Pr(a.id.name)){e.report({node:a,messageId:"useMemoDirectiveNaming"});return}if(sn(a,e.sourceCode)){e.report({node:a,messageId:"functionCallingHooksMustBeComponent"});return}if(ln(a,void 0,void 0,e.sourceCode)){let i=wr(a,e.sourceCode),p=tt(a);!i&&!p&&e.report({node:a,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(l){let c=a.body.range[0]+1;return l.insertTextAfterRange([c,c],`
21
21
  "use memo"
22
- `)}}]})}},FunctionExpression(o){if(Ze(o)){e.report({node:o,messageId:"useMemoDirectiveNaming"});return}tn(o,e.sourceCode)&&e.report({node:o,messageId:"functionCallingHooksMustBeComponent"})}}}}),sn={name:Ar,rule:Oo};import{AST_NODE_TYPES as Te,ESLintUtils as No}from"@typescript-eslint/utils";import{z as Re}from"zod/v4";var Do=No.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rr="react-compiler-migration",jo=Re.object({disallowHooks:Re.array(Re.object({name:Re.string(),replacement:Re.string()})).optional(),disallowMethods:Re.array(Re.object({name:Re.string(),replacement:Re.string().optional(),requireTrueProp:Re.string().optional()})).optional()}),Lo=/eslint +react-compiler\/react-compiler: +\["error/;function Mo(e){return e.type===Te.Identifier?e.name.startsWith("use"):e.type===Te.MemberExpression&&e.property.type===Te.Identifier?e.property.name.startsWith("use"):!1}var $o=Do({name:Rr,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:[$(jo)]},defaultOptions:[{disallowHooks:[],disallowMethods:[]}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Lo.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let s=null,o=null;if(n.callee.type===Te.Identifier?(s=n.callee.name,o=n.callee):n.callee.type===Te.MemberExpression&&n.callee.property.type===Te.Identifier&&(s=n.callee.property.name,o=n.callee.property),s){let i=t.disallowHooks.find(p=>p.name===s);i&&o&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:p=>p.replaceText(o,i.replacement)}]})}}if(t.disallowMethods?.length&&Mo(n.callee)){for(let s of n.arguments)if(s.type===Te.ObjectExpression){for(let o of s.properties)if(o.type===Te.Property&&o.key.type===Te.Identifier){let i=o.key.name,p=t.disallowMethods.find(a=>a.name===i);if(p){if(p.requireTrueProp){let a=p.requireTrueProp,c=!1;for(let g of s.properties)if(g.type===Te.Property&&g.key.type===Te.Identifier&&g.key.name===a&&g.value.type===Te.Literal&&g.value.value===!0){c=!0;break}if(!c){e.report({node:o,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:p.name,requireTrueProp:a}});continue}}p.replacement&&e.report({node:o,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:p.name,replacement:p.replacement},suggest:[{messageId:"replace",data:{replacement:p.replacement},fix:a=>p.replacement?a.replaceText(o.key,p.replacement):null}]})}}}}}}:{}}}),on={name:Rr,rule:$o};import{AST_NODE_TYPES as O}from"@typescript-eslint/utils";import{z as Pr}from"zod";var _o=Pr.object({runOnlyWithEnableCompilerDirective:Pr.boolean().optional()}),Uo=/eslint +react-compiler\/react-compiler: +\["error/,zo=/^\d+$/,Wo=/[\s_-]+/,Jo=/[a-z][A-Z]/,Vo=/^(.+?)([A-Z][a-z]+s?)$/,Xo=/^[a-z][a-zA-Z]*$/;function vr(e,t){let r=[];if(e.type===O.JSXElement){for(let n of e.openingElement.attributes)if(n.type===O.JSXAttribute&&n.name.type===O.JSXIdentifier&&n.value?.type===O.JSXExpressionContainer&&n.value.expression.type!==O.JSXEmptyExpression){let s=n.name.name,o=n.value.expression,i=!1;Ae(o,p=>{switch(p.type){case O.ObjectExpression:case O.ArrowFunctionExpression:case O.FunctionExpression:case O.ArrayExpression:return i=!0,!0}return!1},t),i&&r.push(s)}}return{hasUnstable:r.length>0,problematicProps:r}}function Ho(e){if(e.body.type===O.JSXElement||e.body.type===O.JSXFragment)return!0;if(e.body.type===O.BlockStatement){for(let t of e.body.body)if(t.type===O.ReturnStatement&&t.argument&&(t.argument.type===O.JSXElement||t.argument.type===O.JSXFragment))return!0}return!1}function Bo(e,t){let r=e.callee;if(r.type===O.MemberExpression){let n=r.object;if(n.type===O.Identifier){let s=n.name,o=Yo(s);if(o!==s)return ln(o)}}if(t.length>0){let n=t[0];if(n&&n.type===O.Identifier)return ln(n.name)}return"ListItem"}function Yo(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(Jo)){let n=e.match(Vo);if(n){let s=n[1],o=n[2];if(!s||!o)return an(e);let i=an(o);if(i!==o)return s+i}}return an(e)}function an(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 ln(e){return e.match(Xo)?e.charAt(0).toUpperCase()+e.slice(1):e.split(Wo).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function Fr(e,t,r){let n=[],s=new Set,o=new Set(["console","document","window","Math","Object","Array","String","Number","Boolean","undefined","null"]);Ae(e,i=>{if(i.type===O.Identifier&&!t.includes(i.name)&&!o.has(i.name)&&!zo.test(i.name)){let p=i.parent;if(p.type===O.Property&&p.key===i||p.type===O.MemberExpression&&p.property===i&&!p.computed||p.type===O.JSXOpeningElement||p.type===O.JSXClosingElement||p.type===O.JSXAttribute&&p.name.type===O.JSXIdentifier&&p.name.name===i.name)return!1;s.add(i.name)}return!1},r);for(let i of s)t.includes(i)||n.push({name:i,type:"unknown"});return n}function kr(e,t,r,n,s){let i=[...r.map(S=>S.type===O.Identifier?S.name:"item").map((S,l)=>({name:S,type:l===0?`${e}Type`:l===1?"number":"unknown"})),...n],p=i.map(S=>{let l=S.type;return S.name.includes("on")&&l==="any"&&(l="unknown"),` ${S.name}: ${l};`}).join(`
23
- `),a=i.map(S=>S.name).join(", "),c=s.getText(t),g=`${e}Props`;return`type ${g} = {
22
+ `)}}]})}},FunctionExpression(a){if(tt(a)){e.report({node:a,messageId:"useMemoDirectiveNaming"});return}sn(a,e.sourceCode)&&e.report({node:a,messageId:"functionCallingHooksMustBeComponent"})}}}}),pn={name:vr,rule:Ns};import{AST_NODE_TYPES as Re,ESLintUtils as Ds}from"@typescript-eslint/utils";import{z as De}from"zod/v4";var js=Ds.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Or="react-compiler-migration",Ls=De.object({disallowHooks:De.array(De.object({name:De.string(),replacement:De.string()})).optional(),disallowMethods:De.array(De.object({name:De.string(),replacement:De.string().optional(),requireTrueProp:De.string().optional()})).optional()}),Ms=/eslint +react-compiler\/react-compiler: +\["error/;function $s(e){return e.type===Re.Identifier?e.name.startsWith("use"):e.type===Re.MemberExpression&&e.property.type===Re.Identifier?e.property.name.startsWith("use"):!1}var _s=js({name:Or,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:[V(Ls)]},defaultOptions:[{disallowHooks:[],disallowMethods:[]}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Ms.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let s=null,a=null;if(n.callee.type===Re.Identifier?(s=n.callee.name,a=n.callee):n.callee.type===Re.MemberExpression&&n.callee.property.type===Re.Identifier&&(s=n.callee.property.name,a=n.callee.property),s){let i=t.disallowHooks.find(p=>p.name===s);i&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:p=>p.replaceText(a,i.replacement)}]})}}if(t.disallowMethods?.length&&$s(n.callee)){for(let s of n.arguments)if(s.type===Re.ObjectExpression){for(let a of s.properties)if(a.type===Re.Property&&a.key.type===Re.Identifier){let i=a.key.name,p=t.disallowMethods.find(l=>l.name===i);if(p){if(p.requireTrueProp){let l=p.requireTrueProp,c=!1;for(let d of s.properties)if(d.type===Re.Property&&d.key.type===Re.Identifier&&d.key.name===l&&d.value.type===Re.Literal&&d.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:p.name,requireTrueProp:l}});continue}}p.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:p.name,replacement:p.replacement},suggest:[{messageId:"replace",data:{replacement:p.replacement},fix:l=>p.replacement?l.replaceText(a.key,p.replacement):null}]})}}}}}}:{}}}),cn={name:Or,rule:_s};import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";import{z as Nr}from"zod";var Us=Nr.object({runOnlyWithEnableCompilerDirective:Nr.boolean().optional()}),zs=/eslint +react-compiler\/react-compiler: +\["error/,Ws=/^\d+$/,Js=/[\s_-]+/,Vs=/[a-z][A-Z]/,Xs=/^(.+?)([A-Z][a-z]+s?)$/,Bs=/^[a-z][a-zA-Z]*$/;function Dr(e,t){let r=[];if(e.type===L.JSXElement){for(let n of e.openingElement.attributes)if(n.type===L.JSXAttribute&&n.name.type===L.JSXIdentifier&&n.value?.type===L.JSXExpressionContainer&&n.value.expression.type!==L.JSXEmptyExpression){let s=n.name.name,a=n.value.expression,i=!1;Fe(a,p=>{switch(p.type){case L.ObjectExpression:case L.ArrowFunctionExpression:case L.FunctionExpression:case L.ArrayExpression:return i=!0,!0}return!1},t),i&&r.push(s)}}return{hasUnstable:r.length>0,problematicProps:r}}function Hs(e){if(e.body.type===L.JSXElement||e.body.type===L.JSXFragment)return!0;if(e.body.type===L.BlockStatement){for(let t of e.body.body)if(t.type===L.ReturnStatement&&t.argument&&(t.argument.type===L.JSXElement||t.argument.type===L.JSXFragment))return!0}return!1}function Ys(e,t){let r=e.callee;if(r.type===L.MemberExpression){let n=r.object;if(n.type===L.Identifier){let s=n.name,a=qs(s);if(a!==s)return fn(a)}}if(t.length>0){let n=t[0];if(n&&n.type===L.Identifier)return fn(n.name)}return"ListItem"}function qs(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(Vs)){let n=e.match(Xs);if(n){let s=n[1],a=n[2];if(!s||!a)return un(e);let i=un(a);if(i!==a)return s+i}}return un(e)}function un(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 fn(e){return e.match(Bs)?e.charAt(0).toUpperCase()+e.slice(1):e.split(Js).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function jr(e,t,r){let n=[],s=new Set,a=new Set(["console","document","window","Math","Object","Array","String","Number","Boolean","undefined","null"]);Fe(e,i=>{if(i.type===L.Identifier&&!t.includes(i.name)&&!a.has(i.name)&&!Ws.test(i.name)){let p=i.parent;if(p.type===L.Property&&p.key===i||p.type===L.MemberExpression&&p.property===i&&!p.computed||p.type===L.JSXOpeningElement||p.type===L.JSXClosingElement||p.type===L.JSXAttribute&&p.name.type===L.JSXIdentifier&&p.name.name===i.name)return!1;s.add(i.name)}return!1},r);for(let i of s)t.includes(i)||n.push({name:i,type:"unknown"});return n}function Lr(e,t,r,n,s){let i=[...r.map(y=>y.type===L.Identifier?y.name:"item").map((y,g)=>({name:y,type:g===0?`${e}Type`:g===1?"number":"unknown"})),...n],p=i.map(y=>{let g=y.type;return y.name.includes("on")&&g==="any"&&(g="unknown"),` ${y.name}: ${g};`}).join(`
23
+ `),l=i.map(y=>y.name).join(", "),c=s.getText(t),d=`${e}Props`;return`type ${d} = {
24
24
  ${p}
25
25
  };
26
26
 
27
- const ${e}: FC<${g}> = ({ ${a} }) => {
27
+ const ${e}: FC<${d}> = ({ ${l} }) => {
28
28
  return (
29
29
  ${c}
30
30
  );
31
- };`}function qo(e,t,r,n){let s=t.map(i=>i.type===O.Identifier?i.name:"item"),o=[n?`key={${n}}`:`key={${s[0]}.id}`,...s.map(i=>`${i}={${i}}`),...r.map(i=>`${i.name}={${i.name}}`)].filter(Boolean);return`<${e} ${o.join(" ")} />`}function Zo(e){if(e.type===O.JSXElement&&e.openingElement.name.type===O.JSXIdentifier){let t=e.openingElement.name.name;if(t!=="div"&&t!=="span")return ln(t)}return"ListItem"}function Go(e,t,r){let n=[r?`key={${r}}`:"",...t.map(s=>`${s.name}={${s.name}}`)].filter(Boolean);return`<${e}${n.length>0?` ${n.join(" ")}`:""} />`}function Or(e,t){for(let r of e.openingElement.attributes)if(r.type===O.JSXAttribute&&r.name.type===O.JSXIdentifier&&r.name.name==="key"&&r.value&&r.value.type===O.JSXExpressionContainer&&r.value.expression.type!==O.JSXEmptyExpression)return t.getText(r.value.expression);return null}var pn=_({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:[$(_o)],hasSuggestions:!0},defaultOptions:[{runOnlyWithEnableCompilerDirective:!1}],create(e,[t]){let{sourceCode:r}=e;if(t.runOnlyWithEnableCompilerDirective){let n=!1;for(let s of r.getAllComments())if(Uo.test(s.value)){n=!0;break}if(!n)return{}}return{CallExpression(n){n.callee.type===O.MemberExpression&&n.callee.property.type===O.Identifier&&(n.callee.property.name==="map"||n.callee.property.name==="push")&&(n.callee.property.name==="map"?Ko(n,r,e):Qo(n,r,e))}}}});function Ko(e,t,r){let n=e.arguments[0];if(!n||n.type!==O.ArrowFunctionExpression&&n.type!==O.FunctionExpression||!Ho(n))return;let s=null;if(n.body.type===O.JSXElement||n.body.type===O.JSXFragment?s=n.body:n.body.type===O.BlockStatement&&n.body.body[0]?.type===O.ReturnStatement&&n.body.body[0].argument&&(n.body.body[0].argument.type===O.JSXElement||n.body.body[0].argument.type===O.JSXFragment)&&(s=n.body.body[0].argument),!s)return;let o=vr(s,t);if(!o.hasUnstable)return;let i=Bo(e,n.params),p=n.params.map(S=>S.type===O.Identifier?S.name:"item"),a=Fr(s,p,t),c=s.type===O.JSXElement?Or(s,t):null,g=o.problematicProps.length===1?`prop "${o.problematicProps[0]}"`:`props "${o.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:g},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:S=>{let l=kr(i,s,n.params,a,t),E=qo(i,n.params,a,c),f=e;for(;f.parent.type!==O.Program&&!(f.type===O.FunctionDeclaration||f.type===O.VariableDeclarator&&f.init&&(f.init.type===O.ArrowFunctionExpression||f.init.type===O.FunctionExpression));)f=f.parent;let h=[];return h.push(S.insertTextAfter(f,`
31
+ };`}function Zs(e,t,r,n){let s=t.map(i=>i.type===L.Identifier?i.name:"item"),a=[n?`key={${n}}`:`key={${s[0]}.id}`,...s.map(i=>`${i}={${i}}`),...r.map(i=>`${i.name}={${i.name}}`)].filter(Boolean);return`<${e} ${a.join(" ")} />`}function Gs(e){if(e.type===L.JSXElement&&e.openingElement.name.type===L.JSXIdentifier){let t=e.openingElement.name.name;if(t!=="div"&&t!=="span")return fn(t)}return"ListItem"}function Ks(e,t,r){let n=[r?`key={${r}}`:"",...t.map(s=>`${s.name}={${s.name}}`)].filter(Boolean);return`<${e}${n.length>0?` ${n.join(" ")}`:""} />`}function Mr(e,t){for(let r of e.openingElement.attributes)if(r.type===L.JSXAttribute&&r.name.type===L.JSXIdentifier&&r.name.name==="key"&&r.value&&r.value.type===L.JSXExpressionContainer&&r.value.expression.type!==L.JSXEmptyExpression)return t.getText(r.value.expression);return null}var mn=B({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:[V(Us)],hasSuggestions:!0},defaultOptions:[{runOnlyWithEnableCompilerDirective:!1}],create(e,[t]){let{sourceCode:r}=e;if(t.runOnlyWithEnableCompilerDirective){let n=!1;for(let s of r.getAllComments())if(zs.test(s.value)){n=!0;break}if(!n)return{}}return{CallExpression(n){n.callee.type===L.MemberExpression&&n.callee.property.type===L.Identifier&&(n.callee.property.name==="map"||n.callee.property.name==="push")&&(n.callee.property.name==="map"?Qs(n,r,e):ea(n,r,e))}}}});function Qs(e,t,r){let n=e.arguments[0];if(!n||n.type!==L.ArrowFunctionExpression&&n.type!==L.FunctionExpression||!Hs(n))return;let s=null;if(n.body.type===L.JSXElement||n.body.type===L.JSXFragment?s=n.body:n.body.type===L.BlockStatement&&n.body.body[0]?.type===L.ReturnStatement&&n.body.body[0].argument&&(n.body.body[0].argument.type===L.JSXElement||n.body.body[0].argument.type===L.JSXFragment)&&(s=n.body.body[0].argument),!s)return;let a=Dr(s,t);if(!a.hasUnstable)return;let i=Ys(e,n.params),p=n.params.map(y=>y.type===L.Identifier?y.name:"item"),l=jr(s,p,t),c=s.type===L.JSXElement?Mr(s,t):null,d=a.problematicProps.length===1?`prop "${a.problematicProps[0]}"`:`props "${a.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:d},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:y=>{let g=Lr(i,s,n.params,l,t),b=Zs(i,n.params,l,c),f=e;for(;f.parent.type!==L.Program&&!(f.type===L.FunctionDeclaration||f.type===L.VariableDeclarator&&f.init&&(f.init.type===L.ArrowFunctionExpression||f.init.type===L.FunctionExpression));)f=f.parent;let E=[];return E.push(y.insertTextAfter(f,`
32
32
 
33
- ${l}`)),h.push(S.replaceText(s,E)),h}}]})}function Qo(e,t,r){let n=e.arguments[0];if(!n||n.type!==O.JSXElement&&n.type!==O.JSXFragment)return;let s=n,o=vr(s,t);if(!o.hasUnstable)return;let i=Zo(s),p=Fr(s,[],t),a=s.type===O.JSXElement?Or(s,t):null,c=o.problematicProps.length===1?`prop "${o.problematicProps[0]}"`:`props "${o.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:c},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:g=>{let S=kr(i,s,[],p,t),l=Go(i,p,a),E=e;for(;E.parent.type!==O.Program&&!(E.type===O.FunctionDeclaration||E.type===O.VariableDeclarator&&E.init&&(E.init.type===O.ArrowFunctionExpression||E.init.type===O.FunctionExpression));)E=E.parent;let f=[];return f.push(g.insertTextAfter(E,`
33
+ ${g}`)),E.push(y.replaceText(s,b)),E}}]})}function ea(e,t,r){let n=e.arguments[0];if(!n||n.type!==L.JSXElement&&n.type!==L.JSXFragment)return;let s=n,a=Dr(s,t);if(!a.hasUnstable)return;let i=Gs(s),p=jr(s,[],t),l=s.type===L.JSXElement?Mr(s,t):null,c=a.problematicProps.length===1?`prop "${a.problematicProps[0]}"`:`props "${a.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:c},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:d=>{let y=Lr(i,s,[],p,t),g=Ks(i,p,l),b=e;for(;b.parent.type!==L.Program&&!(b.type===L.FunctionDeclaration||b.type===L.VariableDeclarator&&b.init&&(b.init.type===L.ArrowFunctionExpression||b.init.type===L.FunctionExpression));)b=b.parent;let f=[];return f.push(d.insertTextAfter(b,`
34
34
 
35
- ${S}`)),f.push(g.replaceText(s,l)),f}}]})}import{ESLintUtils as ea,TSESTree as ta}from"@typescript-eslint/utils";var na=ea.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nr="require-description",ra=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ia=/^eslint-disable-(next-)?line$/u,sa=na({name:Nr,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,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let o=oa(s);o!=null&&(n.has(o.kind)||o.description||e.report({loc:pa(s.loc),messageId:"missingDescription"}))}}}}}),Dr={name:Nr,rule:sa};function oa(e){let{text:t,description:r}=la(e.value);if(!t)return null;let n=ra.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let o=ia.test(s);if(e.type===ta.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+s.length);return{kind:s,value:i.trim(),description:r}}var aa=/\s-{2,}\s/u;function la(e){let t=e.split(aa);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function pa(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as H}from"@typescript-eslint/utils";import{z as ke}from"zod/v4";var ca=ke.object({varsToCheck:ke.array(ke.object({selector:ke.string().optional(),fromFnCall:ke.string().optional(),prop:ke.string().or(ke.array(ke.string())),errorMsg:ke.string().optional()}))}),cn=_({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:[$(ca)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,p,a,c){let g=new Set;for(let l of i.properties)l.type===H.Property&&l.key.type===H.Identifier&&g.add(l.key.name);let S=p.filter(l=>!g.has(l));if(S.length>0)if(S.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:S[0],fnName:c,customMsg:a||""}});else{let l=S.map(E=>`"${E}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:l,fnName:c,customMsg:a||""}})}}function s(i){if(i.init?.type===H.CallExpression){if(i.init.callee.type===H.Identifier)return i.init.callee.name;if(i.init.callee.type===H.MemberExpression&&i.init.callee.property.type===H.Identifier)return i.init.callee.object.type===H.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let o={};for(let i of t.varsToCheck)i.selector&&(o[i.selector]=p=>{if(p.type===H.VariableDeclarator&&p.id.type===H.Identifier&&r.set(p.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:p.id,fnName:s(p)}),p.type===H.VariableDeclarator&&p.id.type===H.ObjectPattern){let a=Array.isArray(i.prop)?i.prop:[i.prop];n(p.id,a,i.errorMsg,s(p))}});for(let i of t.varsToCheck)if(i.fromFnCall){let p=i.fromFnCall;if(p.startsWith("*.")){let c=`VariableDeclarator > CallExpression > MemberExpression[property.name="${p.slice(2)}"]`;o[c]=g=>{if(g.type!==H.MemberExpression||g.parent.type!==H.CallExpression)return;let S=g.parent;if(S.parent.type!==H.VariableDeclarator)return;let l=S.parent;if(l.id.type===H.Identifier)r.set(l.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:l.id,fnName:i.fromFnCall||"unknown function"});else if(l.id.type===H.ObjectPattern){let E=Array.isArray(i.prop)?i.prop:[i.prop];n(l.id,E,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(p.includes(".")){let[a,c]=p.split("."),g=`VariableDeclarator > CallExpression > MemberExpression[object.name="${a}"][property.name="${c}"]`;o[g]=S=>{if(S.type!==H.MemberExpression||S.parent.type!==H.CallExpression)return;let l=S.parent;if(l.parent.type!==H.VariableDeclarator)return;let E=l.parent;if(E.id.type===H.Identifier)r.set(E.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:E.id,fnName:i.fromFnCall||"unknown function"});else if(E.id.type===H.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];n(E.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let a=`VariableDeclarator > CallExpression > Identifier[name="${p}"]`;o[a]=c=>{if(c.type!==H.Identifier||c.parent.type!==H.CallExpression)return;let g=c.parent;if(g.parent.type!==H.VariableDeclarator)return;let S=g.parent;if(S.id.type===H.Identifier)r.set(S.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:S.id,fnName:i.fromFnCall||"unknown function"});else if(S.id.type===H.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(S.id,l,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:p,errorMsg:a,node:c,fnName:g}]of r){let l=e.sourceCode.getScope(c).set.get(i);if(l){let E=new Set(p);for(let f of l.references){let h=f.identifier,T=h.parent;if(!(T.type===H.VariableDeclarator&&T.id===h)){if(T.type===H.MemberExpression&&T.object===h&&T.property.type===H.Identifier&&E.has(T.property.name)){if(E.delete(T.property.name),E.size===0)break;continue}if(T.type===H.VariableDeclarator&&T.init===h&&T.id.type===H.ObjectPattern){for(let m of T.id.properties)m.type===H.Property&&m.key.type===H.Identifier&&E.has(m.key.name)&&E.delete(m.key.name);if(E.size===0)break;continue}if(!(T.type===H.MemberExpression&&T.object===h&&T.property.type===H.Identifier&&!p.includes(T.property.name))){E.clear();break}}}if(E.size>0){let f=Array.from(E);if(f.length===1)e.report({node:c,messageId:"propNotRead",data:{prop:f[0],fnName:g,customMsg:a||""}});else{let h=f.map(T=>`"${T}"`).join(", ");e.report({node:c,messageId:"propsNotRead",data:{props:h,fnName:g,customMsg:a||""}})}}}}}}}});function Mr(e){return/^use[A-Z0-9]/.test(e)}function ut(e){return e.type==="Identifier"?Mr(e.name):e.type==="MemberExpression"&&!e.computed&&ut(e.property)?e.object.type==="Identifier":!1}function $r(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function _r(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Ur(e){return!!(e.parent&&e.parent.callee&&_r(e.parent.callee,"forwardRef"))}function zr(e){return!!(e.parent&&e.parent.callee&&_r(e.parent.callee,"memo"))}function un(e){for(;e;){let t=Jr(e);if(t&&($r(t)||ut(t))||Ur(e)||zr(e))return!0;e=e.parent}return!1}function jr(e){return!1}function fn(e){return!1}var ua=/eslint +react-compiler\/react-compiler: +\["error/,Wr={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"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let a of e.sourceCode.getAllComments())if(ua.test(a.value))return{CallExpression(c){let g=null;c.callee.name==="useMemo"?g="useMemo":c.callee.name==="useCallback"&&(g="useCallback"),g&&e.report({node:c,message:`"${g}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),r=typeof e.getScope=="function"?()=>r():a=>e.sourceCode.getScope(a),n=null,s=[],o=[],i=new WeakSet;function p(a){for(let c of a.references){let g=c.identifier.parent;if(g.type==="VariableDeclarator"&&g.init&&g.init.type==="CallExpression"&&g.init.callee&&jr(g.init.callee))for(let S of c.resolved.references)S!==c&&i.add(S.identifier)}}return{onCodePathSegmentStart:a=>o.push(a),onCodePathSegmentEnd:()=>o.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(a,c){let g=s.pop();if(g.size===0)return;let S=new Set;function l(y,x){let{cache:u}=l,d=u.get(y.id),A=new Set(x);if(A.has(y.id)){let I=[...A],R=I.slice(I.indexOf(y.id)+1);for(let v of R)S.add(v);return BigInt("0")}if(A.add(y.id),d!==void 0)return d;if(a.thrownSegments.includes(y))d=BigInt("0");else if(y.prevSegments.length===0)d=BigInt("1");else{d=BigInt("0");for(let I of y.prevSegments)d+=l(I,A)}return y.reachable&&d===BigInt("0")?u.delete(y.id):u.set(y.id,d),d}function E(y,x){let{cache:u}=E,d=u.get(y.id),A=new Set(x);if(A.has(y.id)){let I=Array.from(A),R=I.slice(I.indexOf(y.id)+1);for(let v of R)S.add(v);return BigInt("0")}if(A.add(y.id),d!==void 0)return d;if(a.thrownSegments.includes(y))d=BigInt("0");else if(y.nextSegments.length===0)d=BigInt("1");else{d=BigInt("0");for(let I of y.nextSegments)d+=E(I,A)}return u.set(y.id,d),d}function f(y){let{cache:x}=f,u=x.get(y.id);if(u===null)return 1/0;if(u!==void 0)return u;if(x.set(y.id,null),y.prevSegments.length===0)u=1;else{u=1/0;for(let d of y.prevSegments){let A=f(d);A<u&&(u=A)}u+=1}return x.set(y.id,u),u}l.cache=new Map,E.cache=new Map,f.cache=new Map;let h=E(a.initialSegment),T=Jr(c),m=un(c),b=T?$r(T)||ut(T):Ur(c)||zr(c),C=1/0;for(let y of a.finalSegments){if(!y.reachable)continue;let x=f(y);x<C&&(C=x)}for(let[y,x]of g){if(!y.reachable)continue;let u=y.nextSegments.length===0?C<=f(y):C<f(y),d=l(y)*E(y),A=S.has(y.id);for(let I of x)if(A&&!fn(I)&&e.report({node:I,message:`React Hook "${t(I)}" 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.`}),b){if(c.async&&e.report({node:I,message:`React Hook "${t(I)}" cannot be called in an async function.`}),!A&&d!==h&&!fn(I)){let v=`React Hook "${t(I)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(u?" Did you accidentally call a React Hook after an early return?":"");e.report({node:I,message:v})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let R=`React Hook "${t(I)}" 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:I,message:R})}else if(T){let R=`React Hook "${t(I)}" is called in function "${t(T)}" 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:I,message:R})}else if(c.type==="Program"){let R=`React Hook "${t(I)}" 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:I,message:R})}else if(m&&!fn(I)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let v=c.parent;if(v.parent.type==="VariableDeclarator"&&Mr(v.parent.id.name))return}let R=`React Hook "${t(I)}" 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:I,message:R})}}},CallExpression(a){if(ut(a.callee)){let c=Lr(s),g=Lr(o),S=c.get(g);S||(S=[],c.set(g,S)),S.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||jr(a.callee))&&a.arguments.length>0&&(n=a)},Identifier(a){n==null&&i.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(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===n&&(n=null)},FunctionDeclaration(a){un(a)&&p(r(a))},ArrowFunctionExpression(a){un(a)&&p(r(a))}}}};function Jr(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 Lr(e){return e[e.length-1]}import{AST_NODE_TYPES as le,AST_TOKEN_TYPES as fa}from"@typescript-eslint/utils";import*as fe from"zod/v4";var ma=/^\s+$/,mn=/\r?\n/,ya=/^(\s*)/,da=/^(\s*)\S/,ga=/\r?\n/,Sa=fe.object({indent:fe.union([fe.string().regex(ma),fe.number().int().min(1)]).optional(),tags:fe.array(fe.string()).optional(),functions:fe.array(fe.string()).optional(),comments:fe.array(fe.string()).optional()}),yn=_({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[$(Sa)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(m=>m.toLowerCase());function p(m){let b=m.split(mn),C=b.filter(x=>x.trim()!=="");if(C.length===0)return m;let y=Number.POSITIVE_INFINITY;for(let x of C){let u=x.match(ya);u&&(y=Math.min(y,u[1]?.length??0))}return!isFinite(y)||y===0?m:b.map(x=>x.slice(y)).join(`
36
- `)}function a(m,b,C){return m.split(mn).map(x=>x.trim()===""?x:C.repeat(b)+x).join(`
37
- `)}function c(m){if(m.type===le.Identifier)return m.name;if(m.type===le.MemberExpression){let b=m.object.type===le.Identifier?m.object.name:null,C=m.property.type===le.Identifier?m.property.name:null;return b&&C?`${b}.${C}`:C}return null}function g(m,b){if(!m)return!1;for(let C of b)if(C.includes(".")){let y=C.split(".");if(m.type===le.MemberExpression&&m.object.type===le.Identifier&&m.property.type===le.Identifier&&m.object.name===y[0]&&m.property.name===y[1])return!0}else if(m.type===le.Identifier&&m.name===C)return!0;return!1}function S(m,b){let C=m.parent;if(C.type!==le.TaggedTemplateExpression)return!1;let y=c(C.tag);return y?b.includes(y):!1}function l(m,b){if(!m||m.type!==le.CallExpression)return!1;let{method:C,argumentsLength:y,optionalCall:x=!0,optionalMember:u=!0}=b;return y!==void 0&&m.arguments.length!==y||!x&&m.optional||m.callee.type!==le.MemberExpression||!u&&m.callee.optional||m.callee.property.type!==le.Identifier?!1:m.callee.property.name===C}function E(m,b){if(!m||m.type!==le.CallExpression)return!1;let{name:C,argumentsLength:y,optionalCall:x=!0}=b;return y!==void 0&&m.arguments.length!==y||!x&&m.optional||m.callee.type!==le.Identifier?!1:m.callee.name===C}function f(m){return l(m.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&m.parent.type===le.CallExpression&&m.parent.arguments[0]===m&&E(m.parent.callee.type===le.MemberExpression?m.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function h(m){if(i.length>0){let b=t.getTokenBefore(m,{includeComments:!0});if(b?.type===fa.Block&&i.includes(b.value.trim().toLowerCase()))return!0}return!!(f(m)||s.length>0&&S(m,s)||n.length>0&&m.parent.type===le.CallExpression&&m.parent.arguments.includes(m)&&g(m.parent.callee,n))}function T(m){let b=`__PLACEHOLDER__${Math.random()}`,C=m.quasis.map(V=>t.getText(V).slice(1,V.tail?-1:-2)).join(b),y=C.match(ga);if(!y)return;let x=y[0],u=t.lines[t.getLocFromIndex(m.range[0]).line-1];if(!u)return;let A=u.match(da)?.[1]??"",I;typeof o=="string"?I=o:typeof o=="number"?I=" ".repeat(o):I=A.startsWith(" ")?" ":" ";let v=p(C).replace(new RegExp(`^${x}|${x}[ ]*$`,"g"),""),J=x+a(v,1,A+I)+x+A,Y=C.includes(`\r
35
+ ${y}`)),f.push(d.replaceText(s,g)),f}}]})}import{ESLintUtils as ta,TSESTree as na}from"@typescript-eslint/utils";var ra=ta.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$r="require-description",ia=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,oa=/^eslint-disable-(next-)?line$/u,sa=ra({name:$r,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,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let a=aa(s);a!=null&&(n.has(a.kind)||a.description||e.report({loc:ca(s.loc),messageId:"missingDescription"}))}}}}}),_r={name:$r,rule:sa};function aa(e){let{text:t,description:r}=pa(e.value);if(!t)return null;let n=ia.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let a=oa.test(s);if(e.type===na.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+s.length);return{kind:s,value:i.trim(),description:r}}var la=/\s-{2,}\s/u;function pa(e){let t=e.split(la);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ca(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as Q}from"@typescript-eslint/utils";import{z as $e}from"zod/v4";var ua=$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()}))}),dn=B({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:[V(ua)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,p,l,c){let d=new Set;for(let g of i.properties)g.type===Q.Property&&g.key.type===Q.Identifier&&d.add(g.key.name);let y=p.filter(g=>!d.has(g));if(y.length>0)if(y.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:y[0],fnName:c,customMsg:l||""}});else{let g=y.map(b=>`"${b}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:g,fnName:c,customMsg:l||""}})}}function s(i){if(i.init?.type===Q.CallExpression){if(i.init.callee.type===Q.Identifier)return i.init.callee.name;if(i.init.callee.type===Q.MemberExpression&&i.init.callee.property.type===Q.Identifier)return i.init.callee.object.type===Q.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let a={};for(let i of t.varsToCheck)i.selector&&(a[i.selector]=p=>{if(p.type===Q.VariableDeclarator&&p.id.type===Q.Identifier&&r.set(p.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:p.id,fnName:s(p)}),p.type===Q.VariableDeclarator&&p.id.type===Q.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(p.id,l,i.errorMsg,s(p))}});for(let i of t.varsToCheck)if(i.fromFnCall){let p=i.fromFnCall;if(p.startsWith("*.")){let c=`VariableDeclarator > CallExpression > MemberExpression[property.name="${p.slice(2)}"]`;a[c]=d=>{if(d.type!==Q.MemberExpression||d.parent.type!==Q.CallExpression)return;let y=d.parent;if(y.parent.type!==Q.VariableDeclarator)return;let g=y.parent;if(g.id.type===Q.Identifier)r.set(g.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:g.id,fnName:i.fromFnCall||"unknown function"});else if(g.id.type===Q.ObjectPattern){let b=Array.isArray(i.prop)?i.prop:[i.prop];n(g.id,b,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(p.includes(".")){let[l,c]=p.split("."),d=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${c}"]`;a[d]=y=>{if(y.type!==Q.MemberExpression||y.parent.type!==Q.CallExpression)return;let g=y.parent;if(g.parent.type!==Q.VariableDeclarator)return;let b=g.parent;if(b.id.type===Q.Identifier)r.set(b.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:b.id,fnName:i.fromFnCall||"unknown function"});else if(b.id.type===Q.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];n(b.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${p}"]`;a[l]=c=>{if(c.type!==Q.Identifier||c.parent.type!==Q.CallExpression)return;let d=c.parent;if(d.parent.type!==Q.VariableDeclarator)return;let y=d.parent;if(y.id.type===Q.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===Q.ObjectPattern){let g=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,g,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...a,"Program:exit"(){for(let[i,{props:p,errorMsg:l,node:c,fnName:d}]of r){let g=e.sourceCode.getScope(c).set.get(i);if(g){let b=new Set(p);for(let f of g.references){let E=f.identifier,h=E.parent;if(!(h.type===Q.VariableDeclarator&&h.id===E)){if(h.type===Q.MemberExpression&&h.object===E&&h.property.type===Q.Identifier&&b.has(h.property.name)){if(b.delete(h.property.name),b.size===0)break;continue}if(h.type===Q.VariableDeclarator&&h.init===E&&h.id.type===Q.ObjectPattern){for(let m of h.id.properties)m.type===Q.Property&&m.key.type===Q.Identifier&&b.has(m.key.name)&&b.delete(m.key.name);if(b.size===0)break;continue}if(!(h.type===Q.MemberExpression&&h.object===E&&h.property.type===Q.Identifier&&!p.includes(h.property.name))){b.clear();break}}}if(b.size>0){let f=Array.from(b);if(f.length===1)e.report({node:c,messageId:"propNotRead",data:{prop:f[0],fnName:d,customMsg:l||""}});else{let E=f.map(h=>`"${h}"`).join(", ");e.report({node:c,messageId:"propsNotRead",data:{props:E,fnName:d,customMsg:l||""}})}}}}}}}});function Wr(e){return/^use[A-Z0-9]/.test(e)}function yt(e){return e.type==="Identifier"?Wr(e.name):e.type==="MemberExpression"&&!e.computed&&yt(e.property)?e.object.type==="Identifier":!1}function Jr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Vr(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Xr(e){return!!(e.parent&&e.parent.callee&&Vr(e.parent.callee,"forwardRef"))}function Br(e){return!!(e.parent&&e.parent.callee&&Vr(e.parent.callee,"memo"))}function yn(e){for(;e;){let t=Yr(e);if(t&&(Jr(t)||yt(t))||Xr(e)||Br(e))return!0;e=e.parent}return!1}function Ur(e){return!1}function gn(e){return!1}var fa=/eslint +react-compiler\/react-compiler: +\["error/,Hr={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"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(fa.test(l.value))return{CallExpression(c){let d=null;c.callee.name==="useMemo"?d="useMemo":c.callee.name==="useCallback"&&(d="useCallback"),d&&e.report({node:c,message:`"${d}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,s=[],a=[],i=new WeakSet;function p(l){for(let c of l.references){let d=c.identifier.parent;if(d.type==="VariableDeclarator"&&d.init&&d.init.type==="CallExpression"&&d.init.callee&&Ur(d.init.callee))for(let y of c.resolved.references)y!==c&&i.add(y.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(l,c){let d=s.pop();if(d.size===0)return;let y=new Set;function g(o,S){let{cache:u}=g,T=u.get(o.id),w=new Set(S);if(w.has(o.id)){let R=[...w],v=R.slice(R.indexOf(o.id)+1);for(let x of v)y.add(x);return BigInt("0")}if(w.add(o.id),T!==void 0)return T;if(l.thrownSegments.includes(o))T=BigInt("0");else if(o.prevSegments.length===0)T=BigInt("1");else{T=BigInt("0");for(let R of o.prevSegments)T+=g(R,w)}return o.reachable&&T===BigInt("0")?u.delete(o.id):u.set(o.id,T),T}function b(o,S){let{cache:u}=b,T=u.get(o.id),w=new Set(S);if(w.has(o.id)){let R=Array.from(w),v=R.slice(R.indexOf(o.id)+1);for(let x of v)y.add(x);return BigInt("0")}if(w.add(o.id),T!==void 0)return T;if(l.thrownSegments.includes(o))T=BigInt("0");else if(o.nextSegments.length===0)T=BigInt("1");else{T=BigInt("0");for(let R of o.nextSegments)T+=b(R,w)}return u.set(o.id,T),T}function f(o){let{cache:S}=f,u=S.get(o.id);if(u===null)return 1/0;if(u!==void 0)return u;if(S.set(o.id,null),o.prevSegments.length===0)u=1;else{u=1/0;for(let T of o.prevSegments){let w=f(T);w<u&&(u=w)}u+=1}return S.set(o.id,u),u}g.cache=new Map,b.cache=new Map,f.cache=new Map;let E=b(l.initialSegment),h=Yr(c),m=yn(c),A=h?Jr(h)||yt(h):Xr(c)||Br(c),I=1/0;for(let o of l.finalSegments){if(!o.reachable)continue;let S=f(o);S<I&&(I=S)}for(let[o,S]of d){if(!o.reachable)continue;let u=o.nextSegments.length===0?I<=f(o):I<f(o),T=g(o)*b(o),w=y.has(o.id);for(let R of S)if(w&&!gn(R)&&e.report({node:R,message:`React Hook "${t(R)}" 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(c.async&&e.report({node:R,message:`React Hook "${t(R)}" cannot be called in an async function.`}),!w&&T!==E&&!gn(R)){let x=`React Hook "${t(R)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(u?" Did you accidentally call a React Hook after an early return?":"");e.report({node:R,message:x})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let v=`React Hook "${t(R)}" 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:R,message:v})}else if(h){let v=`React Hook "${t(R)}" is called in function "${t(h)}" 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:R,message:v})}else if(c.type==="Program"){let v=`React Hook "${t(R)}" 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:R,message:v})}else if(m&&!gn(R)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let x=c.parent;if(x.parent.type==="VariableDeclarator"&&Wr(x.parent.id.name))return}let v=`React Hook "${t(R)}" 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:R,message:v})}}},CallExpression(l){if(yt(l.callee)){let c=zr(s),d=zr(a),y=c.get(d);y||(y=[],c.set(d,y)),y.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Ur(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` 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"(l){l===n&&(n=null)},FunctionDeclaration(l){yn(l)&&p(r(l))},ArrowFunctionExpression(l){yn(l)&&p(r(l))}}}};function Yr(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 de,AST_TOKEN_TYPES as ma}from"@typescript-eslint/utils";import*as Te from"zod/v4";var da=/^\s+$/,Sn=/\r?\n/,ya=/^(\s*)/,ga=/^(\s*)\S/,Sa=/\r?\n/,Ta=Te.object({indent:Te.union([Te.string().regex(da),Te.number().int().min(1)]).optional(),tags:Te.array(Te.string()).optional(),functions:Te.array(Te.string()).optional(),comments:Te.array(Te.string()).optional()}),Tn=B({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[V(Ta)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:a}=e.options[0],i=r.map(m=>m.toLowerCase());function p(m){let A=m.split(Sn),I=A.filter(S=>S.trim()!=="");if(I.length===0)return m;let o=Number.POSITIVE_INFINITY;for(let S of I){let u=S.match(ya);u&&(o=Math.min(o,u[1]?.length??0))}return!isFinite(o)||o===0?m:A.map(S=>S.slice(o)).join(`
36
+ `)}function l(m,A,I){return m.split(Sn).map(S=>S.trim()===""?S:I.repeat(A)+S).join(`
37
+ `)}function c(m){if(m.type===de.Identifier)return m.name;if(m.type===de.MemberExpression){let A=m.object.type===de.Identifier?m.object.name:null,I=m.property.type===de.Identifier?m.property.name:null;return A&&I?`${A}.${I}`:I}return null}function d(m,A){if(!m)return!1;for(let I of A)if(I.includes(".")){let o=I.split(".");if(m.type===de.MemberExpression&&m.object.type===de.Identifier&&m.property.type===de.Identifier&&m.object.name===o[0]&&m.property.name===o[1])return!0}else if(m.type===de.Identifier&&m.name===I)return!0;return!1}function y(m,A){let I=m.parent;if(I.type!==de.TaggedTemplateExpression)return!1;let o=c(I.tag);return o?A.includes(o):!1}function g(m,A){if(!m||m.type!==de.CallExpression)return!1;let{method:I,argumentsLength:o,optionalCall:S=!0,optionalMember:u=!0}=A;return o!==void 0&&m.arguments.length!==o||!S&&m.optional||m.callee.type!==de.MemberExpression||!u&&m.callee.optional||m.callee.property.type!==de.Identifier?!1:m.callee.property.name===I}function b(m,A){if(!m||m.type!==de.CallExpression)return!1;let{name:I,argumentsLength:o,optionalCall:S=!0}=A;return o!==void 0&&m.arguments.length!==o||!S&&m.optional||m.callee.type!==de.Identifier?!1:m.callee.name===I}function f(m){return g(m.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&m.parent.type===de.CallExpression&&m.parent.arguments[0]===m&&b(m.parent.callee.type===de.MemberExpression?m.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function E(m){if(i.length>0){let A=t.getTokenBefore(m,{includeComments:!0});if(A?.type===ma.Block&&i.includes(A.value.trim().toLowerCase()))return!0}return!!(f(m)||s.length>0&&y(m,s)||n.length>0&&m.parent.type===de.CallExpression&&m.parent.arguments.includes(m)&&d(m.parent.callee,n))}function h(m){let A=`__PLACEHOLDER__${Math.random()}`,I=m.quasis.map(_=>t.getText(_).slice(1,_.tail?-1:-2)).join(A),o=I.match(Sa);if(!o)return;let S=o[0],u=t.lines[t.getLocFromIndex(m.range[0]).line-1];if(!u)return;let w=u.match(ga)?.[1]??"",R;typeof a=="string"?R=a:typeof a=="number"?R=" ".repeat(a):R=w.startsWith(" ")?" ":" ";let x=p(I).replace(new RegExp(`^${S}|${S}[ ]*$`,"g"),""),C=S+l(x,1,w+R)+S+w,F=I.includes(`\r
38
38
  `)?`\r
39
39
  `:`
40
- `,te=C.split(mn),ee=te.map((V,me)=>me!==te.length-1&&V===I+A?"":V).join(Y);if(J!==ee)return{node:m,messageId:"improperlyIndented",fix:V=>J.split(b).map((me,xe)=>{let ce=m.quasis[xe];return ce?V.replaceTextRange([ce.range[0]+1,ce.range[1]-(ce.tail?1:2)],me):[]}).flat()}}return{TemplateLiteral(m){if(!h(m))return;let b=T(m);if(b)return e.report(b)}}}});import{AST_NODE_TYPES as Vr}from"@typescript-eslint/utils";function Ta(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function ha(e){let t=e.parent;return t?.type===Vr.NewExpression&&t.callee.type===Vr.Identifier&&t.callee.name==="RegExp"}var dn=_({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 t(r){Ta(r)||ha(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});import{AST_NODE_TYPES as pe}from"@typescript-eslint/utils";import{z as Ke}from"zod/v4";var Ea=Ke.object({checkOnly:Ke.array(Ke.enum(["function-args","FC","generic-args-at-fn-calls"])).optional(),checkTypesFromSelectors:Ke.array(Ke.string()).optional()}),gn=_({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:[$(Ea)],messages:{moveTypeAboveUsage:"Type definition should be placed directly above its first usage."}},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=new Map,s=[];function o(f){for(let h of s)if(f.range[0]>=h.range[0]&&f.range[1]<=h.range[1])return h;return null}function i(f){let h=f.parent;for(;h;){if(h.type===pe.FunctionDeclaration||h.type===pe.FunctionExpression||h.type===pe.ArrowFunctionExpression){let T=h.params;for(let m of T)if(f.range[0]>=m.range[0]&&f.range[1]<=m.range[1])return!0;break}h=h.parent}return!1}function p(f){let h=f.parent;for(;h;){if(h.type===pe.TSTypeParameterInstantiation){let T=h.parent;if(T.type===pe.TSTypeReference&&T.typeName.type===pe.Identifier&&(T.typeName.name==="FC"||T.typeName.name==="React.FC")||T.type===pe.TSTypeReference&&T.typeName.type===pe.TSQualifiedName&&T.typeName.right.name==="FC")return!0}h=h.parent}return!1}function a(f){let h=f.parent;for(;h;){if(h.type===pe.TSTypeParameterInstantiation){let T=h.parent;if(T.type===pe.CallExpression||T.type===pe.NewExpression)return!0}h=h.parent}return!1}function c(f){let h=f.parent;for(;h;){if(h.type===pe.TSTypeAliasDeclaration||h.type===pe.TSInterfaceDeclaration)return!0;h=h.parent}return!1}function g(f){return f.parent.type===pe.TSIndexedAccessType&&f.parent.objectType===f}let S=[];function l(f){let h=[],T=new Map;for(let{typeName:b,firstUsage:C}of f){let y=T.get(C)||[];y.push(b),T.set(C,y)}for(let{typeName:b,firstUsage:C,firstUsagePosition:y,firstUsageInFunctionArgs:x}of f){let u=n.get(b);if(!u||u.statement===C)continue;let d=s.indexOf(u.statement),A=s.indexOf(C);if(d===-1||A===-1)continue;let I=!!(t.checkOnly&&t.checkOnly.includes("function-args")&&x),v=(T.get(C)||[]).length>1;(I||v?d>A:d>A||d!==A-1)&&h.push({typeName:b,typeDef:u,targetStatement:C,firstUsagePosition:y})}if(h.length===0)return;h.sort((b,C)=>{let y=b.firstUsagePosition-C.firstUsagePosition;if(y!==0)return y;let x=s.indexOf(b.typeDef.statement),u=s.indexOf(C.typeDef.statement);return x-u});let m=h[0];m&&e.report({node:m.typeDef.node,messageId:"moveTypeAboveUsage",fix:E(h)})}function E(f){return function*(h){let T=new Map;for(let m of f){let b=T.get(m.targetStatement)||[];b.push(m),T.set(m.targetStatement,b)}for(let[,m]of T)m.sort((b,C)=>{let y=b.firstUsagePosition-C.firstUsagePosition;if(y!==0)return y;let x=s.indexOf(b.typeDef.statement),u=s.indexOf(C.typeDef.statement);return x-u});for(let m of f){let{typeDef:b}=m,C=b.statement,y=r.getCommentsBefore(C),x=C.range[0],u=C.range[1];y.length>0&&y[0]&&(x=y[0].range[0]),yield h.removeRange([x,u])}for(let[m,b]of T){let C=r.getCommentsBefore(m),y=C.length>0&&C[0]?C[0].range[0]:m.range[0],x=[];for(let u of b){let d=u.typeDef.statement,A=r.getText(d),I=r.getCommentsBefore(d),R=A;I.length>0&&(R=`${I.map(J=>r.getText(J)).join(`
40
+ `,O=I.split(Sn),G=O.map((_,te)=>te!==O.length-1&&_===R+w?"":_).join(F);if(C!==G)return{node:m,messageId:"improperlyIndented",fix:_=>C.split(A).map((te,M)=>{let W=m.quasis[M];return W?_.replaceTextRange([W.range[0]+1,W.range[1]-(W.tail?1:2)],te):[]}).flat()}}return{TemplateLiteral(m){if(!E(m))return;let A=h(m);if(A)return e.report(A)}}}});import{AST_NODE_TYPES as qr}from"@typescript-eslint/utils";function ha(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function Ea(e){let t=e.parent;return t?.type===qr.NewExpression&&t.callee.type===qr.Identifier&&t.callee.name==="RegExp"}var hn=B({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 t(r){ha(r)||Ea(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});import{AST_NODE_TYPES as ye}from"@typescript-eslint/utils";import{z as rt}from"zod/v4";var ba=rt.object({checkOnly:rt.array(rt.enum(["function-args","FC","generic-args-at-fn-calls"])).optional(),checkTypesFromSelectors:rt.array(rt.string()).optional()}),En=B({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:[V(ba)],messages:{moveTypeAboveUsage:"Type definition should be placed directly above its first usage."}},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=new Map,s=[];function a(f){for(let E of s)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===ye.FunctionDeclaration||E.type===ye.FunctionExpression||E.type===ye.ArrowFunctionExpression){let h=E.params;for(let m of h)if(f.range[0]>=m.range[0]&&f.range[1]<=m.range[1])return!0;break}E=E.parent}return!1}function p(f){let E=f.parent;for(;E;){if(E.type===ye.TSTypeParameterInstantiation){let h=E.parent;if(h.type===ye.TSTypeReference&&h.typeName.type===ye.Identifier&&(h.typeName.name==="FC"||h.typeName.name==="React.FC")||h.type===ye.TSTypeReference&&h.typeName.type===ye.TSQualifiedName&&h.typeName.right.name==="FC")return!0}E=E.parent}return!1}function l(f){let E=f.parent;for(;E;){if(E.type===ye.TSTypeParameterInstantiation){let h=E.parent;if(h.type===ye.CallExpression||h.type===ye.NewExpression)return!0}E=E.parent}return!1}function c(f){let E=f.parent;for(;E;){if(E.type===ye.TSTypeAliasDeclaration||E.type===ye.TSInterfaceDeclaration)return!0;E=E.parent}return!1}function d(f){return f.parent.type===ye.TSIndexedAccessType&&f.parent.objectType===f}let y=[];function g(f){let E=[],h=new Map;for(let{typeName:A,firstUsage:I}of f){let o=h.get(I)||[];o.push(A),h.set(I,o)}for(let{typeName:A,firstUsage:I,firstUsagePosition:o,firstUsageInFunctionArgs:S}of f){let u=n.get(A);if(!u||u.statement===I)continue;let T=s.indexOf(u.statement),w=s.indexOf(I);if(T===-1||w===-1)continue;let R=!!(t.checkOnly&&t.checkOnly.includes("function-args")&&S),x=(h.get(I)||[]).length>1;(R||x?T>w:T>w||T!==w-1)&&E.push({typeName:A,typeDef:u,targetStatement:I,firstUsagePosition:o})}if(E.length===0)return;E.sort((A,I)=>{let o=A.firstUsagePosition-I.firstUsagePosition;if(o!==0)return o;let S=s.indexOf(A.typeDef.statement),u=s.indexOf(I.typeDef.statement);return S-u});let m=E[0];m&&e.report({node:m.typeDef.node,messageId:"moveTypeAboveUsage",fix:b(E)})}function b(f){return function*(E){let h=new Map;for(let m of f){let A=h.get(m.targetStatement)||[];A.push(m),h.set(m.targetStatement,A)}for(let[,m]of h)m.sort((A,I)=>{let o=A.firstUsagePosition-I.firstUsagePosition;if(o!==0)return o;let S=s.indexOf(A.typeDef.statement),u=s.indexOf(I.typeDef.statement);return S-u});for(let m of f){let{typeDef:A}=m,I=A.statement,o=r.getCommentsBefore(I),S=I.range[0],u=I.range[1];o.length>0&&o[0]&&(S=o[0].range[0]),yield E.removeRange([S,u])}for(let[m,A]of h){let I=r.getCommentsBefore(m),o=I.length>0&&I[0]?I[0].range[0]:m.range[0],S=[];for(let u of A){let T=u.typeDef.statement,w=r.getText(T),R=r.getCommentsBefore(T),v=w;R.length>0&&(v=`${R.map(C=>r.getText(C)).join(`
41
41
  `)}
42
- ${A}`),x.push(R)}yield h.insertTextBeforeRange([y,y],`${x.join(`
42
+ ${w}`),S.push(v)}yield E.insertTextBeforeRange([o,o],`${S.join(`
43
43
 
44
44
  `)}
45
45
 
46
- `)}}}return{Program(f){s.push(...f.body)},TSTypeAliasDeclaration(f){if(s.some(T=>T.type===pe.ExportNamedDeclaration&&T.declaration===f?!0:T===f)){let T=o(f);T&&n.set(f.id.name,{node:f,name:f.id.name,statement:T})}},TSInterfaceDeclaration(f){if(s.some(T=>T.type===pe.ExportNamedDeclaration&&T.declaration===f?!0:T===f)){let T=o(f);T&&n.set(f.id.name,{node:f,name:f.id.name,statement:T})}},TSTypeReference(f){if(f.typeName.type===pe.Identifier){if(g(f))return;let h=i(f),T=p(f),m=a(f);S.push({typeName:f.typeName.name,node:f,inFunctionArgs:h,inFCProps:T,inGenericArgAtFunctionCall:m,usagePosition:f.range[0]})}},"Program:exit"(){let f=new Map;function h(m){if(!t.checkOnly||t.checkOnly.length===0)return!0;for(let b of t.checkOnly)if(b==="function-args"&&m.inFunctionArgs||b==="FC"&&m.inFCProps||b==="generic-args-at-fn-calls"&&m.inGenericArgAtFunctionCall)return!0;return!1}for(let m of S){let{typeName:b,node:C}=m;if(!n.has(b)||!h(m))continue;let y=o(C),x=n.get(b);if(!y||!x||y===x.statement)continue;f.has(b)||f.set(b,[]);let u=f.get(b);if(!u)return;u.includes(y)||u.push(y)}let T=[];for(let[m,b]of f)if(b.length>0){if(b.length===0)continue;let C=b[0];if(!C)continue;let y=Number.MAX_SAFE_INTEGER,x=!1;for(let d of b)d.range[0]<C.range[0]&&(C=d);for(let d of S)h(d)&&d.typeName===m&&o(d.node)===C&&d.usagePosition<y&&(y=d.usagePosition,x=d.inFunctionArgs);if(!!(t.checkOnly&&t.checkOnly.length>0)){let d=Number.MAX_SAFE_INTEGER;for(let I of S){if(I.typeName!==m)continue;let R=o(I.node);if(!R)continue;let v=s.indexOf(R);v!==-1&&v<d&&(d=v)}let A=s.indexOf(C);if(d!==Number.MAX_SAFE_INTEGER&&A!==-1&&d<A)continue}else{let d=Number.MAX_SAFE_INTEGER;for(let I of S){if(I.typeName!==m||c(I.node))continue;let R=o(I.node);if(!R)continue;let v=s.indexOf(R);v!==-1&&v<d&&(d=v)}let A=s.indexOf(C);if(d!==Number.MAX_SAFE_INTEGER&&A!==-1&&d<A)continue}T.push({typeName:m,firstUsage:C,firstUsagePosition:y,firstUsageInFunctionArgs:x})}T.length>0&&l(T)}}}});import{AST_NODE_TYPES as B}from"@typescript-eslint/utils";import*as Je from"zod/v4";var ba=["tsx"],xa=/^[A-Z][A-Za-z0-9]*$/,Ca=Je.object({extensions:Je.array(Je.string()).optional()}),Sn=_({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:[$(Ca)]},defaultOptions:[{}],create(e,[t]){let r=e.getFilename(),n=t.extensions??ba,s=!1;for(let y of n)if(r.endsWith(y)){s=!0;break}if(!s)return{};let o=e.sourceCode,i=new Set,p=new Map;function a(y){return xa.test(y)}function c(y){if(y.type!==B.CallExpression)return!1;let x=y.callee;return x.type===B.Identifier?x.name==="memo"||x.name==="forwardRef":x.type===B.MemberExpression&&x.property.type===B.Identifier?x.property.name==="memo"||x.property.name==="forwardRef":!1}function g(y){if(y.type===B.JSXElement||y.type===B.JSXFragment)return!0;if(y.type===B.ArrayExpression){for(let x of y.elements)if(x&&(x.type===B.JSXElement||x.type===B.JSXFragment))return!0}return!1}function S(y){if(y.type!==B.ArrowFunctionExpression)return!1;let x=y.body;if(x.type===B.ArrowFunctionExpression){let u=x.body;if(g(u))return!0}return!1}function l(y){if(y.id.type!==B.Identifier)return;let x=y.id.name,u=y.init;if(u){if(a(x)&&(u.type===B.ArrowFunctionExpression||u.type===B.FunctionExpression||c(u))){i.add(x);return}u.type===B.Identifier&&p.set(x,u.name),a(x)||S(u)&&i.add(x)}}function E(y){if(y.type===B.VariableDeclaration){for(let x of y.declarations)l(x);return}if(y.type===B.FunctionDeclaration&&y.id){a(y.id.name)&&i.add(y.id.name);return}if(y.type===B.ExportNamedDeclaration&&y.declaration){let x=y.declaration;if(x.type===B.VariableDeclaration){for(let u of x.declarations)l(u);return}if(x.type===B.FunctionDeclaration&&x.id){a(x.id.name)&&i.add(x.id.name);return}}}for(let y of o.ast.body)E(y);function f(y,x=new Set){if(i.has(y))return!0;if(x.has(y))return!1;x.add(y);let u=p.get(y);return u?f(u,x):!1}let h=[];function T(y,x,u){h.push({node:y,isType:x,isComponent:u})}for(let y of o.ast.body){if(y.type===B.ExportNamedDeclaration){let x=y.exportKind==="type";if(y.declaration){let u=y.declaration;if(u.type===B.TSTypeAliasDeclaration||u.type===B.TSInterfaceDeclaration){T(u,!0,!1);continue}if(u.type===B.VariableDeclaration){for(let d of u.declarations){if(d.id.type!==B.Identifier)continue;let A=d.id.name,I=f(A);T(d,x,I)}continue}if(u.type===B.FunctionDeclaration){let d=u.id?.name,A=d?f(d)||a(d):!1;T(u,x,A);continue}T(u,x,!1);continue}if(y.specifiers.length>0)for(let u of y.specifiers){if(u.local.type!==B.Identifier)continue;let d=u.local.name,A=f(d);T(u,x,A)}continue}if(y.type===B.ExportDefaultDeclaration){let x=y.declaration;if(x.type===B.Identifier){let u=f(x.name)||a(x.name);T(y,!1,u);continue}if(x.type===B.FunctionDeclaration||x.type===B.ArrowFunctionExpression||x.type===B.FunctionExpression||x.type===B.CallExpression){T(y,!1,!0);continue}T(y,!1,!1);continue}}let m=!1;for(let y of h)if(!y.isType&&y.isComponent){m=!0;break}if(!m)return{};let b=[];for(let y of h)y.isType||b.push(y);let C=-1;for(let[y,x]of b.entries())if(x.isComponent){C=y;break}if(C===-1)return{};for(let[y,x]of b.entries())if(y!==C){e.report({node:x.node,messageId:"multipleExports"});break}return{}}});import{AST_NODE_TYPES as je}from"@typescript-eslint/utils";import{z as Tn}from"zod/v4";function ft(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Aa(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 Ia=Tn.object({ignorePrefixes:Tn.array(Tn.string()).optional()});function Xr(e,t){for(let r of t)if(e.startsWith(r))return e.slice(r.length);return e}function wa(e){return`set${ft(e)}`}var hn=_({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:[$(Ia)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[t]){return{VariableDeclarator(r){if(!r.init||r.init.type!==je.CallExpression||!Aa(r.init)||r.id.type!==je.ArrayPattern||r.id.elements.length!==2)return;let[n,s]=r.id.elements;if(!n||!s||n.type!==je.Identifier||s.type!==je.Identifier)return;let o=n.name,i=s.name,p=t.ignorePrefixes||[],a=Xr(o,p),c=Xr(i,p);if(a===""){if(!c.startsWith("set")){let S=`set${ft(o)}`;e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:ft(o),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:S},fix:l=>l.replaceText(s,S)}]})}return}let g=wa(a);c!==g&&e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:ft(a),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:g},fix:S=>S.replaceText(s,g)}]})}}}});import{AST_NODE_TYPES as se}from"@typescript-eslint/utils";import{z as Ve}from"zod/v4";var Ra=Ve.object({name:Ve.string(),defaults:Ve.array(Ve.unknown())}),Pa=Ve.object({functions:Ve.array(Ra)});function mt(e,t){if(e===t)return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object"||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,o)=>mt(s,t[o]));let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s of r){if(!n.includes(s))return!1;let o=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(t,s);if(!o||!i)return!1;let p=o.value,a=i.value;if(!mt(p,a))return!1}return!0}function va(e,t){let r=new Set;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return r;for(let n in e){if(!(n in t))continue;let s=Object.getOwnPropertyDescriptor(e,n),o=Object.getOwnPropertyDescriptor(t,n);s&&o&&mt(s.value,o.value)&&r.add(n)}return r}function Hr(e){if(e.type===se.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case se.Literal:return e.value;case se.ObjectExpression:{let t={};for(let r of e.properties)r.type===se.Property&&r.key.type===se.Identifier&&!r.computed&&(r.value.type===se.Literal?t[r.key.name]=r.value.value:r.value.type===se.ObjectExpression?t[r.key.name]=Hr(r.value):t[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return t}case se.ArrayExpression:return e.elements.map(t=>{if(!(!t||t.type===se.SpreadElement))return t.type===se.Literal?t.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function Fa(e){return e.type===se.Identifier?e.name:e.type===se.MemberExpression&&e.property.type===se.Identifier&&!e.computed?e.property.name:null}var En=_({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:[$(Pa)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map;for(let n of t.functions)r.set(n.name,n.defaults);return{CallExpression(n){let s=Fa(n.callee);if(!s)return;let o=r.get(s);if(!o)return;let i=n.arguments;if(i.length===0)return;let p=-1,a=!1,c=new Map,g=new Set,S=new Map,l=[];for(let f=0;f<i.length;f++){if(f>=o.length){p=f;continue}let h=o[f],T=i[f];if(!T||T.type===se.SpreadElement){p=f;continue}let m=Hr(T);if(h===void 0){p=f;continue}if(mt(m,h)){T.type===se.ObjectExpression?(g.add(f),l.push({type:"object",position:f+1})):(S.set(f,m),l.push({type:"simple",position:f+1,value:m}));continue}if(T.type===se.ObjectExpression&&T.properties.length===0&&typeof h=="object"&&h!==null&&Object.keys(h).length>0){g.add(f),l.push({type:"object",position:f+1});continue}let b=va(m,h);if(b.size>0){let C=typeof h=="object"&&h!==null?Object.keys(h).length:0;if(T.type===se.ObjectExpression&&T.properties.length===b.size&&T.properties.length===C){g.add(f),l.push({type:"object",position:f+1});continue}else a=!0,c.set(f,b),l.push({type:"partialObject",position:f+1,redundantProperties:Array.from(b)}),p=f}else p=f}if(p<i.length-1||a||g.size>0){let f=function(){let T=[];for(let m of l)if(m.type==="simple")T.push(`Param ${m.position} with value ${JSON.stringify(m.value)}`);else if(m.type==="object")T.push(`Param ${m.position} (object)`);else{let b=m.redundantProperties||[],C=o?o[m.position-1]:void 0;if(typeof C=="object"&&C!==null){let y=C;for(let x of b)if(x in y){let u=Object.getOwnPropertyDescriptor(y,x);u&&T.push(`Param ${m.position} property "${x}" with value ${JSON.stringify(u.value)}`)}}}return{messageId:"redundantParams",data:{details:T.join(", ")}}};var E=f;let h=f();e.report({node:n,messageId:h.messageId,data:h.data,fix(T){let m=[];if(a)for(let[C,y]of c){let x=i[C];if(x&&x.type===se.ObjectExpression){let u=[];for(let A of x.properties)A.type===se.Property&&A.key.type===se.Identifier&&!A.computed&&y.has(A.key.name)||u.push(A);let d=u.map(A=>e.sourceCode.getText(A));m.push(T.replaceText(x,`{ ${d.join(", ")} }`))}}let b=-1;for(let C=i.length-1;C>=0;C--)if(!g.has(C)&&C<=p){b=C;break}if(b<i.length-1)if(b===-1){let C=e.sourceCode.getTokenAfter(n.callee),y=e.sourceCode.getLastToken(n);C&&y&&m.push(T.replaceTextRange([C.range[1],y.range[0]],""))}else{let C=i[b],y=e.sourceCode.getLastToken(n);y&&C&&m.push(T.replaceTextRange([C.range[1],y.range[0]],""))}return m.length>0?m:null}})}}}}});import{AST_NODE_TYPES as he}from"@typescript-eslint/utils";function ka(e){let t=e.parent;for(;t;){if(t.type===he.AwaitExpression||t.type===he.MemberExpression&&t.object===e&&t.property.type===he.Identifier&&t.property.name==="then"||t.type===he.ArrowFunctionExpression&&t.body===e)return!0;if(t.type===he.ArrayExpression&&t.parent.type===he.CallExpression){let r=t.parent;if(r.callee.type===he.MemberExpression&&r.callee.object.type===he.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===he.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(t.parent)t=t.parent;else break}return!1}function Oa(e){let{callee:t}=e;return t.type===he.Identifier&&t.name==="require"||t.type===he.MemberExpression&&t.object.type===he.Identifier&&t.object.name==="require"}var bn=_({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(t){ka(t)||e.report({node:t,messageId:"syncDynamicImport"})},TSImportType(t){e.report({node:t,messageId:"syncDynamicImport"})},CallExpression(t){Oa(t)&&e.report({node:t,messageId:"requireNotAllowed"})}}}});import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";import{z as Br}from"zod/v4";var Na=Br.object({mainComponentRegex:Br.string().optional()}),Da=/^[A-Z][A-Za-z0-9]*$/,xn=_({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:[$(Na)],messages:{stylesShouldBeAboveUsage:"Style definitions should be placed above the first component that uses them"}},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.mainComponentRegex?new RegExp(t.mainComponentRegex):void 0,s=new Set,o=new Map,i=[],p=[];function a(u){return Da.test(u)}function c(u){if(u.type!==L.CallExpression)return!1;let d=u.callee;return d.type===L.Identifier?d.name==="memo"||d.name==="forwardRef":d.type===L.MemberExpression&&d.property.type===L.Identifier?d.property.name==="memo"||d.property.name==="forwardRef":!1}function g(u){if(u.type===L.JSXElement||u.type===L.JSXFragment)return!0;if(u.type===L.BlockStatement){for(let d of u.body)if(d.type===L.ReturnStatement&&d.argument)return g(d.argument)}if(u.type===L.ArrayExpression){for(let d of u.elements)if(d&&(d.type===L.JSXElement||d.type===L.JSXFragment))return!0}return!1}function S(u){if(u.type!==L.ArrowFunctionExpression)return!1;let d=u.body;if(d.type===L.ArrowFunctionExpression){let A=d.body;if(g(A))return!0}return!1}function l(u){if(u.type===L.TaggedTemplateExpression){let d=u.tag;if(d.type===L.MemberExpression&&d.object.type===L.Identifier&&d.object.name==="styled")return!0;if(d.type===L.CallExpression){let A=d.callee;if(A.type===L.Identifier&&A.name==="styled")return!0}}return!1}function E(u){if(u.type===L.TaggedTemplateExpression){let d=u.tag;if(d.type===L.Identifier&&d.name==="css")return!0}return!1}function f(u,d){if(u.id.type!==L.Identifier)return;let A=u.id.name,I=u.init;if(I){if(l(I)||E(I)){p.push({node:d,name:A});return}if((a(A)||I.type===L.ArrowFunctionExpression)&&(I.type===L.ArrowFunctionExpression||I.type===L.FunctionExpression||c(I))){if(I.type===L.ArrowFunctionExpression||I.type===L.FunctionExpression){if(g(I.body)){s.add(A);return}}else if(c(I)){s.add(A);return}}I.type===L.Identifier&&o.set(A,I.name),a(A)||S(I)&&s.add(A)}}function h(u){return u.type===L.ExportDefaultDeclaration||u.type===L.ExportNamedDeclaration}function T(u){if(u.type===L.FunctionDeclaration)return u.id?u.id.name:null;if(u.type===L.VariableDeclaration){let d=u.declarations[0];if(d&&d.id.type===L.Identifier)return d.id.name}if(u.type===L.ExportDefaultDeclaration){let d=u.declaration;if(d.type===L.FunctionDeclaration)return d.id?d.id.name:"default";if(d.type===L.Identifier)return d.name}if(u.type===L.ExportNamedDeclaration){let d=u.declaration;if(d&&d.type===L.FunctionDeclaration)return d.id?d.id.name:null;if(d&&d.type===L.VariableDeclaration){let A=d.declarations[0];if(A&&A.id.type===L.Identifier)return A.id.name}}return null}function m(u,d){return n?n.test(d):h(u)}function b(u){let d=new Set;Ae(u.node,A=>{if(A.type===L.Identifier)for(let I of p)I.name===A.name&&(d.add(I.name),(I.firstUsagePosition===void 0||A.range[0]<I.firstUsagePosition)&&(I.firstUsagePosition=A.range[0]));if(A.type===L.JSXElement){let I=A.openingElement;if(I.name.type===L.JSXIdentifier)for(let R of p)R.name===I.name.name&&(d.add(R.name),(R.firstUsagePosition===void 0||I.name.range[0]<R.firstUsagePosition)&&(R.firstUsagePosition=I.name.range[0]))}return!1},r),u.usedStyles=d}function C(u){if(u.type===L.VariableDeclaration){for(let d of u.declarations)f(d,u);return}if(u.type===L.FunctionDeclaration){u.id&&a(u.id.name)&&g(u.body)&&s.add(u.id.name);return}if(u.type===L.ExportNamedDeclaration&&u.declaration){let d=u.declaration;if(d.type===L.VariableDeclaration){for(let A of d.declarations)f(A,u);return}if(d.type===L.FunctionDeclaration&&d.id){a(d.id.name)&&g(d.body)&&s.add(d.id.name);return}}if(u.type===L.ExportDefaultDeclaration){let d=u.declaration;d.type===L.Identifier&&s.add(d.name),(d.type===L.FunctionDeclaration||d.type===L.ArrowFunctionExpression||d.type===L.FunctionExpression)&&(d.type===L.FunctionDeclaration?d.id?s.add(d.id.name):s.add("default"):g(d.body)&&s.add("default"))}}function y(u,d=new Set){if(s.has(u))return!0;if(d.has(u))return!1;d.add(u);let A=o.get(u);return A?y(A,d):!1}return{Program(u){for(let A of u.body)C(A);for(let A of u.body){let I=T(A);if(I&&y(I)){let R=m(A,I);i.push({node:A,name:I,isMainComponent:R,usedStyles:new Set})}}for(let A of i)b(A);let d=[];for(let A of p){if(A.firstUsagePosition===void 0)continue;let I=u.body.indexOf(A.node),R=-1;for(let ee of i){if(!ee.usedStyles.has(A.name))continue;let V=u.body.indexOf(ee.node);(R===-1||V<R)&&(R=V)}if(R===-1)continue;let v=-1;for(let ee of i){let V=u.body.indexOf(ee.node);V<R&&V>v&&(v=V)}let J=I<R,Y=I>v;J&&Y||d.push({style:A,targetPosition:R})}if(d.length>0){let A=d[0];A&&e.report({node:A.style.node,messageId:"stylesShouldBeAboveUsage",fix:x(d,u.body)})}}};function x(u,d){return function*(A){u.sort((R,v)=>R.targetPosition-v.targetPosition);for(let{style:R}of u){let v=r.getCommentsBefore(R.node),J=R.node.range[0],Y=R.node.range[1];v.length>0&&v[0]&&(J=v[0].range[0]),J===R.node.range[0]&&r.text.slice(0,J).trim().length===0&&(J=0),yield A.removeRange([J,Y])}let I=new Map;for(let R of u){let v=I.get(R.targetPosition)||[];v.push(R),I.set(R.targetPosition,v)}for(let[R,v]of I){let J=d[R];if(!J)continue;let Y=r.getCommentsBefore(J),te=Y.length>0&&Y[0]?Y[0].range[0]:J.range[0],ee=[];for(let{style:V}of v){let me=r.getCommentsBefore(V.node),xe=r.getText(V.node);me.length>0&&(xe=`${me.map(Ce=>r.getText(Ce)).join(`
46
+ `)}}}return{Program(f){s.push(...f.body)},TSTypeAliasDeclaration(f){if(s.some(h=>h.type===ye.ExportNamedDeclaration&&h.declaration===f?!0:h===f)){let h=a(f);h&&n.set(f.id.name,{node:f,name:f.id.name,statement:h})}},TSInterfaceDeclaration(f){if(s.some(h=>h.type===ye.ExportNamedDeclaration&&h.declaration===f?!0:h===f)){let h=a(f);h&&n.set(f.id.name,{node:f,name:f.id.name,statement:h})}},TSTypeReference(f){if(f.typeName.type===ye.Identifier){if(d(f))return;let E=i(f),h=p(f),m=l(f);y.push({typeName:f.typeName.name,node:f,inFunctionArgs:E,inFCProps:h,inGenericArgAtFunctionCall:m,usagePosition:f.range[0]})}},"Program:exit"(){let f=new Map;function E(m){if(!t.checkOnly||t.checkOnly.length===0)return!0;for(let A of t.checkOnly)if(A==="function-args"&&m.inFunctionArgs||A==="FC"&&m.inFCProps||A==="generic-args-at-fn-calls"&&m.inGenericArgAtFunctionCall)return!0;return!1}for(let m of y){let{typeName:A,node:I}=m;if(!n.has(A)||!E(m))continue;let o=a(I),S=n.get(A);if(!o||!S||o===S.statement)continue;f.has(A)||f.set(A,[]);let u=f.get(A);if(!u)return;u.includes(o)||u.push(o)}let h=[];for(let[m,A]of f)if(A.length>0){if(A.length===0)continue;let I=A[0];if(!I)continue;let o=Number.MAX_SAFE_INTEGER,S=!1;for(let T of A)T.range[0]<I.range[0]&&(I=T);for(let T of y)E(T)&&T.typeName===m&&a(T.node)===I&&T.usagePosition<o&&(o=T.usagePosition,S=T.inFunctionArgs);if(!!(t.checkOnly&&t.checkOnly.length>0)){let T=Number.MAX_SAFE_INTEGER;for(let R of y){if(R.typeName!==m)continue;let v=a(R.node);if(!v)continue;let x=s.indexOf(v);x!==-1&&x<T&&(T=x)}let w=s.indexOf(I);if(T!==Number.MAX_SAFE_INTEGER&&w!==-1&&T<w)continue}else{let T=Number.MAX_SAFE_INTEGER;for(let R of y){if(R.typeName!==m||c(R.node))continue;let v=a(R.node);if(!v)continue;let x=s.indexOf(v);x!==-1&&x<T&&(T=x)}let w=s.indexOf(I);if(T!==Number.MAX_SAFE_INTEGER&&w!==-1&&T<w)continue}h.push({typeName:m,firstUsage:I,firstUsagePosition:o,firstUsageInFunctionArgs:S})}h.length>0&&g(h)}}}});import{AST_NODE_TYPES as ee}from"@typescript-eslint/utils";import*as Ye from"zod/v4";var xa=["tsx"],Ca=/^[A-Z][A-Za-z0-9]*$/,Ia=Ye.object({extensions:Ye.array(Ye.string()).optional()}),bn=B({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:[V(Ia)]},defaultOptions:[{}],create(e,[t]){let r=e.getFilename(),n=t.extensions??xa,s=!1;for(let o of n)if(r.endsWith(o)){s=!0;break}if(!s)return{};let a=e.sourceCode,i=new Set,p=new Map;function l(o){return Ca.test(o)}function c(o){if(o.type!==ee.CallExpression)return!1;let S=o.callee;return S.type===ee.Identifier?S.name==="memo"||S.name==="forwardRef":S.type===ee.MemberExpression&&S.property.type===ee.Identifier?S.property.name==="memo"||S.property.name==="forwardRef":!1}function d(o){if(o.type===ee.JSXElement||o.type===ee.JSXFragment)return!0;if(o.type===ee.ArrayExpression){for(let S of o.elements)if(S&&(S.type===ee.JSXElement||S.type===ee.JSXFragment))return!0}return!1}function y(o){if(o.type!==ee.ArrowFunctionExpression)return!1;let S=o.body;if(S.type===ee.ArrowFunctionExpression){let u=S.body;if(d(u))return!0}return!1}function g(o){if(o.id.type!==ee.Identifier)return;let S=o.id.name,u=o.init;if(u){if(l(S)&&(u.type===ee.ArrowFunctionExpression||u.type===ee.FunctionExpression||c(u))){i.add(S);return}u.type===ee.Identifier&&p.set(S,u.name),l(S)||y(u)&&i.add(S)}}function b(o){if(o.type===ee.VariableDeclaration){for(let S of o.declarations)g(S);return}if(o.type===ee.FunctionDeclaration&&o.id){l(o.id.name)&&i.add(o.id.name);return}if(o.type===ee.ExportNamedDeclaration&&o.declaration){let S=o.declaration;if(S.type===ee.VariableDeclaration){for(let u of S.declarations)g(u);return}if(S.type===ee.FunctionDeclaration&&S.id){l(S.id.name)&&i.add(S.id.name);return}}}for(let o of a.ast.body)b(o);function f(o,S=new Set){if(i.has(o))return!0;if(S.has(o))return!1;S.add(o);let u=p.get(o);return u?f(u,S):!1}let E=[];function h(o,S,u){E.push({node:o,isType:S,isComponent:u})}for(let o of a.ast.body){if(o.type===ee.ExportNamedDeclaration){let S=o.exportKind==="type";if(o.declaration){let u=o.declaration;if(u.type===ee.TSTypeAliasDeclaration||u.type===ee.TSInterfaceDeclaration){h(u,!0,!1);continue}if(u.type===ee.VariableDeclaration){for(let T of u.declarations){if(T.id.type!==ee.Identifier)continue;let w=T.id.name,R=f(w);h(T,S,R)}continue}if(u.type===ee.FunctionDeclaration){let T=u.id?.name,w=T?f(T)||l(T):!1;h(u,S,w);continue}h(u,S,!1);continue}if(o.specifiers.length>0)for(let u of o.specifiers){if(u.local.type!==ee.Identifier)continue;let T=u.local.name,w=f(T);h(u,S,w)}continue}if(o.type===ee.ExportDefaultDeclaration){let S=o.declaration;if(S.type===ee.Identifier){let u=f(S.name)||l(S.name);h(o,!1,u);continue}if(S.type===ee.FunctionDeclaration||S.type===ee.ArrowFunctionExpression||S.type===ee.FunctionExpression||S.type===ee.CallExpression){h(o,!1,!0);continue}h(o,!1,!1);continue}}let m=!1;for(let o of E)if(!o.isType&&o.isComponent){m=!0;break}if(!m)return{};let A=[];for(let o of E)o.isType||A.push(o);let I=-1;for(let[o,S]of A.entries())if(S.isComponent){I=o;break}if(I===-1)return{};for(let[o,S]of A.entries())if(o!==I){e.report({node:S.node,messageId:"multipleExports"});break}return{}}});import{AST_NODE_TYPES as ze}from"@typescript-eslint/utils";import{z as xn}from"zod/v4";function gt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Aa(e){return e.callee.type===ze.Identifier?e.callee.name==="useState":e.callee.type===ze.MemberExpression&&e.callee.object.type===ze.Identifier&&e.callee.property.type===ze.Identifier?e.callee.object.name==="React"&&e.callee.property.name==="useState":!1}var wa=xn.object({ignorePrefixes:xn.array(xn.string()).optional()});function Zr(e,t){for(let r of t)if(e.startsWith(r))return e.slice(r.length);return e}function Ra(e){return`set${gt(e)}`}var Cn=B({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:[V(wa)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[t]){return{VariableDeclarator(r){if(!r.init||r.init.type!==ze.CallExpression||!Aa(r.init)||r.id.type!==ze.ArrayPattern||r.id.elements.length!==2)return;let[n,s]=r.id.elements;if(!n||!s||n.type!==ze.Identifier||s.type!==ze.Identifier)return;let a=n.name,i=s.name,p=t.ignorePrefixes||[],l=Zr(a,p),c=Zr(i,p);if(l===""){if(!c.startsWith("set")){let y=`set${gt(a)}`;e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(a),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:y},fix:g=>g.replaceText(s,y)}]})}return}let d=Ra(l);c!==d&&e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(l),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:d},fix:y=>y.replaceText(s,d)}]})}}}});import{AST_NODE_TYPES as me}from"@typescript-eslint/utils";import{z as qe}from"zod/v4";var Pa=qe.object({name:qe.string(),defaults:qe.array(qe.unknown())}),va=qe.object({functions:qe.array(Pa)});function St(e,t){if(e===t)return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object"||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>St(s,t[a]));let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s of r){if(!n.includes(s))return!1;let a=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(t,s);if(!a||!i)return!1;let p=a.value,l=i.value;if(!St(p,l))return!1}return!0}function Fa(e,t){let r=new Set;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return r;for(let n in e){if(!(n in t))continue;let s=Object.getOwnPropertyDescriptor(e,n),a=Object.getOwnPropertyDescriptor(t,n);s&&a&&St(s.value,a.value)&&r.add(n)}return r}function Gr(e){if(e.type===me.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case me.Literal:return e.value;case me.ObjectExpression:{let t={};for(let r of e.properties)r.type===me.Property&&r.key.type===me.Identifier&&!r.computed&&(r.value.type===me.Literal?t[r.key.name]=r.value.value:r.value.type===me.ObjectExpression?t[r.key.name]=Gr(r.value):t[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return t}case me.ArrayExpression:return e.elements.map(t=>{if(!(!t||t.type===me.SpreadElement))return t.type===me.Literal?t.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function ka(e){return e.type===me.Identifier?e.name:e.type===me.MemberExpression&&e.property.type===me.Identifier&&!e.computed?e.property.name:null}var In=B({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:[V(va)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map;for(let n of t.functions)r.set(n.name,n.defaults);return{CallExpression(n){let s=ka(n.callee);if(!s)return;let a=r.get(s);if(!a)return;let i=n.arguments;if(i.length===0)return;let p=-1,l=!1,c=new Map,d=new Set,y=new Map,g=[];for(let f=0;f<i.length;f++){if(f>=a.length){p=f;continue}let E=a[f],h=i[f];if(!h||h.type===me.SpreadElement){p=f;continue}let m=Gr(h);if(E===void 0){p=f;continue}if(St(m,E)){h.type===me.ObjectExpression?(d.add(f),g.push({type:"object",position:f+1})):(y.set(f,m),g.push({type:"simple",position:f+1,value:m}));continue}if(h.type===me.ObjectExpression&&h.properties.length===0&&typeof E=="object"&&E!==null&&Object.keys(E).length>0){d.add(f),g.push({type:"object",position:f+1});continue}let A=Fa(m,E);if(A.size>0){let I=typeof E=="object"&&E!==null?Object.keys(E).length:0;if(h.type===me.ObjectExpression&&h.properties.length===A.size&&h.properties.length===I){d.add(f),g.push({type:"object",position:f+1});continue}else l=!0,c.set(f,A),g.push({type:"partialObject",position:f+1,redundantProperties:Array.from(A)}),p=f}else p=f}if(p<i.length-1||l||d.size>0){let f=function(){let h=[];for(let m of g)if(m.type==="simple")h.push(`Param ${m.position} with value ${JSON.stringify(m.value)}`);else if(m.type==="object")h.push(`Param ${m.position} (object)`);else{let A=m.redundantProperties||[],I=a?a[m.position-1]:void 0;if(typeof I=="object"&&I!==null){let o=I;for(let S of A)if(S in o){let u=Object.getOwnPropertyDescriptor(o,S);u&&h.push(`Param ${m.position} property "${S}" with value ${JSON.stringify(u.value)}`)}}}return{messageId:"redundantParams",data:{details:h.join(", ")}}};var b=f;let E=f();e.report({node:n,messageId:E.messageId,data:E.data,fix(h){let m=[];if(l)for(let[I,o]of c){let S=i[I];if(S&&S.type===me.ObjectExpression){let u=[];for(let w of S.properties)w.type===me.Property&&w.key.type===me.Identifier&&!w.computed&&o.has(w.key.name)||u.push(w);let T=u.map(w=>e.sourceCode.getText(w));m.push(h.replaceText(S,`{ ${T.join(", ")} }`))}}let A=-1;for(let I=i.length-1;I>=0;I--)if(!d.has(I)&&I<=p){A=I;break}if(A<i.length-1)if(A===-1){let I=e.sourceCode.getTokenAfter(n.callee),o=e.sourceCode.getLastToken(n);I&&o&&m.push(h.replaceTextRange([I.range[1],o.range[0]],""))}else{let I=i[A],o=e.sourceCode.getLastToken(n);o&&I&&m.push(h.replaceTextRange([I.range[1],o.range[0]],""))}return m.length>0?m:null}})}}}}});import{AST_NODE_TYPES as Pe}from"@typescript-eslint/utils";function Oa(e){let t=e.parent;for(;t;){if(t.type===Pe.AwaitExpression||t.type===Pe.MemberExpression&&t.object===e&&t.property.type===Pe.Identifier&&t.property.name==="then"||t.type===Pe.ArrowFunctionExpression&&t.body===e)return!0;if(t.type===Pe.ArrayExpression&&t.parent.type===Pe.CallExpression){let r=t.parent;if(r.callee.type===Pe.MemberExpression&&r.callee.object.type===Pe.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===Pe.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(t.parent)t=t.parent;else break}return!1}function Na(e){let{callee:t}=e;return t.type===Pe.Identifier&&t.name==="require"||t.type===Pe.MemberExpression&&t.object.type===Pe.Identifier&&t.object.name==="require"}var An=B({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(t){Oa(t)||e.report({node:t,messageId:"syncDynamicImport"})},TSImportType(t){e.report({node:t,messageId:"syncDynamicImport"})},CallExpression(t){Na(t)&&e.report({node:t,messageId:"requireNotAllowed"})}}}});import{AST_NODE_TYPES as N}from"@typescript-eslint/utils";import{z as wn}from"zod/v4";var Da=wn.object({mainComponentRegex:wn.string().optional(),mainComponentSelector:wn.string().optional()}),ja=/^[A-Z][A-Za-z0-9]*$/,Rn=B({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:[V(Da)],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,[t]){let r=e.sourceCode,n=t.mainComponentRegex?new RegExp(t.mainComponentRegex):void 0,s=t.mainComponentSelector,a=new Set,i=new Map,p=[],l=[],c=new Set;function d(x){let C=x.node;if(C.type===N.VariableDeclaration){for(let F of C.declarations)if(F.id.type===N.Identifier&&F.id.name===x.name&&F.init)return F.init}if(C.type===N.ExportNamedDeclaration){let F=C.declaration;if(F&&F.type===N.VariableDeclaration){for(let O of F.declarations)if(O.id.type===N.Identifier&&O.id.name===x.name&&O.init)return O.init}}return null}function y(x){let C=new Set;return Fe(x,F=>(F.type===N.Identifier&&F.name!=="styled"&&F.name!=="css"&&C.add(F.name),!1),r),C}function g(x){return ja.test(x)}function b(x){if(x.type!==N.CallExpression)return!1;let C=x.callee;return C.type===N.Identifier?C.name==="memo"||C.name==="forwardRef":C.type===N.MemberExpression&&C.property.type===N.Identifier?C.property.name==="memo"||C.property.name==="forwardRef":!1}function f(x){if(x.type===N.JSXElement||x.type===N.JSXFragment)return!0;if(x.type===N.BlockStatement){for(let C of x.body)if(C.type===N.ReturnStatement&&C.argument)return f(C.argument)}if(x.type===N.ArrayExpression){for(let C of x.elements)if(C&&(C.type===N.JSXElement||C.type===N.JSXFragment))return!0}return!1}function E(x){if(x.type!==N.ArrowFunctionExpression)return!1;let C=x.body;if(C.type===N.ArrowFunctionExpression){let F=C.body;if(f(F))return!0}return!1}function h(x){if(x.type===N.TaggedTemplateExpression){let C=x.tag;if(C.type===N.MemberExpression&&C.object.type===N.Identifier&&C.object.name==="styled")return!0;if(C.type===N.CallExpression){let F=C.callee;if(F.type===N.Identifier&&F.name==="styled")return!0}}return!1}function m(x){if(x.type===N.TaggedTemplateExpression){let C=x.tag;if(C.type===N.Identifier&&C.name==="css")return!0}return!1}function A(x,C){if(x.id.type!==N.Identifier)return;let F=x.id.name,O=x.init;if(O){if(h(O)||m(O)){l.push({node:C,name:F});return}if((g(F)||O.type===N.ArrowFunctionExpression)&&(O.type===N.ArrowFunctionExpression||O.type===N.FunctionExpression||b(O))){if(O.type===N.ArrowFunctionExpression||O.type===N.FunctionExpression){if(f(O.body)){a.add(F);return}}else if(b(O)){a.add(F);return}}O.type===N.Identifier&&i.set(F,O.name),g(F)||E(O)&&a.add(F)}}function I(x){return x.type===N.ExportDefaultDeclaration||x.type===N.ExportNamedDeclaration}function o(x){if(x.type===N.FunctionDeclaration)return x.id?x.id.name:null;if(x.type===N.VariableDeclaration){let C=x.declarations[0];if(C&&C.id.type===N.Identifier)return C.id.name}if(x.type===N.ExportDefaultDeclaration){let C=x.declaration;if(C.type===N.FunctionDeclaration)return C.id?C.id.name:"default";if(C.type===N.Identifier)return C.name}if(x.type===N.ExportNamedDeclaration){let C=x.declaration;if(C&&C.type===N.FunctionDeclaration)return C.id?C.id.name:null;if(C&&C.type===N.VariableDeclaration){let F=C.declarations[0];if(F&&F.id.type===N.Identifier)return F.id.name}}return null}function S(x,C){return s?c.has(x):n?n.test(C):I(x)}function u(x){let C=new Set;Fe(x.node,F=>{if(F.type===N.Identifier)for(let O of l)O.name===F.name&&(C.add(O.name),(O.firstUsagePosition===void 0||F.range[0]<O.firstUsagePosition)&&(O.firstUsagePosition=F.range[0]));if(F.type===N.JSXElement){let O=F.openingElement;if(O.name.type===N.JSXIdentifier)for(let G of l)G.name===O.name.name&&(C.add(G.name),(G.firstUsagePosition===void 0||O.name.range[0]<G.firstUsagePosition)&&(G.firstUsagePosition=O.name.range[0]))}return!1},r),x.usedStyles=C}function T(x){if(x.type===N.VariableDeclaration){for(let C of x.declarations)A(C,x);return}if(x.type===N.FunctionDeclaration){g(x.id.name)&&f(x.body)&&a.add(x.id.name);return}if(x.type===N.ExportNamedDeclaration&&x.declaration){let C=x.declaration;if(C.type===N.VariableDeclaration){for(let F of C.declarations)A(F,x);return}if(C.type===N.FunctionDeclaration&&C.id){g(C.id.name)&&f(C.body)&&a.add(C.id.name);return}}if(x.type===N.ExportDefaultDeclaration){let C=x.declaration;C.type===N.Identifier&&a.add(C.name),(C.type===N.FunctionDeclaration||C.type===N.ArrowFunctionExpression||C.type===N.FunctionExpression)&&(C.type===N.FunctionDeclaration?C.id?a.add(C.id.name):a.add("default"):f(C.body)&&a.add("default"))}}function w(x,C=new Set){if(a.has(x))return!0;if(C.has(x))return!1;C.add(x);let F=i.get(x);return F?w(F,C):!1}let R={};return s&&(R[s]=x=>{let C=x;for(;C.parent&&C.parent.type!==N.Program;)C=C.parent;C.parent&&(C.type===N.VariableDeclaration||C.type===N.FunctionDeclaration||C.type===N.ExportNamedDeclaration||C.type===N.ExportDefaultDeclaration)&&c.add(C)}),R["Program:exit"]=x=>{for(let M of x.body)T(M);for(let M of x.body){let W=o(M);if(W&&w(W)){let X=S(M,W);p.push({node:M,name:W,isMainComponent:X,usedStyles:new Set})}}for(let M of p)u(M);let C=new Set;for(let M of l)C.add(M.name);let F=new Map;for(let M=0;M<x.body.length;M+=1){let W=x.body[M];for(let X of l)X.node===W&&F.set(X.name,M)}let O=new Map;for(let M of l){let W=d(M),X=new Set;if(W){let ne=y(W);for(let le of ne)C.has(le)&&le!==M.name&&X.add(le)}O.set(M.name,X)}let G=new Map;for(let M of l){let W=O.get(M.name);if(!W)continue;let X=F.get(M.name);if(X!==void 0)for(let ne of W){let le=G.get(ne);(le===void 0||X<le)&&G.set(ne,X)}}let _=[];for(let M of l){if(M.firstUsagePosition===void 0)continue;let W=x.body.indexOf(M.node),X=-1;for(let Ce of p){if(!Ce.usedStyles.has(M.name))continue;let Ie=x.body.indexOf(Ce.node);(X===-1||Ie<X)&&(X=Ie)}let ne=G.get(M.name);if(ne!==void 0&&(X===-1||ne<X)&&(X=ne),X===-1)continue;let le=-1;for(let Ce of p){let Ie=x.body.indexOf(Ce.node);Ie<X&&Ie>le&&(le=Ie)}let Ee=W<X,be=W>le,xe=-1,Se=O.get(M.name);if(Se)for(let Ce of Se){let Ie=F.get(Ce);Ie!==void 0&&Ie>xe&&(xe=Ie)}let it=W>xe;if(!(Ee&&be&&it)){let Ce=le+1;if(xe+1>Ce&&(Ce=xe+1),Ce>X)continue;_.push({style:M,targetPosition:Ce})}}let te=null;if(p.length>1){let M=p.map(X=>({c:X,idx:x.body.indexOf(X.node)})).sort((X,ne)=>X.idx-ne.idx)[0]?.c,W=p.find(X=>X.isMainComponent)||null;M&&W&&M.node!==W.node&&(te={component:W,targetBefore:M.node})}if(_.length>0||te){let M=_[0]?.style.node||te?.component.node||x,W=_.length>0?"stylesShouldBeAboveUsage":"mainComponentShouldBeFirst";e.report({node:M,messageId:W,fix:v(_,te,x.body)})}},R;function v(x,C,F){return function*(O){x.sort((_,te)=>_.targetPosition-te.targetPosition);for(let{style:_}of x){let te=r.getCommentsBefore(_.node),M=_.node.range[0],W=_.node.range[1];te.length>0&&te[0]&&(M=te[0].range[0]),M===_.node.range[0]&&r.text.slice(0,M).trim().length===0&&(M=0),yield O.removeRange([M,W])}let G=new Map;for(let _ of x){let te=G.get(_.targetPosition)||[];te.push(_),G.set(_.targetPosition,te)}for(let[_,te]of G){let M=F[_];if(!M)continue;let W=r.getCommentsBefore(M),X=W.length>0&&W[0]?W[0].range[0]:M.range[0],ne=[];for(let{style:le}of te){let Ee=r.getCommentsBefore(le.node),be=r.getText(le.node);Ee.length>0&&(be=`${Ee.map(Se=>r.getText(Se)).join(`
47
47
  `)}
48
- ${xe}`),ee.push(xe)}yield A.insertTextBeforeRange([te,te],`${ee.join(`
48
+ ${be}`),ne.push(be)}yield O.insertTextBeforeRange([X,X],`${ne.join(`
49
49
 
50
50
  `)}
51
51
 
52
- `)}}}}});var Yr={[Bt.name]:Bt.rule,[Pt.name]:Pt.rule,[Rt.name]:Rt.rule,"rules-of-hooks":Wr,"exhaustive-deps":Nn,"require-description":Dr.rule,[vt.name]:vt.rule,[kt.name]:kt.rule,[Zt.name]:Zt.rule,[gt.name]:gt.rule,[wt.name]:wt.rule,[Dt.name]:Dt.rule,[Be.name]:Be.rule,[en.name]:en.rule,[Ot.name]:Ot.rule,[Ft.name]:Ft.rule,[jt.name]:jt.rule,[Tt.name]:Tt.rule,[on.name]:on.rule,[sn.name]:sn.rule,[pn.name]:pn.rule,[At.name]:At.rule,[_t.name]:_t.rule,[Ut.name]:Ut.rule,[zt.name]:zt.rule,[Vt.name]:Vt.rule,[Xt.name]:Xt.rule,[Wt.name]:Wt.rule,[Jt.name]:Jt.rule,[Kt.name]:Kt.rule,[Mt.name]:Mt.rule,[Lt.name]:Lt.rule,[dn.name]:dn.rule,[Yt.name]:Yt.rule,[cn.name]:cn.rule,[yn.name]:yn.rule,[gn.name]:gn.rule,[Sn.name]:Sn.rule,[hn.name]:hn.rule,[En.name]:En.rule,[bn.name]:bn.rule,[xn.name]:xn.rule,[Be.name]:Be.rule};var nf={rules:Yr};export{nf as extendedLintPlugin};
52
+ `)}if(C){let{component:_,targetBefore:te}=C,M=r.getCommentsBefore(_.node),W=_.node.range[0],X=_.node.range[1];M.length>0&&M[0]&&(W=M[0].range[0]),W===_.node.range[0]&&r.text.slice(0,W).trim().length===0&&(W=0);let ne=r.getCommentsBefore(te),le=ne.length>0&&ne[0]?ne[0].range[0]:te.range[0],Ee=(()=>{let be=r.getText(_.node);return M.length>0&&(be=`${M.map(Se=>r.getText(Se)).join(`
53
+ `)}
54
+ ${be}`),be})();yield O.removeRange([W,X]),yield O.insertTextBeforeRange([le,le],`${Ee}
55
+ `)}}}}});var Kr={[Gt.name]:Gt.rule,[Ot.name]:Ot.rule,[kt.name]:kt.rule,"rules-of-hooks":Hr,"exhaustive-deps":Mn,"require-description":_r.rule,[Nt.name]:Nt.rule,[jt.name]:jt.rule,[en.name]:en.rule,[Et.name]:Et.rule,[Ft.name]:Ft.rule,[$t.name]:$t.rule,[Ke.name]:Ke.rule,[on.name]:on.rule,[Lt.name]:Lt.rule,[Dt.name]:Dt.rule,[_t.name]:_t.rule,[xt.name]:xt.rule,[cn.name]:cn.rule,[pn.name]:pn.rule,[mn.name]:mn.rule,[Pt.name]:Pt.rule,[Jt.name]:Jt.rule,[Vt.name]:Vt.rule,[Xt.name]:Xt.rule,[Yt.name]:Yt.rule,[qt.name]:qt.rule,[Bt.name]:Bt.rule,[Ht.name]:Ht.rule,[nn.name]:nn.rule,[zt.name]:zt.rule,[Ut.name]:Ut.rule,[hn.name]:hn.rule,[Kt.name]:Kt.rule,[dn.name]:dn.rule,[Tn.name]:Tn.rule,[En.name]:En.rule,[bn.name]:bn.rule,[Cn.name]:Cn.rule,[In.name]:In.rule,[An.name]:An.rule,[Rn.name]:Rn.rule,[Ke.name]:Ke.rule};var nf={rules:Kr};export{nf as extendedLintPlugin};