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