@ls-stack/extended-lint 0.61.0 → 0.61.1

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 x(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 b(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||!b(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 E(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)E(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&&x(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(x=>y.endsWith(x)))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 x=y.typeAnnotation?.typeAnnotation;if(!x||x.type===z.TSTypeLiteral||!tn(x))return!1;if(x.type===z.TSTypeReference&&x.typeArguments){if(x.typeArguments.params.length>1)return!1;let c=x.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 x=0,h=!1,c=r.getTokenAfter(p,{filter:E=>E.type!==en.Punctuator||h?!0:E.value===","?(x++,!1):E.value===";"?(x++,h=!0,!1):E.value===")"||E.value==="}"?(x++,!1):!0});if(x>4)return;let b=c?.type===en.Template&&c.value.startsWith(`}
2
- `);if(c?.loc.start.line===p.loc.end.line&&!b)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:x=>x.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,b){return function(E){if(b.has(E))return b.get(E);let g=c(E);return b.set(E,g),g}}function x(c,b,E,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 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:
5
5
 
6
6
  useEffect(() => {
7
7
  async function fetchData() {
@@ -12,16 +12,16 @@ 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 F=k.callee;if(F.type==="MemberExpression"&&F.object.name==="React"&&F.property!=null&&!F.computed&&(F=F.property),F.type!=="Identifier")return!1;let O=C.node.id,{name:D}=F;if(D==="useRef"&&O.type==="Identifier")return!0;if(kr(F)&&O.type==="Identifier"){for(let j of T.references)j!==O&&d.add(j.identifier);return!0}else if(D==="useState"||D==="useReducer"){if(O.type==="ArrayPattern"&&O.elements.length===2&&R(T.identifiers)){if(O.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,O.elements[0])}}return!0}else if(O.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"&&O.type==="ArrayPattern"&&O.elements.length===2&&Array.isArray(T.identifiers)&&O.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,F=null,O;for(O=0;O<P.length;O++){let D=P[O],j=D.block;if(k.type==="FunctionDeclaration"&&j===k||k.type==="VariableDeclarator"&&j.parent===k){F=D;break}}if(F==null)return!1;for(O=0;O<F.through.length;O++){let D=F.through[O];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),F=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(F,{reference:C,dependencyNode:P}),P.parent.type==="TSTypeQuery"||P.parent.type==="TSTypeReference")continue;let O=C.resolved.defs[0];if(O!=null&&!(O.node!=null&&O.node.init===c.parent)&&O.type!=="TypeParameter")if(J.has(F))J.get(F).references.push(C);else{let D=C.resolved,j=X(D)||B(D);J.set(F,{isStable:j,references:[C]})}}for(let C of T.childScopes)ve(C)}K.forEach(({reference:T,dependencyNode:C},k)=>{let P=T.resolved.references,F=!1;for(let O=0;O<P.length;O++){let{identifier:D}=P[O],{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){F=!0;break}}F||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(E)} 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(E)}.`}))}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(!b){let T=null;if(J.forEach(({isStable:C,references:k},P)=>{T||k.forEach(F=>{if(T)return;let O=F.identifier;if(!p.has(O))return;let j=F.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:E,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=[],Fe=new Set;b.type!=="ArrayExpression"?s({node:b,message:`React Hook ${r(E)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):b.elements.forEach(T=>{if(T===null)return;if(T.type==="SpreadElement"){s({node:T,message:`React Hook ${r(E)} 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(F){return F.removeRange(T.range)}}]});let C;try{C=Se(T,me)}catch(F){if(/Unsupported node type/.test(F.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(E)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw F}let k=T;for(;k.type==="MemberExpression"||k.type==="OptionalMemberExpression"||k.type==="ChainExpression";)k=k.object||k.expression.object;let P=!A.through.some(F=>F.identifier===k);Ie.push({key:C,node:T}),P||Fe.add(C)});let{suggestedDependencies:ir,unnecessaryDependencies:_e,missingDependencies:xe,duplicateDependencies:Jt}=rt({dependencies:J,declaredDependencies:Ie,stableDependencies:le,externalDependencies:Fe,isEffect:w}),$e=ir;if(Jt.size+xe.size+_e.size===0){if(n)return;Rr({declaredDependencies:Ie,declaredDependenciesNode:b,componentScope:A,scope:S}).forEach(({construction:C,isUsedOutsideOfHook:k,depType:P})=>{let F=P==="function"?"useCallback":"useMemo",O=P==="function"?"definition":"initialization",D=`wrap the ${O} of '${C.name.name}' in its own ${F}() 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 ${b.loc.start.line}) change on every render. ${j}`,Yt;k&&C.type==="Variable"&&P==="function"&&(Yt=[{desc:`Wrap the ${O} of '${C.name.name}' in its own ${F}() Hook.`,fix(Bt){let[or,ar]=F==="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:Fe,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 F=C.slice(0,P+1).join("."),O=me.get(F)===!0;k+=O?"?.":"."}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(F=>"'"+Ze(F)+"'"))+`. 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(Fe.size>0){let C=Array.from(Fe)[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 F=C[P],O=st(A.block,F.identifier);if(!O){k=!1;break}let D=O.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(E)}.`)}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 F=k.defs[0];if(F==null||F.name==null||F.type!=="Parameter")return;let O=!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){O=!0;break}O&&(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,F,O;for(let D=0;D<P.length;D++){for(F=P[D].identifier,O=F.parent;O!=null&&O!==A.block;){if(O.type==="CallExpression"){let j=p.get(O.callee);if(j!=null){if(j.name===C)T={missingDep:C,setter:O.callee.name,form:"updater"};else if(u.has(F))T={missingDep:C,setter:O.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:O.callee.name,form:"inlineReducer"})}}break}}O=O.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:b,message:`React Hook ${r(E)} 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(b,`[${$e.map(Ze).join(", ")}]`)}}]})}function h(c){let b=wr(c.callee,i);if(b===-1)return;let E=c.arguments[b],g=c.callee,w=an(g).name,S=c.arguments[b+1],I=/Effect($|[^a-z])/g.test(w);if(!E){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(E.type){case"FunctionExpression":case"ArrowFunctionExpression":x(E,S,g,w,I);return;case"Identifier":if(!S||S.elements&&S.elements.some(N=>N&&N.type==="Identifier"&&N.name===E.name))return;let A=t(c).set.get(E.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":x(R.node,S,g,w,I);return;case"VariableDeclarator":let N=R.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":x(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: '${E.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${E.name}]`,fix(A){return A.replaceText(S,`[${E.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let c of e.sourceCode.getAllComments())if(Ir.test(c.value))return n=!0,{CallExpression:b=>h(b,!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((x,h)=>{let c=s(a,h);c.isUsed=!0,l(a,h,b=>{b.isSubtreeUsed=!0})}),n.forEach(({key:x})=>{let h=s(a,x);h.isSatisfiedRecursively=!0}),r.forEach(x=>{let h=s(a,x);h.isSatisfiedRecursively=!0});function s(x,h){let c=h.split("."),b=x;for(let E of c){let g=b.children.get(E);g||(g=i(),b.children.set(E,g)),b=g}return b}function l(x,h,c){let b=h.split("."),E=x;for(let g of b){let w=E.children.get(g);if(!w)return;c(w),E=w}}let p=new Set,u=new Set;m(a,p,u,x=>x);function m(x,h,c,b){x.children.forEach((E,g)=>{let w=b(g);if(E.isSatisfiedRecursively){E.isSubtreeUsed&&c.add(w);return}if(E.isUsed){h.add(w);return}m(E,h,c,S=>w+"."+S)})}let f=[],d=new Set,y=new Set;return n.forEach(({key:x})=>{u.has(x)?f.indexOf(x)===-1?f.push(x):y.add(x):d.add(x)}),p.forEach(x=>{f.push(x)}),{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 Or=cn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="improved-no-unnecessary-condition",Fr=Pr.object({}),Nr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Dr=new Set(Nr),ot={name:pn,rule:Or({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:[_(Fr)]},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 Oi}from"@typescript-eslint/utils";var Fi=Oi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sn="no-leaked-text-in-jsx",Ni=[",",";","[","]","(",")"],Di=Fi({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 Oe}from"@typescript-eslint/utils";var Qi="no-unnecessary-async-on-jsx-props";function es(e){if(e.body.type!==Oe.BlockStatement)return!1;let n=e.body.body;if(n.length!==1)return!1;let r=n[0];return!r||r.type!==Oe.ExpressionStatement?!1:r.expression.type===Oe.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===Oe.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===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]":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,x]of u)d.has(y)||e.report({node:x,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()}),On="no-unused-type-props-in-args",vt=null,Ts=gs({name:On,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,x=e.sourceCode.getScope(p).references.find(g=>g.identifier.name===y)?.resolved,h=l&&vt?.some(g=>g.test(y)),c=d&&t;if(!x||!h&&x.references.filter(g=>g.isTypeReference).length>1||!x.defs[0])return;let b=x.defs[0].node,E=b.parent?.type===U.ExportNamedDeclaration;if(!(f&&E&&!c)){if(b.type===U.TSTypeAliasDeclaration){a(l,p,m,b.typeAnnotation,!0,d);return}if(b.type===U.TSInterfaceDeclaration){a(l,p,m,b.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,x]of p)u.includes(y)||(d.push(y),f.push({node:x,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,x]of f.entries())e.report({...x,fix:y===f.length-1?h=>{let c=l.properties.at(-1),b=d.join(", ");return c?c.type===U.RestElement?null:h.insertTextAfter(c,`, ${b}`):h.insertTextBeforeRange([l.range[0]+1,l.range[1]],b)}: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:On,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 Ot,ESLintUtils as hs}from"@typescript-eslint/utils";var Es=hs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nn="prefer-named-functions",Fn=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=Fn.get(n.ignoreRegex);t?r=t:(r=new RegExp(n.ignoreRegex),Fn.set(n.ignoreRegex,r))}return{VariableDeclarator(t){if(t.init&&t.init.type===Ot.ArrowFunctionExpression&&t.id.type===Ot.Identifier){let o=t.id.name;if(t.id.typeAnnotation||r&&r.test(o)||!n.disallowArrowFnWithImplicitReturns&&t.init.body.type!==Ot.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)}`)}]})}}}}}),Ft={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 Os=Ps.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zn="prefer-single-line-if",Fs=Mt.object({maxLineLength:Mt.number().optional(),maxNonSimpleConditionLength:Mt.number().optional()}),Ns=Os({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:[_(Fs)]},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 x=y.identifier,h=x.parent;if(!(h.type===$.VariableDeclarator&&h.id===x)){if(h.type===$.MemberExpression&&h.object===x&&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===x&&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===x&&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 x=y.map(h=>`"${h}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:x,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 x=d(l.initialSegment),h=tr(p),c=$t(p),b=h?Gn(h)||Ge(h):Kn(p)||Qn(p),E=1/0;for(let g of l.finalSegments){if(!g.reachable)continue;let w=y(g);w<E&&(E=w)}for(let[g,w]of u){if(!g.reachable)continue;let S=g.nextSegments.length===0?E<=y(g):E<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.`}),b){if(p.async&&e.report({node:R,message:`React Hook "${n(R)}" cannot be called in an async function.`}),!A&&I!==x&&!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 b=c.split(zt),E=b.filter(w=>w.trim()!=="");if(E.length===0)return c;let g=Number.POSITIVE_INFINITY;for(let w of E){let S=w.match(to);S&&(g=Math.min(g,S[1]?.length??0))}return!isFinite(g)||g===0?c:b.map(w=>w.slice(g)).join(`
17
- `)}function l(c,b,E){return c.split(zt).map(w=>w.trim()===""?w:E.repeat(b)+w).join(`
18
- `)}function p(c){if(c.type===te.Identifier)return c.name;if(c.type===te.MemberExpression){let b=c.object.type===te.Identifier?c.object.name:null,E=c.property.type===te.Identifier?c.property.name:null;return b&&E?`${b}.${E}`:E}return null}function u(c,b){if(!c)return!1;for(let E of b)if(E.includes(".")){let g=E.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===E)return!0;return!1}function m(c,b){let E=c.parent;if(E.type!==te.TaggedTemplateExpression)return!1;let g=p(E.tag);return g?b.includes(g):!1}function f(c,b){if(!c||c.type!==te.CallExpression)return!1;let{method:E,argumentsLength:g,optionalCall:w=!0,optionalMember:S=!0}=b;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===E}function d(c,b){if(!c||c.type!==te.CallExpression)return!1;let{name:E,argumentsLength:g,optionalCall:w=!0}=b;return g!==void 0&&c.arguments.length!==g||!w&&c.optional||c.callee.type!==te.Identifier?!1:c.callee.name===E}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 x(c){if(i.length>0){let b=n.getTokenBefore(c,{includeComments:!0});if(b?.type===Qs.Block&&i.includes(b.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 b=`__PLACEHOLDER__${Math.random()}`,E=c.quasis.map(J=>n.getText(J).slice(1,J.tail?-1:-2)).join(b),g=E.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(E).replace(new RegExp(`^${w}|${w}[ ]*$`,"g"),""),X=w+l(L,1,A+R)+w+A,B=E.includes(`\r
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
19
19
  `)?`\r
20
20
  `:`
21
- `,K=E.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(b).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(!x(c))return;let b=h(c);if(b)return e.report(b)}}}});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 x of y)if(f.range[0]>=x.range[0]&&f.range[1]<=x.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 b=y.get(c)||[];b.push(h),y.set(c,b)}for(let{typeName:h,firstUsage:c,firstUsagePosition:b}of f){let E=t.get(h);if(!E||E.statement===c)continue;let g=o.indexOf(E.statement),w=o.indexOf(c);if(g===-1||w===-1)continue;let S=n.checkOnly&&n.checkOnly.length>0&&n.checkOnly.includes("function-args"),A=(y.get(c)||[]).length>1;(S||A?g>w:g>w||g!==w-1)&&d.push({typeName:h,typeDef:E,targetStatement:c,firstUsagePosition:b})}if(d.length===0)return;d.sort((h,c)=>{let b=h.firstUsagePosition-c.firstUsagePosition;if(b!==0)return b;let E=o.indexOf(h.typeDef.statement),g=o.indexOf(c.typeDef.statement);return E-g});let x=d[0];x&&e.report({node:x.typeDef.node,messageId:"moveTypeAboveUsage",fix:m(d)})}function m(f){return function*(d){let y=new Map;for(let x of f){let h=y.get(x.targetStatement)||[];h.push(x),y.set(x.targetStatement,h)}for(let[,x]of y)x.sort((h,c)=>{let b=h.firstUsagePosition-c.firstUsagePosition;if(b!==0)return b;let E=o.indexOf(h.typeDef.statement),g=o.indexOf(c.typeDef.statement);return E-g});for(let x of f){let{typeDef:h}=x,c=h.statement,b=r.getCommentsBefore(c),E=c.range[0],g=c.range[1];b.length>0&&b[0]&&(E=b[0].range[0]),yield d.removeRange([E,g])}for(let[x,h]of y){let c=r.getCommentsBefore(x),b=c.length>0&&c[0]?c[0].range[0]:x.range[0],E=[];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(`
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(`
22
22
  `)}
23
- ${S}`),E.push(A)}yield d.insertTextBeforeRange([b,b],`${E.join(`
23
+ ${S}`),b.push(A)}yield d.insertTextBeforeRange([x,x],`${b.join(`
24
24
 
25
25
  `)}
26
26
 
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),x=l(f);p.push({typeName:f.typeName.name,node:f,inFunctionArgs:d,inFCProps:y,inGenericArgAtFunctionCall:x,usagePosition:f.range[0]})}},"Program:exit"(){let f=new Map,d=p.filter(x=>{if(!n.checkOnly||n.checkOnly.length===0)return!0;for(let h of n.checkOnly)if(h==="function-args"&&x.inFunctionArgs||h==="FC"&&x.inFCProps||h==="generic-args-at-fn-calls"&&x.inGenericArgAtFunctionCall)return!0;return!1});for(let x of d){let{typeName:h,node:c}=x;if(t.has(h)){let b=a(c),E=t.get(h);if(b&&E&&b!==E.statement){f.has(h)||f.set(h,[]);let g=f.get(h);if(!g)return;g.includes(b)||g.push(b)}}}let y=[];for(let[x,h]of f)if(h.length>0){let c=h[0];if(!c)continue;let b=Number.MAX_SAFE_INTEGER;for(let E of h)E.range[0]<c.range[0]&&(c=E);for(let E of d)E.typeName===x&&a(E.node)===c&&E.usagePosition<b&&(b=E.usagePosition);y.push({typeName:x,firstUsage:c,firstUsagePosition: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,[Ft.name]:Ft.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};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ls-stack/extended-lint",
3
- "version": "0.61.0",
3
+ "version": "0.61.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"