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