@ls-stack/extended-lint 0.61.1 → 0.62.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 Q,ESLintUtils as pr}from"@typescript-eslint/utils";import{z as Xt}from"zod/v4";import{ESLintUtils as lr}from"@typescript-eslint/utils";import*as qt from"zod/v4";function W(e){let r=lr.RuleCreator(t=>`https://github.com/lucasols/extended-lint#${t}`)(e);return{name:e.name,rule:r}}function _(e){return qt.toJSONSchema(e)}var cr=pr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="react-compiler-extra",ur=Xt.object({runOnlyWithEnableCompilerDirective:Xt.boolean().optional()}),fr=/eslint +react-compiler\/react-compiler: +\["error/;function mr(e){return e.type===Q.Identifier?e.name.startsWith("use"):e.type===Q.MemberExpression&&e.property.type===Q.Identifier?e.property.name.startsWith("use"):!1}var dr=/\bthis[.[]/;function Gt(e){return dr.test(e)}var yr=cr({name:Zt,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."},hasSuggestions:!0,schema:[_(ur)]},defaultOptions:[{}],create(e,[n]){let r=!1;if(n.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(fr.test(a.value)){r=!0;break}if(!r)return{}}function t(a){for(let i of a.properties)if(i.type===Q.Property&&i.method&&i.value.type===Q.FunctionExpression){let s=e.sourceCode,l=s.getText(i.key),p=i.value,u=s.getText(p.body);if(Gt(u))e.report({node:i,messageId:"thisKeywordInMethod"});else{let m=p.params.map(d=>s.getText(d)).join(", "),f="";p.generator?f=`${l}: function* (${m}) ${u}`:f=`${l}: (${m}) => ${u}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:d=>d.replaceText(i,f)})}}}function o(a){for(let i of a.properties)if(i.type===Q.Property&&i.value.type===Q.ObjectExpression){for(let s of i.value.properties)if(s.type===Q.Property&&s.method&&s.value.type===Q.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Gt(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(mr(a.callee))for(let i of a.arguments){if(i.type===Q.ObjectExpression&&(t(i),o(i)),i.type===Q.ArrowFunctionExpression&&(i.body.type===Q.ObjectExpression&&(t(i.body),o(i.body)),i.body.type===Q.BlockStatement))for(let s of i.body.body)s.type===Q.ReturnStatement&&s.argument?.type===Q.ObjectExpression&&(t(s.argument),o(s.argument));if(i.type===Q.FunctionExpression)for(let s of i.body.body)s.type===Q.ReturnStatement&&s.argument?.type===Q.ObjectExpression&&(t(s.argument),o(s.argument))}}}}}),Qe={name:Zt,rule:yr};import{AST_NODE_TYPES as ne}from"@typescript-eslint/utils";import{z as v}from"zod/v4";var gr=v.object({disallow:v.array(v.object({selector:v.string(),message:v.string(),replace:v.optional(v.union([v.string(),v.object({regex:v.string(),with:v.string()})])),replaceType:v.optional(v.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:v.optional(v.array(v.object({fn:v.string(),withArgs:v.optional(v.array(v.object({atIndex:v.number(),value:v.union([v.string(),v.number(),v.boolean()])}))),message:v.string(),replaceWith:v.optional(v.string()),ignoreRegex:v.optional(v.string())}))),__dev_simulateFileName:v.optional(v.string()),mustMatchSyntax:v.optional(v.array(v.object({includeRegex:v.string(),mustCallFn:v.optional(v.array(v.object({anyCall:v.array(v.object({fn:v.string(),withArgs:v.array(v.object({atIndex:v.number(),literal:v.union([v.string(),v.number(),v.boolean()])}))})),message:v.optional(v.string())}))),mustMatchSelector:v.optional(v.array(v.object({selector:v.string(),message:v.string()}))),mustHaveExport:v.optional(v.array(v.object({name:v.string(),type:v.enum(["function","variable","any"]).default("any"),message:v.string()})))})))}),et=W({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[_(gr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[n]){let r={},{mustMatchSyntax:t,__dev_simulateFileName:o,disallow:a,disallowFnCalls:i}=n,s=o??e.filename,l=[],p=new Map,u=new Set,m=new Map,f=new Set,d=new Map;function y(S){for(let I of S.specifiers)I.type===ne.ImportSpecifier&&I.imported.type===ne.Identifier&&I.imported.name!==I.local.name&&d.set(I.local.name,I.imported.name)}function E(S){if(S.declaration){if(S.declaration.type===ne.FunctionDeclaration&&S.declaration.id){let I=S.declaration.id.name;for(let A of Array.from(f)){let[R,N]=A.split(":");R===I&&(N==="function"||N==="any")&&f.delete(A)}}else if(S.declaration.type===ne.VariableDeclaration){for(let I of S.declaration.declarations)if(I.id.type===ne.Identifier){let A=I.id.name;for(let R of Array.from(f)){let[N,L]=R.split(":");N===A&&(L==="variable"||L==="any")&&f.delete(R)}}}}for(let I of S.specifiers)if(I.exported.type===ne.Identifier){let A=I.exported.name;for(let R of Array.from(f)){let[N,L]=R.split(":");N===A&&L==="any"&&f.delete(R)}}}function h(S){S.id.type===ne.Identifier&&S.init?.type===ne.Identifier&&d.set(S.id.name,S.init.name)}function c(S){return d.get(S)??S}function x(S,I){return c(S)===I||S===I}for(let{includeRegex:S,mustCallFn:I,mustMatchSelector:A,mustHaveExport:R}of t??[]){let L=function(X){let B=X;for(let{name:K,value:ee}of N??[])B=B.replaceAll(K,ee);return B};var w=L;let N=Sr(s,new RegExp(S));if(N){for(let{anyCall:X,message:B}of I??[]){let K=`Expected file to call the function: ${X.map(({fn:ee})=>ee).join(" or ")}`;u.add(K),l.push(ee=>{let{callee:J}=ee;if(J.type===ne.Identifier){for(let{fn:me,withArgs:ve}of X)if(J.name===me){u.delete(K);for(let re of ve){let Ee=ee.arguments[re.atIndex],le=typeof re.literal=="string"?L(re.literal):re.literal;if(!Ee){e.report({node:ee,messageId:"default",data:{message:`Missing argument with value "${le}" at index ${re.atIndex}${B?`: ${L(B)}`:""}`}});continue}if(Ee.type!==ne.Literal){e.report({node:Ee,messageId:"default",data:{message:`Argument at position ${re.atIndex} should the literal "${le}"${B?`: ${L(B)}`:""}`}});continue}Ee.value!==le&&e.report({node:Ee,messageId:"default",data:{message:`Argument should have the value "${le}"${B?`: ${L(B)}`:""}`},fix:Ie=>Ie.replaceText(Ee,typeof le=="string"?`'${le}'`:String(le))})}break}}})}for(let{selector:X,message:B}of A??[])m.set(X,L(B)),p.set(L(X),()=>{m.delete(X)});for(let{name:X,type:B,message:K}of R??[]){let ee=L(X),J=L(K);f.add(`${ee}:${B}:${J}`)}}}for(let{fn:S,withArgs:I,message:A,replaceWith:R,ignoreRegex:N}of i??[])N&&new RegExp(N).test(s)||l.push(L=>{let{callee:X}=L;if(X.type!==ne.Identifier||!x(X.name,S))return;if(I)for(let K of I){let ee=L.arguments[K.atIndex];if(!ee){e.report({node:L,messageId:"default",data:{message:`Missing argument with value "${K.value}" at index ${K.atIndex}: ${A}`}});return}if(ee.type!==ne.Literal||ee.value!==K.value)return}let B=K=>R?K.replaceText(L,R):null;e.report({node:L,messageId:"default",data:{message:A},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:B}]:void 0})});function b(S,I){let A=r[S];A?r[S]=R=>{A(R),I(R)}:r[S]=I}for(let{selector:S,message:I,replace:A,replaceType:R="suggestion"}of a??[]){if(S==="CallExpression"){l.push(N=>{g(A,N,I,R)});continue}r[S]=N=>{g(A,N,I,R)}}if(p.size>0)for(let[S,I]of p)b(S,I);return l.length>0&&(r.CallExpression=S=>{if(S.type===ne.CallExpression)for(let I of l)I(S)}),r.ImportDeclaration=S=>{S.type===ne.ImportDeclaration&&y(S)},r.ExportNamedDeclaration=S=>{S.type===ne.ExportNamedDeclaration&&E(S)},r.VariableDeclarator=S=>{S.type===ne.VariableDeclarator&&h(S)},r["Program:exit"]=S=>{for(let I of u)e.report({node:S,messageId:"default",data:{message:I}});for(let[,I]of m)e.report({node:S,messageId:"default",data:{message:I}});for(let I of f){let[A,R,N]=I.split(":");e.report({node:S,messageId:"default",data:{message:`Missing required export "${A}" of type ${R}: ${N}`}})}},r;function g(S,I,A,R){let N=L=>{if(!S)return null;if(typeof S=="string")return L.replaceText(I,S);{let X=new RegExp(S.regex),B=e.sourceCode.getText(I);return L.replaceText(I,B.replace(X,S.with))}};e.report({node:I,messageId:"default",data:{message:A},fix:S&&R==="autofix"?N:void 0,suggest:S&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof S=="string"?S:S.with}"`},fix:N}]:void 0})}}});function Sr(e,n){let r=[],t=n.exec(e);if(!t)return null;let[o,...a]=t;r.push({name:"$0_lowercase",value:o.toLowerCase()}),r.push({name:"$0_capitalize",value:Kt(o)}),r.push({name:"$0_uncapitalize",value:Qt(o)}),r.push({name:"$0",value:o});for(let i=0;i<a.length;i++){let s=`$${i+1}`,l=a[i];l!==void 0&&(r.push({name:`${s}_lowercase`,value:l.toLowerCase()}),r.push({name:`${s}_capitalize`,value:Kt(l)}),r.push({name:`${s}_uncapitalize`,value:Qt(l)}),r.push({name:s,value:l}))}return r}function Kt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Qt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as z,AST_TOKEN_TYPES as en,ESLintUtils as Tr}from"@typescript-eslint/utils";import{z as Re}from"zod/v4";var hr=Tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nn="collapse-simple-objs-in-one-line",Er=Re.object({maxLineLength:Re.number().optional(),maxProperties:Re.number().optional(),nestedObjMaxLineLength:Re.number().optional(),nestedObjMaxProperties:Re.number().optional(),ignoreTypesWithSuffix:Re.array(Re.string()).optional()}),xr=hr({name:nn,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:[_(Er)]},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=n.ignoreTypesWithSuffix??[],o=n.maxProperties??2,a=n.nestedObjMaxLineLength??n.maxLineLength,i=n.nestedObjMaxProperties??3;function s(p){if(p.type===z.ObjectExpression){let u=p.parent.type===z.Property,m=u?i:o,f=p.properties.length;if(f>m)return!1;if(f===1){let y=p.properties[0];return!y||y.type===z.Property&&y.value.type===z.ObjectExpression||y.type===z.Property&&y.value.type===z.ArrayExpression&&!y.value.elements.every(h=>h&&tt(h))?!1:{text:r.getText(y),isNested:u,propsSize:f}}let d=[];for(let y of p.properties){if(y.type===z.Property&&!tt(y.value))return!1;d.push(r.getText(y))}return{text:d.join(", "),isNested:u,propsSize:f}}else{let u=p.parent.parent?.type===z.TSPropertySignature,m=u?i:o,f=p.members.length;if(f>m)return!1;if(t.length>0&&p.parent.type===z.TSTypeAliasDeclaration){let y=p.parent.id.name;if(t.some(E=>y.endsWith(E)))return!1}if(f===1){let y=p.members[0];return!y||y.type===z.TSPropertySignature&&y.typeAnnotation?.typeAnnotation.type===z.TSTypeLiteral?!1:{text:r.getText(y),isNested:u,propsSize:1}}if(p.parent.type===z.TSIntersectionType||p.parent.type===z.TSUnionType&&p.parent.types[0]!==p)return!1;let d=[];for(let y of p.members){if(y.type!==z.TSPropertySignature)return!1;let E=y.typeAnnotation?.typeAnnotation;if(!E||E.type===z.TSTypeLiteral||!tn(E))return!1;if(E.type===z.TSTypeReference&&E.typeArguments){if(E.typeArguments.params.length>1)return!1;let c=E.typeArguments.params[0];if(!c||!tn(c))return!1}let h=r.getText(y).trim();(h.endsWith(";")||h.endsWith(","))&&(h=h.slice(0,-1)),d.push(h)}return{text:d.join("; "),isNested:u,propsSize:f}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==z.JSXExpressionContainer){let E=0,h=!1,c=r.getTokenAfter(p,{filter:b=>b.type!==en.Punctuator||h?!0:b.value===","?(E++,!1):b.value===";"?(E++,h=!0,!1):b.value===")"||b.value==="}"?(E++,!1):!0});if(E>4)return;let x=c?.type===en.Template&&c.value.startsWith(`}
2
- `);if(c?.loc.start.line===p.loc.end.line&&!x)return}let u=s(p);if(!u)return;let m=u.text;if(m.includes(`
3
- `)||r.getCommentsInside(p).length>0)return;m.endsWith(";")&&(m=m.slice(0,-1));let f=`{ ${m} }`,d=Cr(r,p),y=u.isNested&&u.propsSize>2?a:n.maxLineLength;y&&f.length+d.length+br(p,r)>y||e.report({node:p,messageId:"singleLineProp",fix:E=>E.replaceText(p,f)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function tn(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 tt(e,n){return!!(e.type===z.Literal||e.type===z.Identifier||e.type===z.TemplateLiteral||e.type===z.TaggedTemplateExpression||!n&&e.type===z.ArrayExpression&&e.elements.every(r=>r&&tt(r,!0)))}function br(e,n){let r=n.getLastToken(e);if(!r)return 0;let t=n.text.indexOf(`
4
- `,r.range[1]);return(t!==-1?t:n.text.length)-r.range[1]}function Cr(e,n){return e.text.slice(n.range[0]-n.loc.start.column,n.range[0])}var nt={name:nn,rule:xr};var Ir=/eslint +react-compiler\/react-compiler: +\["error/,sn={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 n=!1,r=typeof e.getSource=="function"?c=>r(c):c=>e.sourceCode.getText(c),t=typeof e.getScope=="function"?()=>t():c=>e.sourceCode.getScope(c),o=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:o,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function s(c){a&&Array.isArray(c.suggest)&&c.suggest.length>0&&(c.fix=c.suggest[0].fix),e.report(c)}let l=e.getSourceCode().scopeManager,p=new WeakMap,u=new WeakSet,m=new WeakMap,f=new WeakMap,d=new WeakSet;function y(c,x){return function(b){if(x.has(b))return x.get(b);let g=c(b);return x.set(b,g),g}}function E(c,x,b,g,w){w&&c.async&&s({node:c,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ import{AST_NODE_TYPES as ne}from"@typescript-eslint/utils";import{z as v}from"zod/v4";import{ESLintUtils as Sr}from"@typescript-eslint/utils";import*as qt from"zod/v4";function V(e){let r=Sr.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function $(e){return qt.toJSONSchema(e)}var Tr=v.object({disallow:v.array(v.object({selector:v.string(),message:v.string(),replace:v.optional(v.union([v.string(),v.object({regex:v.string(),with:v.string()})])),replaceType:v.optional(v.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:v.optional(v.array(v.object({fn:v.string(),withArgs:v.optional(v.array(v.object({atIndex:v.number(),value:v.union([v.string(),v.number(),v.boolean()])}))),message:v.string(),replaceWith:v.optional(v.string()),ignoreRegex:v.optional(v.string())}))),__dev_simulateFileName:v.optional(v.string()),mustMatchSyntax:v.optional(v.array(v.object({includeRegex:v.string(),mustCallFn:v.optional(v.array(v.object({anyCall:v.array(v.object({fn:v.string(),withArgs:v.array(v.object({atIndex:v.number(),literal:v.union([v.string(),v.number(),v.boolean()])}))})),message:v.optional(v.string())}))),mustMatchSelector:v.optional(v.array(v.object({selector:v.string(),message:v.string()}))),mustHaveExport:v.optional(v.array(v.object({name:v.string(),type:v.enum(["function","variable","any"]).default("any"),message:v.string()})))})))}),et=V({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[$(Tr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:o,disallow:a,disallowFnCalls:i}=t,s=o??e.filename,l=[],p=new Map,c=new Set,m=new Map,f=new Set,d=new Map;function y(S){for(let I of S.specifiers)I.type===ne.ImportSpecifier&&I.imported.type===ne.Identifier&&I.imported.name!==I.local.name&&d.set(I.local.name,I.imported.name)}function E(S){if(S.declaration){if(S.declaration.type===ne.FunctionDeclaration&&S.declaration.id){let I=S.declaration.id.name;for(let w of Array.from(f)){let[R,N]=w.split(":");R===I&&(N==="function"||N==="any")&&f.delete(w)}}else if(S.declaration.type===ne.VariableDeclaration){for(let I of S.declaration.declarations)if(I.id.type===ne.Identifier){let w=I.id.name;for(let R of Array.from(f)){let[N,_]=R.split(":");N===w&&(_==="variable"||_==="any")&&f.delete(R)}}}}for(let I of S.specifiers)if(I.exported.type===ne.Identifier){let w=I.exported.name;for(let R of Array.from(f)){let[N,_]=R.split(":");N===w&&_==="any"&&f.delete(R)}}}function h(S){S.id.type===ne.Identifier&&S.init?.type===ne.Identifier&&d.set(S.id.name,S.init.name)}function u(S){return d.get(S)??S}function x(S,I){return u(S)===I||S===I}for(let{includeRegex:S,mustCallFn:I,mustMatchSelector:w,mustHaveExport:R}of n??[]){let _=function(G){let B=G;for(let{name:Q,value:ee}of N??[])B=B.replaceAll(Q,ee);return B};var A=_;let N=hr(s,new RegExp(S));if(N){for(let{anyCall:G,message:B}of I??[]){let Q=`Expected file to call the function: ${G.map(({fn:ee})=>ee).join(" or ")}`;c.add(Q),l.push(ee=>{let{callee:Y}=ee;if(Y.type===ne.Identifier){for(let{fn:me,withArgs:ke}of G)if(Y.name===me){c.delete(Q);for(let re of ke){let xe=ee.arguments[re.atIndex],le=typeof re.literal=="string"?_(re.literal):re.literal;if(!xe){e.report({node:ee,messageId:"default",data:{message:`Missing argument with value "${le}" at index ${re.atIndex}${B?`: ${_(B)}`:""}`}});continue}if(xe.type!==ne.Literal){e.report({node:xe,messageId:"default",data:{message:`Argument at position ${re.atIndex} should the literal "${le}"${B?`: ${_(B)}`:""}`}});continue}xe.value!==le&&e.report({node:xe,messageId:"default",data:{message:`Argument should have the value "${le}"${B?`: ${_(B)}`:""}`},fix:Re=>Re.replaceText(xe,typeof le=="string"?`'${le}'`:String(le))})}break}}})}for(let{selector:G,message:B}of w??[])m.set(G,_(B)),p.set(_(G),()=>{m.delete(G)});for(let{name:G,type:B,message:Q}of R??[]){let ee=_(G),Y=_(Q);f.add(`${ee}:${B}:${Y}`)}}}for(let{fn:S,withArgs:I,message:w,replaceWith:R,ignoreRegex:N}of i??[])N&&new RegExp(N).test(s)||l.push(_=>{let{callee:G}=_;if(G.type!==ne.Identifier||!x(G.name,S))return;if(I)for(let Q of I){let ee=_.arguments[Q.atIndex];if(!ee){e.report({node:_,messageId:"default",data:{message:`Missing argument with value "${Q.value}" at index ${Q.atIndex}: ${w}`}});return}if(ee.type!==ne.Literal||ee.value!==Q.value)return}let B=Q=>R?Q.replaceText(_,R):null;e.report({node:_,messageId:"default",data:{message:w},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:B}]:void 0})});function b(S,I){let w=r[S];w?r[S]=R=>{w(R),I(R)}:r[S]=I}for(let{selector:S,message:I,replace:w,replaceType:R="suggestion"}of a??[]){if(S==="CallExpression"){l.push(N=>{g(w,N,I,R)});continue}r[S]=N=>{g(w,N,I,R)}}if(p.size>0)for(let[S,I]of p)b(S,I);return l.length>0&&(r.CallExpression=S=>{if(S.type===ne.CallExpression)for(let I of l)I(S)}),r.ImportDeclaration=S=>{S.type===ne.ImportDeclaration&&y(S)},r.ExportNamedDeclaration=S=>{S.type===ne.ExportNamedDeclaration&&E(S)},r.VariableDeclarator=S=>{S.type===ne.VariableDeclarator&&h(S)},r["Program:exit"]=S=>{for(let I of c)e.report({node:S,messageId:"default",data:{message:I}});for(let[,I]of m)e.report({node:S,messageId:"default",data:{message:I}});for(let I of f){let[w,R,N]=I.split(":");e.report({node:S,messageId:"default",data:{message:`Missing required export "${w}" of type ${R}: ${N}`}})}},r;function g(S,I,w,R){let N=_=>{if(!S)return null;if(typeof S=="string")return _.replaceText(I,S);{let G=new RegExp(S.regex),B=e.sourceCode.getText(I);return _.replaceText(I,B.replace(G,S.with))}};e.report({node:I,messageId:"default",data:{message:w},fix:S&&R==="autofix"?N:void 0,suggest:S&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof S=="string"?S:S.with}"`},fix:N}]:void 0})}}});function hr(e,t){let r=[],n=t.exec(e);if(!n)return null;let[o,...a]=n;r.push({name:"$0_lowercase",value:o.toLowerCase()}),r.push({name:"$0_capitalize",value:Gt(o)}),r.push({name:"$0_uncapitalize",value:Zt(o)}),r.push({name:"$0",value:o});for(let i=0;i<a.length;i++){let s=`$${i+1}`,l=a[i];l!==void 0&&(r.push({name:`${s}_lowercase`,value:l.toLowerCase()}),r.push({name:`${s}_capitalize`,value:Gt(l)}),r.push({name:`${s}_uncapitalize`,value:Zt(l)}),r.push({name:s,value:l}))}return r}function Gt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Zt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as W,AST_TOKEN_TYPES as Kt,ESLintUtils as Er}from"@typescript-eslint/utils";import{z as Ae}from"zod/v4";var xr=Er.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),en="collapse-simple-objs-in-one-line",br=Ae.object({maxLineLength:Ae.number().optional(),maxProperties:Ae.number().optional(),nestedObjMaxLineLength:Ae.number().optional(),nestedObjMaxProperties:Ae.number().optional(),ignoreTypesWithSuffix:Ae.array(Ae.string()).optional()}),Cr=xr({name:en,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:[$(br)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function s(p){if(p.type===W.ObjectExpression){let c=p.parent.type===W.Property,m=c?i:o,f=p.properties.length;if(f>m)return!1;if(f===1){let y=p.properties[0];return!y||y.type===W.Property&&y.value.type===W.ObjectExpression||y.type===W.Property&&y.value.type===W.ArrayExpression&&!y.value.elements.every(h=>h&&tt(h))?!1:{text:r.getText(y),isNested:c,propsSize:f}}let d=[];for(let y of p.properties){if(y.type===W.Property&&!tt(y.value))return!1;d.push(r.getText(y))}return{text:d.join(", "),isNested:c,propsSize:f}}else{let c=p.parent.parent?.type===W.TSPropertySignature,m=c?i:o,f=p.members.length;if(f>m)return!1;if(n.length>0&&p.parent.type===W.TSTypeAliasDeclaration){let y=p.parent.id.name;if(n.some(E=>y.endsWith(E)))return!1}if(f===1){let y=p.members[0];return!y||y.type===W.TSPropertySignature&&y.typeAnnotation?.typeAnnotation.type===W.TSTypeLiteral?!1:{text:r.getText(y),isNested:c,propsSize:1}}if(p.parent.type===W.TSIntersectionType||p.parent.type===W.TSUnionType&&p.parent.types[0]!==p)return!1;let d=[];for(let y of p.members){if(y.type!==W.TSPropertySignature)return!1;let E=y.typeAnnotation?.typeAnnotation;if(!E||E.type===W.TSTypeLiteral||!Qt(E))return!1;if(E.type===W.TSTypeReference&&E.typeArguments){if(E.typeArguments.params.length>1)return!1;let u=E.typeArguments.params[0];if(!u||!Qt(u))return!1}let h=r.getText(y).trim();(h.endsWith(";")||h.endsWith(","))&&(h=h.slice(0,-1)),d.push(h)}return{text:d.join("; "),isNested:c,propsSize:f}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==W.JSXExpressionContainer){let E=0,h=!1,u=r.getTokenAfter(p,{filter:b=>b.type!==Kt.Punctuator||h?!0:b.value===","?(E++,!1):b.value===";"?(E++,h=!0,!1):b.value===")"||b.value==="}"?(E++,!1):!0});if(E>4)return;let x=u?.type===Kt.Template&&u.value.startsWith(`}
2
+ `);if(u?.loc.start.line===p.loc.end.line&&!x)return}let c=s(p);if(!c)return;let m=c.text;if(m.includes(`
3
+ `)||r.getCommentsInside(p).length>0)return;m.endsWith(";")&&(m=m.slice(0,-1));let f=`{ ${m} }`,d=Rr(r,p),y=c.isNested&&c.propsSize>2?a:t.maxLineLength;y&&f.length+d.length+Ir(p,r)>y||e.report({node:p,messageId:"singleLineProp",fix:E=>E.replaceText(p,f)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function Qt(e){return e.type===W.TSLiteralType||e.type===W.TSTypeReference||e.type===W.TSNumberKeyword||e.type===W.TSStringKeyword||e.type===W.TSBooleanKeyword||e.type===W.TSNullKeyword||e.type===W.TSUndefinedKeyword}function tt(e,t){return!!(e.type===W.Literal||e.type===W.Identifier||e.type===W.TemplateLiteral||e.type===W.TaggedTemplateExpression||!t&&e.type===W.ArrayExpression&&e.elements.every(r=>r&&tt(r,!0)))}function Ir(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 Rr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var nt={name:en,rule:Cr};var Ar=/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"?u=>r(u):u=>e.sourceCode.getText(u),n=typeof e.getScope=="function"?()=>n():u=>e.sourceCode.getScope(u),o=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:o,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function s(u){a&&Array.isArray(u.suggest)&&u.suggest.length>0&&(u.fix=u.suggest[0].fix),e.report(u)}let l=e.getSourceCode().scopeManager,p=new WeakMap,c=new WeakSet,m=new WeakMap,f=new WeakMap,d=new WeakSet;function y(u,x){return function(b){if(x.has(b))return x.get(b);let g=u(b);return x.set(b,g),g}}function E(u,x,b,g,A){A&&u.async&&s({node:u,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,16 +12,20 @@ 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 S=l.acquire(c),I=new Set,A=null;{let T=S.upper;for(;T&&(I.add(T),T.type!=="function");)T=T.upper;if(!T)return;A=T}let R=Array.isArray;function N(T){if(!R(T.defs))return!1;let C=T.defs[0];if(C==null||C.node.type!=="VariableDeclarator")return!1;let k=C.node.init;if(k==null)return!1;for(;k.type==="TSAsExpression";)k=k.expression;let P=C.node.parent;if(P==null&&(st(A.block,C.node.id),P=C.node.parent,P==null))return!1;if(P.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 O=k.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let F=C.node.id,{name:D}=O;if(D==="useRef"&&F.type==="Identifier")return!0;if(kr(O)&&F.type==="Identifier"){for(let j of T.references)j!==F&&d.add(j.identifier);return!0}else if(D==="useState"||D==="useReducer"){if(F.type==="ArrayPattern"&&F.elements.length===2&&R(T.identifiers)){if(F.elements[1]===T.identifiers[0]){if(D==="useState"){let j=T.references,pe=0;for(let ge=0;ge<j.length;ge++){if(j[ge].isWrite()&&pe++,pe>1)return!1;p.set(j[ge].identifier,F.elements[0])}}return!0}else if(F.elements[0]===T.identifiers[0]){if(D==="useState"){let j=T.references;for(let pe=0;pe<j.length;pe++)u.add(j[pe].identifier)}return!1}}}else if(D==="useTransition"&&F.type==="ArrayPattern"&&F.elements.length===2&&Array.isArray(T.identifiers)&&F.elements[1]===T.identifiers[0])return!0;return!1}function L(T){if(!R(T.defs))return!1;let C=T.defs[0];if(C==null||C.node==null||C.node.id==null)return!1;let k=C.node,P=A.childScopes,O=null,F;for(F=0;F<P.length;F++){let D=P[F],j=D.block;if(k.type==="FunctionDeclaration"&&j===k||k.type==="VariableDeclarator"&&j.parent===k){O=D;break}}if(O==null)return!1;for(F=0;F<O.through.length;F++){let D=O.through[F];if(D.resolved!=null&&I.has(D.resolved.scope)&&!X(D.resolved))return!1}return!0}let X=y(N,m),B=y(L,f),K=new Map;function ee(T){let C=T.from,k=!1;for(;C.block!==c;)C.type==="function"&&(k=C.block.parent!=null&&C.block.parent.type==="ReturnStatement"),C=C.upper;return k}let J=new Map,me=new Map;ve(S);function ve(T){for(let C of T.references){if(!C.resolved||!I.has(C.resolved.scope))continue;let k=st(c,C.identifier),P=on(k),O=Se(P,me);if(w&&P.type==="Identifier"&&(P.parent.type==="MemberExpression"||P.parent.type==="OptionalMemberExpression")&&!P.parent.computed&&P.parent.property.type==="Identifier"&&P.parent.property.name==="current"&&ee(C)&&K.set(O,{reference:C,dependencyNode:P}),P.parent.type==="TSTypeQuery"||P.parent.type==="TSTypeReference")continue;let F=C.resolved.defs[0];if(F!=null&&!(F.node!=null&&F.node.init===c.parent)&&F.type!=="TypeParameter")if(J.has(O))J.get(O).references.push(C);else{let D=C.resolved,j=X(D)||B(D);J.set(O,{isStable:j,references:[C]})}}for(let C of T.childScopes)ve(C)}K.forEach(({reference:T,dependencyNode:C},k)=>{let P=T.resolved.references,O=!1;for(let F=0;F<P.length;F++){let{identifier:D}=P[F],{parent:j}=D;if(j!=null&&j.type==="MemberExpression"&&!j.computed&&j.property.type==="Identifier"&&j.property.name==="current"&&j.parent.type==="AssignmentExpression"&&j.parent.left===j){O=!0;break}}O||s({node:C.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 re=new Set;function Ee(T,C){re.has(C)||(re.add(C),s({node:T,message:`Assignments to the '${C}' variable from inside React Hook ${r(b)} 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(b)}.`}))}let le=new Set;if(J.forEach(({isStable:T,references:C},k)=>{T&&le.add(k),C.forEach(P=>{P.writeExpr&&Ee(P.writeExpr,k)})}),re.size>0)return;if(!x){let T=null;if(J.forEach(({isStable:C,references:k},P)=>{T||k.forEach(O=>{if(T)return;let F=O.identifier;if(!p.has(F))return;let j=O.from;for(;j.type!=="function";)j=j.upper;j.block===c&&(T=P)})}),T){let{suggestedDependencies:C}=rt({dependencies:J,declaredDependencies:[],stableDependencies:le,externalDependencies:new Set,isEffect:!0});s({node:b,message:`React Hook ${g} contains a call to '${T}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+C.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${C.join(", ")}]`,fix(k){return k.insertTextAfter(c,`, [${C.join(", ")}]`)}}]})}return}let Ie=[],Oe=new Set;x.type!=="ArrayExpression"?s({node:x,message:`React Hook ${r(b)} 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.`}):x.elements.forEach(T=>{if(T===null)return;if(T.type==="SpreadElement"){s({node:T,message:`React Hook ${r(b)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}d.has(T)&&s({node:T,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(T)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(T)}\``,fix(O){return O.removeRange(T.range)}}]});let C;try{C=Se(T,me)}catch(O){if(/Unsupported node type/.test(O.message)){T.type==="Literal"?J.has(T.value)?s({node:T,message:`The ${T.raw} literal is not a valid dependency because it never changes. Did you mean to include ${T.value} in the array instead?`}):s({node:T,message:`The ${T.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:T,message:`React Hook ${r(b)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let k=T;for(;k.type==="MemberExpression"||k.type==="OptionalMemberExpression"||k.type==="ChainExpression";)k=k.object||k.expression.object;let P=!A.through.some(O=>O.identifier===k);Ie.push({key:C,node:T}),P||Oe.add(C)});let{suggestedDependencies:ir,unnecessaryDependencies:_e,missingDependencies:xe,duplicateDependencies:Jt}=rt({dependencies:J,declaredDependencies:Ie,stableDependencies:le,externalDependencies:Oe,isEffect:w}),$e=ir;if(Jt.size+xe.size+_e.size===0){if(n)return;Rr({declaredDependencies:Ie,declaredDependenciesNode:x,componentScope:A,scope:S}).forEach(({construction:C,isUsedOutsideOfHook:k,depType:P})=>{let O=P==="function"?"useCallback":"useMemo",F=P==="function"?"definition":"initialization",D=`wrap the ${F} of '${C.name.name}' in its own ${O}() Hook.`,j=k?`To fix this, ${D}`:`Move it inside the ${g} callback. Alternatively, ${D}`,pe=P==="conditional"||P==="logical expression"?"could make":"makes",ge=`The '${C.name.name}' ${P} ${pe} the dependencies of ${g} Hook (at line ${x.loc.start.line}) change on every render. ${j}`,Yt;k&&C.type==="Variable"&&P==="function"&&(Yt=[{desc:`Wrap the ${F} of '${C.name.name}' in its own ${O}() Hook.`,fix(Bt){let[or,ar]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Bt.insertTextBefore(C.node.init,or),Bt.insertTextAfter(C.node.init,ar)]}}]),s({node:C.node,message:ge,suggest:Yt})});return}!w&&xe.size>0&&($e=rt({dependencies:J,declaredDependencies:[],stableDependencies:le,externalDependencies:Oe,isEffect:w}).suggestedDependencies);function sr(){if(Ie.length===0)return!0;let T=Ie.map(k=>k.key),C=T.slice().sort();return T.join(",")===C.join(",")}sr()&&$e.sort();function Ze(T){let C=T.split("."),k="";for(let P=0;P<C.length;P++){if(P!==0){let O=C.slice(0,P+1).join("."),F=me.get(O)===!0;k+=F?"?.":"."}k+=C[P]}return k}function Ke(T,C,k,P){return T.size===0?null:(T.size>1?"":C+" ")+k+" "+(T.size>1?"dependencies":"dependency")+": "+Ar(Array.from(T).sort().map(O=>"'"+Ze(O)+"'"))+`. Either ${P} ${T.size>1?"them":"it"} or remove the dependency array.`}let ue="";if(_e.size>0){let T=null;if(Array.from(_e.keys()).forEach(C=>{T===null&&C.endsWith(".current")&&(T=C)}),T!==null)ue=` Mutable values like '${T}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Oe.size>0){let C=Array.from(Oe)[0];S.set.has(C)||(ue=` Outer scope values like '${C}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ue&&xe.has("props")){let T=J.get("props");if(T==null)return;let C=T.references;if(!Array.isArray(C))return;let k=!0;for(let P=0;P<C.length;P++){let O=C[P],F=st(A.block,O.identifier);if(!F){k=!1;break}let D=F.parent;if(D==null){k=!1;break}if(D.type!=="MemberExpression"&&D.type!=="OptionalMemberExpression"){k=!1;break}}k&&(ue=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${g} call and refer to those specific props inside ${r(b)}.`)}if(!ue&&xe.size>0){let T=null;xe.forEach(C=>{if(T)return;let k=A.set.get(C),P=J.get(C);if(P.references[0].resolved!==k)return;let O=k.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let F=!1,D;for(let j=0;j<P.references.length;j++)if(D=P.references[j].identifier,D!=null&&D.parent!=null&&(D.parent.type==="CallExpression"||D.parent.type==="OptionalCallExpression")&&D.parent.callee===D){F=!0;break}F&&(T=C)}),T!==null&&(ue=` If '${T}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ue&&xe.size>0){let T=null;if(xe.forEach(C=>{if(T!==null)return;let P=J.get(C).references,O,F;for(let D=0;D<P.length;D++){for(O=P[D].identifier,F=O.parent;F!=null&&F!==A.block;){if(F.type==="CallExpression"){let j=p.get(F.callee);if(j!=null){if(j.name===C)T={missingDep:C,setter:F.callee.name,form:"updater"};else if(u.has(O))T={missingDep:C,setter:F.callee.name,form:"reducer"};else{let pe=P[D].resolved;if(pe!=null){let ge=pe.defs[0];ge!=null&&ge.type==="Parameter"&&(T={missingDep:C,setter:F.callee.name,form:"inlineReducer"})}}break}}F=F.parent}if(T!==null)break}}),T!==null)switch(T.form){case"reducer":ue=` You can also replace multiple useState variables with useReducer if '${T.setter}' needs the current value of '${T.missingDep}'.`;break;case"inlineReducer":ue=` If '${T.setter}' needs the current value of '${T.missingDep}', you can also switch to useReducer instead of useState and read '${T.missingDep}' in the reducer.`;break;case"updater":ue=` You can also do a functional update '${T.setter}(${T.missingDep.slice(0,1)} => ...)' if you only need '${T.missingDep}' in the '${T.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:x,message:`React Hook ${r(b)} has `+(Ke(xe,"a","missing","include")||Ke(_e,"an","unnecessary","exclude")||Ke(Jt,"a","duplicate","omit"))+ue,suggest:[{desc:`Update the dependencies array to be: [${$e.map(Ze).join(", ")}]`,fix(T){return T.replaceText(x,`[${$e.map(Ze).join(", ")}]`)}}]})}function h(c){let x=wr(c.callee,i);if(x===-1)return;let b=c.arguments[x],g=c.callee,w=an(g).name,S=c.arguments[x+1],I=/Effect($|[^a-z])/g.test(w);if(!b){s({node:g,message:`React Hook ${w} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(n&&!I)){if(!S&&!I){(w==="useMemo"||w==="useCallback")&&s({node:g,message:`React Hook ${w} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(b.type){case"FunctionExpression":case"ArrowFunctionExpression":E(b,S,g,w,I);return;case"Identifier":if(!S||S.elements&&S.elements.some(N=>N&&N.type==="Identifier"&&N.name===b.name))return;let A=t(c).set.get(b.name);if(A==null||A.defs==null)return;let R=A.defs[0];if(!R||!R.node||R.type!=="Variable"&&R.type!=="FunctionName")break;switch(R.node.type){case"FunctionDeclaration":E(R.node,S,g,w,I);return;case"VariableDeclarator":let N=R.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":E(N,S,g,w,I);return}break}break;default:s({node:g,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:g,message:`React Hook ${w} has a missing dependency: '${b.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${b.name}]`,fix(A){return A.replaceText(S,`[${b.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let c of e.sourceCode.getAllComments())if(Ir.test(c.value))return n=!0,{CallExpression:x=>h(x,!0)}}return{CallExpression:c=>h(c)}}};function rt({dependencies:e,declaredDependencies:n,stableDependencies:r,externalDependencies:t,isEffect:o}){let a=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,h)=>{let c=s(a,h);c.isUsed=!0,l(a,h,x=>{x.isSubtreeUsed=!0})}),n.forEach(({key:E})=>{let h=s(a,E);h.isSatisfiedRecursively=!0}),r.forEach(E=>{let h=s(a,E);h.isSatisfiedRecursively=!0});function s(E,h){let c=h.split("."),x=E;for(let b of c){let g=x.children.get(b);g||(g=i(),x.children.set(b,g)),x=g}return x}function l(E,h,c){let x=h.split("."),b=E;for(let g of x){let w=b.children.get(g);if(!w)return;c(w),b=w}}let p=new Set,u=new Set;m(a,p,u,E=>E);function m(E,h,c,x){E.children.forEach((b,g)=>{let w=x(g);if(b.isSatisfiedRecursively){b.isSubtreeUsed&&c.add(w);return}if(b.isUsed){h.add(w);return}m(b,h,c,S=>w+"."+S)})}let f=[],d=new Set,y=new Set;return n.forEach(({key:E})=>{u.has(E)?f.indexOf(E)===-1?f.push(E):y.add(E):d.add(E)}),p.forEach(E=>{f.push(E)}),{suggestedDependencies:f,unnecessaryDependencies:d,duplicateDependencies:y,missingDependencies:p}}function be(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 be(e.consequent)!=null||be(e.alternate)!=null?"conditional":null;case"LogicalExpression":return be(e.left)!=null||be(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return be(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return be(e.expression);case"TSAsExpression":return be(e.expression)}return null}function Rr({declaredDependencies:e,declaredDependenciesNode:n,componentScope:r,scope:t}){let o=e.map(({key:i})=>{let s=r.variables.find(p=>p.name===i);if(s==null)return null;let l=s.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 p=be(l.node.init);if(p!=null)return[s,p]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[s,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function a(i){let s=!1;for(let l=0;l<i.references.length;l++){let p=i.references[l];if(p.writeExpr){if(s)return!0;s=!0;continue}let u=p.from;for(;u!==t&&u!=null;)u=u.upper;if(u!==t&&!ln(n,p.identifier))return!0}return!1}return o.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:a(i)}))}function on(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)?on(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function it(e,n,r){n&&(e.optional?n.has(r)||n.set(r,!0):n.has(r)||n.set(r,!1))}function Se(e,n){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return n&&n.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=Se(e.object,n),t=Se(e.property,null),o=`${r}.${t}`;return it(e,n,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Se(e.object,n),t=Se(e.property,null),o=`${r}.${t}`;return it(e,n,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let t=Se(r.object,n),o=Se(r.property,null),a=`${t}.${o}`;return it(r,n,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function an(e,n){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function wr(e,n){let r=an(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&n&&n.additionalHooks){let t;try{t=Se(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return n.additionalHooks.test(t)?0:-1}else return-1}}function st(e,n){let r=[e],t=null;for(;r.length;){if(t=r.shift(),vr(t,n))return t;if(ln(t,n))for(let[o,a]of Object.entries(t))o!=="parent"&&(rn(a)?(a.parent=t,r.push(a)):Array.isArray(a)&&a.forEach(i=>{rn(i)&&(i.parent=t,r.push(i))}))}return null}function Ar(e){let n="";for(let r=0;r<e.length;r++)n+=e[r],r===0&&e.length===2?n+=" and ":r===e.length-2&&e.length>2?n+=", and ":r<e.length-1&&(n+=", ");return n}function rn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function vr(e,n){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===n.type&&e.name===n.name&&e.range[0]===n.range[0]&&e.range[1]===n.range[1]}function ln(e,n){return e.range[0]<=n.range[0]&&e.range[1]>=n.range[1]}function kr(e){return!1}import{AST_NODE_TYPES as ze,ESLintUtils as cn}from"@typescript-eslint/utils";import ie from"typescript";import{z as Pr}from"zod/v4";var Fr=cn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="improved-no-unnecessary-condition",Or=Pr.object({}),Nr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Dr=new Set(Nr),ot={name:pn,rule:Fr({name:pn,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}}".'},schema:[_(Or)]},defaultOptions:[{}],create(e){let n=cn.getParserServices(e,!0),r=n.program?.getTypeChecker();if(!r||!n.program)throw new Error("TypeScript services or program not available");function t(s){return s.type===ze.UnaryExpression&&s.operator==="typeof"}function o(s){return s.flags&ie.TypeFlags.Any||s.flags&ie.TypeFlags.Unknown?null:s.flags&ie.TypeFlags.StringLike?["string"]:s.flags&ie.TypeFlags.NumberLike?["number"]:s.flags&ie.TypeFlags.BigIntLike?["bigint"]:s.flags&ie.TypeFlags.BooleanLike?["boolean"]:s.flags&ie.TypeFlags.ESSymbolLike?["symbol"]:s.flags&ie.TypeFlags.Undefined||s.flags&ie.TypeFlags.Void?["undefined"]:s.flags&ie.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&ie.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&ie.TypeFlags.NonPrimitive?["object"]:s.flags&ie.TypeFlags.Never?["never"]:null}function a(s){if(!r)return null;let l=n.esTreeNodeToTSNodeMap.get(s),p=r.getTypeAtLocation(l.expression);if(p.flags&ie.TypeFlags.Any||p.flags&ie.TypeFlags.Unknown)return null;let u=[];if(p.isUnion()){for(let f of p.types){let d=o(f);if(d)u.push(...d);else return null}return u}let m=o(p);return m?(u.push(...m),u):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,u=null;if(t(s.left)?(p=s.left,u=s.right.type===ze.Literal&&typeof s.right.value=="string"?s.right.value:null):t(s.right)&&(p=s.right,u=s.left.type===ze.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!u||!Mr(u,Dr))return;let m=a(p);if(!m)return;let f=s.operator==="!==",d=m.includes(u);m.length===1?d&&!f?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:ke(p,e),type:u}}):!d&&f?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:ke(p,e),type:Array.from(m)[0]}}):!d&&!f?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:ke(p,e),actualType:Ue(m),conditionType:u}}):d&&f&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:ke(p,e),actualType:Ue(m),conditionType:u}}):!d&&!f?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:ke(p,e),actualType:Ue(m),conditionType:u}}):!d&&f&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:ke(p,e),type:Ue(m)}})}return{BinaryExpression:i}}})};function Ue(e){return Array.from(new Set(e)).join(" | ")||"never"}function ke(e,n){let r=e.argument;return r.type===ze.Identifier?r.name:n.sourceCode.getText(r)}function Mr(e,n){return n.has(e)}import{AST_NODE_TYPES as jr,ESLintUtils as Lr}from"@typescript-eslint/utils";import{z as at}from"zod/v4";var _r=Lr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),un="no-call-with-explicit-generics",$r=at.object({functions:at.array(at.string())}),Ur=_r({name:un,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:[_($r)]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Set(n.functions);return{CallExpression(t){let{callee:o}=t;o.type===jr.Identifier&&r.has(o.name)&&t.typeArguments&&e.report({node:t,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),lt={name:un,rule:Ur};import{AST_NODE_TYPES as We,ESLintUtils as zr}from"@typescript-eslint/utils";var Wr=zr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="no-call-with-inferred-generics",Vr=Wr({name:fn,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Map(n.functions.map(t=>[t.name,t]));return{CallExpression(t){let{callee:o}=t;if(o.type!==We.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:i=1,allowAny:s,disallowTypes:l=n.disallowTypes}=a;(t.typeArguments?.params.length||0)<(i||0)&&e.report({node:t,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(s&&!l)&&t.typeArguments?.params.some(u=>!s&&u.type===We.TSAnyKeyword||l&&u.type===We.TSTypeReference&&u.typeName.type===We.Identifier&&l.includes(u.typeName.name))&&e.report({node:t,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),pt={name:fn,rule:Vr};import{ESLintUtils as Hr}from"@typescript-eslint/utils";var Jr=Hr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yn="no-commented-out-code",Yr=["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:"],Br=/^\s*return\s+/,qr=/\w=("|'|`)/,Xr=/\w+:\s*('|"|`)/,Gr=/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,Zr=/\w+-\w+:/,Kr=/\w+_\w+:/,Qr=/\?\s+\w/,ei=/:\s+\w/,ti=/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,ni=/^\s*\d+[,}]/,ri=/^\s*\[[^\]]*\][,}]/,ii=/^\s*\{[^}]*\}[,}]/,si=/\.\w+\(/,oi=/\[\w+\]/,ai=/^\s*(['"`]).+?\1\s*:/,li=/^<[A-Z]\w*(\s|>|\/)/,pi=/^<[a-z]+(\s|>|\/)/,ci=/<[A-Z]\w*(\s.*)?>/,ui=/<\/[A-Z]\w*>/,fi=/<[a-z]+(\s.*)?>/,mi=/<\/[a-z]+>/,di=/^\s*[*\s]*$/,yi=/^[a-zA-Z]/,gi=/^[A-Z][A-Za-z]*(?:\s+\d+)?(?:\s+[a-z]+)*:\s+[A-Za-z]/,Si=/```[\s\S]*?```/g,Ti=/`[^`]*`/g,mn=/[a-zA-Z0-9]/,hi=/\.[A-Za-z_][A-Za-z0-9_]*\(/,Ei=/[{}[\]()`=<>]/,xi=/:\s*(['"`[{(]|\w+\s*=>)/,bi=/\bif\s*\(|\belse\b|=>/,q={returnStatement:Br,stringAssignment:qr,objectPropertyWithQuotes:Xr,computedPropertyAssignment:Gr,kebabCaseProperty:Zr,snakeCaseProperty:Kr,ternaryOperator:Qr,colonWithWord:ei,quotedString:ti,numberWithComma:ni,arrayWithComma:ri,objectWithComma:ii,methodCall:si,arrayAccess:oi,quotedPropertyKey:ai,jsxSelfClosing:li,jsxElement:pi,jsxOpeningTag:ci,jsxClosingTag:ui,htmlOpeningTag:fi,htmlClosingTag:mi,jsdocComment:di};function Ci(e){if(e.includes(":")){let r=e.split(":")[0]?.trim();if(r&&yi.test(r)&&r.includes(" "))return!0}let n=e.trim();return n.length===0||hi.test(n)||Ei.test(n)||xi.test(n)||bi.test(n)?!1:!!(n.includes(":")&&gi.test(n))}var Ii=[") {","return;",q.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",q.stringAssignment,");",q.objectPropertyWithQuotes,q.computedPropertyAssignment,q.kebabCaseProperty,q.snakeCaseProperty,"&&","||","()",q.ternaryOperator,q.colonWithWord,q.quotedString,q.numberWithComma,q.arrayWithComma,q.objectWithComma,q.methodCall,q.arrayAccess,"?.(","??","=>",q.quotedPropertyKey],Ri=["/>","</",q.jsxSelfClosing,q.jsxElement,q.jsxOpeningTag,q.jsxClosingTag,q.htmlOpeningTag,q.htmlClosingTag],dn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],wi=Jr({name:yn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function n(t,o){if(t.startsWith("/"))return!1;let a=t.trimStart();if(t.startsWith("*")||a.startsWith("eslint-disable")||t.includes("@deprecated")||t.includes("@example")||t.includes("@param")||t.includes("@returns")||t.includes("@throws")||t.includes("typescript-eslint")||t.includes("@ts-")||t.includes("prettier-ignore")||q.jsdocComment.test(t))return!1;for(let i of dn)if(a.startsWith(i))return!1;if(t.includes("https://")||Ci(a))return!1;if(o==="Block"){for(let i of Ri)if(typeof i=="string"){if(t.includes(i))return{wrongPattern:i}}else if(i.test(t))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Yr)if(a.startsWith(i))return{wrongPattern:i};for(let i of Ii)if(typeof i=="string"){if(t.includes(i))return{wrongPattern:i}}else if(i.test(t))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(t,o){let a=t,i=a.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let p=a.split(Si);p.some(m=>mn.test(m))&&(a=p.join(""))}if(!a.includes("`"))return a;let s=a.split(Ti);return s.some(p=>mn.test(p))?s.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let i=r(a.value,a.type),s=n(i,a.type);s&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:dn.join(", ")}})}}}}}),ct={name:yn,rule:wi};import{ESLintUtils as Ai,TSESTree as vi}from"@typescript-eslint/utils";var ki=Ai.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn="no-default-export",Pi=ki({name:gn,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(n){e.report({node:n,messageId:"noDefaultExport"})},ExportNamedDeclaration(n){for(let r of n.specifiers)r.exported.type===vi.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:n,messageId:"noDefaultExport"})}}}}),ut={name:gn,rule:Pi};import{ESLintUtils as Fi}from"@typescript-eslint/utils";var Oi=Fi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sn="no-leaked-text-in-jsx",Ni=[",",";","[","]","(",")"],Di=Oi({name:Sn,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(n){let r=n.value.trim();if(!r)return;let t="";Ni.includes(r)?t=r:r.includes("&&")?t="&&":r.includes("||")?t="||":r.endsWith("? (")&&(t="? ("),t&&e.report({node:n,messageId:"leakedTextInJSX",data:{text:t}})}}}}),ft={name:Sn,rule:Di};import{AST_NODE_TYPES as Ne,ESLintUtils as Mi}from"@typescript-eslint/utils";var ji=Mi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hn="no-non-camel-case-functions",Li=/^(\$?[a-z][a-zA-Z0-9]*)$/;function Tn(e){if(e.typeName.type!==Ne.TSQualifiedName)return!1;let{left:n,right:r}=e.typeName;return n.type===Ne.Identifier&&n.name==="JSX"&&r.name==="Element"}var _i=ji({name:hn,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(n){if(n.id&&!Li.test(n.id.name)){let r=n.returnType?.typeAnnotation;if(r&&(r.type===Ne.TSTypeReference?Tn(r):r.type===Ne.TSUnionType&&r.types.some(o=>o.type===Ne.TSTypeReference&&Tn(o))))return;e.report({node:n.id,messageId:"nonCamelCaseFunction",data:{functionName:n.id.name}})}}}}}),mt={name:hn,rule:_i};import{ESLintUtils as $i,TSESTree as V}from"@typescript-eslint/utils";import{AST_NODE_TYPES as En}from"@typescript-eslint/utils";function Pe(e,n,r=1/0){if(r!==0&&e.parent)return e.type===n?e:Pe(e.parent,n,r===1/0?r:r-1)}function*dt(e){yield e,e.parent&&(yield*dt(e.parent))}function yt(e,n){for(let r of e){let t=n(r);if(t!=null&&t!==!1)return t}}function xn(e,n,r){let o=r.getDeclaredVariables(e).find(a=>a.name===n||a.identifiers[0]?.parent.type===En.Property&&a.identifiers[0].parent.key.type===En.Identifier&&a.identifiers[0].parent.key.name===n);return o?o.references.filter(a=>!a.init):[]}var Ui=$i.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bn="no-optional-root-props",zi=Ui({name:bn,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function n(t){let a=e.sourceCode.getDeclaredVariables(t)[0];if(!a||a.references.length!==1)return!1;let i=a.references[0];if(!i)return!1;for(let s of dt(i.identifier)){if("returnType"in s||s.type===V.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=s.parent;if(!l)return!1;if(l.type===V.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===V.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===V.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let u=Pe(l.parent.parent,V.AST_NODE_TYPES.VariableDeclaration,4);if(!u)return!1;let m=Ve(u,e.sourceCode);return m?!(m.parent.type===V.AST_NODE_TYPES.CallExpression&&m.parent.callee.type===V.AST_NODE_TYPES.Identifier&&m.parent.callee.name==="memo"):!1}if(s.type===V.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===V.AST_NODE_TYPES.ArrowFunctionExpression){let p=Pe(l,V.AST_NODE_TYPES.VariableDeclaration);return p?!!Ve(p,e.sourceCode):!1}if(l.type===V.AST_NODE_TYPES.FunctionDeclaration)return!!Ve(l,e.sourceCode)}return!1}function r(t){t.key.type!==V.AST_NODE_TYPES.Identifier||!t.optional||e.report({node:t.key,messageId:"optionalNotAllowed",data:{propertyName:t.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Pe(t,V.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let i=e.sourceCode.getText(a);return o.replaceText(a,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(t){if(t.typeAnnotation.type===V.AST_NODE_TYPES.TSTypeLiteral&&!(He(t)||!n(t)))for(let o of t.typeAnnotation.members)o.type===V.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(t){if(!(He(t)||!n(t)))for(let o of t.body.body)o.type===V.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(t){if(t.typeName.type!==V.AST_NODE_TYPES.Identifier||t.typeName.name!=="FC"||!t.typeArguments?.params[0])return;let o=t.typeArguments.params[0];if(o.type!==V.AST_NODE_TYPES.TSTypeLiteral)return;let a=Pe(t.parent,V.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let i=Ve(a,e.sourceCode);if(!(!i||i.parent.type===V.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===V.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of o.members)l.type===V.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function He(e){return e?e.parent?.type===V.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===V.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ve(e,n){if(He(e))return;let r;if(e.type===V.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===V.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let t=n.getScope(e);e.type===V.AST_NODE_TYPES.FunctionDeclaration&&t.upper&&(t=t.upper);let o=t.variables.find(i=>i.identifiers.includes(r));if(!o)return;let a=o.references.filter(i=>i.identifier!==r);if(!(a.length!==1||!a[0])&&!He(a[0].identifier.parent.parent))return a[0].identifier}var gt={name:bn,rule:zi};import{AST_NODE_TYPES as Je}from"@typescript-eslint/utils";var De=W({name:"no-reexport",meta:{type:"problem",docs:{description:"Disallow re-exports to prevent indirection"},schema:[],messages:{noReexport:"Re-exports are not allowed. Use direct exports only."}},defaultOptions:[],create(e){let n=new Set;function r(t){return t?t.type===Je.Identifier?n.has(t.name):t.type===Je.MemberExpression?r(t.object):!1:!1}return{ImportDeclaration(t){for(let o of t.specifiers)n.add(o.local.name)},ExportNamedDeclaration(t){if(t.source){e.report({node:t,messageId:"noReexport"});return}if(t.declaration?.type===Je.VariableDeclaration)for(let o of t.declaration.declarations)r(o.init)&&e.report({node:t,messageId:"noReexport"});t.specifiers.length>0&&e.report({node:t,messageId:"noReexport"})},ExportDefaultDeclaration(t){t.declaration.type===Je.Identifier&&n.has(t.declaration.name)&&e.report({node:t,messageId:"noReexport"})},ExportAllDeclaration(t){e.report({node:t,messageId:"noReexport"})}}}});import{ESLintUtils as Wi}from"@typescript-eslint/utils";import St from"path";import{z as Ce}from"zod/v4";var Vi=Wi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cn="no-relative-imports",Hi=Ce.object({find:Ce.string(),replacement:Ce.string()}),Ji=Ce.object({aliases:Ce.array(Hi),rootDir:Ce.string().optional(),allowNotFoundAliases:Ce.boolean().optional(),_dev_simulateFileName:Ce.string().optional()}),Yi=Vi({name:Cn,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:[_(Ji)]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[n]){let r=n._dev_simulateFileName??e.filename;function t(i){return i.startsWith(".")||i.startsWith("..")}function o(i,s){let l=St.dirname(s);return St.resolve(l,i)}function a(i){let s=n.rootDir??process.cwd(),l=St.relative(s,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:u}of n.aliases)if(l.startsWith(u)){let m=l.replace(u,p);return{alias:p,newPath:m}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!t(s))return;let l=o(s,r),p=a(l);!p&&n.allowNotFoundAliases||e.report({node:i,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?u=>u.replaceText(i.source,`'${p.newPath}'`):void 0})}}}}),Tt={name:Cn,rule:Yi};import{AST_NODE_TYPES as G}from"@typescript-eslint/utils";import{z as In}from"zod/v4";var Bi=In.object({customMessage:In.string().optional()}),ht=W({name:"no-static-style-prop",meta:{type:"problem",docs:{description:"Prevent using static style props in JSX, only dynamic values should be allowed"},schema:[_(Bi)],messages:{noStaticStyleProp:"Static style props are not allowed use css instead.{{customMessage}}"}},defaultOptions:[{}],create(e,[n]){function r(t){switch(t.type){case G.Literal:return!0;case G.ObjectExpression:return t.properties.every(o=>o.type===G.Property?o.computed||o.value.type===G.Identifier&&o.key.type===G.Identifier&&o.key.name===o.value.name?!1:r(o.value):!1);case G.ArrayExpression:return t.elements.every(o=>o?o.type===G.SpreadElement?!1:r(o):!0);case G.TemplateLiteral:return t.expressions.length===0;case G.ConditionalExpression:case G.LogicalExpression:case G.BinaryExpression:case G.UnaryExpression:case G.CallExpression:case G.MemberExpression:case G.Identifier:case G.ArrowFunctionExpression:case G.FunctionExpression:return!1;default:return!1}}return{JSXAttribute(t){if(t.name.type===G.JSXIdentifier&&t.name.name==="style"&&t.value){let o=null;t.value.type===G.JSXExpressionContainer?t.value.expression.type!==G.JSXEmptyExpression&&(o=t.value.expression):t.value.type===G.Literal&&(o=t.value),o&&r(o)&&e.report({node:t,messageId:"noStaticStyleProp",data:{customMessage:n.customMessage?` ${n.customMessage}`:""}})}}}}});import{AST_NODE_TYPES as Ye}from"@typescript-eslint/utils";import*as we from"zod/v4";var qi=we.object({alternativeMsgs:we.object({inArrayFind:we.string().optional(),inArrayFilter:we.string().optional()}).optional(),__dev_simulateFileName:we.string().optional()});function Xi(e){return e.typeAnnotation.type!==Ye.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}var Gi=/\.(typeGuards|type-guards)\.(ts|tsx)$/;function Zi(e){return Gi.test(e)}function Ki(e){let n=e.parent;for(;n;){if(n.type===Ye.CallExpression&&n.callee.type===Ye.MemberExpression&&n.callee.property.type===Ye.Identifier){let r=n.callee.property.name;if(r==="filter"||r==="find")return{method:r}}n=n.parent}return null}var Et=W({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:[_(qi)],hasSuggestions:!0},defaultOptions:[{}],create(e,[n]){let r=n.__dev_simulateFileName??e.filename;if(Zi(r))return{};function t(o){if(!Xi(o))return;let a=Ki(o);if(n.alternativeMsgs&&a){let i=a.method==="filter"?n.alternativeMsgs.inArrayFilter:n.alternativeMsgs.inArrayFind;if(i){let s=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:s,data:{message:i}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":t,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":t,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":t}}});import{AST_NODE_TYPES as Fe}from"@typescript-eslint/utils";var Qi="no-unnecessary-async-on-jsx-props";function es(e){if(e.body.type!==Fe.BlockStatement)return!1;let n=e.body.body;if(n.length!==1)return!1;let r=n[0];return!r||r.type!==Fe.ExpressionStatement?!1:r.expression.type===Fe.AwaitExpression}var xt=W({name:Qi,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function n(r){es(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(t){let o=e.sourceCode,a=[],i=o.getFirstToken(r,l=>l.value==="async");if(i){let l=o.getTokenAfter(i);l?a.push(t.replaceTextRange([i.range[0],l.range[0]],"")):a.push(t.remove(i))}function s(l){if(l.type===Fe.AwaitExpression){let p=o.getFirstToken(l);if(p&&p.value==="await"){let u=o.getTokenAfter(p);u?a.push(t.replaceTextRange([p.range[0],u.range[0]],"")):a.push(t.remove(p))}}if(l.type===Fe.BlockStatement)for(let p of l.body)s(p);else l.type===Fe.ExpressionStatement&&s(l.expression)}return s(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":n,"JSXAttribute FunctionExpression[async=true]":n}}});import{AST_NODE_TYPES as Me,ESLintUtils as wn}from"@typescript-eslint/utils";import*as bt from"typescript";import je from"zod/v4";var ts=wn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rn="no-unnecessary-casting",ns=je.object({additionalCastFunctions:je.array(je.object({name:je.string(),expectedType:je.enum(["string","number"])})).optional()}),Ct={name:Rn,rule:ts({name:Rn,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:[_(ns)],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],t=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=wn.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function i(u,m){switch(u.type){case Me.Literal:return m==="number"?typeof u.value=="number":typeof u.value=="string";case Me.TemplateLiteral:return m==="string";case Me.UnaryExpression:return m==="number"?u.operator==="+"||u.operator==="-"||u.operator==="~":!1;default:return!1}}function s(u,m){return m==="number"?!!(u.flags&bt.TypeFlags.NumberLike):!!(u.flags&bt.TypeFlags.StringLike)}function l(u,m){return f=>f.replaceText(u,e.sourceCode.getText(m))}function p(u){if(!a||u.arguments.length!==1)return;let m=u.arguments[0];if(!m||m.type===Me.SpreadElement)return;let{callee:f}=u;if(f.type!==Me.Identifier)return;let d=f.name,y=t.find(h=>h.name===d);if(!y)return;if(i(m,y.expectedType)||s(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(m)),y.expectedType)){let h,c;d==="Number"?h="unnecessaryNumberCasting":d==="String"?h="unnecessaryStringCasting":(h="unnecessaryCustomCasting",c={name:y.name,type:y.expectedType}),e.report({node:u,messageId:h,...c?{data:c}:{},fix:l(u,m)})}}return{CallExpression:p}}})};import{AST_NODE_TYPES as Be}from"@typescript-eslint/utils";import*as de from"zod/v4";var rs=de.object({methods:de.union([de.array(de.string()),de.literal("array")])}),It=W({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:[_(rs)]},defaultOptions:[{methods:"array"}],create(e,[n]){let r=n.methods,t=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(s){return Array.isArray(r)?r.includes(s):t.has(s)}function a(s){let{callee:l}=s;if(l.type===Be.MemberExpression){let p=l.property;if(p.type===Be.Identifier)return p.name}return null}function i(s,l){if(s.type!==Be.Identifier||!s.typeAnnotation)return;let p=l.parent;if(p.type===Be.CallExpression){let u=a(p);u&&o(u)&&p.arguments.indexOf(l)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(f){return s.typeAnnotation?f.remove(s.typeAnnotation):null}})}}return{ArrowFunctionExpression(s){for(let l of s.params)i(l,s)},FunctionExpression(s){for(let l of s.params)i(l,s)}}}});import{AST_NODE_TYPES as ae}from"@typescript-eslint/utils";var Rt=W({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(n){if(n.id.type===ae.ObjectPattern||!n.init||n.init.type!==ae.ObjectExpression||n.id.type===ae.Identifier&&n.id.typeAnnotation||n.parent.parent.type===ae.ExportNamedDeclaration)return;let r=new Map;for(let i of n.init.properties)i.type===ae.Property&&i.key.type===ae.Identifier&&r.set(i.key.name,i);if(r.size===0||n.id.type!==ae.Identifier)return;let t=is(n,e.sourceCode);if(t.length===0)return;let o=n.init.properties.some(i=>i.type!==ae.Property?!1:i.value.type===ae.FunctionExpression),a=new Set;for(let i of t){if(i.identifier.parent.type!==ae.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===ae.Literal&&typeof s.property.value=="string")a.add(s.property.value);else return;else{if(s.property.type!==ae.Identifier)return;a.add(s.property.name)}if(s.parent.type===ae.CallExpression&&o)return}for(let[i,s]of r)a.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function is(e,n){let r=n.getDeclaredVariables(e);if(r.length!==1)return[];let t=r[0];return t?t.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as Y,ESLintUtils as ss}from"@typescript-eslint/utils";import{z as Ae}from"zod/v4";var os=Ae.object({selectors:Ae.array(Ae.object({name:Ae.string(),selectorProp:Ae.string().optional(),selectorArgPos:Ae.number().optional(),returnProp:Ae.string().optional()}))}),as=ss.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),An="no-unused-selected-values",wt={name:An,rule:as({name:An,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[_(os)]},defaultOptions:[{selectors:[]}],create(e,[n]){let{selectors:r=[]}=n,t=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===Y.CallExpression&&(a=o.init),!a)return;let i=ps(a);if(!i)return;let s=t.get(i);if(!s)return;let l=ls(a,s.selectorArgPos??0,s.selectorProp);if(!l)return;let p=cs(l);if(!p)return;let u=vn(p.properties,void 0);if(!u)return;if(o.id.type===Y.ObjectPattern){let d=vn(o.id.properties,s.returnProp);if(!d)return;for(let[y,E]of u)d.has(y)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:y}});return}if(o.id.type!==Y.Identifier||s.returnProp)return;let m=us(o,e.sourceCode);if(m.length===0)return;let f=new Set;for(let d of m){if(d.identifier.parent.type!==Y.MemberExpression)return;let y=d.identifier.parent.property;if(y.type!==Y.Identifier)return;f.add(y.name)}for(let[d,y]of u)f.has(d)||e.report({node:y,messageId:"unusedSelectedValue",data:{name:d}})}}}})};function ls(e,n,r){let t=e.arguments[n];if(!t)return null;if(t.type===Y.ArrowFunctionExpression||t.type===Y.FunctionExpression)return t;if(r&&t.type===Y.ObjectExpression){let o=t.properties.find(i=>i.type===Y.Property&&i.key.type===Y.Identifier&&i.key.name===r);if(o?.type!==Y.Property)return null;let a=o.value;if(a.type===Y.ArrowFunctionExpression||a.type===Y.FunctionExpression)return a}return null}function ps(e){return e.callee.type===Y.Identifier?e.callee.name:e.callee.type===Y.MemberExpression&&e.callee.property.type===Y.Identifier?e.callee.property.name:null}function cs(e){if(e.body.type===Y.ObjectExpression)return e.body;if(e.body.type===Y.BlockStatement){let n=e.body.body.filter(r=>r.type===Y.ReturnStatement);return n.length!==1||!n[0]||n[0].argument?.type!==Y.ObjectExpression?null:n[0].argument}return null}function vn(e,n){let r=e;if(n){let o=e.find(a=>a.type===Y.Property&&a.key.type===Y.Identifier&&a.key.name===n);if(o?.type!==Y.Property||o.value.type!==Y.ObjectPattern)return null;r=o.value.properties}let t=new Map;for(let o of r){if(o.type!==Y.Property||o.key.type!==Y.Identifier)return null;t.set(o.key.name,o)}return t.size>0?t:null}function us(e,n){let r=n.getDeclaredVariables(e);if(r.length!==1)return[];let t=r[0];return t?t.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as H}from"@typescript-eslint/utils";var At=W({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===H.ImportDeclaration&&a.source.value==="t-state-form"))return{};let t=null,o=!1;return{CallExpression(a){if(o)return;if(!t){let s=fs(a);s&&(t=s);return}let i=ms(a,e.sourceCode);if(i){o=!0;for(let s of i)t.delete(s);if(t.size!==0)for(let[s,l]of t)e.report({node:l,messageId:"unusedField",data:{name:s}})}}}}});function fs(e){if(!(e.callee.type===H.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==H.ObjectExpression)return null;let t=yt(r.properties,a=>a.type!==H.Property||a.key.type!==H.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.ObjectExpression?a.value:a.value.type===H.ArrowFunctionExpression||a.value.type===H.FunctionExpression?ds(a.value):null);if(!t)return null;let o=new Map;for(let a of t.properties)a.type===H.Property&&a.key.type===H.Identifier&&o.set(a.key.name,a);return o}function ms(e,n){if(!(e.callee.type===H.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.VariableDeclarator||e.parent.id.type!==H.ObjectPattern||!yt(e.parent.id.properties,i=>i.type===H.Property&&i.key.type===H.Identifier&&i.key.name==="formFields"&&i))return null;let o=xn(e.parent,"formFields",n),a=new Set;for(let{identifier:i}of o){if(i.type!==H.Identifier||i.parent.type===H.Property&&i.parent.parent.type===H.ObjectExpression&&i.parent.parent.parent.type===H.ReturnStatement||i.parent.type===H.ReturnStatement)return null;if(i.parent.type===H.MemberExpression){if(i.parent.object.type!==H.Identifier||i.parent.property.type!==H.Identifier)return null;a.add(i.parent.property.name)}}return a}function ds(e){if(e.body.type===H.ObjectExpression)return e.body;if(e.body.type===H.BlockStatement){let n=e.body.body.filter(r=>r.type===H.ReturnStatement);return n.length!==1||!n[0]||n[0].argument?.type!==H.ObjectExpression?null:n[0].argument}return null}import{AST_NODE_TYPES as U,ESLintUtils as ys}from"@typescript-eslint/utils";import{z as qe}from"zod/v4";var gs=ys.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function kn(e){let n=[];for(let r of e.members)r.type===U.TSPropertySignature&&r.key.type===U.Identifier&&n.push([r.key.name,r]);return n}function Pn(e,...n){for(let r of n)e.set(...r);return e}var Ss=qe.object({forceCheckOnFCPropTypesWithName:qe.array(qe.string()).optional(),alwaysCheckFunctionOptionTypes:qe.boolean().optional()}),Fn="no-unused-type-props-in-args",vt=null,Ts=gs({name:Fn,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:[_(Ss)],fixable:"code"},defaultOptions:[{alwaysCheckFunctionOptionTypes:!0}],create(e,[n]){let{forceCheckOnFCPropTypesWithName:r,alwaysCheckFunctionOptionTypes:t=!0}=n;r&&!vt&&(vt=r.map(l=>new RegExp(l)));function o(l,p,u,m,f=!0,d=!1){let y=u.name,E=e.sourceCode.getScope(p).references.find(g=>g.identifier.name===y)?.resolved,h=l&&vt?.some(g=>g.test(y)),c=d&&t;if(!E||!h&&E.references.filter(g=>g.isTypeReference).length>1||!E.defs[0])return;let x=E.defs[0].node,b=x.parent?.type===U.ExportNamedDeclaration;if(!(f&&b&&!c)){if(x.type===U.TSTypeAliasDeclaration){a(l,p,m,x.typeAnnotation,!0,d);return}if(x.type===U.TSInterfaceDeclaration){a(l,p,m,x.body,!0,d);return}}}function a(l,p,u,m,f,d=!1){if(m.type===U.TSInterfaceBody){for(let y of m.body)y.type===U.TSPropertySignature&&y.key.type===U.Identifier&&u.set(y.key.name,y);return}if(m.type===U.TSTypeLiteral){Pn(u,...kn(m));return}if(m.type===U.TSIntersectionType){for(let y of m.types)a(l,p,u,y,!0,d);return}f||m.type===U.TSTypeReference&&m.typeName.type===U.Identifier&&o(l,p,m.typeName,u,!0,d)}function i(l,p,u,m=!1){for(let f of u)if(f.type===U.ObjectPattern&&f.typeAnnotation){let d=new Map;if(a(l,p,d,f.typeAnnotation.typeAnnotation,!1,m),d.size===0)continue;s(f,d)}else f.type===U.AssignmentPattern&&f.left.type===U.ObjectPattern&&i(l,p,[f.left],m)}function s(l,p){let u=[];if(l.properties.at(-1)?.type===U.RestElement)return;for(let y of l.properties)y.type===U.Property&&y.key.type===U.Identifier&&u.push(y.key.name);let f=[],d=[];for(let[y,E]of p)u.includes(y)||(d.push(y),f.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,E]of f.entries())e.report({...E,fix:y===f.length-1?h=>{let c=l.properties.at(-1),x=d.join(", ");return c?c.type===U.RestElement?null:h.insertTextAfter(c,`, ${x}`):h.insertTextBeforeRange([l.range[0]+1,l.range[1]],x)}:void 0})}return{VariableDeclaration(l){let p=l.declarations[0],u=new Map,m=p.id.type===U.Identifier&&p.id.typeAnnotation?.typeAnnotation.type===U.TSTypeReference&&p.id.typeAnnotation.typeAnnotation.typeName.type===U.Identifier&&p.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&p.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(m){if(m.type===U.TSTypeReference&&m.typeName.type===U.Identifier)o(!0,l,m.typeName,u,!1);else if(m.type===U.TSTypeLiteral)Pn(u,...kn(m));else if(m.type===U.TSIntersectionType)for(let f of m.types)f.type===U.TSTypeReference&&f.typeName.type===U.Identifier?o(!0,l,f.typeName,u,!1):a(!0,l,u,f,!0);if(u.size!==0&&p.init?.type===U.ArrowFunctionExpression){let f=p.init.params[0];if(!f){e.report({node:p.init,messageId:"missingComponentParam"});return}f.type===U.ObjectPattern&&s(f,u)}}},FunctionDeclaration(l){i(!1,l,l.params,t)},ArrowFunctionExpression(l){i(!1,l,l.params,t)}}}}),kt={name:Fn,rule:Ts};import{AST_NODE_TYPES as fe}from"@typescript-eslint/utils";var Pt=W({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let n=new Set;function r(t){return t.callee.type===fe.Identifier?n.has(t.callee.name):t.callee.type===fe.MemberExpression&&t.callee.object.type===fe.Identifier&&t.callee.property.type===fe.Identifier?t.callee.property.name==="useRef":!1}return{ImportDeclaration(t){if(t.source.value==="react")for(let o of t.specifiers)o.type===fe.ImportSpecifier&&o.imported.type===fe.Identifier&&o.imported.name==="useRef"&&n.add(o.local.name)},VariableDeclarator(t){if(t.init&&t.init.type===fe.CallExpression&&r(t.init)&&t.id.type===fe.Identifier){let a=e.sourceCode.getScope(t).set.get(t.id.name);if(a){let i=!1;for(let s of a.references){let p=s.identifier.parent;if(p!==t&&!(p.type===fe.JSXExpressionContainer&&p.parent.type===fe.JSXAttribute&&p.parent.name.type===fe.JSXIdentifier&&p.parent.name.name==="ref")){i=!0;break}}i||e.report({node:t.id,messageId:"refNotRead",data:{name:t.id.name}})}}}}}});import{AST_NODE_TYPES as Ft,ESLintUtils as hs}from"@typescript-eslint/utils";var Es=hs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nn="prefer-named-functions",On=new Map,xs=Es({name:Nn,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[n]){let r=null;if(n.ignoreRegex){let t=On.get(n.ignoreRegex);t?r=t:(r=new RegExp(n.ignoreRegex),On.set(n.ignoreRegex,r))}return{VariableDeclarator(t){if(t.init&&t.init.type===Ft.ArrowFunctionExpression&&t.id.type===Ft.Identifier){let o=t.id.name;if(t.id.typeAnnotation||r&&r.test(o)||!n.disallowArrowFnWithImplicitReturns&&t.init.body.type!==Ft.BlockStatement)return;let a=t.parent,i=t.init.params,s=t.init.body,l=t.init;e.report({node:t.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:n.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(a,`${l.async?"async ":""}function ${o}(${i.map(u=>e.sourceCode.getText(u)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),Ot={name:Nn,rule:xs};import{AST_NODE_TYPES as M}from"@typescript-eslint/utils";import{z as Te}from"zod/v4";var bs=Te.object({disallowedFunctions:Te.array(Te.object({name:Te.string(),allowUsingWithArgs:Te.boolean().optional(),hookAlternative:Te.string().optional(),message:Te.string().optional(),allowUseInside:Te.array(Te.string()).optional()}))}),Cs=/^use[A-Z]/,Is=/^[A-Z]/;function Xe(e){return Cs.test(e)}function Dn(e){return Is.test(e)}function Rs(e){return e.type===M.Identifier?Xe(e.name):e.type===M.MemberExpression&&e.property.type===M.Identifier?Xe(e.property.name):!1}function Mn(e,n){return e.type===M.Identifier?e.name===n:e.type===M.MemberExpression&&e.object.type===M.Identifier&&e.property.type===M.Identifier?e.object.name==="React"&&e.property.name===n:!1}function jn(e){return!!(e.parent&&e.parent.type===M.CallExpression&&Mn(e.parent.callee,"forwardRef"))}function Ln(e){return!!(e.parent&&e.parent.type===M.CallExpression&&Mn(e.parent.callee,"memo"))}function Nt(e){if(e.type===M.FunctionDeclaration||e.type===M.FunctionExpression&&e.id)return e.id||void 0;if(e.type===M.FunctionExpression||e.type===M.ArrowFunctionExpression){if(e.parent.type===M.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===M.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===M.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===M.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function ws(e){let n=e.parent,r=!1;for(;n;){if(n.type===M.FunctionDeclaration||n.type===M.FunctionExpression||n.type===M.ArrowFunctionExpression){let t=Nt(n);if(t&&t.type===M.Identifier){if(Dn(t.name)||Xe(t.name))return!r;r=!0}else{if(jn(n)||Ln(n))return!r;if(n.parent.type===M.CallExpression){let o=n.parent;Rs(o.callee)||(r=!0)}else n.parent.type===M.JSXExpressionContainer||(r=!0)}}n=n.parent}return!1}function _n(e){return e.callee.type===M.Identifier?e.callee.name:e.callee.type===M.MemberExpression&&e.callee.property.type===M.Identifier?e.callee.property.name:null}function As(e,n){if(!n.length)return!1;let r=e.parent;for(;r;){if(r.type===M.FunctionDeclaration||r.type===M.FunctionExpression||r.type===M.ArrowFunctionExpression){let t=Nt(r);if(t&&t.type===M.Identifier&&n.includes(t.name))return!0}else if(r.type===M.CallExpression){let t=_n(r);if(t&&n.includes(t))return!0}r=r.parent}return!1}function vs(e){return e.arguments.length>0&&!e.arguments.every(n=>n.type===M.Identifier&&n.name==="undefined")}function ks(e,n){let r=!1,t=e.parent;for(;t;){if(t.type===M.FunctionDeclaration||t.type===M.FunctionExpression||t.type===M.ArrowFunctionExpression){let o=Nt(t);if(o&&o.type===M.Identifier){if(Dn(o.name)||Xe(o.name)){r=!0;break}}else if(jn(t)||Ln(t)){r=!0;break}}t=t.parent}return r?n.length===0?ws(e):!As(e,n):!1}var Dt=W({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:[_(bs)],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[n]){let{disallowedFunctions:r}=n,t=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=_n(o);if(!a)return;let i=t.get(a);if(!i||i.allowUsingWithArgs&&vs(o))return;let s=i.allowUseInside||[];ks(o,s)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:l=>{let p=i.hookAlternative;return p?o.callee.type===M.Identifier?l.replaceText(o.callee,p):o.callee.type===M.MemberExpression&&o.callee.property.type===M.Identifier?l.replaceText(o.callee.property,p):null:null}}]:[]})}}}});import{AST_NODE_TYPES as Z,AST_TOKEN_TYPES as $n,ESLintUtils as Ps}from"@typescript-eslint/utils";import Mt from"zod/v4";var Fs=Ps.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zn="prefer-single-line-if",Os=Mt.object({maxLineLength:Mt.number().optional(),maxNonSimpleConditionLength:Mt.number().optional()}),Ns=Fs({name:zn,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:[_(Os)]},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode;return{IfStatement(t){if(t.consequent.type!==Z.BlockStatement||t.loc.start.line===t.loc.end.line||r.getCommentsInside(t.consequent).length>0||t.alternate||t.consequent.body.length!==1)return;let a=t.consequent.body[0];if(!a)return;if(a.type===Z.ReturnStatement){if(!Vn(a))return}else if(!(a.type===Z.ContinueStatement||a.type===Z.BreakStatement))return;if(t.test.type===Z.LogicalExpression||t.test.type===Z.ConditionalExpression)return;let i;if(n.maxNonSimpleConditionLength){let m=Un(t.test);if(!m&&t.test.type===Z.UnaryExpression&&t.test.operator==="!"){let f=t.test.argument;Un(f)&&(m=!0)}if(m&&(i=r.getText(t.test),i.length>n.maxNonSimpleConditionLength))return}i||(i=r.getText(t.test));let s=r.getText(a);if(i.includes(`
16
- `))return;let l=r.getTokenAfter(t);if(l&&l.type===$n.Punctuator&&l.value==="}"){let m=r.getTokenAfter(l);if(m&&m.type===$n.Keyword&&(m.value==="else"||m.value==="catch"))return}let p=Ds(r,t),u=`if (${i}) ${s}`;n.maxLineLength&&u.length+p.length>n.maxLineLength||e.report({node:t,messageId:"noSingleLineCurly",fix:m=>m.replaceText(t,u)})}}}});function Un(e){return e.type===Z.CallExpression||e.type===Z.BinaryExpression||e.type===Z.MemberExpression&&Wn(e)}function Wn(e){return e.object.type===Z.MemberExpression?Wn(e.object):e.object.type!==Z.Identifier}function Ds(e,n){return e.text.slice(n.range[0]-n.loc.start.column,n.range[0])}function Vn(e){if(!e.argument)return!0;let n=e.argument;return n.type===Z.ArrayExpression&&n.elements.length===0||n.type===Z.ObjectExpression&&n.properties.length===0||n.type===Z.Literal||n.type===Z.Identifier||n.type===Z.TemplateLiteral||n.type===Z.TaggedTemplateExpression?!0:n.type===Z.CallExpression?n.arguments.length===0:n.type===Z.UnaryExpression?Vn(n):!1}var jt={name:zn,rule:Ns};import{AST_NODE_TYPES as ce,ESLintUtils as Ms}from"@typescript-eslint/utils";import{z as ye}from"zod/v4";var js=Ms.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Hn="react-compiler-migration",Ls=ye.object({disallowHooks:ye.array(ye.object({name:ye.string(),replacement:ye.string()})).optional(),disallowMethods:ye.array(ye.object({name:ye.string(),replacement:ye.string().optional(),requireTrueProp:ye.string().optional()})).optional()}),_s=/eslint +react-compiler\/react-compiler: +\["error/;function $s(e){return e.type===ce.Identifier?e.name.startsWith("use"):e.type===ce.MemberExpression&&e.property.type===ce.Identifier?e.property.name.startsWith("use"):!1}var Us=js({name:Hn,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:[_(Ls)]},defaultOptions:[{disallowHooks:[],disallowMethods:[]}],create(e,[n]){let r=!1;for(let t of e.sourceCode.getAllComments())if(_s.test(t.value)){r=!0;break}return r?{CallExpression(t){if(n.disallowHooks?.length){let o=null,a=null;if(t.callee.type===ce.Identifier?(o=t.callee.name,a=t.callee):t.callee.type===ce.MemberExpression&&t.callee.property.type===ce.Identifier&&(o=t.callee.property.name,a=t.callee.property),o){let i=n.disallowHooks.find(s=>s.name===o);i&&a&&e.report({node:t,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(a,i.replacement)}]})}}if(n.disallowMethods?.length&&$s(t.callee)){for(let o of t.arguments)if(o.type===ce.ObjectExpression){for(let a of o.properties)if(a.type===ce.Property&&a.key.type===ce.Identifier){let i=a.key.name,s=n.disallowMethods.find(l=>l.name===i);if(s){if(s.requireTrueProp){let l=s.requireTrueProp,p=!1;for(let u of o.properties)if(u.type===ce.Property&&u.key.type===ce.Identifier&&u.key.name===l&&u.value.type===ce.Literal&&u.value.value===!0){p=!0;break}if(!p){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:l}});continue}}s.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:l=>s.replacement?l.replaceText(a.key,s.replacement):null}]})}}}}}}:{}}}),Lt={name:Hn,rule:Us};import{ESLintUtils as zs,TSESTree as Ws}from"@typescript-eslint/utils";var Vs=zs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jn="require-description",Hs=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Js=/^eslint-disable-(next-)?line$/u,Ys=Vs({name:Jn,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[n]){let r=e.sourceCode,t=new Set(n.ignore||[]);return{Program(){for(let o of r.getAllComments()){let a=Bs(o);a!=null&&(t.has(a.kind)||a.description||e.report({loc:Gs(o.loc),messageId:"missingDescription"}))}}}}}),Yn={name:Jn,rule:Ys};function Bs(e){let{text:n,description:r}=Xs(e.value);if(!n)return null;let t=Hs.exec(n);if(!t)return null;let o=t[1];if(!o)return null;let a=Js.test(o);if(e.type===Ws.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let i=n.slice(t.index+o.length);return{kind:o,value:i.trim(),description:r}}var qs=/\s-{2,}\s/u;function Xs(e){let n=e.split(qs);return{text:n[0]?.trim(),description:n.length>1?n[1]?.trim()??null:null}}function Gs(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as $}from"@typescript-eslint/utils";import{z as he}from"zod/v4";var Zs=he.object({varsToCheck:he.array(he.object({selector:he.string().optional(),fromFnCall:he.string().optional(),prop:he.string().or(he.array(he.string())),errorMsg:he.string().optional()}))}),_t=W({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:[_(Zs)]},defaultOptions:[{varsToCheck:[]}],create(e,[n]){let r=new Map;function t(i,s,l,p){let u=new Set;for(let f of i.properties)f.type===$.Property&&f.key.type===$.Identifier&&u.add(f.key.name);let m=s.filter(f=>!u.has(f));if(m.length>0)if(m.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:m[0],fnName:p,customMsg:l||""}});else{let f=m.map(d=>`"${d}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:f,fnName:p,customMsg:l||""}})}}function o(i){if(i.init?.type===$.CallExpression){if(i.init.callee.type===$.Identifier)return i.init.callee.name;if(i.init.callee.type===$.MemberExpression&&i.init.callee.property.type===$.Identifier)return i.init.callee.object.type===$.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 n.varsToCheck)i.selector&&(a[i.selector]=s=>{if(s.type===$.VariableDeclarator&&s.id.type===$.Identifier&&r.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:o(s)}),s.type===$.VariableDeclarator&&s.id.type===$.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];t(s.id,l,i.errorMsg,o(s))}});for(let i of n.varsToCheck)if(i.fromFnCall){let s=i.fromFnCall;if(s.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${s.slice(2)}"]`;a[p]=u=>{if(u.type!==$.MemberExpression||u.parent.type!==$.CallExpression)return;let m=u.parent;if(m.parent.type!==$.VariableDeclarator)return;let f=m.parent;if(f.id.type===$.Identifier)r.set(f.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:f.id,fnName:i.fromFnCall||"unknown function"});else if(f.id.type===$.ObjectPattern){let d=Array.isArray(i.prop)?i.prop:[i.prop];t(f.id,d,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[l,p]=s.split("."),u=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;a[u]=m=>{if(m.type!==$.MemberExpression||m.parent.type!==$.CallExpression)return;let f=m.parent;if(f.parent.type!==$.VariableDeclarator)return;let d=f.parent;if(d.id.type===$.Identifier)r.set(d.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:d.id,fnName:i.fromFnCall||"unknown function"});else if(d.id.type===$.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];t(d.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;a[l]=p=>{if(p.type!==$.Identifier||p.parent.type!==$.CallExpression)return;let u=p.parent;if(u.parent.type!==$.VariableDeclarator)return;let m=u.parent;if(m.id.type===$.Identifier)r.set(m.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:m.id,fnName:i.fromFnCall||"unknown function"});else if(m.id.type===$.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];t(m.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...a,"Program:exit"(){for(let[i,{props:s,errorMsg:l,node:p,fnName:u}]of r){let f=e.sourceCode.getScope(p).set.get(i);if(f){let d=new Set(s);for(let y of f.references){let E=y.identifier,h=E.parent;if(!(h.type===$.VariableDeclarator&&h.id===E)){if(h.type===$.MemberExpression&&h.object===E&&h.property.type===$.Identifier&&d.has(h.property.name)){if(d.delete(h.property.name),d.size===0)break;continue}if(h.type===$.VariableDeclarator&&h.init===E&&h.id.type===$.ObjectPattern){for(let c of h.id.properties)c.type===$.Property&&c.key.type===$.Identifier&&d.has(c.key.name)&&d.delete(c.key.name);if(d.size===0)break;continue}if(!(h.type===$.MemberExpression&&h.object===E&&h.property.type===$.Identifier&&!s.includes(h.property.name))){d.clear();break}}}if(d.size>0){let y=Array.from(d);if(y.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:y[0],fnName:u,customMsg:l||""}});else{let E=y.map(h=>`"${h}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:E,fnName:u,customMsg:l||""}})}}}}}}}});function Xn(e){return/^use[A-Z0-9]/.test(e)}function Ge(e){return e.type==="Identifier"?Xn(e.name):e.type==="MemberExpression"&&!e.computed&&Ge(e.property)?e.object.type==="Identifier":!1}function Gn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Zn(e,n){return e.name===n||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===n}function Kn(e){return!!(e.parent&&e.parent.callee&&Zn(e.parent.callee,"forwardRef"))}function Qn(e){return!!(e.parent&&e.parent.callee&&Zn(e.parent.callee,"memo"))}function $t(e){for(;e;){let n=tr(e);if(n&&(Gn(n)||Ge(n))||Kn(e)||Qn(e))return!0;e=e.parent}return!1}function Bn(e){return!1}function Ut(e){return!1}var Ks=/eslint +react-compiler\/react-compiler: +\["error/,er={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(Ks.test(l.value))return{CallExpression(p){let u=null;p.callee.name==="useMemo"?u="useMemo":p.callee.name==="useCallback"&&(u="useCallback"),u&&e.report({node:p,message:`"${u}" is not necessary when using React Compiler.`})}}}let n=typeof e.getSource=="function"?l=>n(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),t=null,o=[],a=[],i=new WeakSet;function s(l){for(let p of l.references){let u=p.identifier.parent;if(u.type==="VariableDeclarator"&&u.init&&u.init.type==="CallExpression"&&u.init.callee&&Bn(u.init.callee))for(let m of p.resolved.references)m!==p&&i.add(m.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,p){let u=o.pop();if(u.size===0)return;let m=new Set;function f(g,w){let{cache:S}=f,I=S.get(g.id),A=new Set(w);if(A.has(g.id)){let R=[...A],N=R.slice(R.indexOf(g.id)+1);for(let L of N)m.add(L);return BigInt("0")}if(A.add(g.id),I!==void 0)return I;if(l.thrownSegments.includes(g))I=BigInt("0");else if(g.prevSegments.length===0)I=BigInt("1");else{I=BigInt("0");for(let R of g.prevSegments)I+=f(R,A)}return g.reachable&&I===BigInt("0")?S.delete(g.id):S.set(g.id,I),I}function d(g,w){let{cache:S}=d,I=S.get(g.id),A=new Set(w);if(A.has(g.id)){let R=Array.from(A),N=R.slice(R.indexOf(g.id)+1);for(let L of N)m.add(L);return BigInt("0")}if(A.add(g.id),I!==void 0)return I;if(l.thrownSegments.includes(g))I=BigInt("0");else if(g.nextSegments.length===0)I=BigInt("1");else{I=BigInt("0");for(let R of g.nextSegments)I+=d(R,A)}return S.set(g.id,I),I}function y(g){let{cache:w}=y,S=w.get(g.id);if(S===null)return 1/0;if(S!==void 0)return S;if(w.set(g.id,null),g.prevSegments.length===0)S=1;else{S=1/0;for(let I of g.prevSegments){let A=y(I);A<S&&(S=A)}S+=1}return w.set(g.id,S),S}f.cache=new Map,d.cache=new Map,y.cache=new Map;let E=d(l.initialSegment),h=tr(p),c=$t(p),x=h?Gn(h)||Ge(h):Kn(p)||Qn(p),b=1/0;for(let g of l.finalSegments){if(!g.reachable)continue;let w=y(g);w<b&&(b=w)}for(let[g,w]of u){if(!g.reachable)continue;let S=g.nextSegments.length===0?b<=y(g):b<y(g),I=f(g)*d(g),A=m.has(g.id);for(let R of w)if(A&&!Ut(R)&&e.report({node:R,message:`React Hook "${n(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.`}),x){if(p.async&&e.report({node:R,message:`React Hook "${n(R)}" cannot be called in an async function.`}),!A&&I!==E&&!Ut(R)){let L=`React Hook "${n(R)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(S?" Did you accidentally call a React Hook after an early return?":"");e.report({node:R,message:L})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let N=`React Hook "${n(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:N})}else if(h){let N=`React Hook "${n(R)}" is called in function "${n(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:N})}else if(p.type==="Program"){let N=`React Hook "${n(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:N})}else if(c&&!Ut(R)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let L=p.parent;if(L.parent.type==="VariableDeclarator"&&Xn(L.parent.id.name))return}let N=`React Hook "${n(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:N})}}},CallExpression(l){if(Ge(l.callee)){let p=qn(o),u=qn(a),m=p.get(u);m||(m=[],p.set(u,m)),m.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Bn(l.callee))&&l.arguments.length>0&&(t=l)},Identifier(l){t==null&&i.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${n(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===t&&(t=null)},FunctionDeclaration(l){$t(l)&&s(r(l))},ArrowFunctionExpression(l){$t(l)&&s(r(l))}}}};function tr(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 qn(e){return e[e.length-1]}import{AST_NODE_TYPES as te,AST_TOKEN_TYPES as Qs}from"@typescript-eslint/utils";import*as se from"zod/v4";var eo=/^\s+$/,zt=/\r?\n/,to=/^(\s*)/,no=/^(\s*)\S/,ro=/\r?\n/,io=se.object({indent:se.union([se.string().regex(eo),se.number().int().min(1)]).optional(),tags:se.array(se.string()).optional(),functions:se.array(se.string()).optional(),comments:se.array(se.string()).optional()}),Wt=W({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[_(io)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let n=e.sourceCode,{comments:r=["HTML","indent"],functions:t=["dedent","stripIndent"],tags:o=["outdent","dedent","gql","sql","html","styled"],indent:a}=e.options[0],i=r.map(c=>c.toLowerCase());function s(c){let x=c.split(zt),b=x.filter(w=>w.trim()!=="");if(b.length===0)return c;let g=Number.POSITIVE_INFINITY;for(let w of b){let S=w.match(to);S&&(g=Math.min(g,S[1]?.length??0))}return!isFinite(g)||g===0?c:x.map(w=>w.slice(g)).join(`
17
- `)}function l(c,x,b){return c.split(zt).map(w=>w.trim()===""?w:b.repeat(x)+w).join(`
18
- `)}function p(c){if(c.type===te.Identifier)return c.name;if(c.type===te.MemberExpression){let x=c.object.type===te.Identifier?c.object.name:null,b=c.property.type===te.Identifier?c.property.name:null;return x&&b?`${x}.${b}`:b}return null}function u(c,x){if(!c)return!1;for(let b of x)if(b.includes(".")){let g=b.split(".");if(c.type===te.MemberExpression&&c.object.type===te.Identifier&&c.property.type===te.Identifier&&c.object.name===g[0]&&c.property.name===g[1])return!0}else if(c.type===te.Identifier&&c.name===b)return!0;return!1}function m(c,x){let b=c.parent;if(b.type!==te.TaggedTemplateExpression)return!1;let g=p(b.tag);return g?x.includes(g):!1}function f(c,x){if(!c||c.type!==te.CallExpression)return!1;let{method:b,argumentsLength:g,optionalCall:w=!0,optionalMember:S=!0}=x;return g!==void 0&&c.arguments.length!==g||!w&&c.optional||c.callee.type!==te.MemberExpression||!S&&c.callee.optional||c.callee.property.type!==te.Identifier?!1:c.callee.property.name===b}function d(c,x){if(!c||c.type!==te.CallExpression)return!1;let{name:b,argumentsLength:g,optionalCall:w=!0}=x;return g!==void 0&&c.arguments.length!==g||!w&&c.optional||c.callee.type!==te.Identifier?!1:c.callee.name===b}function y(c){return f(c.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&c.parent.type===te.CallExpression&&c.parent.arguments[0]===c&&d(c.parent.callee.type===te.MemberExpression?c.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function E(c){if(i.length>0){let x=n.getTokenBefore(c,{includeComments:!0});if(x?.type===Qs.Block&&i.includes(x.value.trim().toLowerCase()))return!0}return!!(y(c)||o.length>0&&m(c,o)||t.length>0&&c.parent.type===te.CallExpression&&c.parent.arguments.includes(c)&&u(c.parent.callee,t))}function h(c){let x=`__PLACEHOLDER__${Math.random()}`,b=c.quasis.map(J=>n.getText(J).slice(1,J.tail?-1:-2)).join(x),g=b.match(ro);if(!g)return;let w=g[0],S=n.lines[n.getLocFromIndex(c.range[0]).line-1];if(!S)return;let A=S.match(no)?.[1]??"",R;typeof a=="string"?R=a:typeof a=="number"?R=" ".repeat(a):R=A.startsWith(" ")?" ":" ";let L=s(b).replace(new RegExp(`^${w}|${w}[ ]*$`,"g"),""),X=w+l(L,1,A+R)+w+A,B=b.includes(`\r
15
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let S=l.acquire(u),I=new Set,w=null;{let T=S.upper;for(;T&&(I.add(T),T.type!=="function");)T=T.upper;if(!T)return;w=T}let R=Array.isArray;function N(T){if(!R(T.defs))return!1;let C=T.defs[0];if(C==null||C.node.type!=="VariableDeclarator")return!1;let k=C.node.init;if(k==null)return!1;for(;k.type==="TSAsExpression";)k=k.expression;let F=C.node.parent;if(F==null&&(st(w.block,C.node.id),F=C.node.parent,F==null))return!1;if(F.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 O=k.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let P=C.node.id,{name:M}=O;if(M==="useRef"&&P.type==="Identifier")return!0;if(Pr(O)&&P.type==="Identifier"){for(let L of T.references)L!==P&&d.add(L.identifier);return!0}else if(M==="useState"||M==="useReducer"){if(P.type==="ArrayPattern"&&P.elements.length===2&&R(T.identifiers)){if(P.elements[1]===T.identifiers[0]){if(M==="useState"){let L=T.references,pe=0;for(let Se=0;Se<L.length;Se++){if(L[Se].isWrite()&&pe++,pe>1)return!1;p.set(L[Se].identifier,P.elements[0])}}return!0}else if(P.elements[0]===T.identifiers[0]){if(M==="useState"){let L=T.references;for(let pe=0;pe<L.length;pe++)c.add(L[pe].identifier)}return!1}}}else if(M==="useTransition"&&P.type==="ArrayPattern"&&P.elements.length===2&&Array.isArray(T.identifiers)&&P.elements[1]===T.identifiers[0])return!0;return!1}function _(T){if(!R(T.defs))return!1;let C=T.defs[0];if(C==null||C.node==null||C.node.id==null)return!1;let k=C.node,F=w.childScopes,O=null,P;for(P=0;P<F.length;P++){let M=F[P],L=M.block;if(k.type==="FunctionDeclaration"&&L===k||k.type==="VariableDeclarator"&&L.parent===k){O=M;break}}if(O==null)return!1;for(P=0;P<O.through.length;P++){let M=O.through[P];if(M.resolved!=null&&I.has(M.resolved.scope)&&!G(M.resolved))return!1}return!0}let G=y(N,m),B=y(_,f),Q=new Map;function ee(T){let C=T.from,k=!1;for(;C.block!==u;)C.type==="function"&&(k=C.block.parent!=null&&C.block.parent.type==="ReturnStatement"),C=C.upper;return k}let Y=new Map,me=new Map;ke(S);function ke(T){for(let C of T.references){if(!C.resolved||!I.has(C.resolved.scope))continue;let k=st(u,C.identifier),F=rn(k),O=Te(F,me);if(A&&F.type==="Identifier"&&(F.parent.type==="MemberExpression"||F.parent.type==="OptionalMemberExpression")&&!F.parent.computed&&F.parent.property.type==="Identifier"&&F.parent.property.name==="current"&&ee(C)&&Q.set(O,{reference:C,dependencyNode:F}),F.parent.type==="TSTypeQuery"||F.parent.type==="TSTypeReference")continue;let P=C.resolved.defs[0];if(P!=null&&!(P.node!=null&&P.node.init===u.parent)&&P.type!=="TypeParameter")if(Y.has(O))Y.get(O).references.push(C);else{let M=C.resolved,L=G(M)||B(M);Y.set(O,{isStable:L,references:[C]})}}for(let C of T.childScopes)ke(C)}Q.forEach(({reference:T,dependencyNode:C},k)=>{let F=T.resolved.references,O=!1;for(let P=0;P<F.length;P++){let{identifier:M}=F[P],{parent:L}=M;if(L!=null&&L.type==="MemberExpression"&&!L.computed&&L.property.type==="Identifier"&&L.property.name==="current"&&L.parent.type==="AssignmentExpression"&&L.parent.left===L){O=!0;break}}O||s({node:C.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 re=new Set;function xe(T,C){re.has(C)||(re.add(C),s({node:T,message:`Assignments to the '${C}' variable from inside React Hook ${r(b)} 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(b)}.`}))}let le=new Set;if(Y.forEach(({isStable:T,references:C},k)=>{T&&le.add(k),C.forEach(F=>{F.writeExpr&&xe(F.writeExpr,k)})}),re.size>0)return;if(!x){let T=null;if(Y.forEach(({isStable:C,references:k},F)=>{T||k.forEach(O=>{if(T)return;let P=O.identifier;if(!p.has(P))return;let L=O.from;for(;L.type!=="function";)L=L.upper;L.block===u&&(T=F)})}),T){let{suggestedDependencies:C}=rt({dependencies:Y,declaredDependencies:[],stableDependencies:le,externalDependencies:new Set,isEffect:!0});s({node:b,message:`React Hook ${g} contains a call to '${T}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+C.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${C.join(", ")}]`,fix(k){return k.insertTextAfter(u,`, [${C.join(", ")}]`)}}]})}return}let Re=[],Ne=new Set;x.type!=="ArrayExpression"?s({node:x,message:`React Hook ${r(b)} 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.`}):x.elements.forEach(T=>{if(T===null)return;if(T.type==="SpreadElement"){s({node:T,message:`React Hook ${r(b)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}d.has(T)&&s({node:T,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(T)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(T)}\``,fix(O){return O.removeRange(T.range)}}]});let C;try{C=Te(T,me)}catch(O){if(/Unsupported node type/.test(O.message)){T.type==="Literal"?Y.has(T.value)?s({node:T,message:`The ${T.raw} literal is not a valid dependency because it never changes. Did you mean to include ${T.value} in the array instead?`}):s({node:T,message:`The ${T.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:T,message:`React Hook ${r(b)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let k=T;for(;k.type==="MemberExpression"||k.type==="OptionalMemberExpression"||k.type==="ChainExpression";)k=k.object||k.expression.object;let F=!w.through.some(O=>O.identifier===k);Re.push({key:C,node:T}),F||Ne.add(C)});let{suggestedDependencies:mr,unnecessaryDependencies:$e,missingDependencies:be,duplicateDependencies:Yt}=rt({dependencies:Y,declaredDependencies:Re,stableDependencies:le,externalDependencies:Ne,isEffect:A}),Ue=mr;if(Yt.size+be.size+$e.size===0){if(t)return;wr({declaredDependencies:Re,declaredDependenciesNode:x,componentScope:w,scope:S}).forEach(({construction:C,isUsedOutsideOfHook:k,depType:F})=>{let O=F==="function"?"useCallback":"useMemo",P=F==="function"?"definition":"initialization",M=`wrap the ${P} of '${C.name.name}' in its own ${O}() Hook.`,L=k?`To fix this, ${M}`:`Move it inside the ${g} callback. Alternatively, ${M}`,pe=F==="conditional"||F==="logical expression"?"could make":"makes",Se=`The '${C.name.name}' ${F} ${pe} the dependencies of ${g} Hook (at line ${x.loc.start.line}) change on every render. ${L}`,Xt;k&&C.type==="Variable"&&F==="function"&&(Xt=[{desc:`Wrap the ${P} of '${C.name.name}' in its own ${O}() Hook.`,fix(Bt){let[yr,gr]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Bt.insertTextBefore(C.node.init,yr),Bt.insertTextAfter(C.node.init,gr)]}}]),s({node:C.node,message:Se,suggest:Xt})});return}!A&&be.size>0&&(Ue=rt({dependencies:Y,declaredDependencies:[],stableDependencies:le,externalDependencies:Ne,isEffect:A}).suggestedDependencies);function dr(){if(Re.length===0)return!0;let T=Re.map(k=>k.key),C=T.slice().sort();return T.join(",")===C.join(",")}dr()&&Ue.sort();function Ke(T){let C=T.split("."),k="";for(let F=0;F<C.length;F++){if(F!==0){let O=C.slice(0,F+1).join("."),P=me.get(O)===!0;k+=P?"?.":"."}k+=C[F]}return k}function Qe(T,C,k,F){return T.size===0?null:(T.size>1?"":C+" ")+k+" "+(T.size>1?"dependencies":"dependency")+": "+kr(Array.from(T).sort().map(O=>"'"+Ke(O)+"'"))+`. Either ${F} ${T.size>1?"them":"it"} or remove the dependency array.`}let ue="";if($e.size>0){let T=null;if(Array.from($e.keys()).forEach(C=>{T===null&&C.endsWith(".current")&&(T=C)}),T!==null)ue=` Mutable values like '${T}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Ne.size>0){let C=Array.from(Ne)[0];S.set.has(C)||(ue=` Outer scope values like '${C}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ue&&be.has("props")){let T=Y.get("props");if(T==null)return;let C=T.references;if(!Array.isArray(C))return;let k=!0;for(let F=0;F<C.length;F++){let O=C[F],P=st(w.block,O.identifier);if(!P){k=!1;break}let M=P.parent;if(M==null){k=!1;break}if(M.type!=="MemberExpression"&&M.type!=="OptionalMemberExpression"){k=!1;break}}k&&(ue=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${g} call and refer to those specific props inside ${r(b)}.`)}if(!ue&&be.size>0){let T=null;be.forEach(C=>{if(T)return;let k=w.set.get(C),F=Y.get(C);if(F.references[0].resolved!==k)return;let O=k.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let P=!1,M;for(let L=0;L<F.references.length;L++)if(M=F.references[L].identifier,M!=null&&M.parent!=null&&(M.parent.type==="CallExpression"||M.parent.type==="OptionalCallExpression")&&M.parent.callee===M){P=!0;break}P&&(T=C)}),T!==null&&(ue=` If '${T}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ue&&be.size>0){let T=null;if(be.forEach(C=>{if(T!==null)return;let F=Y.get(C).references,O,P;for(let M=0;M<F.length;M++){for(O=F[M].identifier,P=O.parent;P!=null&&P!==w.block;){if(P.type==="CallExpression"){let L=p.get(P.callee);if(L!=null){if(L.name===C)T={missingDep:C,setter:P.callee.name,form:"updater"};else if(c.has(O))T={missingDep:C,setter:P.callee.name,form:"reducer"};else{let pe=F[M].resolved;if(pe!=null){let Se=pe.defs[0];Se!=null&&Se.type==="Parameter"&&(T={missingDep:C,setter:P.callee.name,form:"inlineReducer"})}}break}}P=P.parent}if(T!==null)break}}),T!==null)switch(T.form){case"reducer":ue=` You can also replace multiple useState variables with useReducer if '${T.setter}' needs the current value of '${T.missingDep}'.`;break;case"inlineReducer":ue=` If '${T.setter}' needs the current value of '${T.missingDep}', you can also switch to useReducer instead of useState and read '${T.missingDep}' in the reducer.`;break;case"updater":ue=` You can also do a functional update '${T.setter}(${T.missingDep.slice(0,1)} => ...)' if you only need '${T.missingDep}' in the '${T.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:x,message:`React Hook ${r(b)} has `+(Qe(be,"a","missing","include")||Qe($e,"an","unnecessary","exclude")||Qe(Yt,"a","duplicate","omit"))+ue,suggest:[{desc:`Update the dependencies array to be: [${Ue.map(Ke).join(", ")}]`,fix(T){return T.replaceText(x,`[${Ue.map(Ke).join(", ")}]`)}}]})}function h(u){let x=vr(u.callee,i);if(x===-1)return;let b=u.arguments[x],g=u.callee,A=sn(g).name,S=u.arguments[x+1],I=/Effect($|[^a-z])/g.test(A);if(!b){s({node:g,message:`React Hook ${A} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!I)){if(!S&&!I){(A==="useMemo"||A==="useCallback")&&s({node:g,message:`React Hook ${A} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(b.type){case"FunctionExpression":case"ArrowFunctionExpression":E(b,S,g,A,I);return;case"Identifier":if(!S||S.elements&&S.elements.some(N=>N&&N.type==="Identifier"&&N.name===b.name))return;let w=n(u).set.get(b.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,S,g,A,I);return;case"VariableDeclarator":let N=R.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":E(N,S,g,A,I);return}break}break;default:s({node:g,message:`React Hook ${A} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:g,message:`React Hook ${A} has a missing dependency: '${b.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${b.name}]`,fix(w){return w.replaceText(S,`[${b.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let u of e.sourceCode.getAllComments())if(Ar.test(u.value))return t=!0,{CallExpression:x=>h(x,!0)}}return{CallExpression:u=>h(u)}}};function rt({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,h)=>{let u=s(a,h);u.isUsed=!0,l(a,h,x=>{x.isSubtreeUsed=!0})}),t.forEach(({key:E})=>{let h=s(a,E);h.isSatisfiedRecursively=!0}),r.forEach(E=>{let h=s(a,E);h.isSatisfiedRecursively=!0});function s(E,h){let u=h.split("."),x=E;for(let b of u){let g=x.children.get(b);g||(g=i(),x.children.set(b,g)),x=g}return x}function l(E,h,u){let x=h.split("."),b=E;for(let g of x){let A=b.children.get(g);if(!A)return;u(A),b=A}}let p=new Set,c=new Set;m(a,p,c,E=>E);function m(E,h,u,x){E.children.forEach((b,g)=>{let A=x(g);if(b.isSatisfiedRecursively){b.isSubtreeUsed&&u.add(A);return}if(b.isUsed){h.add(A);return}m(b,h,u,S=>A+"."+S)})}let f=[],d=new Set,y=new Set;return t.forEach(({key:E})=>{c.has(E)?f.indexOf(E)===-1?f.push(E):y.add(E):d.add(E)}),p.forEach(E=>{f.push(E)}),{suggestedDependencies:f,unnecessaryDependencies:d,duplicateDependencies:y,missingDependencies:p}}function Ce(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 Ce(e.consequent)!=null||Ce(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Ce(e.left)!=null||Ce(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Ce(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Ce(e.expression);case"TSAsExpression":return Ce(e.expression)}return null}function wr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:i})=>{let s=r.variables.find(p=>p.name===i);if(s==null)return null;let l=s.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 p=Ce(l.node.init);if(p!=null)return[s,p]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[s,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function a(i){let s=!1;for(let l=0;l<i.references.length;l++){let p=i.references[l];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!on(t,p.identifier))return!0}return!1}return o.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:a(i)}))}function rn(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)?rn(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 Te(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=Te(e.object,t),n=Te(e.property,null),o=`${r}.${n}`;return it(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Te(e.object,t),n=Te(e.property,null),o=`${r}.${n}`;return it(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=Te(r.object,t),o=Te(r.property,null),a=`${n}.${o}`;return it(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function sn(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function vr(e,t){let r=sn(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=Te(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(n)?0:-1}else return-1}}function st(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),Fr(n,t))return n;if(on(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(tn(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(i=>{tn(i)&&(i.parent=n,r.push(i))}))}return null}function kr(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 tn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Fr(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 on(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Pr(e){return!1}import{AST_NODE_TYPES as We,ESLintUtils as ln}from"@typescript-eslint/utils";import ie from"typescript";import{z as Or}from"zod/v4";var Nr=ln.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="improved-no-unnecessary-condition",Dr=Or.object({}),Mr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],jr=new Set(Mr),ot={name:an,rule:Nr({name:an,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}}".'},schema:[$(Dr)]},defaultOptions:[{}],create(e){let t=ln.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(s){return s.type===We.UnaryExpression&&s.operator==="typeof"}function o(s){return s.flags&ie.TypeFlags.Any||s.flags&ie.TypeFlags.Unknown?null:s.flags&ie.TypeFlags.StringLike?["string"]:s.flags&ie.TypeFlags.NumberLike?["number"]:s.flags&ie.TypeFlags.BigIntLike?["bigint"]:s.flags&ie.TypeFlags.BooleanLike?["boolean"]:s.flags&ie.TypeFlags.ESSymbolLike?["symbol"]:s.flags&ie.TypeFlags.Undefined||s.flags&ie.TypeFlags.Void?["undefined"]:s.flags&ie.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&ie.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&ie.TypeFlags.NonPrimitive?["object"]:s.flags&ie.TypeFlags.Never?["never"]:null}function a(s){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(s),p=r.getTypeAtLocation(l.expression);if(p.flags&ie.TypeFlags.Any||p.flags&ie.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let f of p.types){let d=o(f);if(d)c.push(...d);else return null}return c}let m=o(p);return m?(c.push(...m),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(n(s.left)?(p=s.left,c=s.right.type===We.Literal&&typeof s.right.value=="string"?s.right.value:null):n(s.right)&&(p=s.right,c=s.left.type===We.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!Lr(c,jr))return;let m=a(p);if(!m)return;let f=s.operator==="!==",d=m.includes(c);m.length===1?d&&!f?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Fe(p,e),type:c}}):!d&&f?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Fe(p,e),type:Array.from(m)[0]}}):!d&&!f?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Fe(p,e),actualType:ze(m),conditionType:c}}):d&&f&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Fe(p,e),actualType:ze(m),conditionType:c}}):!d&&!f?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Fe(p,e),actualType:ze(m),conditionType:c}}):!d&&f&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Fe(p,e),type:ze(m)}})}return{BinaryExpression:i}}})};function ze(e){return Array.from(new Set(e)).join(" | ")||"never"}function Fe(e,t){let r=e.argument;return r.type===We.Identifier?r.name:t.sourceCode.getText(r)}function Lr(e,t){return t.has(e)}import{AST_NODE_TYPES as _r,ESLintUtils as $r}from"@typescript-eslint/utils";import{z as at}from"zod/v4";var Ur=$r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-call-with-explicit-generics",zr=at.object({functions:at.array(at.string())}),Wr=Ur({name:pn,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:[$(zr)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===_r.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),lt={name:pn,rule:Wr};import{AST_NODE_TYPES as Ve,ESLintUtils as Vr}from"@typescript-eslint/utils";var Hr=Vr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cn="no-call-with-inferred-generics",Jr=Hr({name:cn,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:o}=n;if(o.type!==Ve.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:i=1,allowAny:s,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(s&&!l)&&n.typeArguments?.params.some(c=>!s&&c.type===Ve.TSAnyKeyword||l&&c.type===Ve.TSTypeReference&&c.typeName.type===Ve.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),pt={name:cn,rule:Jr};import{ESLintUtils as Yr}from"@typescript-eslint/utils";var Xr=Yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-commented-out-code",Br=["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:"],qr=/^\s*return\s+/,Gr=/\w=("|'|`)/,Zr=/\w+:\s*('|"|`)/,Kr=/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,Qr=/\w+-\w+:/,ei=/\w+_\w+:/,ti=/\?\s+\w/,ni=/:\s+\w/,ri=/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,ii=/^\s*\d+[,}]/,si=/^\s*\[[^\]]*\][,}]/,oi=/^\s*\{[^}]*\}[,}]/,ai=/\.\w+\(/,li=/\[\w+\]/,pi=/^\s*(['"`]).+?\1\s*:/,ci=/^<[A-Z]\w*(\s|>|\/)/,ui=/^<[a-z]+(\s|>|\/)/,fi=/<[A-Z]\w*(\s.*)?>/,mi=/<\/[A-Z]\w*>/,di=/<[a-z]+(\s.*)?>/,yi=/<\/[a-z]+>/,gi=/^\s*[*\s]*$/,Si=/^[a-zA-Z]/,Ti=/^[A-Z][A-Za-z]*(?:\s+\d+)?(?:\s+[a-z]+)*:\s+[A-Za-z]/,hi=/```[\s\S]*?```/g,Ei=/`[^`]*`/g,un=/[a-zA-Z0-9]/,xi=/\.[A-Za-z_][A-Za-z0-9_]*\(/,bi=/[{}[\]()`=<>]/,Ci=/:\s*(['"`[{(]|\w+\s*=>)/,Ii=/\bif\s*\(|\belse\b|=>/,q={returnStatement:qr,stringAssignment:Gr,objectPropertyWithQuotes:Zr,computedPropertyAssignment:Kr,kebabCaseProperty:Qr,snakeCaseProperty:ei,ternaryOperator:ti,colonWithWord:ni,quotedString:ri,numberWithComma:ii,arrayWithComma:si,objectWithComma:oi,methodCall:ai,arrayAccess:li,quotedPropertyKey:pi,jsxSelfClosing:ci,jsxElement:ui,jsxOpeningTag:fi,jsxClosingTag:mi,htmlOpeningTag:di,htmlClosingTag:yi,jsdocComment:gi};function Ri(e){if(e.includes(":")){let r=e.split(":")[0]?.trim();if(r&&Si.test(r)&&r.includes(" "))return!0}let t=e.trim();return t.length===0||xi.test(t)||bi.test(t)||Ci.test(t)||Ii.test(t)?!1:!!(t.includes(":")&&Ti.test(t))}var Ai=[") {","return;",q.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",q.stringAssignment,");",q.objectPropertyWithQuotes,q.computedPropertyAssignment,q.kebabCaseProperty,q.snakeCaseProperty,"&&","||","()",q.ternaryOperator,q.colonWithWord,q.quotedString,q.numberWithComma,q.arrayWithComma,q.objectWithComma,q.methodCall,q.arrayAccess,"?.(","??","=>",q.quotedPropertyKey],wi=["/>","</",q.jsxSelfClosing,q.jsxElement,q.jsxOpeningTag,q.jsxClosingTag,q.htmlOpeningTag,q.htmlClosingTag],fn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],vi=Xr({name:mn,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,o){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")||q.jsdocComment.test(n))return!1;for(let i of fn)if(a.startsWith(i))return!1;if(n.includes("https://")||Ri(a))return!1;if(o==="Block"){for(let i of wi)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 Br)if(a.startsWith(i))return{wrongPattern:i};for(let i of Ai)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,o){let a=n,i=a.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let p=a.split(hi);p.some(m=>un.test(m))&&(a=p.join(""))}if(!a.includes("`"))return a;let s=a.split(Ei);return s.some(p=>un.test(p))?s.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let i=r(a.value,a.type),s=t(i,a.type);s&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:fn.join(", ")}})}}}}}),ct={name:mn,rule:vi};import{ESLintUtils as ki,TSESTree as Fi}from"@typescript-eslint/utils";var Pi=ki.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="no-default-export",Oi=Pi({name:dn,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===Fi.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ut={name:dn,rule:Oi};import{ESLintUtils as Ni}from"@typescript-eslint/utils";var Di=Ni.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yn="no-leaked-text-in-jsx",Mi=[",",";","[","]","(",")"],ji=Di({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="";Mi.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:ji};import{AST_NODE_TYPES as De,ESLintUtils as Li}from"@typescript-eslint/utils";var _i=Li.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sn="no-non-camel-case-functions",$i=/^(\$?[a-z][a-zA-Z0-9]*)$/;function gn(e){if(e.typeName.type!==De.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===De.Identifier&&t.name==="JSX"&&r.name==="Element"}var Ui=_i({name:Sn,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&&!$i.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===De.TSTypeReference?gn(r):r.type===De.TSUnionType&&r.types.some(o=>o.type===De.TSTypeReference&&gn(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),mt={name:Sn,rule:Ui};import{ESLintUtils as Wi,TSESTree as H}from"@typescript-eslint/utils";import{AST_NODE_TYPES as Tn}from"@typescript-eslint/utils";function Pe(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Pe(e.parent,t,r===1/0?r:r-1)}function*dt(e){yield e,e.parent&&(yield*dt(e.parent))}function yt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function En(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Tn.Property&&a.identifiers[0].parent.key.type===Tn.Identifier&&a.identifiers[0].parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}function hn(e){return e===null||typeof e!="object"||!("type"in e)?!1:typeof e.type=="string"}function zi(e,t){return e[t]}function xn(e,t,r){let n=r.visitorKeys,o=new Set;function a(i){if(o.has(i))return!1;if(o.add(i),t(i)===!0)return!0;let l=n[i.type];if(l)for(let p of l){let c=zi(i,p);if(c){if(Array.isArray(c)){for(let m of c)if(hn(m)&&a(m))return!0}else if(hn(c)&&a(c))return!0}}return!1}a(e)}var Vi=Wi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bn="no-optional-root-props",Hi=Vi({name:bn,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 s of dt(i.identifier)){if("returnType"in s||s.type===H.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=s.parent;if(!l)return!1;if(l.type===H.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===H.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===H.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let c=Pe(l.parent.parent,H.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let m=He(c,e.sourceCode);return m?!(m.parent.type===H.AST_NODE_TYPES.CallExpression&&m.parent.callee.type===H.AST_NODE_TYPES.Identifier&&m.parent.callee.name==="memo"):!1}if(s.type===H.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===H.AST_NODE_TYPES.ArrowFunctionExpression){let p=Pe(l,H.AST_NODE_TYPES.VariableDeclaration);return p?!!He(p,e.sourceCode):!1}if(l.type===H.AST_NODE_TYPES.FunctionDeclaration)return!!He(l,e.sourceCode)}return!1}function r(n){n.key.type!==H.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Pe(n,H.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let i=e.sourceCode.getText(a);return o.replaceText(a,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===H.AST_NODE_TYPES.TSTypeLiteral&&!(Je(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===H.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Je(n)||!t(n)))for(let o of n.body.body)o.type===H.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==H.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==H.AST_NODE_TYPES.TSTypeLiteral)return;let a=Pe(n.parent,H.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let i=He(a,e.sourceCode);if(!(!i||i.parent.type===H.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===H.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of o.members)l.type===H.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Je(e){return e?e.parent?.type===H.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===H.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function He(e,t){if(Je(e))return;let r;if(e.type===H.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===H.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===H.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(i=>i.identifiers.includes(r));if(!o)return;let a=o.references.filter(i=>i.identifier!==r);if(!(a.length!==1||!a[0])&&!Je(a[0].identifier.parent.parent))return a[0].identifier}var gt={name:bn,rule:Hi};import{AST_NODE_TYPES as Ye}from"@typescript-eslint/utils";var Me=V({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===Ye.Identifier?t.has(n.name):n.type===Ye.MemberExpression?r(n.object):!1:!1}return{ImportDeclaration(n){for(let o of n.specifiers)t.add(o.local.name)},ExportNamedDeclaration(n){if(n.source){e.report({node:n,messageId:"noReexport"});return}if(n.declaration?.type===Ye.VariableDeclaration)for(let o of n.declaration.declarations)r(o.init)&&e.report({node:n,messageId:"noReexport"});n.specifiers.length>0&&e.report({node:n,messageId:"noReexport"})},ExportDefaultDeclaration(n){n.declaration.type===Ye.Identifier&&t.has(n.declaration.name)&&e.report({node:n,messageId:"noReexport"})},ExportAllDeclaration(n){e.report({node:n,messageId:"noReexport"})}}}});import{ESLintUtils as Ji}from"@typescript-eslint/utils";import St from"path";import{z as Ie}from"zod/v4";var Yi=Ji.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cn="no-relative-imports",Xi=Ie.object({find:Ie.string(),replacement:Ie.string()}),Bi=Ie.object({aliases:Ie.array(Xi),rootDir:Ie.string().optional(),allowNotFoundAliases:Ie.boolean().optional(),_dev_simulateFileName:Ie.string().optional()}),qi=Yi({name:Cn,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:[$(Bi)]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function o(i,s){let l=St.dirname(s);return St.resolve(l,i)}function a(i){let s=t.rootDir??process.cwd(),l=St.relative(s,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let m=l.replace(c,p);return{alias:p,newPath:m}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!n(s))return;let l=o(s,r),p=a(l);!p&&t.allowNotFoundAliases||e.report({node:i,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(i.source,`'${p.newPath}'`):void 0})}}}}),Tt={name:Cn,rule:qi};import{AST_NODE_TYPES as Z}from"@typescript-eslint/utils";import{z as In}from"zod/v4";var Gi=In.object({customMessage:In.string().optional()}),ht=V({name:"no-static-style-prop",meta:{type:"problem",docs:{description:"Prevent using static style props in JSX, only dynamic values should be allowed"},schema:[$(Gi)],messages:{noStaticStyleProp:"Static style props are not allowed use css instead.{{customMessage}}"}},defaultOptions:[{}],create(e,[t]){function r(n){switch(n.type){case Z.Literal:return!0;case Z.ObjectExpression:return n.properties.every(o=>o.type===Z.Property?o.computed||o.value.type===Z.Identifier&&o.key.type===Z.Identifier&&o.key.name===o.value.name?!1:r(o.value):!1);case Z.ArrayExpression:return n.elements.every(o=>o?o.type===Z.SpreadElement?!1:r(o):!0);case Z.TemplateLiteral:return n.expressions.length===0;case Z.ConditionalExpression:case Z.LogicalExpression:case Z.BinaryExpression:case Z.UnaryExpression:case Z.CallExpression:case Z.MemberExpression:case Z.Identifier:case Z.ArrowFunctionExpression:case Z.FunctionExpression:return!1;default:return!1}}return{JSXAttribute(n){if(n.name.type===Z.JSXIdentifier&&n.name.name==="style"&&n.value){let o=null;n.value.type===Z.JSXExpressionContainer?n.value.expression.type!==Z.JSXEmptyExpression&&(o=n.value.expression):n.value.type===Z.Literal&&(o=n.value),o&&r(o)&&e.report({node:n,messageId:"noStaticStyleProp",data:{customMessage:t.customMessage?` ${t.customMessage}`:""}})}}}}});import{AST_NODE_TYPES as Xe}from"@typescript-eslint/utils";import*as we from"zod/v4";var Zi=we.object({alternativeMsgs:we.object({inArrayFind:we.string().optional(),inArrayFilter:we.string().optional()}).optional(),__dev_simulateFileName:we.string().optional()});function Ki(e){return e.typeAnnotation.type!==Xe.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}var Qi=/(typeGuards|type-guards)\.(ts|tsx)$/;function es(e){return Qi.test(e)}function ts(e){let t=e.parent;for(;t;){if(t.type===Xe.CallExpression&&t.callee.type===Xe.MemberExpression&&t.callee.property.type===Xe.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var Et=V({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:[$(Zi)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(es(r))return{};function n(o){if(!Ki(o))return;let a=ts(o);if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let s=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:s,data:{message:i}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as Oe}from"@typescript-eslint/utils";var ns="no-unnecessary-async-on-jsx-props";function rs(e){if(e.body.type!==Oe.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==Oe.ExpressionStatement?!1:r.expression.type===Oe.AwaitExpression}var xt=V({name:ns,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){rs(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let o=e.sourceCode,a=[],i=o.getFirstToken(r,l=>l.value==="async");if(i){let l=o.getTokenAfter(i);l?a.push(n.replaceTextRange([i.range[0],l.range[0]],"")):a.push(n.remove(i))}function s(l){if(l.type===Oe.AwaitExpression){let p=o.getFirstToken(l);if(p&&p.value==="await"){let c=o.getTokenAfter(p);c?a.push(n.replaceTextRange([p.range[0],c.range[0]],"")):a.push(n.remove(p))}}if(l.type===Oe.BlockStatement)for(let p of l.body)s(p);else l.type===Oe.ExpressionStatement&&s(l.expression)}return s(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as je,ESLintUtils as An}from"@typescript-eslint/utils";import*as bt from"typescript";import Le from"zod/v4";var is=An.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rn="no-unnecessary-casting",ss=Le.object({additionalCastFunctions:Le.array(Le.object({name:Le.string(),expectedType:Le.enum(["string","number"])})).optional()}),Ct={name:Rn,rule:is({name:Rn,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:[$(ss)],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=An.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function i(c,m){switch(c.type){case je.Literal:return m==="number"?typeof c.value=="number":typeof c.value=="string";case je.TemplateLiteral:return m==="string";case je.UnaryExpression:return m==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function s(c,m){return m==="number"?!!(c.flags&bt.TypeFlags.NumberLike):!!(c.flags&bt.TypeFlags.StringLike)}function l(c,m){return f=>f.replaceText(c,e.sourceCode.getText(m))}function p(c){if(!a||c.arguments.length!==1)return;let m=c.arguments[0];if(!m||m.type===je.SpreadElement)return;let{callee:f}=c;if(f.type!==je.Identifier)return;let d=f.name,y=n.find(h=>h.name===d);if(!y)return;if(i(m,y.expectedType)||s(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(m)),y.expectedType)){let h,u;d==="Number"?h="unnecessaryNumberCasting":d==="String"?h="unnecessaryStringCasting":(h="unnecessaryCustomCasting",u={name:y.name,type:y.expectedType}),e.report({node:c,messageId:h,...u?{data:u}:{},fix:l(c,m)})}}return{CallExpression:p}}})};import{AST_NODE_TYPES as Be}from"@typescript-eslint/utils";import*as de from"zod/v4";var os=de.object({methods:de.union([de.array(de.string()),de.literal("array")])}),It=V({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:[$(os)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(s){return Array.isArray(r)?r.includes(s):n.has(s)}function a(s){let{callee:l}=s;if(l.type===Be.MemberExpression){let p=l.property;if(p.type===Be.Identifier)return p.name}return null}function i(s,l){if(s.type!==Be.Identifier||!s.typeAnnotation)return;let p=l.parent;if(p.type===Be.CallExpression){let c=a(p);c&&o(c)&&p.arguments.indexOf(l)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(f){return s.typeAnnotation?f.remove(s.typeAnnotation):null}})}}return{ArrowFunctionExpression(s){for(let l of s.params)i(l,s)},FunctionExpression(s){for(let l of s.params)i(l,s)}}}});import{AST_NODE_TYPES as ae}from"@typescript-eslint/utils";var Rt=V({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===ae.ObjectPattern||!t.init||t.init.type!==ae.ObjectExpression||t.id.type===ae.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ae.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===ae.Property&&i.key.type===ae.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==ae.Identifier)return;let n=as(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(i=>i.type!==ae.Property?!1:i.value.type===ae.FunctionExpression),a=new Set;for(let i of n){if(i.identifier.parent.type!==ae.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===ae.Literal&&typeof s.property.value=="string")a.add(s.property.value);else return;else{if(s.property.type!==ae.Identifier)return;a.add(s.property.name)}if(s.parent.type===ae.CallExpression&&o)return}for(let[i,s]of r)a.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function as(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as X,ESLintUtils as ls}from"@typescript-eslint/utils";import{z as ve}from"zod/v4";var ps=ve.object({selectors:ve.array(ve.object({name:ve.string(),selectorProp:ve.string().optional(),selectorArgPos:ve.number().optional(),returnProp:ve.string().optional()}))}),cs=ls.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wn="no-unused-selected-values",At={name:wn,rule:cs({name:wn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[$(ps)]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===X.CallExpression&&(a=o.init),!a)return;let i=fs(a);if(!i)return;let s=n.get(i);if(!s)return;let l=us(a,s.selectorArgPos??0,s.selectorProp);if(!l)return;let p=ms(l);if(!p)return;let c=vn(p.properties,void 0);if(!c)return;if(o.id.type===X.ObjectPattern){let d=vn(o.id.properties,s.returnProp);if(!d)return;for(let[y,E]of c)d.has(y)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:y}});return}if(o.id.type!==X.Identifier||s.returnProp)return;let m=ds(o,e.sourceCode);if(m.length===0)return;let f=new Set;for(let d of m){if(d.identifier.parent.type!==X.MemberExpression)return;let y=d.identifier.parent.property;if(y.type!==X.Identifier)return;f.add(y.name)}for(let[d,y]of c)f.has(d)||e.report({node:y,messageId:"unusedSelectedValue",data:{name:d}})}}}})};function us(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===X.ArrowFunctionExpression||n.type===X.FunctionExpression)return n;if(r&&n.type===X.ObjectExpression){let o=n.properties.find(i=>i.type===X.Property&&i.key.type===X.Identifier&&i.key.name===r);if(o?.type!==X.Property)return null;let a=o.value;if(a.type===X.ArrowFunctionExpression||a.type===X.FunctionExpression)return a}return null}function fs(e){return e.callee.type===X.Identifier?e.callee.name:e.callee.type===X.MemberExpression&&e.callee.property.type===X.Identifier?e.callee.property.name:null}function ms(e){if(e.body.type===X.ObjectExpression)return e.body;if(e.body.type===X.BlockStatement){let t=e.body.body.filter(r=>r.type===X.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==X.ObjectExpression?null:t[0].argument}return null}function vn(e,t){let r=e;if(t){let o=e.find(a=>a.type===X.Property&&a.key.type===X.Identifier&&a.key.name===t);if(o?.type!==X.Property||o.value.type!==X.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==X.Property||o.key.type!==X.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function ds(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as J}from"@typescript-eslint/utils";var wt=V({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===J.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let s=ys(a);s&&(n=s);return}let i=gs(a,e.sourceCode);if(i){o=!0;for(let s of i)n.delete(s);if(n.size!==0)for(let[s,l]of n)e.report({node:l,messageId:"unusedField",data:{name:s}})}}}}});function ys(e){if(!(e.callee.type===J.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==J.ObjectExpression)return null;let n=yt(r.properties,a=>a.type!==J.Property||a.key.type!==J.Identifier||a.key.name!=="initialConfig"?null:a.value.type===J.ObjectExpression?a.value:a.value.type===J.ArrowFunctionExpression||a.value.type===J.FunctionExpression?Ss(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===J.Property&&a.key.type===J.Identifier&&o.set(a.key.name,a);return o}function gs(e,t){if(!(e.callee.type===J.Identifier&&e.callee.name==="useFormState")||e.parent.type!==J.VariableDeclarator||e.parent.id.type!==J.ObjectPattern||!yt(e.parent.id.properties,i=>i.type===J.Property&&i.key.type===J.Identifier&&i.key.name==="formFields"&&i))return null;let o=En(e.parent,"formFields",t),a=new Set;for(let{identifier:i}of o){if(i.type!==J.Identifier||i.parent.type===J.Property&&i.parent.parent.type===J.ObjectExpression&&i.parent.parent.parent.type===J.ReturnStatement||i.parent.type===J.ReturnStatement)return null;if(i.parent.type===J.MemberExpression){if(i.parent.object.type!==J.Identifier||i.parent.property.type!==J.Identifier)return null;a.add(i.parent.property.name)}}return a}function Ss(e){if(e.body.type===J.ObjectExpression)return e.body;if(e.body.type===J.BlockStatement){let t=e.body.body.filter(r=>r.type===J.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==J.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as z,ESLintUtils as Ts}from"@typescript-eslint/utils";import{z as qe}from"zod/v4";var hs=Ts.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function kn(e){let t=[];for(let r of e.members)r.type===z.TSPropertySignature&&r.key.type===z.Identifier&&t.push([r.key.name,r]);return t}function Fn(e,...t){for(let r of t)e.set(...r);return e}var Es=qe.object({forceCheckOnFCPropTypesWithName:qe.array(qe.string()).optional(),alwaysCheckFunctionOptionTypes:qe.boolean().optional()}),Pn="no-unused-type-props-in-args",vt=null,xs=hs({name:Pn,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:[$(Es)],fixable:"code"},defaultOptions:[{alwaysCheckFunctionOptionTypes:!0}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r,alwaysCheckFunctionOptionTypes:n=!0}=t;r&&!vt&&(vt=r.map(l=>new RegExp(l)));function o(l,p,c,m,f=!0,d=!1){let y=c.name,E=e.sourceCode.getScope(p).references.find(g=>g.identifier.name===y)?.resolved,h=l&&vt?.some(g=>g.test(y)),u=d&&n;if(!E||!h&&E.references.filter(g=>g.isTypeReference).length>1||!E.defs[0])return;let x=E.defs[0].node,b=x.parent?.type===z.ExportNamedDeclaration;if(!(f&&b&&!u)){if(x.type===z.TSTypeAliasDeclaration){a(l,p,m,x.typeAnnotation,!0,d);return}if(x.type===z.TSInterfaceDeclaration){a(l,p,m,x.body,!0,d);return}}}function a(l,p,c,m,f,d=!1){if(m.type===z.TSInterfaceBody){for(let y of m.body)y.type===z.TSPropertySignature&&y.key.type===z.Identifier&&c.set(y.key.name,y);return}if(m.type===z.TSTypeLiteral){Fn(c,...kn(m));return}if(m.type===z.TSIntersectionType){for(let y of m.types)a(l,p,c,y,!0,d);return}f||m.type===z.TSTypeReference&&m.typeName.type===z.Identifier&&o(l,p,m.typeName,c,!0,d)}function i(l,p,c,m=!1){for(let f of c)if(f.type===z.ObjectPattern&&f.typeAnnotation){let d=new Map;if(a(l,p,d,f.typeAnnotation.typeAnnotation,!1,m),d.size===0)continue;s(f,d)}else f.type===z.AssignmentPattern&&f.left.type===z.ObjectPattern&&i(l,p,[f.left],m)}function s(l,p){let c=[];if(l.properties.at(-1)?.type===z.RestElement)return;for(let y of l.properties)y.type===z.Property&&y.key.type===z.Identifier&&c.push(y.key.name);let f=[],d=[];for(let[y,E]of p)c.includes(y)||(d.push(y),f.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,E]of f.entries())e.report({...E,fix:y===f.length-1?h=>{let u=l.properties.at(-1),x=d.join(", ");return u?u.type===z.RestElement?null:h.insertTextAfter(u,`, ${x}`):h.insertTextBeforeRange([l.range[0]+1,l.range[1]],x)}:void 0})}return{VariableDeclaration(l){let p=l.declarations[0],c=new Map,m=p.id.type===z.Identifier&&p.id.typeAnnotation?.typeAnnotation.type===z.TSTypeReference&&p.id.typeAnnotation.typeAnnotation.typeName.type===z.Identifier&&p.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&p.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(m){if(m.type===z.TSTypeReference&&m.typeName.type===z.Identifier)o(!0,l,m.typeName,c,!1);else if(m.type===z.TSTypeLiteral)Fn(c,...kn(m));else if(m.type===z.TSIntersectionType)for(let f of m.types)f.type===z.TSTypeReference&&f.typeName.type===z.Identifier?o(!0,l,f.typeName,c,!1):a(!0,l,c,f,!0);if(c.size!==0&&p.init?.type===z.ArrowFunctionExpression){let f=p.init.params[0];if(!f){e.report({node:p.init,messageId:"missingComponentParam"});return}f.type===z.ObjectPattern&&s(f,c)}}},FunctionDeclaration(l){i(!1,l,l.params,n)},ArrowFunctionExpression(l){i(!1,l,l.params,n)}}}}),kt={name:Pn,rule:xs};import{AST_NODE_TYPES as fe}from"@typescript-eslint/utils";var Ft=V({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===fe.Identifier?t.has(n.callee.name):n.callee.type===fe.MemberExpression&&n.callee.object.type===fe.Identifier&&n.callee.property.type===fe.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let o of n.specifiers)o.type===fe.ImportSpecifier&&o.imported.type===fe.Identifier&&o.imported.name==="useRef"&&t.add(o.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===fe.CallExpression&&r(n.init)&&n.id.type===fe.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let i=!1;for(let s of a.references){let p=s.identifier.parent;if(p!==n&&!(p.type===fe.JSXExpressionContainer&&p.parent.type===fe.JSXAttribute&&p.parent.name.type===fe.JSXIdentifier&&p.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 Pt,ESLintUtils as bs}from"@typescript-eslint/utils";var Cs=bs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nn="prefer-named-functions",On=new Map,Is=Cs({name:Nn,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=On.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),On.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Pt.ArrowFunctionExpression&&n.id.type===Pt.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Pt.BlockStatement)return;let a=n.parent,i=n.init.params,s=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(a,`${l.async?"async ":""}function ${o}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),Ot={name:Nn,rule:Is};import{AST_NODE_TYPES as j}from"@typescript-eslint/utils";import{z as he}from"zod/v4";var Rs=he.object({disallowedFunctions:he.array(he.object({name:he.string(),allowUsingWithArgs:he.boolean().optional(),hookAlternative:he.string().optional(),message:he.string().optional(),allowUseInside:he.array(he.string()).optional()}))}),As=/^use[A-Z]/,ws=/^[A-Z]/;function Ge(e){return As.test(e)}function Dn(e){return ws.test(e)}function vs(e){return e.type===j.Identifier?Ge(e.name):e.type===j.MemberExpression&&e.property.type===j.Identifier?Ge(e.property.name):!1}function Mn(e,t){return e.type===j.Identifier?e.name===t:e.type===j.MemberExpression&&e.object.type===j.Identifier&&e.property.type===j.Identifier?e.object.name==="React"&&e.property.name===t:!1}function jn(e){return!!(e.parent&&e.parent.type===j.CallExpression&&Mn(e.parent.callee,"forwardRef"))}function Ln(e){return!!(e.parent&&e.parent.type===j.CallExpression&&Mn(e.parent.callee,"memo"))}function Nt(e){if(e.type===j.FunctionDeclaration||e.type===j.FunctionExpression&&e.id)return e.id||void 0;if(e.type===j.FunctionExpression||e.type===j.ArrowFunctionExpression){if(e.parent.type===j.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===j.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===j.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===j.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function ks(e){let t=e.parent,r=!1;for(;t;){if(t.type===j.FunctionDeclaration||t.type===j.FunctionExpression||t.type===j.ArrowFunctionExpression){let n=Nt(t);if(n&&n.type===j.Identifier){if(Dn(n.name)||Ge(n.name))return!r;r=!0}else{if(jn(t)||Ln(t))return!r;if(t.parent.type===j.CallExpression){let o=t.parent;vs(o.callee)||(r=!0)}else t.parent.type===j.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function _n(e){return e.callee.type===j.Identifier?e.callee.name:e.callee.type===j.MemberExpression&&e.callee.property.type===j.Identifier?e.callee.property.name:null}function Fs(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===j.FunctionDeclaration||r.type===j.FunctionExpression||r.type===j.ArrowFunctionExpression){let n=Nt(r);if(n&&n.type===j.Identifier&&t.includes(n.name))return!0}else if(r.type===j.CallExpression){let n=_n(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Ps(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===j.Identifier&&t.name==="undefined")}function Os(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===j.FunctionDeclaration||n.type===j.FunctionExpression||n.type===j.ArrowFunctionExpression){let o=Nt(n);if(o&&o.type===j.Identifier){if(Dn(o.name)||Ge(o.name)){r=!0;break}}else if(jn(n)||Ln(n)){r=!0;break}}n=n.parent}return r?t.length===0?ks(e):!Fs(e,t):!1}var Dt=V({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:[$(Rs)],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=_n(o);if(!a)return;let i=n.get(a);if(!i||i.allowUsingWithArgs&&Ps(o))return;let s=i.allowUseInside||[];Os(o,s)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:l=>{let p=i.hookAlternative;return p?o.callee.type===j.Identifier?l.replaceText(o.callee,p):o.callee.type===j.MemberExpression&&o.callee.property.type===j.Identifier?l.replaceText(o.callee.property,p):null:null}}]:[]})}}}});import{AST_NODE_TYPES as K,AST_TOKEN_TYPES as $n,ESLintUtils as Ns}from"@typescript-eslint/utils";import Mt from"zod/v4";var Ds=Ns.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zn="prefer-single-line-if",Ms=Mt.object({maxLineLength:Mt.number().optional(),maxNonSimpleConditionLength:Mt.number().optional()}),js=Ds({name:zn,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:[$(Ms)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==K.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===K.ReturnStatement){if(!Vn(a))return}else if(!(a.type===K.ContinueStatement||a.type===K.BreakStatement))return;if(n.test.type===K.LogicalExpression||n.test.type===K.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let m=Un(n.test);if(!m&&n.test.type===K.UnaryExpression&&n.test.operator==="!"){let f=n.test.argument;Un(f)&&(m=!0)}if(m&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let s=r.getText(a);if(i.includes(`
16
+ `))return;let l=r.getTokenAfter(n);if(l&&l.type===$n.Punctuator&&l.value==="}"){let m=r.getTokenAfter(l);if(m&&m.type===$n.Keyword&&(m.value==="else"||m.value==="catch"))return}let p=Ls(r,n),c=`if (${i}) ${s}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:m=>m.replaceText(n,c)})}}}});function Un(e){return e.type===K.CallExpression||e.type===K.BinaryExpression||e.type===K.MemberExpression&&Wn(e)}function Wn(e){return e.object.type===K.MemberExpression?Wn(e.object):e.object.type!==K.Identifier}function Ls(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Vn(e){if(!e.argument)return!0;let t=e.argument;return t.type===K.ArrayExpression&&t.elements.length===0||t.type===K.ObjectExpression&&t.properties.length===0||t.type===K.Literal||t.type===K.Identifier||t.type===K.TemplateLiteral||t.type===K.TaggedTemplateExpression?!0:t.type===K.CallExpression?t.arguments.length===0:t.type===K.UnaryExpression?Vn(t):!1}var jt={name:zn,rule:js};import{AST_NODE_TYPES as D,ESLintUtils as _s}from"@typescript-eslint/utils";import{z as Hn}from"zod/v4";var $s=_s.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zn="react-compiler-extra",Us=Hn.object({runOnlyWithEnableCompilerDirective:Hn.boolean().optional()}),zs=/eslint +react-compiler\/react-compiler: +\["error/;function Kn(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 ye(e){if(!e)return!1;switch(e.type){case D.JSXElement:case D.JSXFragment:return!0;case D.ConditionalExpression:return ye(e.consequent)||ye(e.alternate);case D.LogicalExpression:return e.operator==="&&"?ye(e.right):e.operator==="||"?ye(e.left)||ye(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&&ye(t))return!0;return!1;default:return!1}}function Ws(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 Vs=/^[A-Z][a-zA-Z0-9]*$/;function Jn(e){return Vs.test(e)}function Yn(e){return e.startsWith("use")&&e.length>3}function Xn(e,t,r){return r&&Ws(r)?t?Jn(t.name):e.type===D.FunctionDeclaration&&e.id?Jn(e.id.name):!0:!!(t&&Yn(t.name)||e.type===D.FunctionDeclaration&&e.id&&Yn(e.id.name))}function Bn(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 Hs(e,t){let r={containsJSX:!1,containsHookCalls:!1};return xn(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:Kn(n.callee)&&(r.containsHookCalls=!0),ye(n)&&(r.containsJSX=!0);break;case D.ReturnStatement:n.argument&&ye(n.argument)&&(r.containsJSX=!0);break;case D.VariableDeclarator:n.init&&ye(n.init)&&(r.containsJSX=!0);break;case D.AssignmentExpression:ye(n.right)&&(r.containsJSX=!0);break}},t),r}function qn(e,t){let r=e.body,n=Hs(r,t);return n.containsJSX||n.containsHookCalls}var Js=/\bthis[.[]/;function Gn(e){return Js.test(e)}var Ys=$s({name:Zn,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 or call other hooks for optimal React compiler detection.",addUseMemoDirective:'Add "use memo" directive to opt into React compiler memoization'},hasSuggestions:!0,schema:[$(Us)]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(zs.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let i of a.properties)if(i.type===D.Property&&i.method&&i.value.type===D.FunctionExpression){let s=e.sourceCode,l=s.getText(i.key),p=i.value,c=s.getText(p.body);if(Gn(c))e.report({node:i,messageId:"thisKeywordInMethod"});else{let m=p.params.map(d=>s.getText(d)).join(", "),f="";p.generator?f=`${l}: function* (${m}) ${c}`:f=`${l}: (${m}) => ${c}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:d=>d.replaceText(i,f)})}}}function o(a){for(let i of a.properties)if(i.type===D.Property&&i.value.type===D.ObjectExpression){for(let s of i.value.properties)if(s.type===D.Property&&s.method&&s.value.type===D.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Gn(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Kn(a.callee))for(let i of a.arguments){if(i.type===D.ObjectExpression&&(n(i),o(i)),i.type===D.ArrowFunctionExpression&&(i.body.type===D.ObjectExpression&&(n(i.body),o(i.body)),i.body.type===D.BlockStatement))for(let s of i.body.body)s.type===D.ReturnStatement&&s.argument?.type===D.ObjectExpression&&(n(s.argument),o(s.argument));if(i.type===D.FunctionExpression)for(let s of i.body.body)s.type===D.ReturnStatement&&s.argument?.type===D.ObjectExpression&&(n(s.argument),o(s.argument))}},VariableDeclarator(a){if(a.id.type===D.Identifier&&a.init&&(a.init.type===D.ArrowFunctionExpression||a.init.type===D.FunctionExpression)){let i=a.init,s=a.id,l=a.id.typeAnnotation;if(Xn(i,s,l)){let p=qn(i,e.sourceCode),c=Bn(i);!p&&!c&&e.report({node:i,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(m){if(i.body.type===D.BlockStatement){let f=i.body.range[0]+1;return m.insertTextAfterRange([f,f],`
17
+ "use memo"
18
+ `)}return null}}]})}}},FunctionDeclaration(a){if(Xn(a)){let i=qn(a,e.sourceCode),s=Bn(a);!i&&!s&&e.report({node:a,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(l){let p=a.body.range[0]+1;return l.insertTextAfterRange([p,p],`
19
+ "use memo"
20
+ `)}}]})}}}}}),Lt={name:Zn,rule:Ys};import{AST_NODE_TYPES as ce,ESLintUtils as Xs}from"@typescript-eslint/utils";import{z as ge}from"zod/v4";var Bs=Xs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qn="react-compiler-migration",qs=ge.object({disallowHooks:ge.array(ge.object({name:ge.string(),replacement:ge.string()})).optional(),disallowMethods:ge.array(ge.object({name:ge.string(),replacement:ge.string().optional(),requireTrueProp:ge.string().optional()})).optional()}),Gs=/eslint +react-compiler\/react-compiler: +\["error/;function Zs(e){return e.type===ce.Identifier?e.name.startsWith("use"):e.type===ce.MemberExpression&&e.property.type===ce.Identifier?e.property.name.startsWith("use"):!1}var Ks=Bs({name:Qn,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:[$(qs)]},defaultOptions:[{disallowHooks:[],disallowMethods:[]}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Gs.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===ce.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===ce.MemberExpression&&n.callee.property.type===ce.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let i=t.disallowHooks.find(s=>s.name===o);i&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(a,i.replacement)}]})}}if(t.disallowMethods?.length&&Zs(n.callee)){for(let o of n.arguments)if(o.type===ce.ObjectExpression){for(let a of o.properties)if(a.type===ce.Property&&a.key.type===ce.Identifier){let i=a.key.name,s=t.disallowMethods.find(l=>l.name===i);if(s){if(s.requireTrueProp){let l=s.requireTrueProp,p=!1;for(let c of o.properties)if(c.type===ce.Property&&c.key.type===ce.Identifier&&c.key.name===l&&c.value.type===ce.Literal&&c.value.value===!0){p=!0;break}if(!p){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:l}});continue}}s.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:l=>s.replacement?l.replaceText(a.key,s.replacement):null}]})}}}}}}:{}}}),_t={name:Qn,rule:Ks};import{ESLintUtils as Qs,TSESTree as eo}from"@typescript-eslint/utils";var to=Qs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),er="require-description",no=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ro=/^eslint-disable-(next-)?line$/u,io=to({name:er,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 o of r.getAllComments()){let a=so(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:lo(o.loc),messageId:"missingDescription"}))}}}}}),tr={name:er,rule:io};function so(e){let{text:t,description:r}=ao(e.value);if(!t)return null;let n=no.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=ro.test(o);if(e.type===eo.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+o.length);return{kind:o,value:i.trim(),description:r}}var oo=/\s-{2,}\s/u;function ao(e){let t=e.split(oo);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function lo(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as U}from"@typescript-eslint/utils";import{z as Ee}from"zod/v4";var po=Ee.object({varsToCheck:Ee.array(Ee.object({selector:Ee.string().optional(),fromFnCall:Ee.string().optional(),prop:Ee.string().or(Ee.array(Ee.string())),errorMsg:Ee.string().optional()}))}),$t=V({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:[$(po)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,s,l,p){let c=new Set;for(let f of i.properties)f.type===U.Property&&f.key.type===U.Identifier&&c.add(f.key.name);let m=s.filter(f=>!c.has(f));if(m.length>0)if(m.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:m[0],fnName:p,customMsg:l||""}});else{let f=m.map(d=>`"${d}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:f,fnName:p,customMsg:l||""}})}}function o(i){if(i.init?.type===U.CallExpression){if(i.init.callee.type===U.Identifier)return i.init.callee.name;if(i.init.callee.type===U.MemberExpression&&i.init.callee.property.type===U.Identifier)return i.init.callee.object.type===U.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]=s=>{if(s.type===U.VariableDeclarator&&s.id.type===U.Identifier&&r.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:o(s)}),s.type===U.VariableDeclarator&&s.id.type===U.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(s.id,l,i.errorMsg,o(s))}});for(let i of t.varsToCheck)if(i.fromFnCall){let s=i.fromFnCall;if(s.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${s.slice(2)}"]`;a[p]=c=>{if(c.type!==U.MemberExpression||c.parent.type!==U.CallExpression)return;let m=c.parent;if(m.parent.type!==U.VariableDeclarator)return;let f=m.parent;if(f.id.type===U.Identifier)r.set(f.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:f.id,fnName:i.fromFnCall||"unknown function"});else if(f.id.type===U.ObjectPattern){let d=Array.isArray(i.prop)?i.prop:[i.prop];n(f.id,d,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[l,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;a[c]=m=>{if(m.type!==U.MemberExpression||m.parent.type!==U.CallExpression)return;let f=m.parent;if(f.parent.type!==U.VariableDeclarator)return;let d=f.parent;if(d.id.type===U.Identifier)r.set(d.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:d.id,fnName:i.fromFnCall||"unknown function"});else if(d.id.type===U.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];n(d.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;a[l]=p=>{if(p.type!==U.Identifier||p.parent.type!==U.CallExpression)return;let c=p.parent;if(c.parent.type!==U.VariableDeclarator)return;let m=c.parent;if(m.id.type===U.Identifier)r.set(m.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:m.id,fnName:i.fromFnCall||"unknown function"});else if(m.id.type===U.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];n(m.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...a,"Program:exit"(){for(let[i,{props:s,errorMsg:l,node:p,fnName:c}]of r){let f=e.sourceCode.getScope(p).set.get(i);if(f){let d=new Set(s);for(let y of f.references){let E=y.identifier,h=E.parent;if(!(h.type===U.VariableDeclarator&&h.id===E)){if(h.type===U.MemberExpression&&h.object===E&&h.property.type===U.Identifier&&d.has(h.property.name)){if(d.delete(h.property.name),d.size===0)break;continue}if(h.type===U.VariableDeclarator&&h.init===E&&h.id.type===U.ObjectPattern){for(let u of h.id.properties)u.type===U.Property&&u.key.type===U.Identifier&&d.has(u.key.name)&&d.delete(u.key.name);if(d.size===0)break;continue}if(!(h.type===U.MemberExpression&&h.object===E&&h.property.type===U.Identifier&&!s.includes(h.property.name))){d.clear();break}}}if(d.size>0){let y=Array.from(d);if(y.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:y[0],fnName:c,customMsg:l||""}});else{let E=y.map(h=>`"${h}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:E,fnName:c,customMsg:l||""}})}}}}}}}});function ir(e){return/^use[A-Z0-9]/.test(e)}function Ze(e){return e.type==="Identifier"?ir(e.name):e.type==="MemberExpression"&&!e.computed&&Ze(e.property)?e.object.type==="Identifier":!1}function sr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function or(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function ar(e){return!!(e.parent&&e.parent.callee&&or(e.parent.callee,"forwardRef"))}function lr(e){return!!(e.parent&&e.parent.callee&&or(e.parent.callee,"memo"))}function Ut(e){for(;e;){let t=cr(e);if(t&&(sr(t)||Ze(t))||ar(e)||lr(e))return!0;e=e.parent}return!1}function nr(e){return!1}function zt(e){return!1}var co=/eslint +react-compiler\/react-compiler: +\["error/,pr={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(co.test(l.value))return{CallExpression(p){let c=null;p.callee.name==="useMemo"?c="useMemo":p.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:p,message:`"${c}" 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,o=[],a=[],i=new WeakSet;function s(l){for(let p of l.references){let c=p.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&nr(c.init.callee))for(let m of p.resolved.references)m!==p&&i.add(m.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,p){let c=o.pop();if(c.size===0)return;let m=new Set;function f(g,A){let{cache:S}=f,I=S.get(g.id),w=new Set(A);if(w.has(g.id)){let R=[...w],N=R.slice(R.indexOf(g.id)+1);for(let _ of N)m.add(_);return BigInt("0")}if(w.add(g.id),I!==void 0)return I;if(l.thrownSegments.includes(g))I=BigInt("0");else if(g.prevSegments.length===0)I=BigInt("1");else{I=BigInt("0");for(let R of g.prevSegments)I+=f(R,w)}return g.reachable&&I===BigInt("0")?S.delete(g.id):S.set(g.id,I),I}function d(g,A){let{cache:S}=d,I=S.get(g.id),w=new Set(A);if(w.has(g.id)){let R=Array.from(w),N=R.slice(R.indexOf(g.id)+1);for(let _ of N)m.add(_);return BigInt("0")}if(w.add(g.id),I!==void 0)return I;if(l.thrownSegments.includes(g))I=BigInt("0");else if(g.nextSegments.length===0)I=BigInt("1");else{I=BigInt("0");for(let R of g.nextSegments)I+=d(R,w)}return S.set(g.id,I),I}function y(g){let{cache:A}=y,S=A.get(g.id);if(S===null)return 1/0;if(S!==void 0)return S;if(A.set(g.id,null),g.prevSegments.length===0)S=1;else{S=1/0;for(let I of g.prevSegments){let w=y(I);w<S&&(S=w)}S+=1}return A.set(g.id,S),S}f.cache=new Map,d.cache=new Map,y.cache=new Map;let E=d(l.initialSegment),h=cr(p),u=Ut(p),x=h?sr(h)||Ze(h):ar(p)||lr(p),b=1/0;for(let g of l.finalSegments){if(!g.reachable)continue;let A=y(g);A<b&&(b=A)}for(let[g,A]of c){if(!g.reachable)continue;let S=g.nextSegments.length===0?b<=y(g):b<y(g),I=f(g)*d(g),w=m.has(g.id);for(let R of A)if(w&&!zt(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.`}),x){if(p.async&&e.report({node:R,message:`React Hook "${t(R)}" cannot be called in an async function.`}),!w&&I!==E&&!zt(R)){let _=`React Hook "${t(R)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(S?" Did you accidentally call a React Hook after an early return?":"");e.report({node:R,message:_})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let N=`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:N})}else if(h){let N=`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:N})}else if(p.type==="Program"){let N=`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:N})}else if(u&&!zt(R)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let _=p.parent;if(_.parent.type==="VariableDeclarator"&&ir(_.parent.id.name))return}let N=`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:N})}}},CallExpression(l){if(Ze(l.callee)){let p=rr(o),c=rr(a),m=p.get(c);m||(m=[],p.set(c,m)),m.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||nr(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){Ut(l)&&s(r(l))},ArrowFunctionExpression(l){Ut(l)&&s(r(l))}}}};function cr(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 rr(e){return e[e.length-1]}import{AST_NODE_TYPES as te,AST_TOKEN_TYPES as uo}from"@typescript-eslint/utils";import*as se from"zod/v4";var fo=/^\s+$/,Wt=/\r?\n/,mo=/^(\s*)/,yo=/^(\s*)\S/,go=/\r?\n/,So=se.object({indent:se.union([se.string().regex(fo),se.number().int().min(1)]).optional(),tags:se.array(se.string()).optional(),functions:se.array(se.string()).optional(),comments:se.array(se.string()).optional()}),Vt=V({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[$(So)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:o=["outdent","dedent","gql","sql","html","styled"],indent:a}=e.options[0],i=r.map(u=>u.toLowerCase());function s(u){let x=u.split(Wt),b=x.filter(A=>A.trim()!=="");if(b.length===0)return u;let g=Number.POSITIVE_INFINITY;for(let A of b){let S=A.match(mo);S&&(g=Math.min(g,S[1]?.length??0))}return!isFinite(g)||g===0?u:x.map(A=>A.slice(g)).join(`
21
+ `)}function l(u,x,b){return u.split(Wt).map(A=>A.trim()===""?A:b.repeat(x)+A).join(`
22
+ `)}function p(u){if(u.type===te.Identifier)return u.name;if(u.type===te.MemberExpression){let x=u.object.type===te.Identifier?u.object.name:null,b=u.property.type===te.Identifier?u.property.name:null;return x&&b?`${x}.${b}`:b}return null}function c(u,x){if(!u)return!1;for(let b of x)if(b.includes(".")){let g=b.split(".");if(u.type===te.MemberExpression&&u.object.type===te.Identifier&&u.property.type===te.Identifier&&u.object.name===g[0]&&u.property.name===g[1])return!0}else if(u.type===te.Identifier&&u.name===b)return!0;return!1}function m(u,x){let b=u.parent;if(b.type!==te.TaggedTemplateExpression)return!1;let g=p(b.tag);return g?x.includes(g):!1}function f(u,x){if(!u||u.type!==te.CallExpression)return!1;let{method:b,argumentsLength:g,optionalCall:A=!0,optionalMember:S=!0}=x;return g!==void 0&&u.arguments.length!==g||!A&&u.optional||u.callee.type!==te.MemberExpression||!S&&u.callee.optional||u.callee.property.type!==te.Identifier?!1:u.callee.property.name===b}function d(u,x){if(!u||u.type!==te.CallExpression)return!1;let{name:b,argumentsLength:g,optionalCall:A=!0}=x;return g!==void 0&&u.arguments.length!==g||!A&&u.optional||u.callee.type!==te.Identifier?!1:u.callee.name===b}function y(u){return f(u.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&u.parent.type===te.CallExpression&&u.parent.arguments[0]===u&&d(u.parent.callee.type===te.MemberExpression?u.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function E(u){if(i.length>0){let x=t.getTokenBefore(u,{includeComments:!0});if(x?.type===uo.Block&&i.includes(x.value.trim().toLowerCase()))return!0}return!!(y(u)||o.length>0&&m(u,o)||n.length>0&&u.parent.type===te.CallExpression&&u.parent.arguments.includes(u)&&c(u.parent.callee,n))}function h(u){let x=`__PLACEHOLDER__${Math.random()}`,b=u.quasis.map(Y=>t.getText(Y).slice(1,Y.tail?-1:-2)).join(x),g=b.match(go);if(!g)return;let A=g[0],S=t.lines[t.getLocFromIndex(u.range[0]).line-1];if(!S)return;let w=S.match(yo)?.[1]??"",R;typeof a=="string"?R=a:typeof a=="number"?R=" ".repeat(a):R=w.startsWith(" ")?" ":" ";let _=s(b).replace(new RegExp(`^${A}|${A}[ ]*$`,"g"),""),G=A+l(_,1,w+R)+A+w,B=b.includes(`\r
19
23
  `)?`\r
20
24
  `:`
21
- `,K=b.split(zt),ee=K.map((J,me)=>me!==K.length-1&&J===R+A?"":J).join(B);if(X!==ee)return{node:c,messageId:"improperlyIndented",fix:J=>X.split(x).map((me,ve)=>{let re=c.quasis[ve];return re?J.replaceTextRange([re.range[0]+1,re.range[1]-(re.tail?1:2)],me):[]}).flat()}}return{TemplateLiteral(c){if(!E(c))return;let x=h(c);if(x)return e.report(x)}}}});import{AST_NODE_TYPES as nr}from"@typescript-eslint/utils";function so(e){if(!("regex"in e))return!1;let n=e.regex.flags;return n.includes("g")||n.includes("y")}function oo(e){let n=e.parent;return n?.type===nr.NewExpression&&n.callee.type===nr.Identifier&&n.callee.name==="RegExp"}var Vt=W({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function n(r){so(r)||oo(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":n}}});import{AST_NODE_TYPES as oe}from"@typescript-eslint/utils";import{z as Le}from"zod/v4";var ao=Le.object({checkOnly:Le.array(Le.enum(["function-args","FC","generic-args-at-fn-calls"])).optional(),checkTypesFromSelectors:Le.array(Le.string()).optional()}),Ht=W({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:[_(ao)],messages:{moveTypeAboveUsage:"Type definition should be placed directly above its first usage."}},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=new Map,o=[];function a(f){for(let d of o)if(f.range[0]>=d.range[0]&&f.range[1]<=d.range[1])return d;return null}function i(f){let d=f.parent;for(;d;){if(d.type===oe.FunctionDeclaration||d.type===oe.FunctionExpression||d.type===oe.ArrowFunctionExpression){let y=d.params;for(let E of y)if(f.range[0]>=E.range[0]&&f.range[1]<=E.range[1])return!0;break}d=d.parent}return!1}function s(f){let d=f.parent;for(;d;){if(d.type===oe.TSTypeParameterInstantiation){let y=d.parent;if(y.type===oe.TSTypeReference&&y.typeName.type===oe.Identifier&&(y.typeName.name==="FC"||y.typeName.name==="React.FC")||y.type===oe.TSTypeReference&&y.typeName.type===oe.TSQualifiedName&&y.typeName.right.name==="FC")return!0}d=d.parent}return!1}function l(f){let d=f.parent;for(;d;){if(d.type===oe.TSTypeParameterInstantiation){let y=d.parent;if(y.type===oe.CallExpression||y.type===oe.NewExpression)return!0}d=d.parent}return!1}let p=[];function u(f){let d=[],y=new Map;for(let{typeName:h,firstUsage:c}of f){let x=y.get(c)||[];x.push(h),y.set(c,x)}for(let{typeName:h,firstUsage:c,firstUsagePosition:x,firstUsageInFunctionArgs:b}of f){let g=t.get(h);if(!g||g.statement===c)continue;let w=o.indexOf(g.statement),S=o.indexOf(c);if(w===-1||S===-1)continue;let I=!!(n.checkOnly&&n.checkOnly.includes("function-args")&&b),R=(y.get(c)||[]).length>1;(I||R?w>S:w>S||w!==S-1)&&d.push({typeName:h,typeDef:g,targetStatement:c,firstUsagePosition:x})}if(d.length===0)return;d.sort((h,c)=>{let x=h.firstUsagePosition-c.firstUsagePosition;if(x!==0)return x;let b=o.indexOf(h.typeDef.statement),g=o.indexOf(c.typeDef.statement);return b-g});let E=d[0];E&&e.report({node:E.typeDef.node,messageId:"moveTypeAboveUsage",fix:m(d)})}function m(f){return function*(d){let y=new Map;for(let E of f){let h=y.get(E.targetStatement)||[];h.push(E),y.set(E.targetStatement,h)}for(let[,E]of y)E.sort((h,c)=>{let x=h.firstUsagePosition-c.firstUsagePosition;if(x!==0)return x;let b=o.indexOf(h.typeDef.statement),g=o.indexOf(c.typeDef.statement);return b-g});for(let E of f){let{typeDef:h}=E,c=h.statement,x=r.getCommentsBefore(c),b=c.range[0],g=c.range[1];x.length>0&&x[0]&&(b=x[0].range[0]),yield d.removeRange([b,g])}for(let[E,h]of y){let c=r.getCommentsBefore(E),x=c.length>0&&c[0]?c[0].range[0]:E.range[0],b=[];for(let g of h){let w=g.typeDef.statement,S=r.getText(w),I=r.getCommentsBefore(w),A=S;I.length>0&&(A=`${I.map(N=>r.getText(N)).join(`
25
+ `,Q=b.split(Wt),ee=Q.map((Y,me)=>me!==Q.length-1&&Y===R+w?"":Y).join(B);if(G!==ee)return{node:u,messageId:"improperlyIndented",fix:Y=>G.split(x).map((me,ke)=>{let re=u.quasis[ke];return re?Y.replaceTextRange([re.range[0]+1,re.range[1]-(re.tail?1:2)],me):[]}).flat()}}return{TemplateLiteral(u){if(!E(u))return;let x=h(u);if(x)return e.report(x)}}}});import{AST_NODE_TYPES as ur}from"@typescript-eslint/utils";function To(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function ho(e){let t=e.parent;return t?.type===ur.NewExpression&&t.callee.type===ur.Identifier&&t.callee.name==="RegExp"}var Ht=V({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){To(r)||ho(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 oe}from"@typescript-eslint/utils";import{z as _e}from"zod/v4";var Eo=_e.object({checkOnly:_e.array(_e.enum(["function-args","FC","generic-args-at-fn-calls"])).optional(),checkTypesFromSelectors:_e.array(_e.string()).optional()}),Jt=V({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:[$(Eo)],messages:{moveTypeAboveUsage:"Type definition should be placed directly above its first usage."}},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=new Map,o=[];function a(f){for(let d of o)if(f.range[0]>=d.range[0]&&f.range[1]<=d.range[1])return d;return null}function i(f){let d=f.parent;for(;d;){if(d.type===oe.FunctionDeclaration||d.type===oe.FunctionExpression||d.type===oe.ArrowFunctionExpression){let y=d.params;for(let E of y)if(f.range[0]>=E.range[0]&&f.range[1]<=E.range[1])return!0;break}d=d.parent}return!1}function s(f){let d=f.parent;for(;d;){if(d.type===oe.TSTypeParameterInstantiation){let y=d.parent;if(y.type===oe.TSTypeReference&&y.typeName.type===oe.Identifier&&(y.typeName.name==="FC"||y.typeName.name==="React.FC")||y.type===oe.TSTypeReference&&y.typeName.type===oe.TSQualifiedName&&y.typeName.right.name==="FC")return!0}d=d.parent}return!1}function l(f){let d=f.parent;for(;d;){if(d.type===oe.TSTypeParameterInstantiation){let y=d.parent;if(y.type===oe.CallExpression||y.type===oe.NewExpression)return!0}d=d.parent}return!1}let p=[];function c(f){let d=[],y=new Map;for(let{typeName:h,firstUsage:u}of f){let x=y.get(u)||[];x.push(h),y.set(u,x)}for(let{typeName:h,firstUsage:u,firstUsagePosition:x,firstUsageInFunctionArgs:b}of f){let g=n.get(h);if(!g||g.statement===u)continue;let A=o.indexOf(g.statement),S=o.indexOf(u);if(A===-1||S===-1)continue;let I=!!(t.checkOnly&&t.checkOnly.includes("function-args")&&b),R=(y.get(u)||[]).length>1;(I||R?A>S:A>S||A!==S-1)&&d.push({typeName:h,typeDef:g,targetStatement:u,firstUsagePosition:x})}if(d.length===0)return;d.sort((h,u)=>{let x=h.firstUsagePosition-u.firstUsagePosition;if(x!==0)return x;let b=o.indexOf(h.typeDef.statement),g=o.indexOf(u.typeDef.statement);return b-g});let E=d[0];E&&e.report({node:E.typeDef.node,messageId:"moveTypeAboveUsage",fix:m(d)})}function m(f){return function*(d){let y=new Map;for(let E of f){let h=y.get(E.targetStatement)||[];h.push(E),y.set(E.targetStatement,h)}for(let[,E]of y)E.sort((h,u)=>{let x=h.firstUsagePosition-u.firstUsagePosition;if(x!==0)return x;let b=o.indexOf(h.typeDef.statement),g=o.indexOf(u.typeDef.statement);return b-g});for(let E of f){let{typeDef:h}=E,u=h.statement,x=r.getCommentsBefore(u),b=u.range[0],g=u.range[1];x.length>0&&x[0]&&(b=x[0].range[0]),yield d.removeRange([b,g])}for(let[E,h]of y){let u=r.getCommentsBefore(E),x=u.length>0&&u[0]?u[0].range[0]:E.range[0],b=[];for(let g of h){let A=g.typeDef.statement,S=r.getText(A),I=r.getCommentsBefore(A),w=S;I.length>0&&(w=`${I.map(N=>r.getText(N)).join(`
22
26
  `)}
23
- ${S}`),b.push(A)}yield d.insertTextBeforeRange([x,x],`${b.join(`
27
+ ${S}`),b.push(w)}yield d.insertTextBeforeRange([x,x],`${b.join(`
24
28
 
25
29
  `)}
26
30
 
27
- `)}}}return{Program(f){o.push(...f.body)},TSTypeAliasDeclaration(f){if(o.some(y=>y.type===oe.ExportNamedDeclaration&&y.declaration===f?!0:y===f)){let y=a(f);y&&t.set(f.id.name,{node:f,name:f.id.name,statement:y})}},TSInterfaceDeclaration(f){if(o.some(y=>y.type===oe.ExportNamedDeclaration&&y.declaration===f?!0:y===f)){let y=a(f);y&&t.set(f.id.name,{node:f,name:f.id.name,statement:y})}},TSTypeReference(f){if(f.typeName.type===oe.Identifier){let d=i(f),y=s(f),E=l(f);p.push({typeName:f.typeName.name,node:f,inFunctionArgs:d,inFCProps:y,inGenericArgAtFunctionCall:E,usagePosition:f.range[0]})}},"Program:exit"(){let f=new Map,d=p.filter(E=>{if(!n.checkOnly||n.checkOnly.length===0)return!0;for(let h of n.checkOnly)if(h==="function-args"&&E.inFunctionArgs||h==="FC"&&E.inFCProps||h==="generic-args-at-fn-calls"&&E.inGenericArgAtFunctionCall)return!0;return!1});for(let E of d){let{typeName:h,node:c}=E;if(t.has(h)){let x=a(c),b=t.get(h);if(x&&b&&x!==b.statement){f.has(h)||f.set(h,[]);let g=f.get(h);if(!g)return;g.includes(x)||g.push(x)}}}let y=[];for(let[E,h]of f)if(h.length>0){let c=h[0];if(!c)continue;let x=Number.MAX_SAFE_INTEGER,b=!1;for(let g of h)g.range[0]<c.range[0]&&(c=g);for(let g of d)g.typeName===E&&a(g.node)===c&&g.usagePosition<x&&(x=g.usagePosition,b=g.inFunctionArgs);y.push({typeName:E,firstUsage:c,firstUsagePosition:x,firstUsageInFunctionArgs:b})}y.length>0&&u(y)}}}});var rr={[kt.name]:kt.rule,[ct.name]:ct.rule,[pt.name]:pt.rule,"rules-of-hooks":er,"exhaustive-deps":sn,"require-description":Yn.rule,[ut.name]:ut.rule,[mt.name]:mt.rule,[Ot.name]:Ot.rule,[et.name]:et.rule,[lt.name]:lt.rule,[Tt.name]:Tt.rule,[De.name]:De.rule,[jt.name]:jt.rule,[gt.name]:gt.rule,[ft.name]:ft.rule,[ht.name]:ht.rule,[nt.name]:nt.rule,[Lt.name]:Lt.rule,[Qe.name]:Qe.rule,[ot.name]:ot.rule,[Ct.name]:Ct.rule,[It.name]:It.rule,[wt.name]:wt.rule,[At.name]:At.rule,[Rt.name]:Rt.rule,[Dt.name]:Dt.rule,[xt.name]:xt.rule,[Et.name]:Et.rule,[Vt.name]:Vt.rule,[Pt.name]:Pt.rule,[_t.name]:_t.rule,[Wt.name]:Wt.rule,[Ht.name]:Ht.rule,[De.name]:De.rule};var Np={rules:rr};export{Np as extendedLintPlugin};
31
+ `)}}}return{Program(f){o.push(...f.body)},TSTypeAliasDeclaration(f){if(o.some(y=>y.type===oe.ExportNamedDeclaration&&y.declaration===f?!0:y===f)){let y=a(f);y&&n.set(f.id.name,{node:f,name:f.id.name,statement:y})}},TSInterfaceDeclaration(f){if(o.some(y=>y.type===oe.ExportNamedDeclaration&&y.declaration===f?!0:y===f)){let y=a(f);y&&n.set(f.id.name,{node:f,name:f.id.name,statement:y})}},TSTypeReference(f){if(f.typeName.type===oe.Identifier){let d=i(f),y=s(f),E=l(f);p.push({typeName:f.typeName.name,node:f,inFunctionArgs:d,inFCProps:y,inGenericArgAtFunctionCall:E,usagePosition:f.range[0]})}},"Program:exit"(){let f=new Map,d=p.filter(E=>{if(!t.checkOnly||t.checkOnly.length===0)return!0;for(let h of t.checkOnly)if(h==="function-args"&&E.inFunctionArgs||h==="FC"&&E.inFCProps||h==="generic-args-at-fn-calls"&&E.inGenericArgAtFunctionCall)return!0;return!1});for(let E of d){let{typeName:h,node:u}=E;if(n.has(h)){let x=a(u),b=n.get(h);if(x&&b&&x!==b.statement){f.has(h)||f.set(h,[]);let g=f.get(h);if(!g)return;g.includes(x)||g.push(x)}}}let y=[];for(let[E,h]of f)if(h.length>0){let u=h[0];if(!u)continue;let x=Number.MAX_SAFE_INTEGER,b=!1;for(let g of h)g.range[0]<u.range[0]&&(u=g);for(let g of d)g.typeName===E&&a(g.node)===u&&g.usagePosition<x&&(x=g.usagePosition,b=g.inFunctionArgs);y.push({typeName:E,firstUsage:u,firstUsagePosition:x,firstUsageInFunctionArgs:b})}y.length>0&&c(y)}}}});var fr={[kt.name]:kt.rule,[ct.name]:ct.rule,[pt.name]:pt.rule,"rules-of-hooks":pr,"exhaustive-deps":nn,"require-description":tr.rule,[ut.name]:ut.rule,[mt.name]:mt.rule,[Ot.name]:Ot.rule,[et.name]:et.rule,[lt.name]:lt.rule,[Tt.name]:Tt.rule,[Me.name]:Me.rule,[jt.name]:jt.rule,[gt.name]:gt.rule,[ft.name]:ft.rule,[ht.name]:ht.rule,[nt.name]:nt.rule,[_t.name]:_t.rule,[Lt.name]:Lt.rule,[ot.name]:ot.rule,[Ct.name]:Ct.rule,[It.name]:It.rule,[At.name]:At.rule,[wt.name]:wt.rule,[Rt.name]:Rt.rule,[Dt.name]:Dt.rule,[xt.name]:xt.rule,[Et.name]:Et.rule,[Ht.name]:Ht.rule,[Ft.name]:Ft.rule,[$t.name]:$t.rule,[Vt.name]:Vt.rule,[Jt.name]:Jt.rule,[Me.name]:Me.rule};var Xp={rules:fr};export{Xp as extendedLintPlugin};