@ls-stack/extended-lint 0.73.0 → 0.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extended-lint.js +19 -19
- package/dist/extended-lint.mjs +19 -19
- 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 Te}from"@typescript-eslint/utils";import{z as j}from"zod/v4";import{ESLintUtils as ti}from"@typescript-eslint/utils";import*as vn from"zod/v4";function X(e){let r=ti.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function J(e){return vn.toJSONSchema(e)}var ni=j.object({disallow:j.array(j.object({selector:j.string(),message:j.string(),replace:j.optional(j.union([j.string(),j.object({regex:j.string(),with:j.string()})])),replaceType:j.optional(j.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:j.optional(j.array(j.object({fn:j.string(),withArgs:j.optional(j.array(j.object({atIndex:j.number(),value:j.union([j.string(),j.number(),j.boolean()])}))),message:j.string(),replaceWith:j.optional(j.string()),ignoreRegex:j.optional(j.string())}))),__dev_simulateFileName:j.optional(j.string()),mustMatchSyntax:j.optional(j.array(j.object({includeRegex:j.string(),mustCallFn:j.optional(j.array(j.object({anyCall:j.array(j.object({fn:j.string(),withArgs:j.array(j.object({atIndex:j.number(),literal:j.union([j.string(),j.number(),j.boolean()])}))})),message:j.optional(j.string())}))),mustMatchSelector:j.optional(j.array(j.object({selector:j.string(),message:j.string()}))),mustHaveExport:j.optional(j.array(j.object({name:j.string(),type:j.enum(["function","variable","any"]).default("any"),message:j.string()})))})))}),ht=X({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[J(ni)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:s,disallow:a,disallowFnCalls:i}=t,p=s??e.filename,l=[],c=new Map,d=new Set,y=new Map,g=new Set,b=new Map;function f(u){for(let T of u.specifiers)T.type===Te.ImportSpecifier&&T.imported.type===Te.Identifier&&T.imported.name!==T.local.name&&b.set(T.local.name,T.imported.name)}function E(u){if(u.declaration){if(u.declaration.type===Te.FunctionDeclaration&&u.declaration.id){let T=u.declaration.id.name;for(let w of Array.from(g)){let[R,v]=w.split(":");R===T&&(v==="function"||v==="any")&&g.delete(w)}}else if(u.declaration.type===Te.VariableDeclaration){for(let T of u.declaration.declarations)if(T.id.type===Te.Identifier){let w=T.id.name;for(let R of Array.from(g)){let[v,x]=R.split(":");v===w&&(x==="variable"||x==="any")&&g.delete(R)}}}}for(let T of u.specifiers)if(T.exported.type===Te.Identifier){let w=T.exported.name;for(let R of Array.from(g)){let[v,x]=R.split(":");v===w&&x==="any"&&g.delete(R)}}}function h(u){u.id.type===Te.Identifier&&u.init?.type===Te.Identifier&&b.set(u.id.name,u.init.name)}function m(u){return b.get(u)??u}function A(u,T){return m(u)===T||u===T}for(let{includeRegex:u,mustCallFn:T,mustMatchSelector:w,mustHaveExport:R}of n??[]){let x=function(C){let F=C;for(let{name:O,value:G}of v??[])F=F.replaceAll(O,G);return F};var S=x;let v=ri(p,new RegExp(u));if(v){for(let{anyCall:C,message:F}of T??[]){let O=`Expected file to call the function: ${C.map(({fn:G})=>G).join(" or ")}`;d.add(O),l.push(G=>{let{callee:z}=G;if(z.type===Te.Identifier){for(let{fn:te,withArgs:ie}of C)if(z.name===te){d.delete(O);for(let D of ie){let q=G.arguments[D.atIndex],V=typeof D.literal=="string"?x(D.literal):D.literal;if(!q){e.report({node:G,messageId:"default",data:{message:`Missing argument with value "${V}" at index ${D.atIndex}${F?`: ${x(F)}`:""}`}});continue}if(q.type!==Te.Literal){e.report({node:q,messageId:"default",data:{message:`Argument at position ${D.atIndex} should the literal "${V}"${F?`: ${x(F)}`:""}`}});continue}q.value!==V&&e.report({node:q,messageId:"default",data:{message:`Argument should have the value "${V}"${F?`: ${x(F)}`:""}`},fix:le=>le.replaceText(q,typeof V=="string"?`'${V}'`:String(V))})}break}}})}for(let{selector:C,message:F}of w??[])y.set(C,x(F)),c.set(x(C),()=>{y.delete(C)});for(let{name:C,type:F,message:O}of R??[]){let G=x(C),z=x(O);g.add(`${G}:${F}:${z}`)}}}for(let{fn:u,withArgs:T,message:w,replaceWith:R,ignoreRegex:v}of i??[])v&&new RegExp(v).test(p)||l.push(x=>{let{callee:C}=x;if(C.type!==Te.Identifier||!A(C.name,u))return;if(T)for(let O of T){let G=x.arguments[O.atIndex];if(!G){e.report({node:x,messageId:"default",data:{message:`Missing argument with value "${O.value}" at index ${O.atIndex}: ${w}`}});return}if(G.type!==Te.Literal||G.value!==O.value)return}let F=O=>R?O.replaceText(x,R):null;e.report({node:x,messageId:"default",data:{message:w},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:F}]:void 0})});function I(u,T){let w=r[u];w?r[u]=R=>{w(R),T(R)}:r[u]=T}for(let{selector:u,message:T,replace:w,replaceType:R="suggestion"}of a??[]){if(u==="CallExpression"){l.push(v=>{o(w,v,T,R)});continue}r[u]=v=>{o(w,v,T,R)}}if(c.size>0)for(let[u,T]of c)I(u,T);return l.length>0&&(r.CallExpression=u=>{if(u.type===Te.CallExpression)for(let T of l)T(u)}),r.ImportDeclaration=u=>{u.type===Te.ImportDeclaration&&f(u)},r.ExportNamedDeclaration=u=>{u.type===Te.ExportNamedDeclaration&&E(u)},r.VariableDeclarator=u=>{u.type===Te.VariableDeclarator&&h(u)},r["Program:exit"]=u=>{for(let T of d)e.report({node:u,messageId:"default",data:{message:T}});for(let[,T]of y)e.report({node:u,messageId:"default",data:{message:T}});for(let T of g){let[w,R,v]=T.split(":");e.report({node:u,messageId:"default",data:{message:`Missing required export "${w}" of type ${R}: ${v}`}})}},r;function o(u,T,w,R){let v=x=>{if(!u)return null;if(typeof u=="string")return x.replaceText(T,u);{let C=new RegExp(u.regex),F=e.sourceCode.getText(T);return x.replaceText(T,F.replace(C,u.with))}};e.report({node:T,messageId:"default",data:{message:w},fix:u&&R==="autofix"?v:void 0,suggest:u&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof u=="string"?u:u.with}"`},fix:v}]:void 0})}}});function ri(e,t){let r=[],n=t.exec(e);if(!n)return null;let[s,...a]=n;r.push({name:"$0_lowercase",value:s.toLowerCase()}),r.push({name:"$0_capitalize",value:Fn(s)}),r.push({name:"$0_uncapitalize",value:kn(s)}),r.push({name:"$0",value:s});for(let i=0;i<a.length;i++){let p=`$${i+1}`,l=a[i];l!==void 0&&(r.push({name:`${p}_lowercase`,value:l.toLowerCase()}),r.push({name:`${p}_capitalize`,value:Fn(l)}),r.push({name:`${p}_uncapitalize`,value:kn(l)}),r.push({name:p,value:l}))}return r}function Fn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function kn(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as re,AST_TOKEN_TYPES as On,ESLintUtils as ii}from"@typescript-eslint/utils";import{z as We}from"zod/v4";var oi=ii.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dn="collapse-simple-objs-in-one-line",si=We.object({maxLineLength:We.number().optional(),maxProperties:We.number().optional(),nestedObjMaxLineLength:We.number().optional(),nestedObjMaxProperties:We.number().optional(),ignoreTypesWithSuffix:We.array(We.string()).optional()}),ai=oi({name:Dn,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(si)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function p(c){if(c.type===re.ObjectExpression){let d=c.parent.type===re.Property,y=d?i:s,g=c.properties.length;if(g>y)return!1;if(g===1){let f=c.properties[0];return!f||f.type===re.Property&&f.value.type===re.ObjectExpression||f.type===re.Property&&f.value.type===re.ArrayExpression&&!f.value.elements.every(h=>h&&Et(h))?!1:{text:r.getText(f),isNested:d,propsSize:g}}let b=[];for(let f of c.properties){if(f.type===re.Property&&!Et(f.value))return!1;b.push(r.getText(f))}return{text:b.join(", "),isNested:d,propsSize:g}}else{let d=c.parent.parent?.type===re.TSPropertySignature,y=d?i:s,g=c.members.length;if(g>y)return!1;if(n.length>0&&c.parent.type===re.TSTypeAliasDeclaration){let f=c.parent.id.name;if(n.some(E=>f.endsWith(E)))return!1}if(g===1){let f=c.members[0];return!f||f.type===re.TSPropertySignature&&f.typeAnnotation?.typeAnnotation.type===re.TSTypeLiteral?!1:{text:r.getText(f),isNested:d,propsSize:1}}if(c.parent.type===re.TSIntersectionType||c.parent.type===re.TSUnionType&&c.parent.types[0]!==c)return!1;let b=[];for(let f of c.members){if(f.type!==re.TSPropertySignature)return!1;let E=f.typeAnnotation?.typeAnnotation;if(!E||E.type===re.TSTypeLiteral||!Nn(E))return!1;if(E.type===re.TSTypeReference&&E.typeArguments){if(E.typeArguments.params.length>1)return!1;let m=E.typeArguments.params[0];if(!m||!Nn(m))return!1}let h=r.getText(f).trim();(h.endsWith(";")||h.endsWith(","))&&(h=h.slice(0,-1)),b.push(h)}return{text:b.join("; "),isNested:d,propsSize:g}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==re.JSXExpressionContainer){let E=0,h=!1,m=r.getTokenAfter(c,{filter:I=>I.type!==On.Punctuator||h?!0:I.value===","?(E++,!1):I.value===";"?(E++,h=!0,!1):I.value===")"||I.value==="}"?(E++,!1):!0});if(E>4)return;let A=m?.type===On.Template&&m.value.startsWith(`}
|
|
2
2
|
`);if(m?.loc.start.line===c.loc.end.line&&!A)return}let d=p(c);if(!d)return;let y=d.text;if(y.includes(`
|
|
3
|
-
`)||r.getCommentsInside(c).length>0)return;y.endsWith(";")&&(y=y.slice(0,-1));let g=`{ ${y} }`,b=pi(r,c),f=d.isNested&&d.propsSize>2?a:t.maxLineLength;f&&g.length+b.length+li(c,r)>f||e.report({node:c,messageId:"singleLineProp",fix:E=>E.replaceText(c,g)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function
|
|
4
|
-
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function pi(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var
|
|
3
|
+
`)||r.getCommentsInside(c).length>0)return;y.endsWith(";")&&(y=y.slice(0,-1));let g=`{ ${y} }`,b=pi(r,c),f=d.isNested&&d.propsSize>2?a:t.maxLineLength;f&&g.length+b.length+li(c,r)>f||e.report({node:c,messageId:"singleLineProp",fix:E=>E.replaceText(c,g)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function Nn(e){return e.type===re.TSLiteralType||e.type===re.TSTypeReference||e.type===re.TSNumberKeyword||e.type===re.TSStringKeyword||e.type===re.TSBooleanKeyword||e.type===re.TSNullKeyword||e.type===re.TSUndefinedKeyword}function Et(e,t){return!!(e.type===re.Literal||e.type===re.Identifier||e.type===re.TemplateLiteral||e.type===re.TaggedTemplateExpression||!t&&e.type===re.ArrayExpression&&e.elements.every(r=>r&&Et(r,!0)))}function li(e,t){let r=t.getLastToken(e);if(!r)return 0;let n=t.text.indexOf(`
|
|
4
|
+
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function pi(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var bt={name:Dn,rule:ai};var ci=/eslint +react-compiler\/react-compiler: +\["error/,Ln={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,r=typeof e.getSource=="function"?m=>r(m):m=>e.sourceCode.getText(m),n=typeof e.getScope=="function"?()=>n():m=>e.sourceCode.getScope(m),s=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,a=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:s,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function p(m){a&&Array.isArray(m.suggest)&&m.suggest.length>0&&(m.fix=m.suggest[0].fix),e.report(m)}let l=e.getSourceCode().scopeManager,c=new WeakMap,d=new WeakSet,y=new WeakMap,g=new WeakMap,b=new WeakSet;function f(m,A){return function(I){if(A.has(I))return A.get(I);let o=m(I);return A.set(I,o),o}}function E(m,A,I,o,S){S&&m.async&&p({node:m,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
5
5
|
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
async function fetchData() {
|
|
@@ -12,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 u=l.acquire(m),T=new Set,w=null;{let P=u.upper;for(;P&&(T.add(P),P.type!=="function");)P=P.upper;if(!P)return;w=P}let R=Array.isArray;function v(P){if(!R(P.defs))return!1;let k=P.defs[0];if(k==null||k.node.type!=="VariableDeclarator")return!1;let j=k.node.init;if(j==null)return!1;for(;j.type==="TSAsExpression";)j=j.expression;let $=k.node.parent;if($==null&&(At(w.block,k.node.id),$=k.node.parent,$==null))return!1;if($.kind==="const"&&j.type==="Literal"&&(typeof j.value=="string"||typeof j.value=="number"||j.value===null))return!0;if(j.type!=="CallExpression")return!1;let J=j.callee;if(J.type==="MemberExpression"&&J.object.name==="React"&&J.property!=null&&!J.computed&&(J=J.property),J.type!=="Identifier")return!1;let z=k.node.id,{name:H}=J;if(H==="useRef"&&z.type==="Identifier")return!0;if(yi(J)&&z.type==="Identifier"){for(let Z of P.references)Z!==z&&b.add(Z.identifier);return!0}else if(H==="useState"||H==="useReducer"){if(z.type==="ArrayPattern"&&z.elements.length===2&&R(P.identifiers)){if(z.elements[1]===P.identifiers[0]){if(H==="useState"){let Z=P.references,Ae=0;for(let je=0;je<Z.length;je++){if(Z[je].isWrite()&&Ae++,Ae>1)return!1;c.set(Z[je].identifier,z.elements[0])}}return!0}else if(z.elements[0]===P.identifiers[0]){if(H==="useState"){let Z=P.references;for(let Ae=0;Ae<Z.length;Ae++)d.add(Z[Ae].identifier)}return!1}}}else if(H==="useTransition"&&z.type==="ArrayPattern"&&z.elements.length===2&&Array.isArray(P.identifiers)&&z.elements[1]===P.identifiers[0])return!0;return!1}function x(P){if(!R(P.defs))return!1;let k=P.defs[0];if(k==null||k.node==null||k.node.id==null)return!1;let j=k.node,$=w.childScopes,J=null,z;for(z=0;z<$.length;z++){let H=$[z],Z=H.block;if(j.type==="FunctionDeclaration"&&Z===j||j.type==="VariableDeclarator"&&Z.parent===j){J=H;break}}if(J==null)return!1;for(z=0;z<J.through.length;z++){let H=J.through[z];if(H.resolved!=null&&T.has(H.resolved.scope)&&!C(H.resolved))return!1}return!0}let C=f(v,y),F=f(x,g),O=new Map;function G(P){let k=P.from,j=!1;for(;k.block!==m;)k.type==="function"&&(j=k.block.parent!=null&&k.block.parent.type==="ReturnStatement"),k=k.upper;return j}let _=new Map,te=new Map;M(u);function M(P){for(let k of P.references){if(!k.resolved||!T.has(k.resolved.scope))continue;let j=At(m,k.identifier),$=$n(j),J=Le($,te);if(S&&$.type==="Identifier"&&($.parent.type==="MemberExpression"||$.parent.type==="OptionalMemberExpression")&&!$.parent.computed&&$.parent.property.type==="Identifier"&&$.parent.property.name==="current"&&G(k)&&O.set(J,{reference:k,dependencyNode:$}),$.parent.type==="TSTypeQuery"||$.parent.type==="TSTypeReference")continue;let z=k.resolved.defs[0];if(z!=null&&!(z.node!=null&&z.node.init===m.parent)&&z.type!=="TypeParameter")if(_.has(J))_.get(J).references.push(k);else{let H=k.resolved,Z=C(H)||F(H);_.set(J,{isStable:Z,references:[k]})}}for(let k of P.childScopes)M(k)}O.forEach(({reference:P,dependencyNode:k},j)=>{let $=P.resolved.references,J=!1;for(let z=0;z<$.length;z++){let{identifier:H}=$[z],{parent:Z}=H;if(Z!=null&&Z.type==="MemberExpression"&&!Z.computed&&Z.property.type==="Identifier"&&Z.property.name==="current"&&Z.parent.type==="AssignmentExpression"&&Z.parent.left===Z){J=!0;break}}J||p({node:k.parent.property,message:`The ref value '${j}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${j}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let W=new Set;function X(P,k){W.has(k)||(W.add(k),p({node:P,message:`Assignments to the '${k}' variable from inside React Hook ${r(I)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${r(I)}.`}))}let ne=new Set;if(_.forEach(({isStable:P,references:k},j)=>{P&&ne.add(j),k.forEach($=>{$.writeExpr&&X($.writeExpr,j)})}),W.size>0)return;if(!A){let P=null;if(_.forEach(({isStable:k,references:j},$)=>{P||j.forEach(J=>{if(P)return;let z=J.identifier;if(!c.has(z))return;let Z=J.from;for(;Z.type!=="function";)Z=Z.upper;Z.block===m&&(P=$)})}),P){let{suggestedDependencies:k}=Ct({dependencies:_,declaredDependencies:[],stableDependencies:ne,externalDependencies:new Set,isEffect:!0});p({node:I,message:`React Hook ${o} contains a call to '${P}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+k.join(", ")+`] as a second argument to the ${o} Hook.`,suggest:[{desc:`Add dependencies array: [${k.join(", ")}]`,fix(j){return j.insertTextAfter(m,`, [${k.join(", ")}]`)}}]})}return}let le=[],Ee=new Set;A.type!=="ArrayExpression"?p({node:A,message:`React Hook ${r(I)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):A.elements.forEach(P=>{if(P===null)return;if(P.type==="SpreadElement"){p({node:P,message:`React Hook ${r(I)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}b.has(P)&&p({node:P,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(P)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(P)}\``,fix(J){return J.removeRange(P.range)}}]});let k;try{k=Le(P,te)}catch(J){if(/Unsupported node type/.test(J.message)){P.type==="Literal"?_.has(P.value)?p({node:P,message:`The ${P.raw} literal is not a valid dependency because it never changes. Did you mean to include ${P.value} in the array instead?`}):p({node:P,message:`The ${P.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):p({node:P,message:`React Hook ${r(I)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw J}let j=P;for(;j.type==="MemberExpression"||j.type==="OptionalMemberExpression"||j.type==="ChainExpression";)j=j.object||j.expression.object;let $=!w.through.some(J=>J.identifier===j);le.push({key:k,node:P}),$||Ee.add(k)});let{suggestedDependencies:be,unnecessaryDependencies:xe,missingDependencies:Se,duplicateDependencies:it}=Ct({dependencies:_,declaredDependencies:le,stableDependencies:ne,externalDependencies:Ee,isEffect:S}),Ze=be;if(it.size+Se.size+xe.size===0){if(t)return;ui({declaredDependencies:le,declaredDependenciesNode:A,componentScope:w,scope:u}).forEach(({construction:k,isUsedOutsideOfHook:j,depType:$})=>{let J=$==="function"?"useCallback":"useMemo",z=$==="function"?"definition":"initialization",H=`wrap the ${z} of '${k.name.name}' in its own ${J}() Hook.`,Z=j?`To fix this, ${H}`:`Move it inside the ${o} callback. Alternatively, ${H}`,Ae=$==="conditional"||$==="logical expression"?"could make":"makes",je=`The '${k.name.name}' ${$} ${Ae} the dependencies of ${o} Hook (at line ${A.loc.start.line}) change on every render. ${Z}`,Pn;j&&k.type==="Variable"&&$==="function"&&(Pn=[{desc:`Wrap the ${z} of '${k.name.name}' in its own ${J}() Hook.`,fix(vn){let[Qr,ei]=J==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[vn.insertTextBefore(k.node.init,Qr),vn.insertTextAfter(k.node.init,ei)]}}]),p({node:k.node,message:je,suggest:Pn})});return}!S&&Se.size>0&&(Ze=Ct({dependencies:_,declaredDependencies:[],stableDependencies:ne,externalDependencies:Ee,isEffect:S}).suggestedDependencies);function Ie(){if(le.length===0)return!0;let P=le.map(j=>j.key),k=P.slice().sort();return P.join(",")===k.join(",")}Ie()&&Ze.sort();function Tt(P){let k=P.split("."),j="";for(let $=0;$<k.length;$++){if($!==0){let J=k.slice(0,$+1).join("."),z=te.get(J)===!0;j+=z?"?.":"."}j+=k[$]}return j}function ht(P,k,j,$){return P.size===0?null:(P.size>1?"":k+" ")+j+" "+(P.size>1?"dependencies":"dependency")+": "+mi(Array.from(P).sort().map(J=>"'"+Tt(J)+"'"))+`. Either ${$} ${P.size>1?"them":"it"} or remove the dependency array.`}let ve="";if(xe.size>0){let P=null;if(Array.from(xe.keys()).forEach(k=>{P===null&&k.endsWith(".current")&&(P=k)}),P!==null)ve=` Mutable values like '${P}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Ee.size>0){let k=Array.from(Ee)[0];u.set.has(k)||(ve=` Outer scope values like '${k}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ve&&Se.has("props")){let P=_.get("props");if(P==null)return;let k=P.references;if(!Array.isArray(k))return;let j=!0;for(let $=0;$<k.length;$++){let J=k[$],z=At(w.block,J.identifier);if(!z){j=!1;break}let H=z.parent;if(H==null){j=!1;break}if(H.type!=="MemberExpression"&&H.type!=="OptionalMemberExpression"){j=!1;break}}j&&(ve=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${o} call and refer to those specific props inside ${r(I)}.`)}if(!ve&&Se.size>0){let P=null;Se.forEach(k=>{if(P)return;let j=w.set.get(k),$=_.get(k);if($.references[0].resolved!==j)return;let J=j.defs[0];if(J==null||J.name==null||J.type!=="Parameter")return;let z=!1,H;for(let Z=0;Z<$.references.length;Z++)if(H=$.references[Z].identifier,H!=null&&H.parent!=null&&(H.parent.type==="CallExpression"||H.parent.type==="OptionalCallExpression")&&H.parent.callee===H){z=!0;break}z&&(P=k)}),P!==null&&(ve=` If '${P}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ve&&Se.size>0){let P=null;if(Se.forEach(k=>{if(P!==null)return;let $=_.get(k).references,J,z;for(let H=0;H<$.length;H++){for(J=$[H].identifier,z=J.parent;z!=null&&z!==w.block;){if(z.type==="CallExpression"){let Z=c.get(z.callee);if(Z!=null){if(Z.name===k)P={missingDep:k,setter:z.callee.name,form:"updater"};else if(d.has(J))P={missingDep:k,setter:z.callee.name,form:"reducer"};else{let Ae=$[H].resolved;if(Ae!=null){let je=Ae.defs[0];je!=null&&je.type==="Parameter"&&(P={missingDep:k,setter:z.callee.name,form:"inlineReducer"})}}break}}z=z.parent}if(P!==null)break}}),P!==null)switch(P.form){case"reducer":ve=` You can also replace multiple useState variables with useReducer if '${P.setter}' needs the current value of '${P.missingDep}'.`;break;case"inlineReducer":ve=` If '${P.setter}' needs the current value of '${P.missingDep}', you can also switch to useReducer instead of useState and read '${P.missingDep}' in the reducer.`;break;case"updater":ve=` You can also do a functional update '${P.setter}(${P.missingDep.slice(0,1)} => ...)' if you only need '${P.missingDep}' in the '${P.setter}' call.`;break;default:throw new Error("Unknown case.")}}p({node:A,message:`React Hook ${r(I)} has `+(ht(Se,"a","missing","include")||ht(xe,"an","unnecessary","exclude")||ht(it,"a","duplicate","omit"))+ve,suggest:[{desc:`Update the dependencies array to be: [${Ze.map(Tt).join(", ")}]`,fix(P){return P.replaceText(A,`[${Ze.map(Tt).join(", ")}]`)}}]})}function h(m){let A=fi(m.callee,i);if(A===-1)return;let I=m.arguments[A],o=m.callee,S=_n(o).name,u=m.arguments[A+1],T=/Effect($|[^a-z])/g.test(S);if(!I){p({node:o,message:`React Hook ${S} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!T)){if(!u&&!T){(S==="useMemo"||S==="useCallback")&&p({node:o,message:`React Hook ${S} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(I.type){case"FunctionExpression":case"ArrowFunctionExpression":E(I,u,o,S,T);return;case"Identifier":if(!u||u.elements&&u.elements.some(v=>v&&v.type==="Identifier"&&v.name===I.name))return;let w=n(m).set.get(I.name);if(w==null||w.defs==null)return;let R=w.defs[0];if(!R||!R.node||R.type!=="Variable"&&R.type!=="FunctionName")break;switch(R.node.type){case"FunctionDeclaration":E(R.node,u,o,S,T);return;case"VariableDeclarator":let v=R.node.init;if(!v)break;switch(v.type){case"ArrowFunctionExpression":case"FunctionExpression":E(v,u,o,S,T);return}break}break;default:p({node:o,message:`React Hook ${S} received a function whose dependencies are unknown. Pass an inline function instead.`});return}p({node:o,message:`React Hook ${S} has a missing dependency: '${I.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${I.name}]`,fix(w){return w.replaceText(u,`[${I.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let m of e.sourceCode.getAllComments())if(ci.test(m.value))return t=!0,{CallExpression:A=>h(A,!0)}}return{CallExpression:m=>h(m)}}};function Ct({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:s}){let a=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,h)=>{let m=p(a,h);m.isUsed=!0,l(a,h,A=>{A.isSubtreeUsed=!0})}),t.forEach(({key:E})=>{let h=p(a,E);h.isSatisfiedRecursively=!0}),r.forEach(E=>{let h=p(a,E);h.isSatisfiedRecursively=!0});function p(E,h){let m=h.split("."),A=E;for(let I of m){let o=A.children.get(I);o||(o=i(),A.children.set(I,o)),A=o}return A}function l(E,h,m){let A=h.split("."),I=E;for(let o of A){let S=I.children.get(o);if(!S)return;m(S),I=S}}let c=new Set,d=new Set;y(a,c,d,E=>E);function y(E,h,m,A){E.children.forEach((I,o)=>{let S=A(o);if(I.isSatisfiedRecursively){I.isSubtreeUsed&&m.add(S);return}if(I.isUsed){h.add(S);return}y(I,h,m,u=>S+"."+u)})}let g=[],b=new Set,f=new Set;return t.forEach(({key:E})=>{d.has(E)?g.indexOf(E)===-1?g.push(E):f.add(E):b.add(E)}),c.forEach(E=>{g.push(E)}),{suggestedDependencies:g,unnecessaryDependencies:b,duplicateDependencies:f,missingDependencies:c}}function _e(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return _e(e.consequent)!=null||_e(e.alternate)!=null?"conditional":null;case"LogicalExpression":return _e(e.left)!=null||_e(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return _e(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return _e(e.expression);case"TSAsExpression":return _e(e.expression)}return null}function ui({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let s=e.map(({key:i})=>{let p=r.variables.find(c=>c.name===i);if(p==null)return null;let l=p.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=_e(l.node.init);if(c!=null)return[p,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[p,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[p,"class"]:null}).filter(Boolean);function a(i){let p=!1;for(let l=0;l<i.references.length;l++){let c=i.references[l];if(c.writeExpr){if(p)return!0;p=!0;continue}let d=c.from;for(;d!==n&&d!=null;)d=d.upper;if(d!==n&&!Un(t,c.identifier))return!0}return!1}return s.map(([i,p])=>({construction:i.defs[0],depType:p,isUsedOutsideOfHook:a(i)}))}function $n(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?$n(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function It(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function Le(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=Le(e.object,t),n=Le(e.property,null),s=`${r}.${n}`;return It(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Le(e.object,t),n=Le(e.property,null),s=`${r}.${n}`;return It(e,t,s),s}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=Le(r.object,t),s=Le(r.property,null),a=`${n}.${s}`;return It(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function _n(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function fi(e,t){let r=_n(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let n;try{n=Le(r,null)}catch(s){if(/Unsupported node type/.test(s.message))return 0;throw s}return t.additionalHooks.test(n)?0:-1}else return-1}}function At(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),di(n,t))return n;if(Un(n,t))for(let[s,a]of Object.entries(n))s!=="parent"&&(Ln(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(i=>{Ln(i)&&(i.parent=n,r.push(i))}))}return null}function mi(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function Ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function di(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function Un(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function yi(e){return!1}import{AST_NODE_TYPES as ce,ESLintUtils as Bn}from"@typescript-eslint/utils";import Y from"typescript";import{z as Vn}from"zod/v4";import{AST_NODE_TYPES as zn}from"@typescript-eslint/utils";function Xe(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Xe(e.parent,t,r===1/0?r:r-1)}function*wt(e){yield e,e.parent&&(yield*wt(e.parent))}function Rt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function Jn(e,t,r){let s=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===zn.Property&&a.identifiers[0].parent.key.type===zn.Identifier&&a.identifiers[0].parent.key.name===t);return s?s.references.filter(a=>!a.init):[]}function Wn(e){return e===null||typeof e!="object"||!("type"in e)?!1:typeof e.type=="string"}function gi(e,t){return e[t]}function Fe(e,t,r){let n=r.visitorKeys,s=new Set;function a(i){if(s.has(i))return!1;if(s.add(i),t(i)===!0)return!0;let l=n[i.type];if(l)for(let c of l){let d=gi(i,c);if(d){if(Array.isArray(d)){for(let y of d)if(Wn(y)&&a(y))return!0}else if(Wn(d)&&a(d))return!0}}return!1}a(e)}var Si=Bn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xn="improved-no-unnecessary-condition",Ti=Vn.object({alternativeForInCondition:Vn.string().optional().describe("Alternative to appear in the error for `in` condition")}),hi=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Ei=new Set(hi),Pt={name:Xn,rule:Si({name:Xn,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".',unnecessaryStartsWithCondition:"This startsWith check is unnecessary as it always evaluates to true.",alwaysFalseStartsWithCondition:"This startsWith check will always be false.",unnecessaryEndsWithCondition:"This endsWith check is unnecessary as it always evaluates to true.",alwaysFalseEndsWithCondition:"This endsWith check will always be false.",unnecessaryIncludesCondition:"This includes check is unnecessary as it always evaluates to true.",alwaysFalseIncludesCondition:"This includes check will always be false.",unnecessaryLengthCondition:"This length comparison is unnecessary as it always evaluates to true.",alwaysFalseLengthCondition:"This length comparison will always be false.",unnecessaryInCondition:'This in check is unnecessary. Property "{{property}}" always exists on type "{{type}}".{{alternative}}',alwaysFalseInCondition:'This in check will always be false. Property "{{property}}" does not exist on type "{{type}}".{{alternative}}'},schema:[V(Ti)]},defaultOptions:[{}],create(e,[t]){let r=Bn.getParserServices(e,!0),n=r.program?.getTypeChecker();if(!n||!r.program)throw new Error("TypeScript services or program not available");function s(o){return o.type===ce.UnaryExpression&&o.operator==="typeof"}function a(o){return o.flags&Y.TypeFlags.Any||o.flags&Y.TypeFlags.Unknown?null:o.flags&Y.TypeFlags.StringLike?["string"]:o.flags&Y.TypeFlags.NumberLike?["number"]:o.flags&Y.TypeFlags.BigIntLike?["bigint"]:o.flags&Y.TypeFlags.BooleanLike?["boolean"]:o.flags&Y.TypeFlags.ESSymbolLike?["symbol"]:o.flags&Y.TypeFlags.Undefined||o.flags&Y.TypeFlags.Void?["undefined"]:o.flags&Y.TypeFlags.Null?["object"]:o.getCallSignatures().length>0?["function"]:o.flags&Y.TypeFlags.Object?o.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:o.flags&Y.TypeFlags.NonPrimitive?["object"]:o.flags&Y.TypeFlags.Never?["never"]:null}function i(o){if(!n)return null;let S=r.esTreeNodeToTSNodeMap.get(o),u=n.getTypeAtLocation(S.expression);if(u.flags&Y.TypeFlags.Any||u.flags&Y.TypeFlags.Unknown)return null;let T=[];if(u.isUnion()){for(let R of u.types){let v=a(R);if(v)T.push(...v);else return null}return T}let w=a(u);return w?(T.push(...w),T):null}function p(o){if(!(o.operator==="==="||o.operator==="!=="))return;let u=null,T=null;if(s(o.left)?(u=o.left,T=o.right.type===ce.Literal&&typeof o.right.value=="string"?o.right.value:null):s(o.right)&&(u=o.right,T=o.left.type===ce.Literal&&typeof o.left.value=="string"?o.left.value:null),!u||!T||!bi(T,Ei))return;let w=i(u);if(!w)return;let R=o.operator==="!==",v=w.includes(T);w.length===1?v&&!R?e.report({node:o,messageId:"unnecessaryTypeofCondition",data:{name:Be(u,e),type:T}}):!v&&R?e.report({node:o,messageId:"unnecessaryTypeofCondition",data:{name:Be(u,e),type:Array.from(w)[0]}}):!v&&!R?e.report({node:o,messageId:"alwaysFalseTypeofCondition",data:{name:Be(u,e),actualType:ot(w),conditionType:T}}):v&&R&&e.report({node:o,messageId:"alwaysFalseTypeofCondition",data:{name:Be(u,e),actualType:ot(w),conditionType:T}}):!v&&!R?e.report({node:o,messageId:"alwaysFalseTypeofCondition",data:{name:Be(u,e),actualType:ot(w),conditionType:T}}):!v&&R&&e.report({node:o,messageId:"unnecessaryTypeofCondition",data:{name:Be(u,e),type:ot(w)}})}function l(o){if(o.flags&Y.TypeFlags.Any||o.flags&Y.TypeFlags.Unknown)return null;if(o.isUnion()){let S=[];for(let u of o.types)if(u.flags&Y.TypeFlags.StringLiteral){let T=u.value;S.push(T)}else return null;return S}return o.flags&Y.TypeFlags.StringLiteral?[o.value]:null}function c(o){if(!n)return null;let S=r.esTreeNodeToTSNodeMap.get(o),u=n.getTypeAtLocation(S),T=l(u);if(T)return T;let w=n.getSymbolAtLocation(S);if(w){let R=n.getTypeOfSymbolAtLocation(w,S),v=l(R);if(v)return v}return null}function d(o){let S=e.sourceCode.ast,u=null;return Fe(S,T=>{if(T.type===ce.VariableDeclarator&&T.id.type===ce.Identifier&&T.id.name===o.name&&T.id.typeAnnotation){let w=T.id.typeAnnotation.typeAnnotation;if(w.type===ce.TSUnionType){let R=[];for(let v of w.types)if(v.type===ce.TSLiteralType&&v.literal.type===ce.Literal&&typeof v.literal.value=="string")R.push(v.literal.value);else return!0;return u=R,!0}if(w.type===ce.TSLiteralType&&w.literal.type===ce.Literal&&typeof w.literal.value=="string")return u=[w.literal.value],!0}return!1},e.sourceCode),u}function y(o){if(o.callee.type!==ce.MemberExpression||o.callee.property.type!==ce.Identifier||o.callee.computed)return;let S=o.callee.property.name;if(S!=="startsWith"&&S!=="endsWith"&&S!=="includes"||o.arguments.length!==1)return;let[u]=o.arguments;if(!u||u.type!==ce.Literal||typeof u.value!="string")return;let T=o.callee.object,w=c(T);if(!w&&T.type===ce.Identifier&&(w=d(T)),!w||w.length===0)return;let R=u.value;if(S==="includes"&&w.length>1)return;let v=0,x=0;for(let C of w)if((S==="startsWith"?C.startsWith(R):S==="endsWith"?C.endsWith(R):C.includes(R))?v++:x++,v>0&&x>0)return;if(v>0&&x===0){let C=S==="startsWith"?"unnecessaryStartsWithCondition":S==="endsWith"?"unnecessaryEndsWithCondition":"unnecessaryIncludesCondition";e.report({node:o,messageId:C})}else if(x>0&&v===0){let C=S==="startsWith"?"alwaysFalseStartsWithCondition":S==="endsWith"?"alwaysFalseEndsWithCondition":"alwaysFalseIncludesCondition";e.report({node:o,messageId:C})}}function g(o){if(!new Set(["===","!==",">",">=","<","<="]).has(o.operator))return;function u(F){if(F.type!==ce.MemberExpression||F.computed||F.property.type!==ce.Identifier||F.property.name!=="length")return null;let O=F.object,G=c(O);if(!G||G.length===0)return null;let _=[];for(let te of G)_.push(te.length);return{values:_}}let T=u(o.left),w=u(o.right),R=null,v=null;if(T?o.right.type===ce.Literal&&typeof o.right.value=="number"&&(R=T.values,v=o.right.value):w&&o.left.type===ce.Literal&&typeof o.left.value=="number"&&(R=w.values,v=o.left.value),!R||v===null)return;let x=0,C=0;for(let F of R){let O=!1;if(o.operator==="==="?O=F===v:o.operator==="!=="?O=F!==v:o.operator===">"?O=F>v:o.operator===">="?O=F>=v:o.operator==="<"?O=F<v:o.operator==="<="&&(O=F<=v),O?x++:C++,x>0&&C>0)return}x>0&&C===0?e.report({node:o,messageId:"unnecessaryLengthCondition"}):C>0&&x===0&&e.report({node:o,messageId:"alwaysFalseLengthCondition"})}function b(o){if(o.type===ce.Literal&&typeof o.value=="string")return o.value;let S=c(o);if(!S||S.length!==1)return null;let[u]=S;return u??null}function f(o){return(o.flags&Y.TypeFlags.Intersection)!==0}function E(o){return(o.flags&Y.TypeFlags.Object)!==0}function h(o){return!n||n.getIndexTypeOfType(o,Y.IndexKind.String)?!0:!!n.getIndexTypeOfType(o,Y.IndexKind.Number)}function m(o,S){if(!n||h(o)||o.getProperties().length===0)return"unknown";let u=n.getPropertyOfType(o,S);return u?u.flags&Y.SymbolFlags.Optional?"optional":"required":"absent"}function A(o,S){if(o.flags&Y.TypeFlags.Any||o.flags&Y.TypeFlags.Unknown||o.flags&Y.TypeFlags.Never||o.flags&Y.TypeFlags.TypeParameter||o.flags&Y.TypeFlags.IndexedAccess||o.flags&Y.TypeFlags.StringLike||o.flags&Y.TypeFlags.NumberLike||o.flags&Y.TypeFlags.BigIntLike||o.flags&Y.TypeFlags.BooleanLike||o.flags&Y.TypeFlags.EnumLike||o.flags&Y.TypeFlags.ESSymbolLike||o.flags&Y.TypeFlags.NonPrimitive||o.flags&Y.TypeFlags.Null||o.flags&Y.TypeFlags.Undefined||o.flags&Y.TypeFlags.Void)return"unknown";if(o.isUnion()){let u=!0,T=!0;for(let w of o.types){let R=A(w,S);if(R==="unknown"||(R!=="required"&&(u=!1),R!=="absent"&&(T=!1),R==="optional"))return"unknown"}return u?"required":T?"absent":"unknown"}if(f(o)){let u=o,T=!1,w=!1;for(let R of u.types){let v=A(R,S);if(v==="unknown")return"unknown";v==="required"?T=!0:v==="optional"&&(w=!0)}return T?"required":w?"optional":"absent"}return E(o)?m(o,S):"unknown"}function I(o){if(o.operator!=="in"||o.left.type===ce.PrivateIdentifier)return;let S=b(o.left);if(!S)return;let u=o.right,T=r.esTreeNodeToTSNodeMap.get(u);if(!n)return;let w=n.getTypeAtLocation(T),R=A(w,S);R==="required"?e.report({node:o,messageId:"unnecessaryInCondition",data:{property:S,type:n.typeToString(w),alternative:t.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${t.alternativeForInCondition}`:""}}):R==="absent"&&e.report({node:o,messageId:"alwaysFalseInCondition",data:{property:S,type:n.typeToString(w),alternative:t.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${t.alternativeForInCondition}`:""}})}return{BinaryExpression(o){p(o),g(o),I(o)},CallExpression:y}}})};function ot(e){return Array.from(new Set(e)).join(" | ")||"never"}function Be(e,t){let r=e.argument;return r.type===ce.Identifier?r.name:t.sourceCode.getText(r)}function bi(e,t){return t.has(e)}import{AST_NODE_TYPES as xi,ESLintUtils as Ci}from"@typescript-eslint/utils";import{z as vt}from"zod/v4";var Ii=Ci.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Hn="no-call-with-explicit-generics",Ai=vt.object({functions:vt.array(vt.string())}),wi=Ii({name:Hn,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[V(Ai)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:s}=n;s.type===xi.Identifier&&r.has(s.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),Ft={name:Hn,rule:wi};import{AST_NODE_TYPES as st,ESLintUtils as Ri}from"@typescript-eslint/utils";var Pi=Ri.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yn="no-call-with-inferred-generics",vi=Pi({name:Yn,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:s}=n;if(s.type!==st.Identifier)return;let a=r.get(s.name);if(!a)return;let{minGenerics:i=1,allowAny:p,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:i||0}}),!(p&&!l)&&n.typeArguments?.params.some(d=>!p&&d.type===st.TSAnyKeyword||l&&d.type===st.TSTypeReference&&d.typeName.type===st.Identifier&&l.includes(d.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),kt={name:Yn,rule:vi};import{ESLintUtils as Fi}from"@typescript-eslint/utils";var ki=Fi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gn="no-commented-out-code",Oi=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],Ni=/^\s*return\s+/,Di=/\w=("|'|`)/,ji=/\w+:\s*('|"|`)/,Li=/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,Mi=/\w+-\w+:/,$i=/\w+_\w+:/,_i=/\?\s+\w/,Ui=/:\s+\w/,zi=/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,Wi=/^\s*\d+[,}]/,Ji=/^\s*\[[^\]]*\][,}]/,Vi=/^\s*\{[^}]*\}[,}]/,Xi=/\.\w+\(/,Bi=/\[\w+\]/,Hi=/^\s*(['"`]).+?\1\s*:/,Yi=/^<[A-Z]\w*(\s|>|\/)/,qi=/^<[a-z]+(\s|>|\/)/,Zi=/<[A-Z]\w*(\s.*)?>/,Gi=/<\/[A-Z]\w*>/,Ki=/<[a-z]+(\s.*)?>/,Qi=/<\/[a-z]+>/,eo=/^\s*[*\s]*$/,to=/^[a-zA-Z]/,no=/^[A-Z][A-Za-z]*(?:\s+\d+)?(?:\s+[a-z]+)*:\s+[A-Za-z]/,ro=/```[\s\S]*?```/g,io=/`[^`]*`/g,qn=/[a-zA-Z0-9]/,oo=/\.[A-Za-z_][A-Za-z0-9_]*\(/,so=/[{}[\]()`=<>]/,ao=/:\s*(['"`[{(]|\w+\s*=>)/,lo=/\bif\s*\(|\belse\b|=>/,pe={returnStatement:Ni,stringAssignment:Di,objectPropertyWithQuotes:ji,computedPropertyAssignment:Li,kebabCaseProperty:Mi,snakeCaseProperty:$i,ternaryOperator:_i,colonWithWord:Ui,quotedString:zi,numberWithComma:Wi,arrayWithComma:Ji,objectWithComma:Vi,methodCall:Xi,arrayAccess:Bi,quotedPropertyKey:Hi,jsxSelfClosing:Yi,jsxElement:qi,jsxOpeningTag:Zi,jsxClosingTag:Gi,htmlOpeningTag:Ki,htmlClosingTag:Qi,jsdocComment:eo};function po(e){if(e.includes(":")){let r=e.split(":")[0]?.trim();if(r&&to.test(r)&&r.includes(" "))return!0}let t=e.trim();return t.length===0||oo.test(t)||so.test(t)||ao.test(t)||lo.test(t)?!1:!!(t.includes(":")&&no.test(t))}var co=[") {","return;",pe.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",pe.stringAssignment,");",pe.objectPropertyWithQuotes,pe.computedPropertyAssignment,pe.kebabCaseProperty,pe.snakeCaseProperty,"&&","||","()",pe.ternaryOperator,pe.colonWithWord,pe.quotedString,pe.numberWithComma,pe.arrayWithComma,pe.objectWithComma,pe.methodCall,pe.arrayAccess,"?.(","??","=>",pe.quotedPropertyKey],uo=["/>","</",pe.jsxSelfClosing,pe.jsxElement,pe.jsxOpeningTag,pe.jsxClosingTag,pe.htmlOpeningTag,pe.htmlClosingTag],Zn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],fo=ki({name:Gn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,s){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||pe.jsdocComment.test(n))return!1;for(let i of Zn)if(a.startsWith(i))return!1;if(n.includes("https://")||po(a))return!1;if(s==="Block"){for(let i of uo)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Oi)if(a.startsWith(i))return{wrongPattern:i};for(let i of co)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,s){let a=n,i=a.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return a;if(s==="Block"&&a.includes("```")){let c=a.split(ro);c.some(y=>qn.test(y))&&(a=c.join(""))}if(!a.includes("`"))return a;let p=a.split(io);return p.some(c=>qn.test(c))?p.join(""):a}return{Program(){let s=e.sourceCode.getAllComments();for(let a of s){let i=r(a.value,a.type),p=t(i,a.type);p&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:p.wrongPattern,allowedPrefixes:Zn.join(", ")}})}}}}}),Ot={name:Gn,rule:fo};import{ESLintUtils as mo,TSESTree as yo}from"@typescript-eslint/utils";var go=mo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kn="no-default-export",So=go({name:Kn,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.type===yo.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Nt={name:Kn,rule:So};import{ESLintUtils as To}from"@typescript-eslint/utils";var ho=To.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qn="no-leaked-text-in-jsx",Eo=[",",";","[","]","(",")"],bo=ho({name:Qn,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let r=t.value.trim();if(!r)return;let n="";Eo.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),Dt={name:Qn,rule:bo};import{AST_NODE_TYPES as Ge,ESLintUtils as xo}from"@typescript-eslint/utils";var Co=xo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tr="no-non-camel-case-functions",Io=/^(\$?[a-z][a-zA-Z0-9]*)$/;function er(e){if(e.typeName.type!==Ge.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Ge.Identifier&&t.name==="JSX"&&r.name==="Element"}var Ao=Co({name:tr,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Io.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Ge.TSTypeReference?er(r):r.type===Ge.TSUnionType&&r.types.some(s=>s.type===Ge.TSTypeReference&&er(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),jt={name:tr,rule:Ao};import{ESLintUtils as wo,TSESTree as oe}from"@typescript-eslint/utils";var Ro=wo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nr="no-optional-root-props",Po=Ro({name:nr,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let i=a.references[0];if(!i)return!1;for(let p of wt(i.identifier)){if("returnType"in p||p.type===oe.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=p.parent;if(!l)return!1;if(l.type===oe.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===oe.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===oe.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let d=Xe(l.parent.parent,oe.AST_NODE_TYPES.VariableDeclaration,4);if(!d)return!1;let y=at(d,e.sourceCode);return y?!(y.parent.type===oe.AST_NODE_TYPES.CallExpression&&y.parent.callee.type===oe.AST_NODE_TYPES.Identifier&&y.parent.callee.name==="memo"):!1}if(p.type===oe.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===oe.AST_NODE_TYPES.ArrowFunctionExpression){let c=Xe(l,oe.AST_NODE_TYPES.VariableDeclaration);return c?!!at(c,e.sourceCode):!1}if(l.type===oe.AST_NODE_TYPES.FunctionDeclaration)return!!at(l,e.sourceCode)}return!1}function r(n){n.key.type!==oe.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:s=>{let a=Xe(n,oe.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let i=e.sourceCode.getText(a);return s.replaceText(a,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===oe.AST_NODE_TYPES.TSTypeLiteral&&!(lt(n)||!t(n)))for(let s of n.typeAnnotation.members)s.type===oe.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSInterfaceDeclaration(n){if(!(lt(n)||!t(n)))for(let s of n.body.body)s.type===oe.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSTypeReference(n){if(n.typeName.type!==oe.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let s=n.typeArguments.params[0];if(s.type!==oe.AST_NODE_TYPES.TSTypeLiteral)return;let a=Xe(n.parent,oe.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let i=at(a,e.sourceCode);if(!(!i||i.parent.type===oe.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===oe.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of s.members)l.type===oe.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function lt(e){return e?e.parent?.type===oe.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===oe.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function at(e,t){if(lt(e))return;let r;if(e.type===oe.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===oe.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===oe.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let s=n.variables.find(i=>i.identifiers.includes(r));if(!s)return;let a=s.references.filter(i=>i.identifier!==r);if(!(a.length!==1||!a[0])&&!lt(a[0].identifier.parent.parent))return a[0].identifier}var Lt={name:nr,rule:Po};import{AST_NODE_TYPES as pt}from"@typescript-eslint/utils";var Ke=B({name:"no-reexport",meta:{type:"problem",docs:{description:"Disallow re-exports to prevent indirection"},schema:[],messages:{noReexport:"Re-exports are not allowed. Use direct exports only."}},defaultOptions:[],create(e){let t=new Set;function r(n){return n?n.type===pt.Identifier?t.has(n.name):n.type===pt.MemberExpression?r(n.object):!1:!1}return{ImportDeclaration(n){for(let s of n.specifiers)t.add(s.local.name)},ExportNamedDeclaration(n){if(n.source){e.report({node:n,messageId:"noReexport"});return}if(n.declaration?.type===pt.VariableDeclaration)for(let s of n.declaration.declarations)r(s.init)&&e.report({node:n,messageId:"noReexport"});n.specifiers.length>0&&e.report({node:n,messageId:"noReexport"})},ExportDefaultDeclaration(n){n.declaration.type===pt.Identifier&&t.has(n.declaration.name)&&e.report({node:n,messageId:"noReexport"})},ExportAllDeclaration(n){e.report({node:n,messageId:"noReexport"})}}}});import{ESLintUtils as vo}from"@typescript-eslint/utils";import Mt from"path";import{z as Ue}from"zod/v4";var Fo=vo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rr="no-relative-imports",ko=Ue.object({find:Ue.string(),replacement:Ue.string()}),Oo=Ue.object({aliases:Ue.array(ko),rootDir:Ue.string().optional(),allowNotFoundAliases:Ue.boolean().optional(),_dev_simulateFileName:Ue.string().optional()}),No=Fo({name:rr,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[V(Oo)]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function s(i,p){let l=Mt.dirname(p);return Mt.resolve(l,i)}function a(i){let p=t.rootDir??process.cwd(),l=Mt.relative(p,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:d}of t.aliases)if(l.startsWith(d)){let y=l.replace(d,c);return{alias:c,newPath:y}}return null}return{ImportDeclaration(i){let p=i.source.value;if(!n(p))return;let l=s(p,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:i,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?d=>d.replaceText(i.source,`'${c.newPath}'`):void 0})}}}}),$t={name:rr,rule:No};import{AST_NODE_TYPES as ue}from"@typescript-eslint/utils";import{z as ir}from"zod/v4";var Do=ir.object({customMessage:ir.string().optional()}),_t=B({name:"no-static-style-prop",meta:{type:"problem",docs:{description:"Prevent using static style props in JSX, only dynamic values should be allowed"},schema:[V(Do)],messages:{noStaticStyleProp:"Static style props are not allowed use css instead.{{customMessage}}"}},defaultOptions:[{}],create(e,[t]){function r(n){switch(n.type){case ue.Literal:return!0;case ue.ObjectExpression:return n.properties.every(s=>s.type===ue.Property?s.computed||s.value.type===ue.Identifier&&s.key.type===ue.Identifier&&s.key.name===s.value.name?!1:r(s.value):!1);case ue.ArrayExpression:return n.elements.every(s=>s?s.type===ue.SpreadElement?!1:r(s):!0);case ue.TemplateLiteral:return n.expressions.length===0;case ue.ConditionalExpression:case ue.LogicalExpression:case ue.BinaryExpression:case ue.UnaryExpression:case ue.CallExpression:case ue.MemberExpression:case ue.Identifier:case ue.ArrowFunctionExpression:case ue.FunctionExpression:return!1;default:return!1}}return{JSXAttribute(n){if(n.name.type===ue.JSXIdentifier&&n.name.name==="style"&&n.value){let s=null;n.value.type===ue.JSXExpressionContainer?n.value.expression.type!==ue.JSXEmptyExpression&&(s=n.value.expression):n.value.type===ue.Literal&&(s=n.value),s&&r(s)&&e.report({node:n,messageId:"noStaticStyleProp",data:{customMessage:t.customMessage?` ${t.customMessage}`:""}})}}}}});import{AST_NODE_TYPES as ct}from"@typescript-eslint/utils";import*as Je from"zod/v4";var jo=Je.object({alternativeMsgs:Je.object({inArrayFind:Je.string().optional(),inArrayFilter:Je.string().optional()}).optional(),__dev_simulateFileName:Je.string().optional()});function Lo(e){return e.typeAnnotation.type!==ct.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}var Mo=/(typeGuards|type-guards)\.(ts|tsx)$/;function $o(e){return Mo.test(e)}function _o(e){let t=e.parent;for(;t;){if(t.type===ct.CallExpression&&t.callee.type===ct.MemberExpression&&t.callee.property.type===ct.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var Ut=B({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Check if the type guard can be inferred by typescript, in most cases it can, e.g. `.filter((nullable) => nullable !== null)`. If not, type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[V(jo)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if($o(r))return{};function n(s){if(!Lo(s))return;let a=_o(s);if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let p=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:s,messageId:p,data:{message:i}});return}}e.report({node:s,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as He}from"@typescript-eslint/utils";var Uo="no-unnecessary-async-on-jsx-props";function zo(e){if(e.body.type!==He.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==He.ExpressionStatement?!1:r.expression.type===He.AwaitExpression}var zt=B({name:Uo,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(r){zo(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let s=e.sourceCode,a=[],i=s.getFirstToken(r,l=>l.value==="async");if(i){let l=s.getTokenAfter(i);l?a.push(n.replaceTextRange([i.range[0],l.range[0]],"")):a.push(n.remove(i))}function p(l){if(l.type===He.AwaitExpression){let c=s.getFirstToken(l);if(c&&c.value==="await"){let d=s.getTokenAfter(c);d?a.push(n.replaceTextRange([c.range[0],d.range[0]],"")):a.push(n.remove(c))}}if(l.type===He.BlockStatement)for(let c of l.body)p(c);else l.type===He.ExpressionStatement&&p(l.expression)}return p(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as Qe,ESLintUtils as sr}from"@typescript-eslint/utils";import*as Wt from"typescript";import et from"zod/v4";var Wo=sr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),or="no-unnecessary-casting",Jo=et.object({additionalCastFunctions:et.array(et.object({name:et.string(),expectedType:et.enum(["string","number"])})).optional()}),Jt={name:or,rule:Wo({name:or,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[V(Jo)],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],s=sr.getParserServices(e,!0),a=s.program?.getTypeChecker();if(!a||!s.program)throw new Error("TypeScript services or program not available");function i(d,y){switch(d.type){case Qe.Literal:return y==="number"?typeof d.value=="number":typeof d.value=="string";case Qe.TemplateLiteral:return y==="string";case Qe.UnaryExpression:return y==="number"?d.operator==="+"||d.operator==="-"||d.operator==="~":!1;default:return!1}}function p(d,y){return y==="number"?!!(d.flags&Wt.TypeFlags.NumberLike):!!(d.flags&Wt.TypeFlags.StringLike)}function l(d,y){return g=>g.replaceText(d,e.sourceCode.getText(y))}function c(d){if(!a||d.arguments.length!==1)return;let y=d.arguments[0];if(!y||y.type===Qe.SpreadElement)return;let{callee:g}=d;if(g.type!==Qe.Identifier)return;let b=g.name,f=n.find(h=>h.name===b);if(!f)return;if(i(y,f.expectedType)||p(a.getTypeAtLocation(s.esTreeNodeToTSNodeMap.get(y)),f.expectedType)){let h,m;b==="Number"?h="unnecessaryNumberCasting":b==="String"?h="unnecessaryStringCasting":(h="unnecessaryCustomCasting",m={name:f.name,type:f.expectedType}),e.report({node:d,messageId:h,...m?{data:m}:{},fix:l(d,y)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as we}from"@typescript-eslint/utils";import*as ut from"zod/v4";var Vo=ut.object({ignoreWithDescription:ut.string().optional()}),Vt=B({name:"no-unnecessary-describe",meta:{type:"suggestion",docs:{description:"Disallow unnecessary describe blocks that wrap all tests in a file"},messages:{unnecessaryDescribe:"Describe blocks that solely wrap all tests in the file are unnecessary, they just add unnecessary nesting to the code. The file itself should be enough to group tests. Remove it.",removeDescribe:"Remove the describe block"},hasSuggestions:!0,schema:[V(Vo)]},defaultOptions:[{}],create(e,[t]){let r=e.getSourceCode(),n=r.ast;function s(l){let c=l.arguments[0];return c&&c.type===we.Literal&&typeof c.value=="string"?c.value:null}function a(l){return!l||!t.ignoreWithDescription?!1:new RegExp(t.ignoreWithDescription).test(l)}function i(l){return l.length!==1?!1:n.body.filter(d=>{if(d.type===we.ExpressionStatement){let y=d.expression;if(y.type===we.CallExpression&&y.callee.type===we.Identifier){let g=y.callee.name;return["test","it","beforeEach","afterEach","beforeAll","afterAll"].includes(g)}}return!1}).length===0}function p(l){let c=l.arguments[1];if(c&&(c.type===we.FunctionExpression||c.type===we.ArrowFunctionExpression)&&c.body.type===we.BlockStatement){let d=c.body.body;return d.length===0?"":d.map(g=>r.text.slice(g.range[0],g.range[1])).join(`
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let u=l.acquire(m),T=new Set,w=null;{let P=u.upper;for(;P&&(T.add(P),P.type!=="function");)P=P.upper;if(!P)return;w=P}let R=Array.isArray;function v(P){if(!R(P.defs))return!1;let k=P.defs[0];if(k==null||k.node.type!=="VariableDeclarator")return!1;let L=k.node.init;if(L==null)return!1;for(;L.type==="TSAsExpression";)L=L.expression;let $=k.node.parent;if($==null&&(It(w.block,k.node.id),$=k.node.parent,$==null))return!1;if($.kind==="const"&&L.type==="Literal"&&(typeof L.value=="string"||typeof L.value=="number"||L.value===null))return!0;if(L.type!=="CallExpression")return!1;let W=L.callee;if(W.type==="MemberExpression"&&W.object.name==="React"&&W.property!=null&&!W.computed&&(W=W.property),W.type!=="Identifier")return!1;let U=k.node.id,{name:B}=W;if(B==="useRef"&&U.type==="Identifier")return!0;if(yi(W)&&U.type==="Identifier"){for(let Z of P.references)Z!==U&&b.add(Z.identifier);return!0}else if(B==="useState"||B==="useReducer"){if(U.type==="ArrayPattern"&&U.elements.length===2&&R(P.identifiers)){if(U.elements[1]===P.identifiers[0]){if(B==="useState"){let Z=P.references,Ie=0;for(let De=0;De<Z.length;De++){if(Z[De].isWrite()&&Ie++,Ie>1)return!1;c.set(Z[De].identifier,U.elements[0])}}return!0}else if(U.elements[0]===P.identifiers[0]){if(B==="useState"){let Z=P.references;for(let Ie=0;Ie<Z.length;Ie++)d.add(Z[Ie].identifier)}return!1}}}else if(B==="useTransition"&&U.type==="ArrayPattern"&&U.elements.length===2&&Array.isArray(P.identifiers)&&U.elements[1]===P.identifiers[0])return!0;return!1}function x(P){if(!R(P.defs))return!1;let k=P.defs[0];if(k==null||k.node==null||k.node.id==null)return!1;let L=k.node,$=w.childScopes,W=null,U;for(U=0;U<$.length;U++){let B=$[U],Z=B.block;if(L.type==="FunctionDeclaration"&&Z===L||L.type==="VariableDeclarator"&&Z.parent===L){W=B;break}}if(W==null)return!1;for(U=0;U<W.through.length;U++){let B=W.through[U];if(B.resolved!=null&&T.has(B.resolved.scope)&&!C(B.resolved))return!1}return!0}let C=f(v,y),F=f(x,g),O=new Map;function G(P){let k=P.from,L=!1;for(;k.block!==m;)k.type==="function"&&(L=k.block.parent!=null&&k.block.parent.type==="ReturnStatement"),k=k.upper;return L}let z=new Map,te=new Map;ie(u);function ie(P){for(let k of P.references){if(!k.resolved||!T.has(k.resolved.scope))continue;let L=It(m,k.identifier),$=Mn(L),W=je($,te);if(S&&$.type==="Identifier"&&($.parent.type==="MemberExpression"||$.parent.type==="OptionalMemberExpression")&&!$.parent.computed&&$.parent.property.type==="Identifier"&&$.parent.property.name==="current"&&G(k)&&O.set(W,{reference:k,dependencyNode:$}),$.parent.type==="TSTypeQuery"||$.parent.type==="TSTypeReference")continue;let U=k.resolved.defs[0];if(U!=null&&!(U.node!=null&&U.node.init===m.parent)&&U.type!=="TypeParameter")if(z.has(W))z.get(W).references.push(k);else{let B=k.resolved,Z=C(B)||F(B);z.set(W,{isStable:Z,references:[k]})}}for(let k of P.childScopes)ie(k)}O.forEach(({reference:P,dependencyNode:k},L)=>{let $=P.resolved.references,W=!1;for(let U=0;U<$.length;U++){let{identifier:B}=$[U],{parent:Z}=B;if(Z!=null&&Z.type==="MemberExpression"&&!Z.computed&&Z.property.type==="Identifier"&&Z.property.name==="current"&&Z.parent.type==="AssignmentExpression"&&Z.parent.left===Z){W=!0;break}}W||p({node:k.parent.property,message:`The ref value '${L}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${L}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let D=new Set;function q(P,k){D.has(k)||(D.add(k),p({node:P,message:`Assignments to the '${k}' variable from inside React Hook ${r(I)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${r(I)}.`}))}let V=new Set;if(z.forEach(({isStable:P,references:k},L)=>{P&&V.add(L),k.forEach($=>{$.writeExpr&&q($.writeExpr,L)})}),D.size>0)return;if(!A){let P=null;if(z.forEach(({isStable:k,references:L},$)=>{P||L.forEach(W=>{if(P)return;let U=W.identifier;if(!c.has(U))return;let Z=W.from;for(;Z.type!=="function";)Z=Z.upper;Z.block===m&&(P=$)})}),P){let{suggestedDependencies:k}=xt({dependencies:z,declaredDependencies:[],stableDependencies:V,externalDependencies:new Set,isEffect:!0});p({node:I,message:`React Hook ${o} contains a call to '${P}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+k.join(", ")+`] as a second argument to the ${o} Hook.`,suggest:[{desc:`Add dependencies array: [${k.join(", ")}]`,fix(L){return L.insertTextAfter(m,`, [${k.join(", ")}]`)}}]})}return}let le=[],pe=new Set;A.type!=="ArrayExpression"?p({node:A,message:`React Hook ${r(I)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):A.elements.forEach(P=>{if(P===null)return;if(P.type==="SpreadElement"){p({node:P,message:`React Hook ${r(I)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}b.has(P)&&p({node:P,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(P)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(P)}\``,fix(W){return W.removeRange(P.range)}}]});let k;try{k=je(P,te)}catch(W){if(/Unsupported node type/.test(W.message)){P.type==="Literal"?z.has(P.value)?p({node:P,message:`The ${P.raw} literal is not a valid dependency because it never changes. Did you mean to include ${P.value} in the array instead?`}):p({node:P,message:`The ${P.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):p({node:P,message:`React Hook ${r(I)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw W}let L=P;for(;L.type==="MemberExpression"||L.type==="OptionalMemberExpression"||L.type==="ChainExpression";)L=L.object||L.expression.object;let $=!w.through.some(W=>W.identifier===L);le.push({key:k,node:P}),$||pe.add(k)});let{suggestedDependencies:Ce,unnecessaryDependencies:$e,missingDependencies:ye,duplicateDependencies:Ge}=xt({dependencies:z,declaredDependencies:le,stableDependencies:V,externalDependencies:pe,isEffect:S}),Xe=Ce;if(Ge.size+ye.size+$e.size===0){if(t)return;ui({declaredDependencies:le,declaredDependenciesNode:A,componentScope:w,scope:u}).forEach(({construction:k,isUsedOutsideOfHook:L,depType:$})=>{let W=$==="function"?"useCallback":"useMemo",U=$==="function"?"definition":"initialization",B=`wrap the ${U} of '${k.name.name}' in its own ${W}() Hook.`,Z=L?`To fix this, ${B}`:`Move it inside the ${o} callback. Alternatively, ${B}`,Ie=$==="conditional"||$==="logical expression"?"could make":"makes",De=`The '${k.name.name}' ${$} ${Ie} the dependencies of ${o} Hook (at line ${A.loc.start.line}) change on every render. ${Z}`,Rn;L&&k.type==="Variable"&&$==="function"&&(Rn=[{desc:`Wrap the ${U} of '${k.name.name}' in its own ${W}() Hook.`,fix(Pn){let[Qr,ei]=W==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Pn.insertTextBefore(k.node.init,Qr),Pn.insertTextAfter(k.node.init,ei)]}}]),p({node:k.node,message:De,suggest:Rn})});return}!S&&ye.size>0&&(Xe=xt({dependencies:z,declaredDependencies:[],stableDependencies:V,externalDependencies:pe,isEffect:S}).suggestedDependencies);function he(){if(le.length===0)return!0;let P=le.map(L=>L.key),k=P.slice().sort();return P.join(",")===k.join(",")}he()&&Xe.sort();function be(P){let k=P.split("."),L="";for(let $=0;$<k.length;$++){if($!==0){let W=k.slice(0,$+1).join("."),U=te.get(W)===!0;L+=U?"?.":"."}L+=k[$]}return L}function Tt(P,k,L,$){return P.size===0?null:(P.size>1?"":k+" ")+L+" "+(P.size>1?"dependencies":"dependency")+": "+mi(Array.from(P).sort().map(W=>"'"+be(W)+"'"))+`. Either ${$} ${P.size>1?"them":"it"} or remove the dependency array.`}let Pe="";if($e.size>0){let P=null;if(Array.from($e.keys()).forEach(k=>{P===null&&k.endsWith(".current")&&(P=k)}),P!==null)Pe=` Mutable values like '${P}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(pe.size>0){let k=Array.from(pe)[0];u.set.has(k)||(Pe=` Outer scope values like '${k}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!Pe&&ye.has("props")){let P=z.get("props");if(P==null)return;let k=P.references;if(!Array.isArray(k))return;let L=!0;for(let $=0;$<k.length;$++){let W=k[$],U=It(w.block,W.identifier);if(!U){L=!1;break}let B=U.parent;if(B==null){L=!1;break}if(B.type!=="MemberExpression"&&B.type!=="OptionalMemberExpression"){L=!1;break}}L&&(Pe=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${o} call and refer to those specific props inside ${r(I)}.`)}if(!Pe&&ye.size>0){let P=null;ye.forEach(k=>{if(P)return;let L=w.set.get(k),$=z.get(k);if($.references[0].resolved!==L)return;let W=L.defs[0];if(W==null||W.name==null||W.type!=="Parameter")return;let U=!1,B;for(let Z=0;Z<$.references.length;Z++)if(B=$.references[Z].identifier,B!=null&&B.parent!=null&&(B.parent.type==="CallExpression"||B.parent.type==="OptionalCallExpression")&&B.parent.callee===B){U=!0;break}U&&(P=k)}),P!==null&&(Pe=` If '${P}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!Pe&&ye.size>0){let P=null;if(ye.forEach(k=>{if(P!==null)return;let $=z.get(k).references,W,U;for(let B=0;B<$.length;B++){for(W=$[B].identifier,U=W.parent;U!=null&&U!==w.block;){if(U.type==="CallExpression"){let Z=c.get(U.callee);if(Z!=null){if(Z.name===k)P={missingDep:k,setter:U.callee.name,form:"updater"};else if(d.has(W))P={missingDep:k,setter:U.callee.name,form:"reducer"};else{let Ie=$[B].resolved;if(Ie!=null){let De=Ie.defs[0];De!=null&&De.type==="Parameter"&&(P={missingDep:k,setter:U.callee.name,form:"inlineReducer"})}}break}}U=U.parent}if(P!==null)break}}),P!==null)switch(P.form){case"reducer":Pe=` You can also replace multiple useState variables with useReducer if '${P.setter}' needs the current value of '${P.missingDep}'.`;break;case"inlineReducer":Pe=` If '${P.setter}' needs the current value of '${P.missingDep}', you can also switch to useReducer instead of useState and read '${P.missingDep}' in the reducer.`;break;case"updater":Pe=` You can also do a functional update '${P.setter}(${P.missingDep.slice(0,1)} => ...)' if you only need '${P.missingDep}' in the '${P.setter}' call.`;break;default:throw new Error("Unknown case.")}}p({node:A,message:`React Hook ${r(I)} has `+(Tt(ye,"a","missing","include")||Tt($e,"an","unnecessary","exclude")||Tt(Ge,"a","duplicate","omit"))+Pe,suggest:[{desc:`Update the dependencies array to be: [${Xe.map(be).join(", ")}]`,fix(P){return P.replaceText(A,`[${Xe.map(be).join(", ")}]`)}}]})}function h(m){let A=fi(m.callee,i);if(A===-1)return;let I=m.arguments[A],o=m.callee,S=$n(o).name,u=m.arguments[A+1],T=/Effect($|[^a-z])/g.test(S);if(!I){p({node:o,message:`React Hook ${S} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!T)){if(!u&&!T){(S==="useMemo"||S==="useCallback")&&p({node:o,message:`React Hook ${S} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(I.type){case"FunctionExpression":case"ArrowFunctionExpression":E(I,u,o,S,T);return;case"Identifier":if(!u||u.elements&&u.elements.some(v=>v&&v.type==="Identifier"&&v.name===I.name))return;let w=n(m).set.get(I.name);if(w==null||w.defs==null)return;let R=w.defs[0];if(!R||!R.node||R.type!=="Variable"&&R.type!=="FunctionName")break;switch(R.node.type){case"FunctionDeclaration":E(R.node,u,o,S,T);return;case"VariableDeclarator":let v=R.node.init;if(!v)break;switch(v.type){case"ArrowFunctionExpression":case"FunctionExpression":E(v,u,o,S,T);return}break}break;default:p({node:o,message:`React Hook ${S} received a function whose dependencies are unknown. Pass an inline function instead.`});return}p({node:o,message:`React Hook ${S} has a missing dependency: '${I.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${I.name}]`,fix(w){return w.replaceText(u,`[${I.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let m of e.sourceCode.getAllComments())if(ci.test(m.value))return t=!0,{CallExpression:A=>h(A,!0)}}return{CallExpression:m=>h(m)}}};function xt({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:s}){let a=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,h)=>{let m=p(a,h);m.isUsed=!0,l(a,h,A=>{A.isSubtreeUsed=!0})}),t.forEach(({key:E})=>{let h=p(a,E);h.isSatisfiedRecursively=!0}),r.forEach(E=>{let h=p(a,E);h.isSatisfiedRecursively=!0});function p(E,h){let m=h.split("."),A=E;for(let I of m){let o=A.children.get(I);o||(o=i(),A.children.set(I,o)),A=o}return A}function l(E,h,m){let A=h.split("."),I=E;for(let o of A){let S=I.children.get(o);if(!S)return;m(S),I=S}}let c=new Set,d=new Set;y(a,c,d,E=>E);function y(E,h,m,A){E.children.forEach((I,o)=>{let S=A(o);if(I.isSatisfiedRecursively){I.isSubtreeUsed&&m.add(S);return}if(I.isUsed){h.add(S);return}y(I,h,m,u=>S+"."+u)})}let g=[],b=new Set,f=new Set;return t.forEach(({key:E})=>{d.has(E)?g.indexOf(E)===-1?g.push(E):f.add(E):b.add(E)}),c.forEach(E=>{g.push(E)}),{suggestedDependencies:g,unnecessaryDependencies:b,duplicateDependencies:f,missingDependencies:c}}function _e(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return _e(e.consequent)!=null||_e(e.alternate)!=null?"conditional":null;case"LogicalExpression":return _e(e.left)!=null||_e(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return _e(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return _e(e.expression);case"TSAsExpression":return _e(e.expression)}return null}function ui({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let s=e.map(({key:i})=>{let p=r.variables.find(c=>c.name===i);if(p==null)return null;let l=p.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=_e(l.node.init);if(c!=null)return[p,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[p,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[p,"class"]:null}).filter(Boolean);function a(i){let p=!1;for(let l=0;l<i.references.length;l++){let c=i.references[l];if(c.writeExpr){if(p)return!0;p=!0;continue}let d=c.from;for(;d!==n&&d!=null;)d=d.upper;if(d!==n&&!_n(t,c.identifier))return!0}return!1}return s.map(([i,p])=>({construction:i.defs[0],depType:p,isUsedOutsideOfHook:a(i)}))}function Mn(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)?Mn(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ct(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function je(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=je(e.object,t),n=je(e.property,null),s=`${r}.${n}`;return Ct(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=je(e.object,t),n=je(e.property,null),s=`${r}.${n}`;return Ct(e,t,s),s}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=je(r.object,t),s=je(r.property,null),a=`${n}.${s}`;return Ct(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function $n(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function fi(e,t){let r=$n(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let n;try{n=je(r,null)}catch(s){if(/Unsupported node type/.test(s.message))return 0;throw s}return t.additionalHooks.test(n)?0:-1}else return-1}}function It(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),di(n,t))return n;if(_n(n,t))for(let[s,a]of Object.entries(n))s!=="parent"&&(jn(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(i=>{jn(i)&&(i.parent=n,r.push(i))}))}return null}function mi(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function jn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function di(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function _n(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function yi(e){return!1}import{AST_NODE_TYPES as ue,ESLintUtils as Xn}from"@typescript-eslint/utils";import H from"typescript";import{z as Jn}from"zod/v4";import{AST_NODE_TYPES as Un}from"@typescript-eslint/utils";function Be(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Be(e.parent,t,r===1/0?r:r-1)}function*At(e){yield e,e.parent&&(yield*At(e.parent))}function wt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function Wn(e,t,r){let s=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Un.Property&&a.identifiers[0].parent.key.type===Un.Identifier&&a.identifiers[0].parent.key.name===t);return s?s.references.filter(a=>!a.init):[]}function zn(e){return e===null||typeof e!="object"||!("type"in e)?!1:typeof e.type=="string"}function gi(e,t){return e[t]}function ve(e,t,r){let n=r.visitorKeys,s=new Set;function a(i){if(s.has(i))return!1;if(s.add(i),t(i)===!0)return!0;let l=n[i.type];if(l)for(let c of l){let d=gi(i,c);if(d){if(Array.isArray(d)){for(let y of d)if(zn(y)&&a(y))return!0}else if(zn(d)&&a(d))return!0}}return!1}a(e)}var Si=Xn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vn="improved-no-unnecessary-condition",Ti=Jn.object({alternativeForInCondition:Jn.string().optional().describe("Alternative to appear in the error for `in` condition")}),hi=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Ei=new Set(hi),Rt={name:Vn,rule:Si({name:Vn,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".',unnecessaryStartsWithCondition:"This startsWith check is unnecessary as it always evaluates to true.",alwaysFalseStartsWithCondition:"This startsWith check will always be false.",unnecessaryEndsWithCondition:"This endsWith check is unnecessary as it always evaluates to true.",alwaysFalseEndsWithCondition:"This endsWith check will always be false.",unnecessaryIncludesCondition:"This includes check is unnecessary as it always evaluates to true.",alwaysFalseIncludesCondition:"This includes check will always be false.",unnecessaryLengthCondition:"This length comparison is unnecessary as it always evaluates to true.",alwaysFalseLengthCondition:"This length comparison will always be false.",unnecessaryInCondition:'This in check is unnecessary. Property "{{property}}" always exists on type "{{type}}".{{alternative}}',alwaysFalseInCondition:'This in check will always be false. Property "{{property}}" does not exist on type "{{type}}".{{alternative}}'},schema:[J(Ti)]},defaultOptions:[{}],create(e,[t]){let r=Xn.getParserServices(e,!0),n=r.program?.getTypeChecker();if(!n||!r.program)throw new Error("TypeScript services or program not available");function s(o){return o.type===ue.UnaryExpression&&o.operator==="typeof"}function a(o){return o.flags&H.TypeFlags.Any||o.flags&H.TypeFlags.Unknown?null:o.flags&H.TypeFlags.StringLike?["string"]:o.flags&H.TypeFlags.NumberLike?["number"]:o.flags&H.TypeFlags.BigIntLike?["bigint"]:o.flags&H.TypeFlags.BooleanLike?["boolean"]:o.flags&H.TypeFlags.ESSymbolLike?["symbol"]:o.flags&H.TypeFlags.Undefined||o.flags&H.TypeFlags.Void?["undefined"]:o.flags&H.TypeFlags.Null?["object"]:o.getCallSignatures().length>0?["function"]:o.flags&H.TypeFlags.Object?o.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:o.flags&H.TypeFlags.NonPrimitive?["object"]:o.flags&H.TypeFlags.Never?["never"]:null}function i(o){if(!n)return null;let S=r.esTreeNodeToTSNodeMap.get(o),u=n.getTypeAtLocation(S.expression);if(u.flags&H.TypeFlags.Any||u.flags&H.TypeFlags.Unknown)return null;let T=[];if(u.isUnion()){for(let R of u.types){let v=a(R);if(v)T.push(...v);else return null}return T}let w=a(u);return w?(T.push(...w),T):null}function p(o){if(!(o.operator==="==="||o.operator==="!=="))return;let u=null,T=null;if(s(o.left)?(u=o.left,T=o.right.type===ue.Literal&&typeof o.right.value=="string"?o.right.value:null):s(o.right)&&(u=o.right,T=o.left.type===ue.Literal&&typeof o.left.value=="string"?o.left.value:null),!u||!T||!bi(T,Ei))return;let w=i(u);if(!w)return;let R=o.operator==="!==",v=w.includes(T);w.length===1?v&&!R?e.report({node:o,messageId:"unnecessaryTypeofCondition",data:{name:He(u,e),type:T}}):!v&&R?e.report({node:o,messageId:"unnecessaryTypeofCondition",data:{name:He(u,e),type:Array.from(w)[0]}}):!v&&!R?e.report({node:o,messageId:"alwaysFalseTypeofCondition",data:{name:He(u,e),actualType:ot(w),conditionType:T}}):v&&R&&e.report({node:o,messageId:"alwaysFalseTypeofCondition",data:{name:He(u,e),actualType:ot(w),conditionType:T}}):!v&&!R?e.report({node:o,messageId:"alwaysFalseTypeofCondition",data:{name:He(u,e),actualType:ot(w),conditionType:T}}):!v&&R&&e.report({node:o,messageId:"unnecessaryTypeofCondition",data:{name:He(u,e),type:ot(w)}})}function l(o){if(o.flags&H.TypeFlags.Any||o.flags&H.TypeFlags.Unknown)return null;if(o.isUnion()){let S=[];for(let u of o.types)if(u.flags&H.TypeFlags.StringLiteral){let T=u.value;S.push(T)}else return null;return S}return o.flags&H.TypeFlags.StringLiteral?[o.value]:null}function c(o){if(!n)return null;let S=r.esTreeNodeToTSNodeMap.get(o),u=n.getTypeAtLocation(S),T=l(u);if(T)return T;let w=n.getSymbolAtLocation(S);if(w){let R=n.getTypeOfSymbolAtLocation(w,S),v=l(R);if(v)return v}return null}function d(o){let S=e.sourceCode.ast,u=null;return ve(S,T=>{if(T.type===ue.VariableDeclarator&&T.id.type===ue.Identifier&&T.id.name===o.name&&T.id.typeAnnotation){let w=T.id.typeAnnotation.typeAnnotation;if(w.type===ue.TSUnionType){let R=[];for(let v of w.types)if(v.type===ue.TSLiteralType&&v.literal.type===ue.Literal&&typeof v.literal.value=="string")R.push(v.literal.value);else return!0;return u=R,!0}if(w.type===ue.TSLiteralType&&w.literal.type===ue.Literal&&typeof w.literal.value=="string")return u=[w.literal.value],!0}return!1},e.sourceCode),u}function y(o){if(o.callee.type!==ue.MemberExpression||o.callee.property.type!==ue.Identifier||o.callee.computed)return;let S=o.callee.property.name;if(S!=="startsWith"&&S!=="endsWith"&&S!=="includes"||o.arguments.length!==1)return;let[u]=o.arguments;if(!u||u.type!==ue.Literal||typeof u.value!="string")return;let T=o.callee.object,w=c(T);if(!w&&T.type===ue.Identifier&&(w=d(T)),!w||w.length===0)return;let R=u.value;if(S==="includes"&&w.length>1)return;let v=0,x=0;for(let C of w)if((S==="startsWith"?C.startsWith(R):S==="endsWith"?C.endsWith(R):C.includes(R))?v++:x++,v>0&&x>0)return;if(v>0&&x===0){let C=S==="startsWith"?"unnecessaryStartsWithCondition":S==="endsWith"?"unnecessaryEndsWithCondition":"unnecessaryIncludesCondition";e.report({node:o,messageId:C})}else if(x>0&&v===0){let C=S==="startsWith"?"alwaysFalseStartsWithCondition":S==="endsWith"?"alwaysFalseEndsWithCondition":"alwaysFalseIncludesCondition";e.report({node:o,messageId:C})}}function g(o){if(!new Set(["===","!==",">",">=","<","<="]).has(o.operator))return;function u(F){if(F.type!==ue.MemberExpression||F.computed||F.property.type!==ue.Identifier||F.property.name!=="length")return null;let O=F.object,G=c(O);if(!G||G.length===0)return null;let z=[];for(let te of G)z.push(te.length);return{values:z}}let T=u(o.left),w=u(o.right),R=null,v=null;if(T?o.right.type===ue.Literal&&typeof o.right.value=="number"&&(R=T.values,v=o.right.value):w&&o.left.type===ue.Literal&&typeof o.left.value=="number"&&(R=w.values,v=o.left.value),!R||v===null)return;let x=0,C=0;for(let F of R){let O=!1;if(o.operator==="==="?O=F===v:o.operator==="!=="?O=F!==v:o.operator===">"?O=F>v:o.operator===">="?O=F>=v:o.operator==="<"?O=F<v:o.operator==="<="&&(O=F<=v),O?x++:C++,x>0&&C>0)return}x>0&&C===0?e.report({node:o,messageId:"unnecessaryLengthCondition"}):C>0&&x===0&&e.report({node:o,messageId:"alwaysFalseLengthCondition"})}function b(o){if(o.type===ue.Literal&&typeof o.value=="string")return o.value;let S=c(o);if(!S||S.length!==1)return null;let[u]=S;return u??null}function f(o){return(o.flags&H.TypeFlags.Intersection)!==0}function E(o){return(o.flags&H.TypeFlags.Object)!==0}function h(o){return!n||n.getIndexTypeOfType(o,H.IndexKind.String)?!0:!!n.getIndexTypeOfType(o,H.IndexKind.Number)}function m(o,S){if(!n||h(o)||o.getProperties().length===0)return"unknown";let u=n.getPropertyOfType(o,S);return u?u.flags&H.SymbolFlags.Optional?"optional":"required":"absent"}function A(o,S){if(o.flags&H.TypeFlags.Any||o.flags&H.TypeFlags.Unknown||o.flags&H.TypeFlags.Never||o.flags&H.TypeFlags.TypeParameter||o.flags&H.TypeFlags.IndexedAccess||o.flags&H.TypeFlags.StringLike||o.flags&H.TypeFlags.NumberLike||o.flags&H.TypeFlags.BigIntLike||o.flags&H.TypeFlags.BooleanLike||o.flags&H.TypeFlags.EnumLike||o.flags&H.TypeFlags.ESSymbolLike||o.flags&H.TypeFlags.NonPrimitive||o.flags&H.TypeFlags.Null||o.flags&H.TypeFlags.Undefined||o.flags&H.TypeFlags.Void)return"unknown";if(o.isUnion()){let u=!0,T=!0;for(let w of o.types){let R=A(w,S);if(R==="unknown"||(R!=="required"&&(u=!1),R!=="absent"&&(T=!1),R==="optional"))return"unknown"}return u?"required":T?"absent":"unknown"}if(f(o)){let u=o,T=!1,w=!1;for(let R of u.types){let v=A(R,S);if(v==="unknown")return"unknown";v==="required"?T=!0:v==="optional"&&(w=!0)}return T?"required":w?"optional":"absent"}return E(o)?m(o,S):"unknown"}function I(o){if(o.operator!=="in"||o.left.type===ue.PrivateIdentifier)return;let S=b(o.left);if(!S)return;let u=o.right,T=r.esTreeNodeToTSNodeMap.get(u);if(!n)return;let w=n.getTypeAtLocation(T),R=A(w,S);R==="required"?e.report({node:o,messageId:"unnecessaryInCondition",data:{property:S,type:n.typeToString(w),alternative:t.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${t.alternativeForInCondition}`:""}}):R==="absent"&&e.report({node:o,messageId:"alwaysFalseInCondition",data:{property:S,type:n.typeToString(w),alternative:t.alternativeForInCondition?`If this a valid condition, you can use as alternative: ${t.alternativeForInCondition}`:""}})}return{BinaryExpression(o){p(o),g(o),I(o)},CallExpression:y}}})};function ot(e){return Array.from(new Set(e)).join(" | ")||"never"}function He(e,t){let r=e.argument;return r.type===ue.Identifier?r.name:t.sourceCode.getText(r)}function bi(e,t){return t.has(e)}import{AST_NODE_TYPES as xi,ESLintUtils as Ci}from"@typescript-eslint/utils";import{z as Pt}from"zod/v4";var Ii=Ci.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bn="no-call-with-explicit-generics",Ai=Pt.object({functions:Pt.array(Pt.string())}),wi=Ii({name:Bn,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(Ai)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:s}=n;s.type===xi.Identifier&&r.has(s.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),vt={name:Bn,rule:wi};import{AST_NODE_TYPES as st,ESLintUtils as Ri}from"@typescript-eslint/utils";var Pi=Ri.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Hn="no-call-with-inferred-generics",vi=Pi({name:Hn,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:s}=n;if(s.type!==st.Identifier)return;let a=r.get(s.name);if(!a)return;let{minGenerics:i=1,allowAny:p,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:i||0}}),!(p&&!l)&&n.typeArguments?.params.some(d=>!p&&d.type===st.TSAnyKeyword||l&&d.type===st.TSTypeReference&&d.typeName.type===st.Identifier&&l.includes(d.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),Ft={name:Hn,rule:vi};import{ESLintUtils as Fi}from"@typescript-eslint/utils";var ki=Fi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zn="no-commented-out-code",Oi=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],Ni=/^\s*return\s+/,Di=/\w=("|'|`)/,ji=/\w+:\s*('|"|`)/,Li=/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,Mi=/\w+-\w+:/,$i=/\w+_\w+:/,_i=/\?\s+\w/,Ui=/:\s+\w/,zi=/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,Wi=/^\s*\d+[,}]/,Ji=/^\s*\[[^\]]*\][,}]/,Vi=/^\s*\{[^}]*\}[,}]/,Xi=/\.\w+\(/,Bi=/\[\w+\]/,Hi=/^\s*(['"`]).+?\1\s*:/,Yi=/^<[A-Z]\w*(\s|>|\/)/,qi=/^<[a-z]+(\s|>|\/)/,Zi=/<[A-Z]\w*(\s.*)?>/,Gi=/<\/[A-Z]\w*>/,Ki=/<[a-z]+(\s.*)?>/,Qi=/<\/[a-z]+>/,eo=/^\s*[*\s]*$/,to=/^[a-zA-Z]/,no=/^[A-Z][A-Za-z]*(?:\s+\d+)?(?:\s+[a-z]+)*:\s+[A-Za-z]/,ro=/```[\s\S]*?```/g,io=/`[^`]*`/g,Yn=/[a-zA-Z0-9]/,oo=/\.[A-Za-z_][A-Za-z0-9_]*\(/,so=/[{}[\]()`=<>]/,ao=/:\s*(['"`[{(]|\w+\s*=>)/,lo=/\bif\s*\(|\belse\b|=>/,ce={returnStatement:Ni,stringAssignment:Di,objectPropertyWithQuotes:ji,computedPropertyAssignment:Li,kebabCaseProperty:Mi,snakeCaseProperty:$i,ternaryOperator:_i,colonWithWord:Ui,quotedString:zi,numberWithComma:Wi,arrayWithComma:Ji,objectWithComma:Vi,methodCall:Xi,arrayAccess:Bi,quotedPropertyKey:Hi,jsxSelfClosing:Yi,jsxElement:qi,jsxOpeningTag:Zi,jsxClosingTag:Gi,htmlOpeningTag:Ki,htmlClosingTag:Qi,jsdocComment:eo};function po(e){if(e.includes(":")){let r=e.split(":")[0]?.trim();if(r&&to.test(r)&&r.includes(" "))return!0}let t=e.trim();return t.length===0||oo.test(t)||so.test(t)||ao.test(t)||lo.test(t)?!1:!!(t.includes(":")&&no.test(t))}var co=[") {","return;",ce.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",ce.stringAssignment,");",ce.objectPropertyWithQuotes,ce.computedPropertyAssignment,ce.kebabCaseProperty,ce.snakeCaseProperty,"&&","||","()",ce.ternaryOperator,ce.colonWithWord,ce.quotedString,ce.numberWithComma,ce.arrayWithComma,ce.objectWithComma,ce.methodCall,ce.arrayAccess,"?.(","??","=>",ce.quotedPropertyKey],uo=["/>","</",ce.jsxSelfClosing,ce.jsxElement,ce.jsxOpeningTag,ce.jsxClosingTag,ce.htmlOpeningTag,ce.htmlClosingTag],qn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],fo=ki({name:Zn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,s){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||ce.jsdocComment.test(n))return!1;for(let i of qn)if(a.startsWith(i))return!1;if(n.includes("https://")||po(a))return!1;if(s==="Block"){for(let i of uo)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Oi)if(a.startsWith(i))return{wrongPattern:i};for(let i of co)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,s){let a=n,i=a.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return a;if(s==="Block"&&a.includes("```")){let c=a.split(ro);c.some(y=>Yn.test(y))&&(a=c.join(""))}if(!a.includes("`"))return a;let p=a.split(io);return p.some(c=>Yn.test(c))?p.join(""):a}return{Program(){let s=e.sourceCode.getAllComments();for(let a of s){let i=r(a.value,a.type),p=t(i,a.type);p&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:p.wrongPattern,allowedPrefixes:qn.join(", ")}})}}}}}),kt={name:Zn,rule:fo};import{ESLintUtils as mo,TSESTree as yo}from"@typescript-eslint/utils";var go=mo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gn="no-default-export",So=go({name:Gn,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.type===yo.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Ot={name:Gn,rule:So};import{ESLintUtils as To}from"@typescript-eslint/utils";var ho=To.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kn="no-leaked-text-in-jsx",Eo=[",",";","[","]","(",")"],bo=ho({name:Kn,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let r=t.value.trim();if(!r)return;let n="";Eo.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),Nt={name:Kn,rule:bo};import{AST_NODE_TYPES as Ke,ESLintUtils as xo}from"@typescript-eslint/utils";var Co=xo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),er="no-non-camel-case-functions",Io=/^(\$?[a-z][a-zA-Z0-9]*)$/;function Qn(e){if(e.typeName.type!==Ke.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Ke.Identifier&&t.name==="JSX"&&r.name==="Element"}var Ao=Co({name:er,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Io.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Ke.TSTypeReference?Qn(r):r.type===Ke.TSUnionType&&r.types.some(s=>s.type===Ke.TSTypeReference&&Qn(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Dt={name:er,rule:Ao};import{ESLintUtils as wo,TSESTree as oe}from"@typescript-eslint/utils";var Ro=wo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tr="no-optional-root-props",Po=Ro({name:tr,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let i=a.references[0];if(!i)return!1;for(let p of At(i.identifier)){if("returnType"in p||p.type===oe.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=p.parent;if(!l)return!1;if(l.type===oe.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===oe.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===oe.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let d=Be(l.parent.parent,oe.AST_NODE_TYPES.VariableDeclaration,4);if(!d)return!1;let y=at(d,e.sourceCode);return y?!(y.parent.type===oe.AST_NODE_TYPES.CallExpression&&y.parent.callee.type===oe.AST_NODE_TYPES.Identifier&&y.parent.callee.name==="memo"):!1}if(p.type===oe.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===oe.AST_NODE_TYPES.ArrowFunctionExpression){let c=Be(l,oe.AST_NODE_TYPES.VariableDeclaration);return c?!!at(c,e.sourceCode):!1}if(l.type===oe.AST_NODE_TYPES.FunctionDeclaration)return!!at(l,e.sourceCode)}return!1}function r(n){n.key.type!==oe.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:s=>{let a=Be(n,oe.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let i=e.sourceCode.getText(a);return s.replaceText(a,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===oe.AST_NODE_TYPES.TSTypeLiteral&&!(lt(n)||!t(n)))for(let s of n.typeAnnotation.members)s.type===oe.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSInterfaceDeclaration(n){if(!(lt(n)||!t(n)))for(let s of n.body.body)s.type===oe.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSTypeReference(n){if(n.typeName.type!==oe.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let s=n.typeArguments.params[0];if(s.type!==oe.AST_NODE_TYPES.TSTypeLiteral)return;let a=Be(n.parent,oe.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let i=at(a,e.sourceCode);if(!(!i||i.parent.type===oe.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===oe.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of s.members)l.type===oe.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function lt(e){return e?e.parent?.type===oe.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===oe.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function at(e,t){if(lt(e))return;let r;if(e.type===oe.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===oe.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===oe.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let s=n.variables.find(i=>i.identifiers.includes(r));if(!s)return;let a=s.references.filter(i=>i.identifier!==r);if(!(a.length!==1||!a[0])&&!lt(a[0].identifier.parent.parent))return a[0].identifier}var jt={name:tr,rule:Po};import{AST_NODE_TYPES as pt}from"@typescript-eslint/utils";var Qe=X({name:"no-reexport",meta:{type:"problem",docs:{description:"Disallow re-exports to prevent indirection"},schema:[],messages:{noReexport:"Re-exports are not allowed. Use direct exports only."}},defaultOptions:[],create(e){let t=new Set;function r(n){return n?n.type===pt.Identifier?t.has(n.name):n.type===pt.MemberExpression?r(n.object):!1:!1}return{ImportDeclaration(n){for(let s of n.specifiers)t.add(s.local.name)},ExportNamedDeclaration(n){if(n.source){e.report({node:n,messageId:"noReexport"});return}if(n.declaration?.type===pt.VariableDeclaration)for(let s of n.declaration.declarations)r(s.init)&&e.report({node:n,messageId:"noReexport"});n.specifiers.length>0&&e.report({node:n,messageId:"noReexport"})},ExportDefaultDeclaration(n){n.declaration.type===pt.Identifier&&t.has(n.declaration.name)&&e.report({node:n,messageId:"noReexport"})},ExportAllDeclaration(n){e.report({node:n,messageId:"noReexport"})}}}});import{ESLintUtils as vo}from"@typescript-eslint/utils";import Lt from"path";import{z as Ue}from"zod/v4";var Fo=vo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nr="no-relative-imports",ko=Ue.object({find:Ue.string(),replacement:Ue.string()}),Oo=Ue.object({aliases:Ue.array(ko),rootDir:Ue.string().optional(),allowNotFoundAliases:Ue.boolean().optional(),_dev_simulateFileName:Ue.string().optional()}),No=Fo({name:nr,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(Oo)]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function s(i,p){let l=Lt.dirname(p);return Lt.resolve(l,i)}function a(i){let p=t.rootDir??process.cwd(),l=Lt.relative(p,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:d}of t.aliases)if(l.startsWith(d)){let y=l.replace(d,c);return{alias:c,newPath:y}}return null}return{ImportDeclaration(i){let p=i.source.value;if(!n(p))return;let l=s(p,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:i,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?d=>d.replaceText(i.source,`'${c.newPath}'`):void 0})}}}}),Mt={name:nr,rule:No};import{AST_NODE_TYPES as fe}from"@typescript-eslint/utils";import{z as rr}from"zod/v4";var Do=rr.object({customMessage:rr.string().optional()}),$t=X({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(Do)],messages:{noStaticStyleProp:"Static style props are not allowed use css instead.{{customMessage}}"}},defaultOptions:[{}],create(e,[t]){function r(n){switch(n.type){case fe.Literal:return!0;case fe.ObjectExpression:return n.properties.every(s=>s.type===fe.Property?s.computed||s.value.type===fe.Identifier&&s.key.type===fe.Identifier&&s.key.name===s.value.name?!1:r(s.value):!1);case fe.ArrayExpression:return n.elements.every(s=>s?s.type===fe.SpreadElement?!1:r(s):!0);case fe.TemplateLiteral:return n.expressions.length===0;case fe.ConditionalExpression:case fe.LogicalExpression:case fe.BinaryExpression:case fe.UnaryExpression:case fe.CallExpression:case fe.MemberExpression:case fe.Identifier:case fe.ArrowFunctionExpression:case fe.FunctionExpression:return!1;default:return!1}}return{JSXAttribute(n){if(n.name.type===fe.JSXIdentifier&&n.name.name==="style"&&n.value){let s=null;n.value.type===fe.JSXExpressionContainer?n.value.expression.type!==fe.JSXEmptyExpression&&(s=n.value.expression):n.value.type===fe.Literal&&(s=n.value),s&&r(s)&&e.report({node:n,messageId:"noStaticStyleProp",data:{customMessage:t.customMessage?` ${t.customMessage}`:""}})}}}}});import{AST_NODE_TYPES as ct}from"@typescript-eslint/utils";import*as Je from"zod/v4";var jo=Je.object({alternativeMsgs:Je.object({inArrayFind:Je.string().optional(),inArrayFilter:Je.string().optional()}).optional(),__dev_simulateFileName:Je.string().optional()});function Lo(e){return e.typeAnnotation.type!==ct.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}var Mo=/(typeGuards|type-guards)\.(ts|tsx)$/;function $o(e){return Mo.test(e)}function _o(e){let t=e.parent;for(;t;){if(t.type===ct.CallExpression&&t.callee.type===ct.MemberExpression&&t.callee.property.type===ct.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var _t=X({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(jo)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if($o(r))return{};function n(s){if(!Lo(s))return;let a=_o(s);if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let p=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:s,messageId:p,data:{message:i}});return}}e.report({node:s,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as Ye}from"@typescript-eslint/utils";var Uo="no-unnecessary-async-on-jsx-props";function zo(e){if(e.body.type!==Ye.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==Ye.ExpressionStatement?!1:r.expression.type===Ye.AwaitExpression}var Ut=X({name:Uo,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(r){zo(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let s=e.sourceCode,a=[],i=s.getFirstToken(r,l=>l.value==="async");if(i){let l=s.getTokenAfter(i);l?a.push(n.replaceTextRange([i.range[0],l.range[0]],"")):a.push(n.remove(i))}function p(l){if(l.type===Ye.AwaitExpression){let c=s.getFirstToken(l);if(c&&c.value==="await"){let d=s.getTokenAfter(c);d?a.push(n.replaceTextRange([c.range[0],d.range[0]],"")):a.push(n.remove(c))}}if(l.type===Ye.BlockStatement)for(let c of l.body)p(c);else l.type===Ye.ExpressionStatement&&p(l.expression)}return p(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as et,ESLintUtils as or}from"@typescript-eslint/utils";import*as zt from"typescript";import tt from"zod/v4";var Wo=or.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ir="no-unnecessary-casting",Jo=tt.object({additionalCastFunctions:tt.array(tt.object({name:tt.string(),expectedType:tt.enum(["string","number"])})).optional()}),Wt={name:ir,rule:Wo({name:ir,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(Jo)],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],s=or.getParserServices(e,!0),a=s.program?.getTypeChecker();if(!a||!s.program)throw new Error("TypeScript services or program not available");function i(d,y){switch(d.type){case et.Literal:return y==="number"?typeof d.value=="number":typeof d.value=="string";case et.TemplateLiteral:return y==="string";case et.UnaryExpression:return y==="number"?d.operator==="+"||d.operator==="-"||d.operator==="~":!1;default:return!1}}function p(d,y){return y==="number"?!!(d.flags&zt.TypeFlags.NumberLike):!!(d.flags&zt.TypeFlags.StringLike)}function l(d,y){return g=>g.replaceText(d,e.sourceCode.getText(y))}function c(d){if(!a||d.arguments.length!==1)return;let y=d.arguments[0];if(!y||y.type===et.SpreadElement)return;let{callee:g}=d;if(g.type!==et.Identifier)return;let b=g.name,f=n.find(h=>h.name===b);if(!f)return;if(i(y,f.expectedType)||p(a.getTypeAtLocation(s.esTreeNodeToTSNodeMap.get(y)),f.expectedType)){let h,m;b==="Number"?h="unnecessaryNumberCasting":b==="String"?h="unnecessaryStringCasting":(h="unnecessaryCustomCasting",m={name:f.name,type:f.expectedType}),e.report({node:d,messageId:h,...m?{data:m}:{},fix:l(d,y)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as Ae}from"@typescript-eslint/utils";import*as ut from"zod/v4";var Vo=ut.object({ignoreWithDescription:ut.string().optional()}),Jt=X({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(Vo)]},defaultOptions:[{}],create(e,[t]){let r=e.getSourceCode(),n=r.ast;function s(l){let c=l.arguments[0];return c&&c.type===Ae.Literal&&typeof c.value=="string"?c.value:null}function a(l){return!l||!t.ignoreWithDescription?!1:new RegExp(t.ignoreWithDescription).test(l)}function i(l){return l.length!==1?!1:n.body.filter(d=>{if(d.type===Ae.ExpressionStatement){let y=d.expression;if(y.type===Ae.CallExpression&&y.callee.type===Ae.Identifier){let g=y.callee.name;return["test","it","beforeEach","afterEach","beforeAll","afterAll"].includes(g)}}return!1}).length===0}function p(l){let c=l.arguments[1];if(c&&(c.type===Ae.FunctionExpression||c.type===Ae.ArrowFunctionExpression)&&c.body.type===Ae.BlockStatement){let d=c.body.body;return d.length===0?"":d.map(g=>r.text.slice(g.range[0],g.range[1])).join(`
|
|
16
16
|
|
|
17
|
-
`)}return""}return{Program(){let l=[];for(let g of n.body)g.type===we.ExpressionStatement&&g.expression.type===we.CallExpression&&g.expression.callee.type===we.Identifier&&g.expression.callee.name==="describe"&&g.expression.arguments.length===2&&l.push(g.expression);if(!i(l))return;let[c]=l;if(!c)return;let d=s(c);if(a(d))return;let y=n.body.find(g=>g.type===we.ExpressionStatement&&g.expression===c);!y||y.type!==we.ExpressionStatement||e.report({node:c,messageId:"unnecessaryDescribe",suggest:[{messageId:"removeDescribe",fix(g){let b=p(c);return b?g.replaceText(y,b):null}}]})}}}});import{AST_NODE_TYPES as ft}from"@typescript-eslint/utils";import*as Oe from"zod/v4";var Xo=Oe.object({methods:Oe.union([Oe.array(Oe.string()),Oe.literal("array")])}),Xt=B({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[V(Xo)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function s(p){return Array.isArray(r)?r.includes(p):n.has(p)}function a(p){let{callee:l}=p;if(l.type===ft.MemberExpression){let c=l.property;if(c.type===ft.Identifier)return c.name}return null}function i(p,l){if(p.type!==ft.Identifier||!p.typeAnnotation)return;let c=l.parent;if(c.type===ft.CallExpression){let d=a(c);d&&s(d)&&c.arguments.indexOf(l)===0&&e.report({node:p.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(g){return p.typeAnnotation?g.remove(p.typeAnnotation):null}})}}return{ArrowFunctionExpression(p){for(let l of p.params)i(l,p)},FunctionExpression(p){for(let l of p.params)i(l,p)}}}});import{AST_NODE_TYPES as he}from"@typescript-eslint/utils";var Bt=B({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(t){if(t.id.type===he.ObjectPattern||!t.init||t.init.type!==he.ObjectExpression||t.id.type===he.Identifier&&t.id.typeAnnotation||t.parent.parent.type===he.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===he.Property&&i.key.type===he.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==he.Identifier)return;let n=Bo(t,e.sourceCode);if(n.length===0)return;let s=t.init.properties.some(i=>i.type!==he.Property?!1:i.value.type===he.FunctionExpression),a=new Set;for(let i of n){if(i.identifier.parent.type!==he.MemberExpression)return;let p=i.identifier.parent;if(p.object!==i.identifier)return;if(p.computed)if(p.property.type===he.Literal&&typeof p.property.value=="string")a.add(p.property.value);else return;else{if(p.property.type!==he.Identifier)return;a.add(p.property.name)}if(p.parent.type===he.CallExpression&&s)return}for(let[i,p]of r)a.has(i)||e.report({node:p,messageId:"unusedObjectProperty",data:{name:i}})}}}});function Bo(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as K}from"@typescript-eslint/utils";import{z as ar}from"zod/v4";var Ho=ar.object({ignoreArgsMatching:ar.string().optional()}),Ht=B({name:"no-unused-optional-args",meta:{type:"problem",docs:{description:"Detect unused optional function arguments in non-exported functions"},messages:{unusedOptionalArg:"Optional parameter '{{name}}' is never used",unusedOptionalProp:"Optional prop '{{name}}' is never provided"},schema:[V(Ho)]},defaultOptions:[{}],create(e,[t]){let r=[];function n(i){return t.ignoreArgsMatching?new RegExp(t.ignoreArgsMatching).test(i):!1}function s(i){return i.type===K.ExportNamedDeclaration||i.type===K.ExportDefaultDeclaration||i.parent?.type===K.ExportNamedDeclaration||i.parent?.type===K.ExportDefaultDeclaration}function a(i){let p=[];for(let l=0;l<i.length;l++){let c=i[l];if(!c||c.type!==K.Identifier)continue;let d=c.name;if(!n(d)){if(c.optional&&c.typeAnnotation&&c.typeAnnotation.typeAnnotation.type===K.TSTypeLiteral){let y=c.typeAnnotation.typeAnnotation,g=[];for(let b of y.members)b.type===K.TSPropertySignature&&b.key.type===K.Identifier&&g.push({name:b.key.name,optional:b.optional===!0});g.some(b=>b.optional)?p.push({param:c,index:l,name:d,isObjectParam:!0,objectProps:g}):p.push({param:c,index:l,name:d,isObjectParam:!1})}else if(c.optional)p.push({param:c,index:l,name:d,isObjectParam:!1});else if(c.typeAnnotation&&c.typeAnnotation.typeAnnotation.type===K.TSTypeLiteral){let y=c.typeAnnotation.typeAnnotation,g=[];for(let b of y.members)b.type===K.TSPropertySignature&&b.key.type===K.Identifier&&g.push({name:b.key.name,optional:b.optional===!0});g.some(b=>b.optional)&&p.push({param:c,index:l,name:d,isObjectParam:!0,objectProps:g})}}}return p}return{FunctionDeclaration(i){if(s(i))return;let p=a(i.params);p.length!==0&&r.push({node:i,declarationNode:i,optionalParams:p})},VariableDeclarator(i){if(i.id.type!==K.Identifier||!i.init||i.init.type!==K.ArrowFunctionExpression&&i.init.type!==K.FunctionExpression||s(i.parent.parent))return;let l=[...a(i.init.params)];if(i.id.typeAnnotation&&i.id.typeAnnotation.typeAnnotation.type===K.TSTypeReference){let c=i.id.typeAnnotation.typeAnnotation;if(c.typeName.type===K.Identifier&&c.typeName.name==="FC"){let d=c.typeArguments;if(d&&d.params.length===1){let y=d.params[0];if(y&&y.type===K.TSTypeLiteral){let g=[];for(let b of y.members)b.type===K.TSPropertySignature&&b.key.type===K.Identifier&&g.push({name:b.key.name,optional:b.optional===!0});g.some(b=>b.optional)&&l.push({param:i.id,index:0,name:"props",isObjectParam:!0,objectProps:g})}}}}l.length!==0&&r.push({node:i.init,declarationNode:i,optionalParams:l})},"Program:exit"(){for(let i of r){let l=e.sourceCode.getDeclaredVariables(i.declarationNode)[0];if(!l)continue;let c=l.references.filter(g=>g.identifier!==l.identifiers[0]);if(c.length===0)continue;let d=!1;for(let g of c){let b=g.identifier.parent;if(b.type===K.CallExpression&&g.identifier.type===K.Identifier&&b.arguments.includes(g.identifier)){d=!0;break}if(b.type===K.ReturnStatement){d=!0;break}if(b.type===K.Property&&b.parent.type===K.ObjectExpression&&b.parent.parent.type===K.ReturnStatement){d=!0;break}if(b.type===K.JSXExpressionContainer){d=!0;break}}if(d)continue;let y=[];for(let g of c){let b=g.identifier.parent;if(b.type===K.CallExpression&&b.callee===g.identifier){let f=b.arguments.length,E=b.arguments.some(m=>m.type===K.SpreadElement);if(E){d=!0;break}let h={argCount:f,hasSpread:E};for(let m of i.optionalParams)if(m.isObjectParam&&m.index<f){let A=b.arguments[m.index];if(A?.type===K.ObjectExpression){let I={};for(let o of A.properties)o.type===K.Property&&o.key.type===K.Identifier&&(I[o.key.name]=!0);h.objectArgs||(h.objectArgs=[]),h.objectArgs[m.index]=I}else if(A){d=!0;break}}y.push(h)}else if(b.type===K.JSXOpeningElement&&b.name===g.identifier){let f=b.attributes.some(h=>h.type===K.JSXSpreadAttribute);if(f){d=!0;break}let E={argCount:1,hasSpread:f};for(let h of i.optionalParams)if(h.isObjectParam&&h.index===0){let m={};for(let A of b.attributes)A.type===K.JSXAttribute&&A.name.type===K.JSXIdentifier&&(m[A.name.name]=!0);E.objectArgs||(E.objectArgs=[]),E.objectArgs[0]=m}y.push(E)}}if(!(d||y.length===0))for(let g of i.optionalParams)if(g.isObjectParam&&g.objectProps)for(let b of g.objectProps){if(!b.optional)continue;let f=!1;for(let E of y)if(E.objectArgs&&E.objectArgs[g.index]){let h=E.objectArgs[g.index];if(h&&h[b.name]){f=!0;break}}f||e.report({node:g.param,messageId:"unusedOptionalProp",data:{name:b.name}})}else{let b=!1;for(let f of y)if(f.argCount>g.index){b=!0;break}b||e.report({node:g.param,messageId:"unusedOptionalArg",data:{name:g.name}})}}}}}});import{AST_NODE_TYPES as ae,ESLintUtils as Yo}from"@typescript-eslint/utils";import{z as Ve}from"zod/v4";var qo=Ve.object({selectors:Ve.array(Ve.object({name:Ve.string(),selectorProp:Ve.string().optional(),selectorArgPos:Ve.number().optional(),returnProp:Ve.string().optional()}))}),Zo=Yo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lr="no-unused-selected-values",Yt={name:lr,rule:Zo({name:lr,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[V(qo)]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(s=>[s.name,s]));return{VariableDeclarator(s){let a=null;if(s.init?.type===ae.CallExpression&&(a=s.init),!a)return;let i=Ko(a);if(!i)return;let p=n.get(i);if(!p)return;let l=Go(a,p.selectorArgPos??0,p.selectorProp);if(!l)return;let c=Qo(l);if(!c)return;let d=pr(c.properties,void 0);if(!d)return;if(s.id.type===ae.ObjectPattern){let b=pr(s.id.properties,p.returnProp);if(!b)return;for(let[f,E]of d)b.has(f)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:f}});return}if(s.id.type!==ae.Identifier||p.returnProp)return;let y=es(s,e.sourceCode);if(y.length===0)return;let g=new Set;for(let b of y){if(b.identifier.parent.type!==ae.MemberExpression)return;let f=b.identifier.parent.property;if(f.type!==ae.Identifier)return;g.add(f.name)}for(let[b,f]of d)g.has(b)||e.report({node:f,messageId:"unusedSelectedValue",data:{name:b}})}}}})};function Go(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===ae.ArrowFunctionExpression||n.type===ae.FunctionExpression)return n;if(r&&n.type===ae.ObjectExpression){let s=n.properties.find(i=>i.type===ae.Property&&i.key.type===ae.Identifier&&i.key.name===r);if(s?.type!==ae.Property)return null;let a=s.value;if(a.type===ae.ArrowFunctionExpression||a.type===ae.FunctionExpression)return a}return null}function Ko(e){return e.callee.type===ae.Identifier?e.callee.name:e.callee.type===ae.MemberExpression&&e.callee.property.type===ae.Identifier?e.callee.property.name:null}function Qo(e){if(e.body.type===ae.ObjectExpression)return e.body;if(e.body.type===ae.BlockStatement){let t=e.body.body.filter(r=>r.type===ae.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==ae.ObjectExpression?null:t[0].argument}return null}function pr(e,t){let r=e;if(t){let s=e.find(a=>a.type===ae.Property&&a.key.type===ae.Identifier&&a.key.name===t);if(s?.type!==ae.Property||s.value.type!==ae.ObjectPattern)return null;r=s.value.properties}let n=new Map;for(let s of r){if(s.type!==ae.Property||s.key.type!==ae.Identifier)return null;n.set(s.key.name,s)}return n.size>0?n:null}function es(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as se}from"@typescript-eslint/utils";var qt=B({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===se.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,s=!1;return{CallExpression(a){if(s)return;if(!n){let p=ts(a);p&&(n=p);return}let i=ns(a,e.sourceCode);if(i){s=!0;for(let p of i)n.delete(p);if(n.size!==0)for(let[p,l]of n)e.report({node:l,messageId:"unusedField",data:{name:p}})}}}}});function ts(e){if(!(e.callee.type===se.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==se.ObjectExpression)return null;let n=Rt(r.properties,a=>a.type!==se.Property||a.key.type!==se.Identifier||a.key.name!=="initialConfig"?null:a.value.type===se.ObjectExpression?a.value:a.value.type===se.ArrowFunctionExpression||a.value.type===se.FunctionExpression?rs(a.value):null);if(!n)return null;let s=new Map;for(let a of n.properties)a.type===se.Property&&a.key.type===se.Identifier&&s.set(a.key.name,a);return s}function ns(e,t){if(!(e.callee.type===se.Identifier&&e.callee.name==="useFormState")||e.parent.type!==se.VariableDeclarator||e.parent.id.type!==se.ObjectPattern||!Rt(e.parent.id.properties,i=>i.type===se.Property&&i.key.type===se.Identifier&&i.key.name==="formFields"&&i))return null;let s=Jn(e.parent,"formFields",t),a=new Set;for(let{identifier:i}of s){if(i.type!==se.Identifier||i.parent.type===se.Property&&i.parent.parent.type===se.ObjectExpression&&i.parent.parent.parent.type===se.ReturnStatement||i.parent.type===se.ReturnStatement)return null;if(i.parent.type===se.MemberExpression){if(i.parent.object.type!==se.Identifier||i.parent.property.type!==se.Identifier)return null;a.add(i.parent.property.name)}}return a}function rs(e){if(e.body.type===se.ObjectExpression)return e.body;if(e.body.type===se.BlockStatement){let t=e.body.body.filter(r=>r.type===se.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==se.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as re,ESLintUtils as is}from"@typescript-eslint/utils";import{z as mt}from"zod/v4";var os=is.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function cr(e){let t=[];for(let r of e.members)r.type===re.TSPropertySignature&&r.key.type===re.Identifier&&t.push([r.key.name,r]);return t}function ur(e,...t){for(let r of t)e.set(...r);return e}var ss=mt.object({forceCheckOnFCPropTypesWithName:mt.array(mt.string()).optional(),alwaysCheckFunctionOptionTypes:mt.boolean().optional()}),fr="no-unused-type-props-in-args",Zt=null,as=os({name:fr,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[V(ss)],fixable:"code"},defaultOptions:[{alwaysCheckFunctionOptionTypes:!0}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r,alwaysCheckFunctionOptionTypes:n=!0}=t;r&&!Zt&&(Zt=r.map(l=>new RegExp(l)));function s(l,c,d,y,g=!0,b=!1){let f=d.name,E=e.sourceCode.getScope(c).references.find(o=>o.identifier.name===f)?.resolved,h=l&&Zt?.some(o=>o.test(f)),m=b&&n;if(!E||!h&&E.references.filter(o=>o.isTypeReference).length>1||!E.defs[0])return;let A=E.defs[0].node,I=A.parent?.type===re.ExportNamedDeclaration;if(!(g&&I&&!m)){if(A.type===re.TSTypeAliasDeclaration){a(l,c,y,A.typeAnnotation,!0,b);return}if(A.type===re.TSInterfaceDeclaration){a(l,c,y,A.body,!0,b);return}}}function a(l,c,d,y,g,b=!1){if(y.type===re.TSInterfaceBody){for(let f of y.body)f.type===re.TSPropertySignature&&f.key.type===re.Identifier&&d.set(f.key.name,f);return}if(y.type===re.TSTypeLiteral){ur(d,...cr(y));return}if(y.type===re.TSIntersectionType){for(let f of y.types)a(l,c,d,f,!0,b);return}g||y.type===re.TSTypeReference&&y.typeName.type===re.Identifier&&s(l,c,y.typeName,d,!0,b)}function i(l,c,d,y=!1){for(let g of d)if(g.type===re.ObjectPattern&&g.typeAnnotation){let b=new Map;if(a(l,c,b,g.typeAnnotation.typeAnnotation,!1,y),b.size===0)continue;p(g,b)}else g.type===re.AssignmentPattern&&g.left.type===re.ObjectPattern&&i(l,c,[g.left],y)}function p(l,c){let d=[];if(l.properties.at(-1)?.type===re.RestElement)return;for(let f of l.properties)f.type===re.Property&&f.key.type===re.Identifier&&d.push(f.key.name);let g=[],b=[];for(let[f,E]of c)d.includes(f)||(b.push(f),g.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:f}}));for(let[f,E]of g.entries())e.report({...E,fix:f===g.length-1?h=>{let m=l.properties.at(-1),A=b.join(", ");return m?m.type===re.RestElement?null:h.insertTextAfter(m,`, ${A}`):h.insertTextBeforeRange([l.range[0]+1,l.range[1]],A)}:void 0})}return{VariableDeclaration(l){let c=l.declarations[0],d=new Map,y=c.id.type===re.Identifier&&c.id.typeAnnotation?.typeAnnotation.type===re.TSTypeReference&&c.id.typeAnnotation.typeAnnotation.typeName.type===re.Identifier&&c.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&c.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(y){if(y.type===re.TSTypeReference&&y.typeName.type===re.Identifier)s(!0,l,y.typeName,d,!1);else if(y.type===re.TSTypeLiteral)ur(d,...cr(y));else if(y.type===re.TSIntersectionType)for(let g of y.types)g.type===re.TSTypeReference&&g.typeName.type===re.Identifier?s(!0,l,g.typeName,d,!1):a(!0,l,d,g,!0);if(d.size!==0&&c.init?.type===re.ArrowFunctionExpression){let g=c.init.params[0];if(!g){e.report({node:c.init,messageId:"missingComponentParam"});return}g.type===re.ObjectPattern&&p(g,d)}}},FunctionDeclaration(l){i(!1,l,l.params,n)},ArrowFunctionExpression(l){i(!1,l,l.params,n)}}}}),Gt={name:fr,rule:as};import{AST_NODE_TYPES as ke}from"@typescript-eslint/utils";var Kt=B({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function r(n){return n.callee.type===ke.Identifier?t.has(n.callee.name):n.callee.type===ke.MemberExpression&&n.callee.object.type===ke.Identifier&&n.callee.property.type===ke.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let s of n.specifiers)s.type===ke.ImportSpecifier&&s.imported.type===ke.Identifier&&s.imported.name==="useRef"&&t.add(s.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===ke.CallExpression&&r(n.init)&&n.id.type===ke.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let i=!1;for(let p of a.references){let c=p.identifier.parent;if(c!==n&&!(c.type===ke.JSXExpressionContainer&&c.parent.type===ke.JSXAttribute&&c.parent.name.type===ke.JSXIdentifier&&c.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});import{AST_NODE_TYPES as Qt,ESLintUtils as ls}from"@typescript-eslint/utils";var ps=ls.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dr="prefer-named-functions",mr=new Map,cs=ps({name:dr,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let r=null;if(t.ignoreRegex){let n=mr.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),mr.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Qt.ArrowFunctionExpression&&n.id.type===Qt.Identifier){let s=n.id.name;if(n.id.typeAnnotation||r&&r.test(s)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Qt.BlockStatement)return;let a=n.parent,i=n.init.params,p=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(a,`${l.async?"async ":""}function ${s}(${i.map(d=>e.sourceCode.getText(d)).join(", ")||""}) ${e.sourceCode.getText(p)}`)}]})}}}}}),en={name:dr,rule:cs};import{AST_NODE_TYPES as q}from"@typescript-eslint/utils";import{z as Me}from"zod/v4";var us=Me.object({disallowedFunctions:Me.array(Me.object({name:Me.string(),allowUsingWithArgs:Me.boolean().optional(),hookAlternative:Me.string().optional(),message:Me.string().optional(),allowUseInside:Me.array(Me.string()).optional()}))}),fs=/^use[A-Z]/,ms=/^[A-Z]/;function dt(e){return fs.test(e)}function yr(e){return ms.test(e)}function ds(e){return e.type===q.Identifier?dt(e.name):e.type===q.MemberExpression&&e.property.type===q.Identifier?dt(e.property.name):!1}function gr(e,t){return e.type===q.Identifier?e.name===t:e.type===q.MemberExpression&&e.object.type===q.Identifier&&e.property.type===q.Identifier?e.object.name==="React"&&e.property.name===t:!1}function Sr(e){return!!(e.parent&&e.parent.type===q.CallExpression&&gr(e.parent.callee,"forwardRef"))}function Tr(e){return!!(e.parent&&e.parent.type===q.CallExpression&&gr(e.parent.callee,"memo"))}function tn(e){if(e.type===q.FunctionDeclaration||e.type===q.FunctionExpression&&e.id)return e.id||void 0;if(e.type===q.FunctionExpression||e.type===q.ArrowFunctionExpression){if(e.parent.type===q.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===q.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===q.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===q.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function ys(e){let t=e.parent,r=!1;for(;t;){if(t.type===q.FunctionDeclaration||t.type===q.FunctionExpression||t.type===q.ArrowFunctionExpression){let n=tn(t);if(n&&n.type===q.Identifier){if(yr(n.name)||dt(n.name))return!r;r=!0}else{if(Sr(t)||Tr(t))return!r;if(t.parent.type===q.CallExpression){let s=t.parent;ds(s.callee)||(r=!0)}else t.parent.type===q.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function hr(e){return e.callee.type===q.Identifier?e.callee.name:e.callee.type===q.MemberExpression&&e.callee.property.type===q.Identifier?e.callee.property.name:null}function gs(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===q.FunctionDeclaration||r.type===q.FunctionExpression||r.type===q.ArrowFunctionExpression){let n=tn(r);if(n&&n.type===q.Identifier&&t.includes(n.name))return!0}else if(r.type===q.CallExpression){let n=hr(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Ss(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===q.Identifier&&t.name==="undefined")}function Ts(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===q.FunctionDeclaration||n.type===q.FunctionExpression||n.type===q.ArrowFunctionExpression){let s=tn(n);if(s&&s.type===q.Identifier){if(yr(s.name)||dt(s.name)){r=!0;break}}else if(Sr(n)||Tr(n)){r=!0;break}}n=n.parent}return r?t.length===0?ys(e):!gs(e,t):!1}var nn=B({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react{{message}}."},schema:[V(us)],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(s=>[s.name,s]));return{CallExpression(s){let a=hr(s);if(!a)return;let i=n.get(a);if(!i||i.allowUsingWithArgs&&Ss(s))return;let p=i.allowUseInside||[];Ts(s,p)&&e.report({node:s,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:l=>{let c=i.hookAlternative;return c?s.callee.type===q.Identifier?l.replaceText(s.callee,c):s.callee.type===q.MemberExpression&&s.callee.property.type===q.Identifier?l.replaceText(s.callee.property,c):null:null}}]:[]})}}}});import{AST_NODE_TYPES as fe,AST_TOKEN_TYPES as Er,ESLintUtils as hs}from"@typescript-eslint/utils";import rn from"zod/v4";var Es=hs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xr="prefer-single-line-if",bs=rn.object({maxLineLength:rn.number().optional(),maxNonSimpleConditionLength:rn.number().optional()}),xs=Es({name:xr,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[V(bs)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==fe.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(!a)return;if(a.type===fe.ReturnStatement){if(!Ir(a))return}else if(!(a.type===fe.ContinueStatement||a.type===fe.BreakStatement))return;if(n.test.type===fe.LogicalExpression||n.test.type===fe.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let y=br(n.test);if(!y&&n.test.type===fe.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;br(g)&&(y=!0)}if(y&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let p=r.getText(a);if(i.includes(`
|
|
18
|
-
`))return;let l=r.getTokenAfter(n);if(l&&l.type===
|
|
17
|
+
`)}return""}return{Program(){let l=[];for(let g of n.body)g.type===Ae.ExpressionStatement&&g.expression.type===Ae.CallExpression&&g.expression.callee.type===Ae.Identifier&&g.expression.callee.name==="describe"&&g.expression.arguments.length===2&&l.push(g.expression);if(!i(l))return;let[c]=l;if(!c)return;let d=s(c);if(a(d))return;let y=n.body.find(g=>g.type===Ae.ExpressionStatement&&g.expression===c);!y||y.type!==Ae.ExpressionStatement||e.report({node:c,messageId:"unnecessaryDescribe",suggest:[{messageId:"removeDescribe",fix(g){let b=p(c);return b?g.replaceText(y,b):null}}]})}}}});import{AST_NODE_TYPES as ft}from"@typescript-eslint/utils";import*as ke from"zod/v4";var Xo=ke.object({methods:ke.union([ke.array(ke.string()),ke.literal("array")])}),Vt=X({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(Xo)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function s(p){return Array.isArray(r)?r.includes(p):n.has(p)}function a(p){let{callee:l}=p;if(l.type===ft.MemberExpression){let c=l.property;if(c.type===ft.Identifier)return c.name}return null}function i(p,l){if(p.type!==ft.Identifier||!p.typeAnnotation)return;let c=l.parent;if(c.type===ft.CallExpression){let d=a(c);d&&s(d)&&c.arguments.indexOf(l)===0&&e.report({node:p.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(g){return p.typeAnnotation?g.remove(p.typeAnnotation):null}})}}return{ArrowFunctionExpression(p){for(let l of p.params)i(l,p)},FunctionExpression(p){for(let l of p.params)i(l,p)}}}});import{AST_NODE_TYPES as xe}from"@typescript-eslint/utils";var Xt=X({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(t){if(t.id.type===xe.ObjectPattern||!t.init||t.init.type!==xe.ObjectExpression||t.id.type===xe.Identifier&&t.id.typeAnnotation||t.parent.parent.type===xe.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===xe.Property&&i.key.type===xe.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==xe.Identifier)return;let n=Bo(t,e.sourceCode);if(n.length===0)return;let s=t.init.properties.some(i=>i.type!==xe.Property?!1:i.value.type===xe.FunctionExpression),a=new Set;for(let i of n){if(i.identifier.parent.type!==xe.MemberExpression)return;let p=i.identifier.parent;if(p.object!==i.identifier)return;if(p.computed)if(p.property.type===xe.Literal&&typeof p.property.value=="string")a.add(p.property.value);else return;else{if(p.property.type!==xe.Identifier)return;a.add(p.property.name)}if(p.parent.type===xe.CallExpression&&s)return}for(let[i,p]of r)a.has(i)||e.report({node:p,messageId:"unusedObjectProperty",data:{name:i}})}}}});function Bo(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as K}from"@typescript-eslint/utils";import{z as sr}from"zod/v4";var Ho=sr.object({ignoreArgsMatching:sr.string().optional()}),Bt=X({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(Ho)]},defaultOptions:[{}],create(e,[t]){let r=[];function n(i){return t.ignoreArgsMatching?new RegExp(t.ignoreArgsMatching).test(i):!1}function s(i){return i.type===K.ExportNamedDeclaration||i.type===K.ExportDefaultDeclaration||i.parent?.type===K.ExportNamedDeclaration||i.parent?.type===K.ExportDefaultDeclaration}function a(i){let p=[];for(let l=0;l<i.length;l++){let c=i[l];if(!c||c.type!==K.Identifier)continue;let d=c.name;if(!n(d)){if(c.optional&&c.typeAnnotation&&c.typeAnnotation.typeAnnotation.type===K.TSTypeLiteral){let y=c.typeAnnotation.typeAnnotation,g=[];for(let b of y.members)b.type===K.TSPropertySignature&&b.key.type===K.Identifier&&g.push({name:b.key.name,optional:b.optional===!0});g.some(b=>b.optional)?p.push({param:c,index:l,name:d,isObjectParam:!0,objectProps:g}):p.push({param:c,index:l,name:d,isObjectParam:!1})}else if(c.optional)p.push({param:c,index:l,name:d,isObjectParam:!1});else if(c.typeAnnotation&&c.typeAnnotation.typeAnnotation.type===K.TSTypeLiteral){let y=c.typeAnnotation.typeAnnotation,g=[];for(let b of y.members)b.type===K.TSPropertySignature&&b.key.type===K.Identifier&&g.push({name:b.key.name,optional:b.optional===!0});g.some(b=>b.optional)&&p.push({param:c,index:l,name:d,isObjectParam:!0,objectProps:g})}}}return p}return{FunctionDeclaration(i){if(s(i))return;let p=a(i.params);p.length!==0&&r.push({node:i,declarationNode:i,optionalParams:p})},VariableDeclarator(i){if(i.id.type!==K.Identifier||!i.init||i.init.type!==K.ArrowFunctionExpression&&i.init.type!==K.FunctionExpression||s(i.parent.parent))return;let l=[...a(i.init.params)];if(i.id.typeAnnotation&&i.id.typeAnnotation.typeAnnotation.type===K.TSTypeReference){let c=i.id.typeAnnotation.typeAnnotation;if(c.typeName.type===K.Identifier&&c.typeName.name==="FC"){let d=c.typeArguments;if(d&&d.params.length===1){let y=d.params[0];if(y&&y.type===K.TSTypeLiteral){let g=[];for(let b of y.members)b.type===K.TSPropertySignature&&b.key.type===K.Identifier&&g.push({name:b.key.name,optional:b.optional===!0});g.some(b=>b.optional)&&l.push({param:i.id,index:0,name:"props",isObjectParam:!0,objectProps:g})}}}}l.length!==0&&r.push({node:i.init,declarationNode:i,optionalParams:l})},"Program:exit"(){for(let i of r){let l=e.sourceCode.getDeclaredVariables(i.declarationNode)[0];if(!l)continue;let c=l.references.filter(g=>g.identifier!==l.identifiers[0]);if(c.length===0)continue;let d=!1;for(let g of c){let b=g.identifier.parent;if(b.type===K.CallExpression&&g.identifier.type===K.Identifier&&b.arguments.includes(g.identifier)){d=!0;break}if(b.type===K.ReturnStatement){d=!0;break}if(b.type===K.Property&&b.parent.type===K.ObjectExpression&&b.parent.parent.type===K.ReturnStatement){d=!0;break}if(b.type===K.JSXExpressionContainer){d=!0;break}}if(d)continue;let y=[];for(let g of c){let b=g.identifier.parent;if(b.type===K.CallExpression&&b.callee===g.identifier){let f=b.arguments.length,E=b.arguments.some(m=>m.type===K.SpreadElement);if(E){d=!0;break}let h={argCount:f,hasSpread:E};for(let m of i.optionalParams)if(m.isObjectParam&&m.index<f){let A=b.arguments[m.index];if(A?.type===K.ObjectExpression){let I={};for(let o of A.properties)o.type===K.Property&&o.key.type===K.Identifier&&(I[o.key.name]=!0);h.objectArgs||(h.objectArgs=[]),h.objectArgs[m.index]=I}else if(A){d=!0;break}}y.push(h)}else if(b.type===K.JSXOpeningElement&&b.name===g.identifier){let f=b.attributes.some(h=>h.type===K.JSXSpreadAttribute);if(f){d=!0;break}let E={argCount:1,hasSpread:f};for(let h of i.optionalParams)if(h.isObjectParam&&h.index===0){let m={};for(let A of b.attributes)A.type===K.JSXAttribute&&A.name.type===K.JSXIdentifier&&(m[A.name.name]=!0);E.objectArgs||(E.objectArgs=[]),E.objectArgs[0]=m}y.push(E)}}if(!(d||y.length===0))for(let g of i.optionalParams)if(g.isObjectParam&&g.objectProps)for(let b of g.objectProps){if(!b.optional)continue;let f=!1;for(let E of y)if(E.objectArgs&&E.objectArgs[g.index]){let h=E.objectArgs[g.index];if(h&&h[b.name]){f=!0;break}}f||e.report({node:g.param,messageId:"unusedOptionalProp",data:{name:b.name}})}else{let b=!1;for(let f of y)if(f.argCount>g.index){b=!0;break}b||e.report({node:g.param,messageId:"unusedOptionalArg",data:{name:g.name}})}}}}}});import{AST_NODE_TYPES as ae,ESLintUtils as Yo}from"@typescript-eslint/utils";import{z as Ve}from"zod/v4";var qo=Ve.object({selectors:Ve.array(Ve.object({name:Ve.string(),selectorProp:Ve.string().optional(),selectorArgPos:Ve.number().optional(),returnProp:Ve.string().optional()}))}),Zo=Yo.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ar="no-unused-selected-values",Ht={name:ar,rule:Zo({name:ar,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[J(qo)]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(s=>[s.name,s]));return{VariableDeclarator(s){let a=null;if(s.init?.type===ae.CallExpression&&(a=s.init),!a)return;let i=Ko(a);if(!i)return;let p=n.get(i);if(!p)return;let l=Go(a,p.selectorArgPos??0,p.selectorProp);if(!l)return;let c=Qo(l);if(!c)return;let d=lr(c.properties,void 0);if(!d)return;if(s.id.type===ae.ObjectPattern){let b=lr(s.id.properties,p.returnProp);if(!b)return;for(let[f,E]of d)b.has(f)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:f}});return}if(s.id.type!==ae.Identifier||p.returnProp)return;let y=es(s,e.sourceCode);if(y.length===0)return;let g=new Set;for(let b of y){if(b.identifier.parent.type!==ae.MemberExpression)return;let f=b.identifier.parent.property;if(f.type!==ae.Identifier)return;g.add(f.name)}for(let[b,f]of d)g.has(b)||e.report({node:f,messageId:"unusedSelectedValue",data:{name:b}})}}}})};function Go(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===ae.ArrowFunctionExpression||n.type===ae.FunctionExpression)return n;if(r&&n.type===ae.ObjectExpression){let s=n.properties.find(i=>i.type===ae.Property&&i.key.type===ae.Identifier&&i.key.name===r);if(s?.type!==ae.Property)return null;let a=s.value;if(a.type===ae.ArrowFunctionExpression||a.type===ae.FunctionExpression)return a}return null}function Ko(e){return e.callee.type===ae.Identifier?e.callee.name:e.callee.type===ae.MemberExpression&&e.callee.property.type===ae.Identifier?e.callee.property.name:null}function Qo(e){if(e.body.type===ae.ObjectExpression)return e.body;if(e.body.type===ae.BlockStatement){let t=e.body.body.filter(r=>r.type===ae.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==ae.ObjectExpression?null:t[0].argument}return null}function lr(e,t){let r=e;if(t){let s=e.find(a=>a.type===ae.Property&&a.key.type===ae.Identifier&&a.key.name===t);if(s?.type!==ae.Property||s.value.type!==ae.ObjectPattern)return null;r=s.value.properties}let n=new Map;for(let s of r){if(s.type!==ae.Property||s.key.type!==ae.Identifier)return null;n.set(s.key.name,s)}return n.size>0?n:null}function es(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as se}from"@typescript-eslint/utils";var Yt=X({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===se.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,s=!1;return{CallExpression(a){if(s)return;if(!n){let p=ts(a);p&&(n=p);return}let i=ns(a,e.sourceCode);if(i){s=!0;for(let p of i)n.delete(p);if(n.size!==0)for(let[p,l]of n)e.report({node:l,messageId:"unusedField",data:{name:p}})}}}}});function ts(e){if(!(e.callee.type===se.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==se.ObjectExpression)return null;let n=wt(r.properties,a=>a.type!==se.Property||a.key.type!==se.Identifier||a.key.name!=="initialConfig"?null:a.value.type===se.ObjectExpression?a.value:a.value.type===se.ArrowFunctionExpression||a.value.type===se.FunctionExpression?rs(a.value):null);if(!n)return null;let s=new Map;for(let a of n.properties)a.type===se.Property&&a.key.type===se.Identifier&&s.set(a.key.name,a);return s}function ns(e,t){if(!(e.callee.type===se.Identifier&&e.callee.name==="useFormState")||e.parent.type!==se.VariableDeclarator||e.parent.id.type!==se.ObjectPattern||!wt(e.parent.id.properties,i=>i.type===se.Property&&i.key.type===se.Identifier&&i.key.name==="formFields"&&i))return null;let s=Wn(e.parent,"formFields",t),a=new Set;for(let{identifier:i}of s){if(i.type!==se.Identifier||i.parent.type===se.Property&&i.parent.parent.type===se.ObjectExpression&&i.parent.parent.parent.type===se.ReturnStatement||i.parent.type===se.ReturnStatement)return null;if(i.parent.type===se.MemberExpression){if(i.parent.object.type!==se.Identifier||i.parent.property.type!==se.Identifier)return null;a.add(i.parent.property.name)}}return a}function rs(e){if(e.body.type===se.ObjectExpression)return e.body;if(e.body.type===se.BlockStatement){let t=e.body.body.filter(r=>r.type===se.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==se.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as ne,ESLintUtils as is}from"@typescript-eslint/utils";import{z as mt}from"zod/v4";var os=is.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function pr(e){let t=[];for(let r of e.members)r.type===ne.TSPropertySignature&&r.key.type===ne.Identifier&&t.push([r.key.name,r]);return t}function cr(e,...t){for(let r of t)e.set(...r);return e}var ss=mt.object({forceCheckOnFCPropTypesWithName:mt.array(mt.string()).optional(),alwaysCheckFunctionOptionTypes:mt.boolean().optional()}),ur="no-unused-type-props-in-args",qt=null,as=os({name:ur,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(ss)],fixable:"code"},defaultOptions:[{alwaysCheckFunctionOptionTypes:!0}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r,alwaysCheckFunctionOptionTypes:n=!0}=t;r&&!qt&&(qt=r.map(l=>new RegExp(l)));function s(l,c,d,y,g=!0,b=!1){let f=d.name,E=e.sourceCode.getScope(c).references.find(o=>o.identifier.name===f)?.resolved,h=l&&qt?.some(o=>o.test(f)),m=b&&n;if(!E||!h&&E.references.filter(o=>o.isTypeReference).length>1||!E.defs[0])return;let A=E.defs[0].node,I=A.parent?.type===ne.ExportNamedDeclaration;if(!(g&&I&&!m)){if(A.type===ne.TSTypeAliasDeclaration){a(l,c,y,A.typeAnnotation,!0,b);return}if(A.type===ne.TSInterfaceDeclaration){a(l,c,y,A.body,!0,b);return}}}function a(l,c,d,y,g,b=!1){if(y.type===ne.TSInterfaceBody){for(let f of y.body)f.type===ne.TSPropertySignature&&f.key.type===ne.Identifier&&d.set(f.key.name,f);return}if(y.type===ne.TSTypeLiteral){cr(d,...pr(y));return}if(y.type===ne.TSIntersectionType){for(let f of y.types)a(l,c,d,f,!0,b);return}g||y.type===ne.TSTypeReference&&y.typeName.type===ne.Identifier&&s(l,c,y.typeName,d,!0,b)}function i(l,c,d,y=!1){for(let g of d)if(g.type===ne.ObjectPattern&&g.typeAnnotation){let b=new Map;if(a(l,c,b,g.typeAnnotation.typeAnnotation,!1,y),b.size===0)continue;p(g,b)}else g.type===ne.AssignmentPattern&&g.left.type===ne.ObjectPattern&&i(l,c,[g.left],y)}function p(l,c){let d=[];if(l.properties.at(-1)?.type===ne.RestElement)return;for(let f of l.properties)f.type===ne.Property&&f.key.type===ne.Identifier&&d.push(f.key.name);let g=[],b=[];for(let[f,E]of c)d.includes(f)||(b.push(f),g.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:f}}));for(let[f,E]of g.entries())e.report({...E,fix:f===g.length-1?h=>{let m=l.properties.at(-1),A=b.join(", ");return m?m.type===ne.RestElement?null:h.insertTextAfter(m,`, ${A}`):h.insertTextBeforeRange([l.range[0]+1,l.range[1]],A)}:void 0})}return{VariableDeclaration(l){let c=l.declarations[0],d=new Map,y=c.id.type===ne.Identifier&&c.id.typeAnnotation?.typeAnnotation.type===ne.TSTypeReference&&c.id.typeAnnotation.typeAnnotation.typeName.type===ne.Identifier&&c.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&c.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(y){if(y.type===ne.TSTypeReference&&y.typeName.type===ne.Identifier)s(!0,l,y.typeName,d,!1);else if(y.type===ne.TSTypeLiteral)cr(d,...pr(y));else if(y.type===ne.TSIntersectionType)for(let g of y.types)g.type===ne.TSTypeReference&&g.typeName.type===ne.Identifier?s(!0,l,g.typeName,d,!1):a(!0,l,d,g,!0);if(d.size!==0&&c.init?.type===ne.ArrowFunctionExpression){let g=c.init.params[0];if(!g){e.report({node:c.init,messageId:"missingComponentParam"});return}g.type===ne.ObjectPattern&&p(g,d)}}},FunctionDeclaration(l){i(!1,l,l.params,n)},ArrowFunctionExpression(l){i(!1,l,l.params,n)}}}}),Zt={name:ur,rule:as};import{AST_NODE_TYPES as Fe}from"@typescript-eslint/utils";var Gt=X({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function r(n){return n.callee.type===Fe.Identifier?t.has(n.callee.name):n.callee.type===Fe.MemberExpression&&n.callee.object.type===Fe.Identifier&&n.callee.property.type===Fe.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let s of n.specifiers)s.type===Fe.ImportSpecifier&&s.imported.type===Fe.Identifier&&s.imported.name==="useRef"&&t.add(s.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===Fe.CallExpression&&r(n.init)&&n.id.type===Fe.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let i=!1;for(let p of a.references){let c=p.identifier.parent;if(c!==n&&!(c.type===Fe.JSXExpressionContainer&&c.parent.type===Fe.JSXAttribute&&c.parent.name.type===Fe.JSXIdentifier&&c.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});import{AST_NODE_TYPES as Kt,ESLintUtils as ls}from"@typescript-eslint/utils";var ps=ls.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mr="prefer-named-functions",fr=new Map,cs=ps({name:mr,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let r=null;if(t.ignoreRegex){let n=fr.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),fr.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Kt.ArrowFunctionExpression&&n.id.type===Kt.Identifier){let s=n.id.name;if(n.id.typeAnnotation||r&&r.test(s)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Kt.BlockStatement)return;let a=n.parent,i=n.init.params,p=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(a,`${l.async?"async ":""}function ${s}(${i.map(d=>e.sourceCode.getText(d)).join(", ")||""}) ${e.sourceCode.getText(p)}`)}]})}}}}}),Qt={name:mr,rule:cs};import{AST_NODE_TYPES as Y}from"@typescript-eslint/utils";import{z as Le}from"zod/v4";var us=Le.object({disallowedFunctions:Le.array(Le.object({name:Le.string(),allowUsingWithArgs:Le.boolean().optional(),hookAlternative:Le.string().optional(),message:Le.string().optional(),allowUseInside:Le.array(Le.string()).optional()}))}),fs=/^use[A-Z]/,ms=/^[A-Z]/;function dt(e){return fs.test(e)}function dr(e){return ms.test(e)}function ds(e){return e.type===Y.Identifier?dt(e.name):e.type===Y.MemberExpression&&e.property.type===Y.Identifier?dt(e.property.name):!1}function yr(e,t){return e.type===Y.Identifier?e.name===t:e.type===Y.MemberExpression&&e.object.type===Y.Identifier&&e.property.type===Y.Identifier?e.object.name==="React"&&e.property.name===t:!1}function gr(e){return!!(e.parent&&e.parent.type===Y.CallExpression&&yr(e.parent.callee,"forwardRef"))}function Sr(e){return!!(e.parent&&e.parent.type===Y.CallExpression&&yr(e.parent.callee,"memo"))}function en(e){if(e.type===Y.FunctionDeclaration||e.type===Y.FunctionExpression&&e.id)return e.id||void 0;if(e.type===Y.FunctionExpression||e.type===Y.ArrowFunctionExpression){if(e.parent.type===Y.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===Y.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===Y.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===Y.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function ys(e){let t=e.parent,r=!1;for(;t;){if(t.type===Y.FunctionDeclaration||t.type===Y.FunctionExpression||t.type===Y.ArrowFunctionExpression){let n=en(t);if(n&&n.type===Y.Identifier){if(dr(n.name)||dt(n.name))return!r;r=!0}else{if(gr(t)||Sr(t))return!r;if(t.parent.type===Y.CallExpression){let s=t.parent;ds(s.callee)||(r=!0)}else t.parent.type===Y.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Tr(e){return e.callee.type===Y.Identifier?e.callee.name:e.callee.type===Y.MemberExpression&&e.callee.property.type===Y.Identifier?e.callee.property.name:null}function gs(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===Y.FunctionDeclaration||r.type===Y.FunctionExpression||r.type===Y.ArrowFunctionExpression){let n=en(r);if(n&&n.type===Y.Identifier&&t.includes(n.name))return!0}else if(r.type===Y.CallExpression){let n=Tr(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Ss(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===Y.Identifier&&t.name==="undefined")}function Ts(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===Y.FunctionDeclaration||n.type===Y.FunctionExpression||n.type===Y.ArrowFunctionExpression){let s=en(n);if(s&&s.type===Y.Identifier){if(dr(s.name)||dt(s.name)){r=!0;break}}else if(gr(n)||Sr(n)){r=!0;break}}n=n.parent}return r?t.length===0?ys(e):!gs(e,t):!1}var tn=X({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(us)],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(s=>[s.name,s]));return{CallExpression(s){let a=Tr(s);if(!a)return;let i=n.get(a);if(!i||i.allowUsingWithArgs&&Ss(s))return;let p=i.allowUseInside||[];Ts(s,p)&&e.report({node:s,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:l=>{let c=i.hookAlternative;return c?s.callee.type===Y.Identifier?l.replaceText(s.callee,c):s.callee.type===Y.MemberExpression&&s.callee.property.type===Y.Identifier?l.replaceText(s.callee.property,c):null:null}}]:[]})}}}});import{AST_NODE_TYPES as me,AST_TOKEN_TYPES as hr,ESLintUtils as hs}from"@typescript-eslint/utils";import nn from"zod/v4";var Es=hs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),br="prefer-single-line-if",bs=nn.object({maxLineLength:nn.number().optional(),maxNonSimpleConditionLength:nn.number().optional()}),xs=Es({name:br,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(bs)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==me.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(!a)return;if(a.type===me.ReturnStatement){if(!Cr(a))return}else if(!(a.type===me.ContinueStatement||a.type===me.BreakStatement))return;if(n.test.type===me.LogicalExpression||n.test.type===me.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let y=Er(n.test);if(!y&&n.test.type===me.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;Er(g)&&(y=!0)}if(y&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let p=r.getText(a);if(i.includes(`
|
|
18
|
+
`))return;let l=r.getTokenAfter(n);if(l&&l.type===hr.Punctuator&&l.value==="}"){let y=r.getTokenAfter(l);if(y&&y.type===hr.Keyword&&(y.value==="else"||y.value==="catch"))return}let c=Cs(r,n),d=`if (${i}) ${p}`;t.maxLineLength&&d.length+c.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:y=>y.replaceText(n,d)})}}}});function Er(e){return e.type===me.CallExpression||e.type===me.BinaryExpression||e.type===me.MemberExpression&&xr(e)}function xr(e){return e.object.type===me.MemberExpression?xr(e.object):e.object.type!==me.Identifier}function Cs(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Cr(e){if(!e.argument)return!0;let t=e.argument;return t.type===me.ArrayExpression&&t.elements.length===0||t.type===me.ObjectExpression&&t.properties.length===0||t.type===me.Literal||t.type===me.Identifier||t.type===me.TemplateLiteral||t.type===me.TaggedTemplateExpression?!0:t.type===me.CallExpression?t.arguments.length===0:t.type===me.UnaryExpression?Cr(t):!1}var rn={name:br,rule:xs};import{AST_NODE_TYPES as _,ESLintUtils as Is}from"@typescript-eslint/utils";import{z as Ir}from"zod/v4";var As=Is.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pr="react-compiler-extra",ws=Ir.object({runOnlyWithEnableCompilerDirective:Ir.boolean().optional()}),Rs=/eslint +react-compiler\/react-compiler: +\["error/;function vr(e){return e.type===_.Identifier?e.name.startsWith("use"):!1}function Ps(e){return e.type===_.Identifier?e.name.startsWith("use"):e.type===_.MemberExpression&&e.property.type===_.Identifier?e.property.name.startsWith("use"):!1}function Oe(e){if(!e)return!1;switch(e.type){case _.JSXElement:case _.JSXFragment:return!0;case _.ConditionalExpression:return Oe(e.consequent)||Oe(e.alternate);case _.LogicalExpression:return e.operator==="&&"?Oe(e.right):e.operator==="||"?Oe(e.left)||Oe(e.right):!1;case _.CallExpression:if(e.callee.type===_.MemberExpression&&e.callee.object.type===_.Identifier&&e.callee.object.name==="React"&&e.callee.property.type===_.Identifier&&e.callee.property.name==="createElement")return!0;for(let t of e.arguments)if(t.type!==_.SpreadElement&&Oe(t))return!0;return!1;default:return!1}}function vs(e){let t=e.typeAnnotation;if(t.type===_.TSTypeReference){if(t.typeName.type===_.Identifier)return t.typeName.name==="FC";if(t.typeName.type===_.TSQualifiedName&&t.typeName.left.type===_.Identifier&&t.typeName.right.type===_.Identifier)return t.typeName.left.name==="React"&&t.typeName.right.name==="FC"}return!1}var Fs=/^[A-Z][a-zA-Z0-9]*$/;function rt(e){return Fs.test(e)}function sn(e){return e.startsWith("use")&&e.length>3}function an(e,t,r,n){if(r&&vs(r))return t?rt(t.name):e.type===_.FunctionDeclaration&&e.id?rt(e.id.name):!0;if(t&&sn(t.name)||e.type===_.FunctionDeclaration&&e.id&&sn(e.id.name))return!0;if(n){let s=t?.name||e.type===_.FunctionDeclaration&&e.id?.name;if(s&&rt(s)&&Fr(e.body,n).containsJSX)return!0}return!1}function nt(e){if(e.body.type===_.BlockStatement){for(let t of e.body.body)if(t.type===_.ExpressionStatement&&t.expression.type===_.Literal&&typeof t.expression.value=="string"&&t.expression.value==="use memo")return!0}return!1}function Fr(e,t){let r={containsJSX:!1,containsHookCalls:!1};return ve(e,n=>{if(r.containsJSX&&r.containsHookCalls)return!0;switch(n.type){case _.JSXElement:case _.JSXFragment:r.containsJSX=!0;break;case _.CallExpression:vr(n.callee)&&(r.containsHookCalls=!0),Oe(n)&&(r.containsJSX=!0);break;case _.ReturnStatement:n.argument&&Oe(n.argument)&&(r.containsJSX=!0);break;case _.VariableDeclarator:n.init&&Oe(n.init)&&(r.containsJSX=!0);break;case _.AssignmentExpression:Oe(n.right)&&(r.containsJSX=!0);break}},t),r}function Ar(e,t){let r=e.body,n=Fr(r,t);return n.containsJSX||n.containsHookCalls}var ks=/\bthis[.[]/;function wr(e){return ks.test(e)}function Os(e,t){let r={containsJSX:!1,containsHookCalls:!1};return ve(e,n=>{if(r.containsHookCalls||(n.type===_.FunctionDeclaration||n.type===_.FunctionExpression||n.type===_.ArrowFunctionExpression)&&n!==e)return!0;n.type===_.CallExpression&&Ps(n.callee)&&(r.containsHookCalls=!0)},t),r}function Rr(e){return rt(e)||sn(e)}function on(e,t,r,n){if(!Os(e.body,t).containsHookCalls)return!1;let a=an(e,r,n,t);if(!a&&n){let i=r?.name||e.type===_.FunctionDeclaration&&e.id?.name;i&&rt(i)&&(a=!0)}return!a}var Ns=As({name:Pr,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually.",fcComponentShouldReturnJsx:'React components and hooks should create JSX elements, call other hooks or use the "use memo" directive for optimal React compiler detection.',addUseMemoDirective:'Add "use memo" directive to opt into React compiler memoization',functionCallingHooksMustBeComponent:'Functions calling hooks must be React components (PascalCase with FC type) or hooks (start with "use").',useMemoDirectiveNaming:'Functions using "use memo" directive must follow React naming conventions (PascalCase for components or start with "use" for hooks).'},hasSuggestions:!0,schema:[J(ws)]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(Rs.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let i of a.properties)if(i.type===_.Property&&i.method&&i.value.type===_.FunctionExpression){let p=e.sourceCode,l=p.getText(i.key),c=i.value,d=p.getText(c.body);if(wr(d))e.report({node:i,messageId:"thisKeywordInMethod"});else{let y=c.params.map(b=>p.getText(b)).join(", "),g="";c.generator?g=`${l}: function* (${y}) ${d}`:g=`${l}: (${y}) => ${d}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:b=>b.replaceText(i,g)})}}}function s(a){for(let i of a.properties)if(i.type===_.Property&&i.value.type===_.ObjectExpression){for(let p of i.value.properties)if(p.type===_.Property&&p.method&&p.value.type===_.FunctionExpression){let c=e.sourceCode.getText(p.value.body);wr(c)&&e.report({node:p,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(vr(a.callee))for(let i of a.arguments){if(i.type===_.ObjectExpression&&(n(i),s(i)),i.type===_.ArrowFunctionExpression&&(i.body.type===_.ObjectExpression&&(n(i.body),s(i.body)),i.body.type===_.BlockStatement))for(let p of i.body.body)p.type===_.ReturnStatement&&p.argument?.type===_.ObjectExpression&&(n(p.argument),s(p.argument));if(i.type===_.FunctionExpression)for(let p of i.body.body)p.type===_.ReturnStatement&&p.argument?.type===_.ObjectExpression&&(n(p.argument),s(p.argument))}},VariableDeclarator(a){if(a.id.type===_.Identifier&&a.init&&(a.init.type===_.ArrowFunctionExpression||a.init.type===_.FunctionExpression)){let i=a.init,p=a.id,l=a.id.typeAnnotation;if(nt(i)&&!Rr(p.name)){e.report({node:i,messageId:"useMemoDirectiveNaming"});return}if(on(i,e.sourceCode,p,l)){e.report({node:i,messageId:"functionCallingHooksMustBeComponent"});return}if(an(i,p,l,e.sourceCode)){let c=Ar(i,e.sourceCode),d=nt(i);!c&&!d&&e.report({node:i,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(y){if(i.body.type===_.BlockStatement){let g=i.body.range[0]+1;return y.insertTextAfterRange([g,g],`
|
|
19
19
|
"use memo"
|
|
20
|
-
`)}return null}}]})}}},FunctionDeclaration(a){if(a.id&&
|
|
20
|
+
`)}return null}}]})}}},FunctionDeclaration(a){if(a.id&&nt(a)&&!Rr(a.id.name)){e.report({node:a,messageId:"useMemoDirectiveNaming"});return}if(on(a,e.sourceCode)){e.report({node:a,messageId:"functionCallingHooksMustBeComponent"});return}if(an(a,void 0,void 0,e.sourceCode)){let i=Ar(a,e.sourceCode),p=nt(a);!i&&!p&&e.report({node:a,messageId:"fcComponentShouldReturnJsx",suggest:[{messageId:"addUseMemoDirective",fix(l){let c=a.body.range[0]+1;return l.insertTextAfterRange([c,c],`
|
|
21
21
|
"use memo"
|
|
22
|
-
`)}}]})}},FunctionExpression(a){if(
|
|
22
|
+
`)}}]})}},FunctionExpression(a){if(nt(a)){e.report({node:a,messageId:"useMemoDirectiveNaming"});return}on(a,e.sourceCode)&&e.report({node:a,messageId:"functionCallingHooksMustBeComponent"})}}}}),ln={name:Pr,rule:Ns};import{AST_NODE_TYPES as we,ESLintUtils as Ds}from"@typescript-eslint/utils";import{z as Ne}from"zod/v4";var js=Ds.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kr="react-compiler-migration",Ls=Ne.object({disallowHooks:Ne.array(Ne.object({name:Ne.string(),replacement:Ne.string()})).optional(),disallowMethods:Ne.array(Ne.object({name:Ne.string(),replacement:Ne.string().optional(),requireTrueProp:Ne.string().optional()})).optional()}),Ms=/eslint +react-compiler\/react-compiler: +\["error/;function $s(e){return e.type===we.Identifier?e.name.startsWith("use"):e.type===we.MemberExpression&&e.property.type===we.Identifier?e.property.name.startsWith("use"):!1}var _s=js({name:kr,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(Ls)]},defaultOptions:[{disallowHooks:[],disallowMethods:[]}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Ms.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let s=null,a=null;if(n.callee.type===we.Identifier?(s=n.callee.name,a=n.callee):n.callee.type===we.MemberExpression&&n.callee.property.type===we.Identifier&&(s=n.callee.property.name,a=n.callee.property),s){let i=t.disallowHooks.find(p=>p.name===s);i&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:p=>p.replaceText(a,i.replacement)}]})}}if(t.disallowMethods?.length&&$s(n.callee)){for(let s of n.arguments)if(s.type===we.ObjectExpression){for(let a of s.properties)if(a.type===we.Property&&a.key.type===we.Identifier){let i=a.key.name,p=t.disallowMethods.find(l=>l.name===i);if(p){if(p.requireTrueProp){let l=p.requireTrueProp,c=!1;for(let d of s.properties)if(d.type===we.Property&&d.key.type===we.Identifier&&d.key.name===l&&d.value.type===we.Literal&&d.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:p.name,requireTrueProp:l}});continue}}p.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:p.name,replacement:p.replacement},suggest:[{messageId:"replace",data:{replacement:p.replacement},fix:l=>p.replacement?l.replaceText(a.key,p.replacement):null}]})}}}}}}:{}}}),pn={name:kr,rule:_s};import{AST_NODE_TYPES as M}from"@typescript-eslint/utils";import{z as Or}from"zod";var Us=Or.object({runOnlyWithEnableCompilerDirective:Or.boolean().optional()}),zs=/eslint +react-compiler\/react-compiler: +\["error/,Ws=/^\d+$/,Js=/[\s_-]+/,Vs=/[a-z][A-Z]/,Xs=/^(.+?)([A-Z][a-z]+s?)$/,Bs=/^[a-z][a-zA-Z]*$/;function Nr(e,t){let r=[];if(e.type===M.JSXElement){for(let n of e.openingElement.attributes)if(n.type===M.JSXAttribute&&n.name.type===M.JSXIdentifier&&n.value?.type===M.JSXExpressionContainer&&n.value.expression.type!==M.JSXEmptyExpression){let s=n.name.name,a=n.value.expression,i=!1;ve(a,p=>{switch(p.type){case M.ObjectExpression:case M.ArrowFunctionExpression:case M.FunctionExpression:case M.ArrayExpression:return i=!0,!0}return!1},t),i&&r.push(s)}}return{hasUnstable:r.length>0,problematicProps:r}}function Hs(e){if(e.body.type===M.JSXElement||e.body.type===M.JSXFragment)return!0;if(e.body.type===M.BlockStatement){for(let t of e.body.body)if(t.type===M.ReturnStatement&&t.argument&&(t.argument.type===M.JSXElement||t.argument.type===M.JSXFragment))return!0}return!1}function Ys(e,t){let r=e.callee;if(r.type===M.MemberExpression){let n=r.object;if(n.type===M.Identifier){let s=n.name,a=qs(s);if(a!==s)return un(a)}}if(t.length>0){let n=t[0];if(n&&n.type===M.Identifier)return un(n.name)}return"ListItem"}function qs(e){let r={people:"person",children:"child",feet:"foot",teeth:"tooth",mice:"mouse",men:"man",women:"woman"}[e.toLowerCase()];if(r)return r;if(e.match(Vs)){let n=e.match(Xs);if(n){let s=n[1],a=n[2];if(!s||!a)return cn(e);let i=cn(a);if(i!==a)return s+i}}return cn(e)}function cn(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 un(e){return e.match(Bs)?e.charAt(0).toUpperCase()+e.slice(1):e.split(Js).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function Dr(e,t,r){let n=[],s=new Set,a=new Set(["console","document","window","Math","Object","Array","String","Number","Boolean","undefined","null"]);ve(e,i=>{if(i.type===M.Identifier&&!t.includes(i.name)&&!a.has(i.name)&&!Ws.test(i.name)){let p=i.parent;if(p.type===M.Property&&p.key===i||p.type===M.MemberExpression&&p.property===i&&!p.computed||p.type===M.JSXOpeningElement||p.type===M.JSXClosingElement||p.type===M.JSXAttribute&&p.name.type===M.JSXIdentifier&&p.name.name===i.name)return!1;s.add(i.name)}return!1},r);for(let i of s)t.includes(i)||n.push({name:i,type:"unknown"});return n}function jr(e,t,r,n,s){let i=[...r.map(y=>y.type===M.Identifier?y.name:"item").map((y,g)=>({name:y,type:g===0?`${e}Type`:g===1?"number":"unknown"})),...n],p=i.map(y=>{let g=y.type;return y.name.includes("on")&&g==="any"&&(g="unknown"),` ${y.name}: ${g};`}).join(`
|
|
23
23
|
`),l=i.map(y=>y.name).join(", "),c=s.getText(t),d=`${e}Props`;return`type ${d} = {
|
|
24
24
|
${p}
|
|
25
25
|
};
|
|
@@ -28,28 +28,28 @@ const ${e}: FC<${d}> = ({ ${l} }) => {
|
|
|
28
28
|
return (
|
|
29
29
|
${c}
|
|
30
30
|
);
|
|
31
|
-
};`}function Zs(e,t,r,n){let s=t.map(i=>i.type===
|
|
31
|
+
};`}function Zs(e,t,r,n){let s=t.map(i=>i.type===M.Identifier?i.name:"item"),a=[n?`key={${n}}`:`key={${s[0]}.id}`,...s.map(i=>`${i}={${i}}`),...r.map(i=>`${i.name}={${i.name}}`)].filter(Boolean);return`<${e} ${a.join(" ")} />`}function Gs(e){if(e.type===M.JSXElement&&e.openingElement.name.type===M.JSXIdentifier){let t=e.openingElement.name.name;if(t!=="div"&&t!=="span")return un(t)}return"ListItem"}function Ks(e,t,r){let n=[r?`key={${r}}`:"",...t.map(s=>`${s.name}={${s.name}}`)].filter(Boolean);return`<${e}${n.length>0?` ${n.join(" ")}`:""} />`}function Lr(e,t){for(let r of e.openingElement.attributes)if(r.type===M.JSXAttribute&&r.name.type===M.JSXIdentifier&&r.name.name==="key"&&r.value&&r.value.type===M.JSXExpressionContainer&&r.value.expression.type!==M.JSXEmptyExpression)return t.getText(r.value.expression);return null}var fn=X({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(Us)],hasSuggestions:!0},defaultOptions:[{runOnlyWithEnableCompilerDirective:!1}],create(e,[t]){let{sourceCode:r}=e;if(t.runOnlyWithEnableCompilerDirective){let n=!1;for(let s of r.getAllComments())if(zs.test(s.value)){n=!0;break}if(!n)return{}}return{CallExpression(n){n.callee.type===M.MemberExpression&&n.callee.property.type===M.Identifier&&(n.callee.property.name==="map"||n.callee.property.name==="push")&&(n.callee.property.name==="map"?Qs(n,r,e):ea(n,r,e))}}}});function Qs(e,t,r){let n=e.arguments[0];if(!n||n.type!==M.ArrowFunctionExpression&&n.type!==M.FunctionExpression||!Hs(n))return;let s=null;if(n.body.type===M.JSXElement||n.body.type===M.JSXFragment?s=n.body:n.body.type===M.BlockStatement&&n.body.body[0]?.type===M.ReturnStatement&&n.body.body[0].argument&&(n.body.body[0].argument.type===M.JSXElement||n.body.body[0].argument.type===M.JSXFragment)&&(s=n.body.body[0].argument),!s)return;let a=Nr(s,t);if(!a.hasUnstable)return;let i=Ys(e,n.params),p=n.params.map(y=>y.type===M.Identifier?y.name:"item"),l=Dr(s,p,t),c=s.type===M.JSXElement?Lr(s,t):null,d=a.problematicProps.length===1?`prop "${a.problematicProps[0]}"`:`props "${a.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:d},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:y=>{let g=jr(i,s,n.params,l,t),b=Zs(i,n.params,l,c),f=e;for(;f.parent.type!==M.Program&&!(f.type===M.FunctionDeclaration||f.type===M.VariableDeclarator&&f.init&&(f.init.type===M.ArrowFunctionExpression||f.init.type===M.FunctionExpression));)f=f.parent;let E=[];return E.push(y.insertTextAfter(f,`
|
|
32
32
|
|
|
33
|
-
${g}`)),E.push(y.replaceText(s,b)),E}}]})}function ea(e,t,r){let n=e.arguments[0];if(!n||n.type!==
|
|
33
|
+
${g}`)),E.push(y.replaceText(s,b)),E}}]})}function ea(e,t,r){let n=e.arguments[0];if(!n||n.type!==M.JSXElement&&n.type!==M.JSXFragment)return;let s=n,a=Nr(s,t);if(!a.hasUnstable)return;let i=Gs(s),p=Dr(s,[],t),l=s.type===M.JSXElement?Lr(s,t):null,c=a.problematicProps.length===1?`prop "${a.problematicProps[0]}"`:`props "${a.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:c},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:d=>{let y=jr(i,s,[],p,t),g=Ks(i,p,l),b=e;for(;b.parent.type!==M.Program&&!(b.type===M.FunctionDeclaration||b.type===M.VariableDeclarator&&b.init&&(b.init.type===M.ArrowFunctionExpression||b.init.type===M.FunctionExpression));)b=b.parent;let f=[];return f.push(d.insertTextAfter(b,`
|
|
34
34
|
|
|
35
|
-
${y}`)),f.push(d.replaceText(s,g)),f}}]})}import{ESLintUtils as ta,TSESTree as na}from"@typescript-eslint/utils";var ra=ta.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$r="require-description",ia=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,oa=/^eslint-disable-(next-)?line$/u,sa=ra({name:$r,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let a=aa(s);a!=null&&(n.has(a.kind)||a.description||e.report({loc:ca(s.loc),messageId:"missingDescription"}))}}}}}),_r={name:$r,rule:sa};function aa(e){let{text:t,description:r}=pa(e.value);if(!t)return null;let n=ia.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let a=oa.test(s);if(e.type===na.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+s.length);return{kind:s,value:i.trim(),description:r}}var la=/\s-{2,}\s/u;function pa(e){let t=e.split(la);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ca(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as Q}from"@typescript-eslint/utils";import{z as $e}from"zod/v4";var ua=$e.object({varsToCheck:$e.array($e.object({selector:$e.string().optional(),fromFnCall:$e.string().optional(),prop:$e.string().or($e.array($e.string())),errorMsg:$e.string().optional()}))}),dn=B({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[V(ua)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,p,l,c){let d=new Set;for(let g of i.properties)g.type===Q.Property&&g.key.type===Q.Identifier&&d.add(g.key.name);let y=p.filter(g=>!d.has(g));if(y.length>0)if(y.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:y[0],fnName:c,customMsg:l||""}});else{let g=y.map(b=>`"${b}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:g,fnName:c,customMsg:l||""}})}}function s(i){if(i.init?.type===Q.CallExpression){if(i.init.callee.type===Q.Identifier)return i.init.callee.name;if(i.init.callee.type===Q.MemberExpression&&i.init.callee.property.type===Q.Identifier)return i.init.callee.object.type===Q.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let a={};for(let i of t.varsToCheck)i.selector&&(a[i.selector]=p=>{if(p.type===Q.VariableDeclarator&&p.id.type===Q.Identifier&&r.set(p.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:p.id,fnName:s(p)}),p.type===Q.VariableDeclarator&&p.id.type===Q.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(p.id,l,i.errorMsg,s(p))}});for(let i of t.varsToCheck)if(i.fromFnCall){let p=i.fromFnCall;if(p.startsWith("*.")){let c=`VariableDeclarator > CallExpression > MemberExpression[property.name="${p.slice(2)}"]`;a[c]=d=>{if(d.type!==Q.MemberExpression||d.parent.type!==Q.CallExpression)return;let y=d.parent;if(y.parent.type!==Q.VariableDeclarator)return;let g=y.parent;if(g.id.type===Q.Identifier)r.set(g.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:g.id,fnName:i.fromFnCall||"unknown function"});else if(g.id.type===Q.ObjectPattern){let b=Array.isArray(i.prop)?i.prop:[i.prop];n(g.id,b,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(p.includes(".")){let[l,c]=p.split("."),d=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${c}"]`;a[d]=y=>{if(y.type!==Q.MemberExpression||y.parent.type!==Q.CallExpression)return;let g=y.parent;if(g.parent.type!==Q.VariableDeclarator)return;let b=g.parent;if(b.id.type===Q.Identifier)r.set(b.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:b.id,fnName:i.fromFnCall||"unknown function"});else if(b.id.type===Q.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];n(b.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${p}"]`;a[l]=c=>{if(c.type!==Q.Identifier||c.parent.type!==Q.CallExpression)return;let d=c.parent;if(d.parent.type!==Q.VariableDeclarator)return;let y=d.parent;if(y.id.type===Q.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===Q.ObjectPattern){let g=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,g,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...a,"Program:exit"(){for(let[i,{props:p,errorMsg:l,node:c,fnName:d}]of r){let g=e.sourceCode.getScope(c).set.get(i);if(g){let b=new Set(p);for(let f of g.references){let E=f.identifier,h=E.parent;if(!(h.type===Q.VariableDeclarator&&h.id===E)){if(h.type===Q.MemberExpression&&h.object===E&&h.property.type===Q.Identifier&&b.has(h.property.name)){if(b.delete(h.property.name),b.size===0)break;continue}if(h.type===Q.VariableDeclarator&&h.init===E&&h.id.type===Q.ObjectPattern){for(let m of h.id.properties)m.type===Q.Property&&m.key.type===Q.Identifier&&b.has(m.key.name)&&b.delete(m.key.name);if(b.size===0)break;continue}if(!(h.type===Q.MemberExpression&&h.object===E&&h.property.type===Q.Identifier&&!p.includes(h.property.name))){b.clear();break}}}if(b.size>0){let f=Array.from(b);if(f.length===1)e.report({node:c,messageId:"propNotRead",data:{prop:f[0],fnName:d,customMsg:l||""}});else{let E=f.map(h=>`"${h}"`).join(", ");e.report({node:c,messageId:"propsNotRead",data:{props:E,fnName:d,customMsg:l||""}})}}}}}}}});function Wr(e){return/^use[A-Z0-9]/.test(e)}function yt(e){return e.type==="Identifier"?Wr(e.name):e.type==="MemberExpression"&&!e.computed&&yt(e.property)?e.object.type==="Identifier":!1}function Jr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Vr(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Xr(e){return!!(e.parent&&e.parent.callee&&Vr(e.parent.callee,"forwardRef"))}function Br(e){return!!(e.parent&&e.parent.callee&&Vr(e.parent.callee,"memo"))}function yn(e){for(;e;){let t=Yr(e);if(t&&(Jr(t)||yt(t))||Xr(e)||Br(e))return!0;e=e.parent}return!1}function Ur(e){return!1}function gn(e){return!1}var fa=/eslint +react-compiler\/react-compiler: +\["error/,Hr={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(fa.test(l.value))return{CallExpression(c){let d=null;c.callee.name==="useMemo"?d="useMemo":c.callee.name==="useCallback"&&(d="useCallback"),d&&e.report({node:c,message:`"${d}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,s=[],a=[],i=new WeakSet;function p(l){for(let c of l.references){let d=c.identifier.parent;if(d.type==="VariableDeclarator"&&d.init&&d.init.type==="CallExpression"&&d.init.callee&&Ur(d.init.callee))for(let y of c.resolved.references)y!==c&&i.add(y.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(l,c){let d=s.pop();if(d.size===0)return;let y=new Set;function g(o,S){let{cache:u}=g,T=u.get(o.id),w=new Set(S);if(w.has(o.id)){let R=[...w],v=R.slice(R.indexOf(o.id)+1);for(let x of v)y.add(x);return BigInt("0")}if(w.add(o.id),T!==void 0)return T;if(l.thrownSegments.includes(o))T=BigInt("0");else if(o.prevSegments.length===0)T=BigInt("1");else{T=BigInt("0");for(let R of o.prevSegments)T+=g(R,w)}return o.reachable&&T===BigInt("0")?u.delete(o.id):u.set(o.id,T),T}function b(o,S){let{cache:u}=b,T=u.get(o.id),w=new Set(S);if(w.has(o.id)){let R=Array.from(w),v=R.slice(R.indexOf(o.id)+1);for(let x of v)y.add(x);return BigInt("0")}if(w.add(o.id),T!==void 0)return T;if(l.thrownSegments.includes(o))T=BigInt("0");else if(o.nextSegments.length===0)T=BigInt("1");else{T=BigInt("0");for(let R of o.nextSegments)T+=b(R,w)}return u.set(o.id,T),T}function f(o){let{cache:S}=f,u=S.get(o.id);if(u===null)return 1/0;if(u!==void 0)return u;if(S.set(o.id,null),o.prevSegments.length===0)u=1;else{u=1/0;for(let T of o.prevSegments){let w=f(T);w<u&&(u=w)}u+=1}return S.set(o.id,u),u}g.cache=new Map,b.cache=new Map,f.cache=new Map;let E=b(l.initialSegment),h=Yr(c),m=yn(c),A=h?Jr(h)||yt(h):Xr(c)||Br(c),I=1/0;for(let o of l.finalSegments){if(!o.reachable)continue;let S=f(o);S<I&&(I=S)}for(let[o,S]of d){if(!o.reachable)continue;let u=o.nextSegments.length===0?I<=f(o):I<f(o),T=g(o)*b(o),w=y.has(o.id);for(let R of S)if(w&&!gn(R)&&e.report({node:R,message:`React Hook "${t(R)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(c.async&&e.report({node:R,message:`React Hook "${t(R)}" cannot be called in an async function.`}),!w&&T!==E&&!gn(R)){let x=`React Hook "${t(R)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(u?" Did you accidentally call a React Hook after an early return?":"");e.report({node:R,message:x})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let v=`React Hook "${t(R)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:R,message:v})}else if(h){let v=`React Hook "${t(R)}" is called in function "${t(h)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:R,message:v})}else if(c.type==="Program"){let v=`React Hook "${t(R)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:R,message:v})}else if(m&&!gn(R)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let x=c.parent;if(x.parent.type==="VariableDeclarator"&&Wr(x.parent.id.name))return}let v=`React Hook "${t(R)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:R,message:v})}}},CallExpression(l){if(yt(l.callee)){let c=zr(s),d=zr(a),y=c.get(d);y||(y=[],c.set(d,y)),y.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Ur(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(l){l===n&&(n=null)},FunctionDeclaration(l){yn(l)&&p(r(l))},ArrowFunctionExpression(l){yn(l)&&p(r(l))}}}};function Yr(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function zr(e){return e[e.length-1]}import{AST_NODE_TYPES as de,AST_TOKEN_TYPES as ma}from"@typescript-eslint/utils";import*as Te from"zod/v4";var da=/^\s+$/,Sn=/\r?\n/,ya=/^(\s*)/,ga=/^(\s*)\S/,Sa=/\r?\n/,Ta=Te.object({indent:Te.union([Te.string().regex(da),Te.number().int().min(1)]).optional(),tags:Te.array(Te.string()).optional(),functions:Te.array(Te.string()).optional(),comments:Te.array(Te.string()).optional()}),Tn=B({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[V(Ta)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:a}=e.options[0],i=r.map(m=>m.toLowerCase());function p(m){let A=m.split(Sn),I=A.filter(S=>S.trim()!=="");if(I.length===0)return m;let o=Number.POSITIVE_INFINITY;for(let S of I){let u=S.match(ya);u&&(o=Math.min(o,u[1]?.length??0))}return!isFinite(o)||o===0?m:A.map(S=>S.slice(o)).join(`
|
|
36
|
-
`)}function l(m,A,I){return m.split(
|
|
37
|
-
`)}function c(m){if(m.type===
|
|
35
|
+
${y}`)),f.push(d.replaceText(s,g)),f}}]})}import{ESLintUtils as ta,TSESTree as na}from"@typescript-eslint/utils";var ra=ta.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Mr="require-description",ia=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,oa=/^eslint-disable-(next-)?line$/u,sa=ra({name:Mr,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let a=aa(s);a!=null&&(n.has(a.kind)||a.description||e.report({loc:ca(s.loc),messageId:"missingDescription"}))}}}}}),$r={name:Mr,rule:sa};function aa(e){let{text:t,description:r}=pa(e.value);if(!t)return null;let n=ia.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let a=oa.test(s);if(e.type===na.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+s.length);return{kind:s,value:i.trim(),description:r}}var la=/\s-{2,}\s/u;function pa(e){let t=e.split(la);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ca(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as Q}from"@typescript-eslint/utils";import{z as Me}from"zod/v4";var ua=Me.object({varsToCheck:Me.array(Me.object({selector:Me.string().optional(),fromFnCall:Me.string().optional(),prop:Me.string().or(Me.array(Me.string())),errorMsg:Me.string().optional()}))}),mn=X({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(ua)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,p,l,c){let d=new Set;for(let g of i.properties)g.type===Q.Property&&g.key.type===Q.Identifier&&d.add(g.key.name);let y=p.filter(g=>!d.has(g));if(y.length>0)if(y.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:y[0],fnName:c,customMsg:l||""}});else{let g=y.map(b=>`"${b}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:g,fnName:c,customMsg:l||""}})}}function s(i){if(i.init?.type===Q.CallExpression){if(i.init.callee.type===Q.Identifier)return i.init.callee.name;if(i.init.callee.type===Q.MemberExpression&&i.init.callee.property.type===Q.Identifier)return i.init.callee.object.type===Q.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let a={};for(let i of t.varsToCheck)i.selector&&(a[i.selector]=p=>{if(p.type===Q.VariableDeclarator&&p.id.type===Q.Identifier&&r.set(p.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:p.id,fnName:s(p)}),p.type===Q.VariableDeclarator&&p.id.type===Q.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(p.id,l,i.errorMsg,s(p))}});for(let i of t.varsToCheck)if(i.fromFnCall){let p=i.fromFnCall;if(p.startsWith("*.")){let c=`VariableDeclarator > CallExpression > MemberExpression[property.name="${p.slice(2)}"]`;a[c]=d=>{if(d.type!==Q.MemberExpression||d.parent.type!==Q.CallExpression)return;let y=d.parent;if(y.parent.type!==Q.VariableDeclarator)return;let g=y.parent;if(g.id.type===Q.Identifier)r.set(g.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:g.id,fnName:i.fromFnCall||"unknown function"});else if(g.id.type===Q.ObjectPattern){let b=Array.isArray(i.prop)?i.prop:[i.prop];n(g.id,b,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(p.includes(".")){let[l,c]=p.split("."),d=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${c}"]`;a[d]=y=>{if(y.type!==Q.MemberExpression||y.parent.type!==Q.CallExpression)return;let g=y.parent;if(g.parent.type!==Q.VariableDeclarator)return;let b=g.parent;if(b.id.type===Q.Identifier)r.set(b.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:b.id,fnName:i.fromFnCall||"unknown function"});else if(b.id.type===Q.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];n(b.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${p}"]`;a[l]=c=>{if(c.type!==Q.Identifier||c.parent.type!==Q.CallExpression)return;let d=c.parent;if(d.parent.type!==Q.VariableDeclarator)return;let y=d.parent;if(y.id.type===Q.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===Q.ObjectPattern){let g=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,g,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...a,"Program:exit"(){for(let[i,{props:p,errorMsg:l,node:c,fnName:d}]of r){let g=e.sourceCode.getScope(c).set.get(i);if(g){let b=new Set(p);for(let f of g.references){let E=f.identifier,h=E.parent;if(!(h.type===Q.VariableDeclarator&&h.id===E)){if(h.type===Q.MemberExpression&&h.object===E&&h.property.type===Q.Identifier&&b.has(h.property.name)){if(b.delete(h.property.name),b.size===0)break;continue}if(h.type===Q.VariableDeclarator&&h.init===E&&h.id.type===Q.ObjectPattern){for(let m of h.id.properties)m.type===Q.Property&&m.key.type===Q.Identifier&&b.has(m.key.name)&&b.delete(m.key.name);if(b.size===0)break;continue}if(!(h.type===Q.MemberExpression&&h.object===E&&h.property.type===Q.Identifier&&!p.includes(h.property.name))){b.clear();break}}}if(b.size>0){let f=Array.from(b);if(f.length===1)e.report({node:c,messageId:"propNotRead",data:{prop:f[0],fnName:d,customMsg:l||""}});else{let E=f.map(h=>`"${h}"`).join(", ");e.report({node:c,messageId:"propsNotRead",data:{props:E,fnName:d,customMsg:l||""}})}}}}}}}});function zr(e){return/^use[A-Z0-9]/.test(e)}function yt(e){return e.type==="Identifier"?zr(e.name):e.type==="MemberExpression"&&!e.computed&&yt(e.property)?e.object.type==="Identifier":!1}function Wr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Jr(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Vr(e){return!!(e.parent&&e.parent.callee&&Jr(e.parent.callee,"forwardRef"))}function Xr(e){return!!(e.parent&&e.parent.callee&&Jr(e.parent.callee,"memo"))}function dn(e){for(;e;){let t=Hr(e);if(t&&(Wr(t)||yt(t))||Vr(e)||Xr(e))return!0;e=e.parent}return!1}function _r(e){return!1}function yn(e){return!1}var fa=/eslint +react-compiler\/react-compiler: +\["error/,Br={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(fa.test(l.value))return{CallExpression(c){let d=null;c.callee.name==="useMemo"?d="useMemo":c.callee.name==="useCallback"&&(d="useCallback"),d&&e.report({node:c,message:`"${d}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,s=[],a=[],i=new WeakSet;function p(l){for(let c of l.references){let d=c.identifier.parent;if(d.type==="VariableDeclarator"&&d.init&&d.init.type==="CallExpression"&&d.init.callee&&_r(d.init.callee))for(let y of c.resolved.references)y!==c&&i.add(y.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(l,c){let d=s.pop();if(d.size===0)return;let y=new Set;function g(o,S){let{cache:u}=g,T=u.get(o.id),w=new Set(S);if(w.has(o.id)){let R=[...w],v=R.slice(R.indexOf(o.id)+1);for(let x of v)y.add(x);return BigInt("0")}if(w.add(o.id),T!==void 0)return T;if(l.thrownSegments.includes(o))T=BigInt("0");else if(o.prevSegments.length===0)T=BigInt("1");else{T=BigInt("0");for(let R of o.prevSegments)T+=g(R,w)}return o.reachable&&T===BigInt("0")?u.delete(o.id):u.set(o.id,T),T}function b(o,S){let{cache:u}=b,T=u.get(o.id),w=new Set(S);if(w.has(o.id)){let R=Array.from(w),v=R.slice(R.indexOf(o.id)+1);for(let x of v)y.add(x);return BigInt("0")}if(w.add(o.id),T!==void 0)return T;if(l.thrownSegments.includes(o))T=BigInt("0");else if(o.nextSegments.length===0)T=BigInt("1");else{T=BigInt("0");for(let R of o.nextSegments)T+=b(R,w)}return u.set(o.id,T),T}function f(o){let{cache:S}=f,u=S.get(o.id);if(u===null)return 1/0;if(u!==void 0)return u;if(S.set(o.id,null),o.prevSegments.length===0)u=1;else{u=1/0;for(let T of o.prevSegments){let w=f(T);w<u&&(u=w)}u+=1}return S.set(o.id,u),u}g.cache=new Map,b.cache=new Map,f.cache=new Map;let E=b(l.initialSegment),h=Hr(c),m=dn(c),A=h?Wr(h)||yt(h):Vr(c)||Xr(c),I=1/0;for(let o of l.finalSegments){if(!o.reachable)continue;let S=f(o);S<I&&(I=S)}for(let[o,S]of d){if(!o.reachable)continue;let u=o.nextSegments.length===0?I<=f(o):I<f(o),T=g(o)*b(o),w=y.has(o.id);for(let R of S)if(w&&!yn(R)&&e.report({node:R,message:`React Hook "${t(R)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(c.async&&e.report({node:R,message:`React Hook "${t(R)}" cannot be called in an async function.`}),!w&&T!==E&&!yn(R)){let x=`React Hook "${t(R)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(u?" Did you accidentally call a React Hook after an early return?":"");e.report({node:R,message:x})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let v=`React Hook "${t(R)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:R,message:v})}else if(h){let v=`React Hook "${t(R)}" is called in function "${t(h)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:R,message:v})}else if(c.type==="Program"){let v=`React Hook "${t(R)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:R,message:v})}else if(m&&!yn(R)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let x=c.parent;if(x.parent.type==="VariableDeclarator"&&zr(x.parent.id.name))return}let v=`React Hook "${t(R)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:R,message:v})}}},CallExpression(l){if(yt(l.callee)){let c=Ur(s),d=Ur(a),y=c.get(d);y||(y=[],c.set(d,y)),y.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||_r(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(l){l===n&&(n=null)},FunctionDeclaration(l){dn(l)&&p(r(l))},ArrowFunctionExpression(l){dn(l)&&p(r(l))}}}};function Hr(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 Ur(e){return e[e.length-1]}import{AST_NODE_TYPES as ge,AST_TOKEN_TYPES as ma}from"@typescript-eslint/utils";import*as Ee from"zod/v4";var da=/^\s+$/,gn=/\r?\n/,ya=/^(\s*)/,ga=/^(\s*)\S/,Sa=/\r?\n/,Ta=Ee.object({indent:Ee.union([Ee.string().regex(da),Ee.number().int().min(1)]).optional(),tags:Ee.array(Ee.string()).optional(),functions:Ee.array(Ee.string()).optional(),comments:Ee.array(Ee.string()).optional()}),Sn=X({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[J(Ta)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:a}=e.options[0],i=r.map(m=>m.toLowerCase());function p(m){let A=m.split(gn),I=A.filter(S=>S.trim()!=="");if(I.length===0)return m;let o=Number.POSITIVE_INFINITY;for(let S of I){let u=S.match(ya);u&&(o=Math.min(o,u[1]?.length??0))}return!isFinite(o)||o===0?m:A.map(S=>S.slice(o)).join(`
|
|
36
|
+
`)}function l(m,A,I){return m.split(gn).map(S=>S.trim()===""?S:I.repeat(A)+S).join(`
|
|
37
|
+
`)}function c(m){if(m.type===ge.Identifier)return m.name;if(m.type===ge.MemberExpression){let A=m.object.type===ge.Identifier?m.object.name:null,I=m.property.type===ge.Identifier?m.property.name:null;return A&&I?`${A}.${I}`:I}return null}function d(m,A){if(!m)return!1;for(let I of A)if(I.includes(".")){let o=I.split(".");if(m.type===ge.MemberExpression&&m.object.type===ge.Identifier&&m.property.type===ge.Identifier&&m.object.name===o[0]&&m.property.name===o[1])return!0}else if(m.type===ge.Identifier&&m.name===I)return!0;return!1}function y(m,A){let I=m.parent;if(I.type!==ge.TaggedTemplateExpression)return!1;let o=c(I.tag);return o?A.includes(o):!1}function g(m,A){if(!m||m.type!==ge.CallExpression)return!1;let{method:I,argumentsLength:o,optionalCall:S=!0,optionalMember:u=!0}=A;return o!==void 0&&m.arguments.length!==o||!S&&m.optional||m.callee.type!==ge.MemberExpression||!u&&m.callee.optional||m.callee.property.type!==ge.Identifier?!1:m.callee.property.name===I}function b(m,A){if(!m||m.type!==ge.CallExpression)return!1;let{name:I,argumentsLength:o,optionalCall:S=!0}=A;return o!==void 0&&m.arguments.length!==o||!S&&m.optional||m.callee.type!==ge.Identifier?!1:m.callee.name===I}function f(m){return g(m.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&m.parent.type===ge.CallExpression&&m.parent.arguments[0]===m&&b(m.parent.callee.type===ge.MemberExpression?m.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function E(m){if(i.length>0){let A=t.getTokenBefore(m,{includeComments:!0});if(A?.type===ma.Block&&i.includes(A.value.trim().toLowerCase()))return!0}return!!(f(m)||s.length>0&&y(m,s)||n.length>0&&m.parent.type===ge.CallExpression&&m.parent.arguments.includes(m)&&d(m.parent.callee,n))}function h(m){let A=`__PLACEHOLDER__${Math.random()}`,I=m.quasis.map(z=>t.getText(z).slice(1,z.tail?-1:-2)).join(A),o=I.match(Sa);if(!o)return;let S=o[0],u=t.lines[t.getLocFromIndex(m.range[0]).line-1];if(!u)return;let w=u.match(ga)?.[1]??"",R;typeof a=="string"?R=a:typeof a=="number"?R=" ".repeat(a):R=w.startsWith(" ")?" ":" ";let x=p(I).replace(new RegExp(`^${S}|${S}[ ]*$`,"g"),""),C=S+l(x,1,w+R)+S+w,F=I.includes(`\r
|
|
38
38
|
`)?`\r
|
|
39
39
|
`:`
|
|
40
|
-
`,O=I.split(
|
|
40
|
+
`,O=I.split(gn),G=O.map((z,te)=>te!==O.length-1&&z===R+w?"":z).join(F);if(C!==G)return{node:m,messageId:"improperlyIndented",fix:z=>C.split(A).map((te,ie)=>{let D=m.quasis[ie];return D?z.replaceTextRange([D.range[0]+1,D.range[1]-(D.tail?1:2)],te):[]}).flat()}}return{TemplateLiteral(m){if(!E(m))return;let A=h(m);if(A)return e.report(A)}}}});import{AST_NODE_TYPES as Yr}from"@typescript-eslint/utils";function ha(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function Ea(e){let t=e.parent;return t?.type===Yr.NewExpression&&t.callee.type===Yr.Identifier&&t.callee.name==="RegExp"}var Tn=X({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function t(r){ha(r)||Ea(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});import{AST_NODE_TYPES as Se}from"@typescript-eslint/utils";import{z as it}from"zod/v4";var ba=it.object({checkOnly:it.array(it.enum(["function-args","FC","generic-args-at-fn-calls"])).optional(),checkTypesFromSelectors:it.array(it.string()).optional()}),hn=X({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(ba)],messages:{moveTypeAboveUsage:"Type definition should be placed directly above its first usage."}},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=new Map,s=[];function a(f){for(let E of s)if(f.range[0]>=E.range[0]&&f.range[1]<=E.range[1])return E;return null}function i(f){let E=f.parent;for(;E;){if(E.type===Se.FunctionDeclaration||E.type===Se.FunctionExpression||E.type===Se.ArrowFunctionExpression){let h=E.params;for(let m of h)if(f.range[0]>=m.range[0]&&f.range[1]<=m.range[1])return!0;break}E=E.parent}return!1}function p(f){let E=f.parent;for(;E;){if(E.type===Se.TSTypeParameterInstantiation){let h=E.parent;if(h.type===Se.TSTypeReference&&h.typeName.type===Se.Identifier&&(h.typeName.name==="FC"||h.typeName.name==="React.FC")||h.type===Se.TSTypeReference&&h.typeName.type===Se.TSQualifiedName&&h.typeName.right.name==="FC")return!0}E=E.parent}return!1}function l(f){let E=f.parent;for(;E;){if(E.type===Se.TSTypeParameterInstantiation){let h=E.parent;if(h.type===Se.CallExpression||h.type===Se.NewExpression)return!0}E=E.parent}return!1}function c(f){let E=f.parent;for(;E;){if(E.type===Se.TSTypeAliasDeclaration||E.type===Se.TSInterfaceDeclaration)return!0;E=E.parent}return!1}function d(f){return f.parent.type===Se.TSIndexedAccessType&&f.parent.objectType===f}let y=[];function g(f){let E=[],h=new Map;for(let{typeName:A,firstUsage:I}of f){let o=h.get(I)||[];o.push(A),h.set(I,o)}for(let{typeName:A,firstUsage:I,firstUsagePosition:o,firstUsageInFunctionArgs:S}of f){let u=n.get(A);if(!u||u.statement===I)continue;let T=s.indexOf(u.statement),w=s.indexOf(I);if(T===-1||w===-1)continue;let R=!!(t.checkOnly&&t.checkOnly.includes("function-args")&&S),x=(h.get(I)||[]).length>1;(R||x?T>w:T>w||T!==w-1)&&E.push({typeName:A,typeDef:u,targetStatement:I,firstUsagePosition:o})}if(E.length===0)return;E.sort((A,I)=>{let o=A.firstUsagePosition-I.firstUsagePosition;if(o!==0)return o;let S=s.indexOf(A.typeDef.statement),u=s.indexOf(I.typeDef.statement);return S-u});let m=E[0];m&&e.report({node:m.typeDef.node,messageId:"moveTypeAboveUsage",fix:b(E)})}function b(f){return function*(E){let h=new Map;for(let m of f){let A=h.get(m.targetStatement)||[];A.push(m),h.set(m.targetStatement,A)}for(let[,m]of h)m.sort((A,I)=>{let o=A.firstUsagePosition-I.firstUsagePosition;if(o!==0)return o;let S=s.indexOf(A.typeDef.statement),u=s.indexOf(I.typeDef.statement);return S-u});for(let m of f){let{typeDef:A}=m,I=A.statement,o=r.getCommentsBefore(I),S=I.range[0],u=I.range[1];o.length>0&&o[0]&&(S=o[0].range[0]),yield E.removeRange([S,u])}for(let[m,A]of h){let I=r.getCommentsBefore(m),o=I.length>0&&I[0]?I[0].range[0]:m.range[0],S=[];for(let u of A){let T=u.typeDef.statement,w=r.getText(T),R=r.getCommentsBefore(T),v=w;R.length>0&&(v=`${R.map(C=>r.getText(C)).join(`
|
|
41
41
|
`)}
|
|
42
42
|
${w}`),S.push(v)}yield E.insertTextBeforeRange([o,o],`${S.join(`
|
|
43
43
|
|
|
44
44
|
`)}
|
|
45
45
|
|
|
46
|
-
`)}}}return{Program(f){s.push(...f.body)},TSTypeAliasDeclaration(f){if(s.some(h=>h.type===ye.ExportNamedDeclaration&&h.declaration===f?!0:h===f)){let h=a(f);h&&n.set(f.id.name,{node:f,name:f.id.name,statement:h})}},TSInterfaceDeclaration(f){if(s.some(h=>h.type===ye.ExportNamedDeclaration&&h.declaration===f?!0:h===f)){let h=a(f);h&&n.set(f.id.name,{node:f,name:f.id.name,statement:h})}},TSTypeReference(f){if(f.typeName.type===ye.Identifier){if(d(f))return;let E=i(f),h=p(f),m=l(f);y.push({typeName:f.typeName.name,node:f,inFunctionArgs:E,inFCProps:h,inGenericArgAtFunctionCall:m,usagePosition:f.range[0]})}},"Program:exit"(){let f=new Map;function E(m){if(!t.checkOnly||t.checkOnly.length===0)return!0;for(let A of t.checkOnly)if(A==="function-args"&&m.inFunctionArgs||A==="FC"&&m.inFCProps||A==="generic-args-at-fn-calls"&&m.inGenericArgAtFunctionCall)return!0;return!1}for(let m of y){let{typeName:A,node:I}=m;if(!n.has(A)||!E(m))continue;let o=a(I),S=n.get(A);if(!o||!S||o===S.statement)continue;f.has(A)||f.set(A,[]);let u=f.get(A);if(!u)return;u.includes(o)||u.push(o)}let h=[];for(let[m,A]of f)if(A.length>0){if(A.length===0)continue;let I=A[0];if(!I)continue;let o=Number.MAX_SAFE_INTEGER,S=!1;for(let T of A)T.range[0]<I.range[0]&&(I=T);for(let T of y)E(T)&&T.typeName===m&&a(T.node)===I&&T.usagePosition<o&&(o=T.usagePosition,S=T.inFunctionArgs);if(!!(t.checkOnly&&t.checkOnly.length>0)){let T=Number.MAX_SAFE_INTEGER;for(let R of y){if(R.typeName!==m)continue;let v=a(R.node);if(!v)continue;let x=s.indexOf(v);x!==-1&&x<T&&(T=x)}let w=s.indexOf(I);if(T!==Number.MAX_SAFE_INTEGER&&w!==-1&&T<w)continue}else{let T=Number.MAX_SAFE_INTEGER;for(let R of y){if(R.typeName!==m||c(R.node))continue;let v=a(R.node);if(!v)continue;let x=s.indexOf(v);x!==-1&&x<T&&(T=x)}let w=s.indexOf(I);if(T!==Number.MAX_SAFE_INTEGER&&w!==-1&&T<w)continue}h.push({typeName:m,firstUsage:I,firstUsagePosition:o,firstUsageInFunctionArgs:S})}h.length>0&&g(h)}}}});import{AST_NODE_TYPES as ee}from"@typescript-eslint/utils";import*as Ye from"zod/v4";var xa=["tsx"],Ca=/^[A-Z][A-Za-z0-9]*$/,Ia=Ye.object({extensions:Ye.array(Ye.string()).optional()}),bn=B({name:"react-single-export",meta:{type:"problem",docs:{description:"Enforces only one export per React component file to support fast refresh"},messages:{multipleExports:"React component files should have only one export to support fast refresh, if you want to export multiple components, use a separate file for each component. Type-only exports are allowed."},schema:[V(Ia)]},defaultOptions:[{}],create(e,[t]){let r=e.getFilename(),n=t.extensions??xa,s=!1;for(let o of n)if(r.endsWith(o)){s=!0;break}if(!s)return{};let a=e.sourceCode,i=new Set,p=new Map;function l(o){return Ca.test(o)}function c(o){if(o.type!==ee.CallExpression)return!1;let S=o.callee;return S.type===ee.Identifier?S.name==="memo"||S.name==="forwardRef":S.type===ee.MemberExpression&&S.property.type===ee.Identifier?S.property.name==="memo"||S.property.name==="forwardRef":!1}function d(o){if(o.type===ee.JSXElement||o.type===ee.JSXFragment)return!0;if(o.type===ee.ArrayExpression){for(let S of o.elements)if(S&&(S.type===ee.JSXElement||S.type===ee.JSXFragment))return!0}return!1}function y(o){if(o.type!==ee.ArrowFunctionExpression)return!1;let S=o.body;if(S.type===ee.ArrowFunctionExpression){let u=S.body;if(d(u))return!0}return!1}function g(o){if(o.id.type!==ee.Identifier)return;let S=o.id.name,u=o.init;if(u){if(l(S)&&(u.type===ee.ArrowFunctionExpression||u.type===ee.FunctionExpression||c(u))){i.add(S);return}u.type===ee.Identifier&&p.set(S,u.name),l(S)||y(u)&&i.add(S)}}function b(o){if(o.type===ee.VariableDeclaration){for(let S of o.declarations)g(S);return}if(o.type===ee.FunctionDeclaration&&o.id){l(o.id.name)&&i.add(o.id.name);return}if(o.type===ee.ExportNamedDeclaration&&o.declaration){let S=o.declaration;if(S.type===ee.VariableDeclaration){for(let u of S.declarations)g(u);return}if(S.type===ee.FunctionDeclaration&&S.id){l(S.id.name)&&i.add(S.id.name);return}}}for(let o of a.ast.body)b(o);function f(o,S=new Set){if(i.has(o))return!0;if(S.has(o))return!1;S.add(o);let u=p.get(o);return u?f(u,S):!1}let E=[];function h(o,S,u){E.push({node:o,isType:S,isComponent:u})}for(let o of a.ast.body){if(o.type===ee.ExportNamedDeclaration){let S=o.exportKind==="type";if(o.declaration){let u=o.declaration;if(u.type===ee.TSTypeAliasDeclaration||u.type===ee.TSInterfaceDeclaration){h(u,!0,!1);continue}if(u.type===ee.VariableDeclaration){for(let T of u.declarations){if(T.id.type!==ee.Identifier)continue;let w=T.id.name,R=f(w);h(T,S,R)}continue}if(u.type===ee.FunctionDeclaration){let T=u.id?.name,w=T?f(T)||l(T):!1;h(u,S,w);continue}h(u,S,!1);continue}if(o.specifiers.length>0)for(let u of o.specifiers){if(u.local.type!==ee.Identifier)continue;let T=u.local.name,w=f(T);h(u,S,w)}continue}if(o.type===ee.ExportDefaultDeclaration){let S=o.declaration;if(S.type===ee.Identifier){let u=f(S.name)||l(S.name);h(o,!1,u);continue}if(S.type===ee.FunctionDeclaration||S.type===ee.ArrowFunctionExpression||S.type===ee.FunctionExpression||S.type===ee.CallExpression){h(o,!1,!0);continue}h(o,!1,!1);continue}}let m=!1;for(let o of E)if(!o.isType&&o.isComponent){m=!0;break}if(!m)return{};let A=[];for(let o of E)o.isType||A.push(o);let I=-1;for(let[o,S]of A.entries())if(S.isComponent){I=o;break}if(I===-1)return{};for(let[o,S]of A.entries())if(o!==I){e.report({node:S.node,messageId:"multipleExports"});break}return{}}});import{AST_NODE_TYPES as ze}from"@typescript-eslint/utils";import{z as xn}from"zod/v4";function gt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Aa(e){return e.callee.type===ze.Identifier?e.callee.name==="useState":e.callee.type===ze.MemberExpression&&e.callee.object.type===ze.Identifier&&e.callee.property.type===ze.Identifier?e.callee.object.name==="React"&&e.callee.property.name==="useState":!1}var wa=xn.object({ignorePrefixes:xn.array(xn.string()).optional()});function Zr(e,t){for(let r of t)if(e.startsWith(r))return e.slice(r.length);return e}function Ra(e){return`set${gt(e)}`}var Cn=B({name:"use-state-setter-naming",meta:{type:"problem",docs:{description:"Enforce consistent naming convention for useState destructuring where setter should be set{Value}"},messages:{incorrectSetterName:'useState setter should follow the pattern "set{{expectedName}}" with a "set" prefix but got "{{actualName}}"',useSuggestedName:'Use "{{expectedSetterName}}" instead'},hasSuggestions:!0,schema:[V(wa)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[t]){return{VariableDeclarator(r){if(!r.init||r.init.type!==ze.CallExpression||!Aa(r.init)||r.id.type!==ze.ArrayPattern||r.id.elements.length!==2)return;let[n,s]=r.id.elements;if(!n||!s||n.type!==ze.Identifier||s.type!==ze.Identifier)return;let a=n.name,i=s.name,p=t.ignorePrefixes||[],l=Zr(a,p),c=Zr(i,p);if(l===""){if(!c.startsWith("set")){let y=`set${gt(a)}`;e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(a),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:y},fix:g=>g.replaceText(s,y)}]})}return}let d=Ra(l);c!==d&&e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(l),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:d},fix:y=>y.replaceText(s,d)}]})}}}});import{AST_NODE_TYPES as me}from"@typescript-eslint/utils";import{z as qe}from"zod/v4";var Pa=qe.object({name:qe.string(),defaults:qe.array(qe.unknown())}),va=qe.object({functions:qe.array(Pa)});function St(e,t){if(e===t)return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object"||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>St(s,t[a]));let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s of r){if(!n.includes(s))return!1;let a=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(t,s);if(!a||!i)return!1;let p=a.value,l=i.value;if(!St(p,l))return!1}return!0}function Fa(e,t){let r=new Set;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return r;for(let n in e){if(!(n in t))continue;let s=Object.getOwnPropertyDescriptor(e,n),a=Object.getOwnPropertyDescriptor(t,n);s&&a&&St(s.value,a.value)&&r.add(n)}return r}function Gr(e){if(e.type===me.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case me.Literal:return e.value;case me.ObjectExpression:{let t={};for(let r of e.properties)r.type===me.Property&&r.key.type===me.Identifier&&!r.computed&&(r.value.type===me.Literal?t[r.key.name]=r.value.value:r.value.type===me.ObjectExpression?t[r.key.name]=Gr(r.value):t[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return t}case me.ArrayExpression:return e.elements.map(t=>{if(!(!t||t.type===me.SpreadElement))return t.type===me.Literal?t.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function ka(e){return e.type===me.Identifier?e.name:e.type===me.MemberExpression&&e.property.type===me.Identifier&&!e.computed?e.property.name:null}var In=B({name:"no-redundant-function-params",meta:{type:"suggestion",docs:{description:"Disallow calling functions with redundant default parameters"},messages:{redundantParams:"Function call has redundant parameters matching its default values and can be removed: {{details}}"},fixable:"code",schema:[V(va)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map;for(let n of t.functions)r.set(n.name,n.defaults);return{CallExpression(n){let s=ka(n.callee);if(!s)return;let a=r.get(s);if(!a)return;let i=n.arguments;if(i.length===0)return;let p=-1,l=!1,c=new Map,d=new Set,y=new Map,g=[];for(let f=0;f<i.length;f++){if(f>=a.length){p=f;continue}let E=a[f],h=i[f];if(!h||h.type===me.SpreadElement){p=f;continue}let m=Gr(h);if(E===void 0){p=f;continue}if(St(m,E)){h.type===me.ObjectExpression?(d.add(f),g.push({type:"object",position:f+1})):(y.set(f,m),g.push({type:"simple",position:f+1,value:m}));continue}if(h.type===me.ObjectExpression&&h.properties.length===0&&typeof E=="object"&&E!==null&&Object.keys(E).length>0){d.add(f),g.push({type:"object",position:f+1});continue}let A=Fa(m,E);if(A.size>0){let I=typeof E=="object"&&E!==null?Object.keys(E).length:0;if(h.type===me.ObjectExpression&&h.properties.length===A.size&&h.properties.length===I){d.add(f),g.push({type:"object",position:f+1});continue}else l=!0,c.set(f,A),g.push({type:"partialObject",position:f+1,redundantProperties:Array.from(A)}),p=f}else p=f}if(p<i.length-1||l||d.size>0){let f=function(){let h=[];for(let m of g)if(m.type==="simple")h.push(`Param ${m.position} with value ${JSON.stringify(m.value)}`);else if(m.type==="object")h.push(`Param ${m.position} (object)`);else{let A=m.redundantProperties||[],I=a?a[m.position-1]:void 0;if(typeof I=="object"&&I!==null){let o=I;for(let S of A)if(S in o){let u=Object.getOwnPropertyDescriptor(o,S);u&&h.push(`Param ${m.position} property "${S}" with value ${JSON.stringify(u.value)}`)}}}return{messageId:"redundantParams",data:{details:h.join(", ")}}};var b=f;let E=f();e.report({node:n,messageId:E.messageId,data:E.data,fix(h){let m=[];if(l)for(let[I,o]of c){let S=i[I];if(S&&S.type===me.ObjectExpression){let u=[];for(let w of S.properties)w.type===me.Property&&w.key.type===me.Identifier&&!w.computed&&o.has(w.key.name)||u.push(w);let T=u.map(w=>e.sourceCode.getText(w));m.push(h.replaceText(S,`{ ${T.join(", ")} }`))}}let A=-1;for(let I=i.length-1;I>=0;I--)if(!d.has(I)&&I<=p){A=I;break}if(A<i.length-1)if(A===-1){let I=e.sourceCode.getTokenAfter(n.callee),o=e.sourceCode.getLastToken(n);I&&o&&m.push(h.replaceTextRange([I.range[1],o.range[0]],""))}else{let I=i[A],o=e.sourceCode.getLastToken(n);o&&I&&m.push(h.replaceTextRange([I.range[1],o.range[0]],""))}return m.length>0?m:null}})}}}}});import{AST_NODE_TYPES as Pe}from"@typescript-eslint/utils";function Oa(e){let t=e.parent;for(;t;){if(t.type===Pe.AwaitExpression||t.type===Pe.MemberExpression&&t.object===e&&t.property.type===Pe.Identifier&&t.property.name==="then"||t.type===Pe.ArrowFunctionExpression&&t.body===e)return!0;if(t.type===Pe.ArrayExpression&&t.parent.type===Pe.CallExpression){let r=t.parent;if(r.callee.type===Pe.MemberExpression&&r.callee.object.type===Pe.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===Pe.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(t.parent)t=t.parent;else break}return!1}function Na(e){let{callee:t}=e;return t.type===Pe.Identifier&&t.name==="require"||t.type===Pe.MemberExpression&&t.object.type===Pe.Identifier&&t.object.name==="require"}var An=B({name:"no-sync-dynamic-import",meta:{type:"problem",docs:{description:"Disallow synchronous dynamic imports and require statements, only allow async dynamic imports with await"},messages:{syncDynamicImport:"Synchronous dynamic import() is not allowed. Use regular import statement or await import() for dynamic imports.",requireNotAllowed:"require() statements are not allowed. Use ES6 import statements instead."},schema:[]},defaultOptions:[],create(e){return{ImportExpression(t){Oa(t)||e.report({node:t,messageId:"syncDynamicImport"})},TSImportType(t){e.report({node:t,messageId:"syncDynamicImport"})},CallExpression(t){Na(t)&&e.report({node:t,messageId:"requireNotAllowed"})}}}});import{AST_NODE_TYPES as N}from"@typescript-eslint/utils";import{z as wn}from"zod/v4";var Da=wn.object({mainComponentRegex:wn.string().optional(),mainComponentSelector:wn.string().optional()}),ja=/^[A-Z][A-Za-z0-9]*$/,Rn=B({name:"sort-react-components-and-styles",meta:{type:"suggestion",docs:{description:"Sort React components and styles with styles placed above their first usage"},fixable:"code",schema:[V(Da)],messages:{stylesShouldBeAboveUsage:"Style definitions should be placed above the first component that uses them",mainComponentShouldBeFirst:"Main component should be placed before other components"}},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.mainComponentRegex?new RegExp(t.mainComponentRegex):void 0,s=t.mainComponentSelector,a=new Set,i=new Map,p=[],l=[],c=new Set;function d(x){let C=x.node;if(C.type===N.VariableDeclaration){for(let F of C.declarations)if(F.id.type===N.Identifier&&F.id.name===x.name&&F.init)return F.init}if(C.type===N.ExportNamedDeclaration){let F=C.declaration;if(F&&F.type===N.VariableDeclaration){for(let O of F.declarations)if(O.id.type===N.Identifier&&O.id.name===x.name&&O.init)return O.init}}return null}function y(x){let C=new Set;return Fe(x,F=>(F.type===N.Identifier&&F.name!=="styled"&&F.name!=="css"&&C.add(F.name),!1),r),C}function g(x){return ja.test(x)}function b(x){if(x.type!==N.CallExpression)return!1;let C=x.callee;return C.type===N.Identifier?C.name==="memo"||C.name==="forwardRef":C.type===N.MemberExpression&&C.property.type===N.Identifier?C.property.name==="memo"||C.property.name==="forwardRef":!1}function f(x){if(x.type===N.JSXElement||x.type===N.JSXFragment)return!0;if(x.type===N.BlockStatement){for(let C of x.body)if(C.type===N.ReturnStatement&&C.argument)return f(C.argument)}if(x.type===N.ArrayExpression){for(let C of x.elements)if(C&&(C.type===N.JSXElement||C.type===N.JSXFragment))return!0}return!1}function E(x){if(x.type!==N.ArrowFunctionExpression)return!1;let C=x.body;if(C.type===N.ArrowFunctionExpression){let F=C.body;if(f(F))return!0}return!1}function h(x){if(x.type===N.TaggedTemplateExpression){let C=x.tag;if(C.type===N.MemberExpression&&C.object.type===N.Identifier&&C.object.name==="styled")return!0;if(C.type===N.CallExpression){let F=C.callee;if(F.type===N.Identifier&&F.name==="styled")return!0}}return!1}function m(x){if(x.type===N.TaggedTemplateExpression){let C=x.tag;if(C.type===N.Identifier&&C.name==="css")return!0}return!1}function A(x,C){if(x.id.type!==N.Identifier)return;let F=x.id.name,O=x.init;if(O){if(h(O)||m(O)){l.push({node:C,name:F});return}if((g(F)||O.type===N.ArrowFunctionExpression)&&(O.type===N.ArrowFunctionExpression||O.type===N.FunctionExpression||b(O))){if(O.type===N.ArrowFunctionExpression||O.type===N.FunctionExpression){if(f(O.body)){a.add(F);return}}else if(b(O)){a.add(F);return}}O.type===N.Identifier&&i.set(F,O.name),g(F)||E(O)&&a.add(F)}}function I(x){return x.type===N.ExportDefaultDeclaration||x.type===N.ExportNamedDeclaration}function o(x){if(x.type===N.FunctionDeclaration)return x.id?x.id.name:null;if(x.type===N.VariableDeclaration){let C=x.declarations[0];if(C&&C.id.type===N.Identifier)return C.id.name}if(x.type===N.ExportDefaultDeclaration){let C=x.declaration;if(C.type===N.FunctionDeclaration)return C.id?C.id.name:"default";if(C.type===N.Identifier)return C.name}if(x.type===N.ExportNamedDeclaration){let C=x.declaration;if(C&&C.type===N.FunctionDeclaration)return C.id?C.id.name:null;if(C&&C.type===N.VariableDeclaration){let F=C.declarations[0];if(F&&F.id.type===N.Identifier)return F.id.name}}return null}function S(x,C){return s?c.has(x):n?n.test(C):I(x)}function u(x){let C=new Set;Fe(x.node,F=>{if(F.type===N.Identifier)for(let O of l)O.name===F.name&&(C.add(O.name),(O.firstUsagePosition===void 0||F.range[0]<O.firstUsagePosition)&&(O.firstUsagePosition=F.range[0]));if(F.type===N.JSXElement){let O=F.openingElement;if(O.name.type===N.JSXIdentifier)for(let G of l)G.name===O.name.name&&(C.add(G.name),(G.firstUsagePosition===void 0||O.name.range[0]<G.firstUsagePosition)&&(G.firstUsagePosition=O.name.range[0]))}return!1},r),x.usedStyles=C}function T(x){if(x.type===N.VariableDeclaration){for(let C of x.declarations)A(C,x);return}if(x.type===N.FunctionDeclaration){g(x.id.name)&&f(x.body)&&a.add(x.id.name);return}if(x.type===N.ExportNamedDeclaration&&x.declaration){let C=x.declaration;if(C.type===N.VariableDeclaration){for(let F of C.declarations)A(F,x);return}if(C.type===N.FunctionDeclaration&&C.id){g(C.id.name)&&f(C.body)&&a.add(C.id.name);return}}if(x.type===N.ExportDefaultDeclaration){let C=x.declaration;C.type===N.Identifier&&a.add(C.name),(C.type===N.FunctionDeclaration||C.type===N.ArrowFunctionExpression||C.type===N.FunctionExpression)&&(C.type===N.FunctionDeclaration?C.id?a.add(C.id.name):a.add("default"):f(C.body)&&a.add("default"))}}function w(x,C=new Set){if(a.has(x))return!0;if(C.has(x))return!1;C.add(x);let F=i.get(x);return F?w(F,C):!1}let R={};return s&&(R[s]=x=>{let C=x;for(;C.parent&&C.parent.type!==N.Program;)C=C.parent;C.parent&&(C.type===N.VariableDeclaration||C.type===N.FunctionDeclaration||C.type===N.ExportNamedDeclaration||C.type===N.ExportDefaultDeclaration)&&c.add(C)}),R["Program:exit"]=x=>{for(let M of x.body)T(M);for(let M of x.body){let W=o(M);if(W&&w(W)){let X=S(M,W);p.push({node:M,name:W,isMainComponent:X,usedStyles:new Set})}}for(let M of p)u(M);let C=new Set;for(let M of l)C.add(M.name);let F=new Map;for(let M=0;M<x.body.length;M+=1){let W=x.body[M];for(let X of l)X.node===W&&F.set(X.name,M)}let O=new Map;for(let M of l){let W=d(M),X=new Set;if(W){let ne=y(W);for(let le of ne)C.has(le)&&le!==M.name&&X.add(le)}O.set(M.name,X)}let G=new Map;for(let M of l){let W=O.get(M.name);if(!W)continue;let X=F.get(M.name);if(X!==void 0)for(let ne of W){let le=G.get(ne);(le===void 0||X<le)&&G.set(ne,X)}}let _=[];for(let M of l){if(M.firstUsagePosition===void 0)continue;let W=x.body.indexOf(M.node),X=-1;for(let Ce of p){if(!Ce.usedStyles.has(M.name))continue;let Ie=x.body.indexOf(Ce.node);(X===-1||Ie<X)&&(X=Ie)}let ne=G.get(M.name);if(ne!==void 0&&(X===-1||ne<X)&&(X=ne),X===-1)continue;let le=-1;for(let Ce of p){let Ie=x.body.indexOf(Ce.node);Ie<X&&Ie>le&&(le=Ie)}let Ee=W<X,be=W>le,xe=-1,Se=O.get(M.name);if(Se)for(let Ce of Se){let Ie=F.get(Ce);Ie!==void 0&&Ie>xe&&(xe=Ie)}let it=W>xe;if(!(Ee&&be&&it)){let Ce=le+1;if(xe+1>Ce&&(Ce=xe+1),Ce>X)continue;_.push({style:M,targetPosition:Ce})}}let te=null;if(p.length>1){let M=p.map(X=>({c:X,idx:x.body.indexOf(X.node)})).sort((X,ne)=>X.idx-ne.idx)[0]?.c,W=p.find(X=>X.isMainComponent)||null;M&&W&&M.node!==W.node&&(te={component:W,targetBefore:M.node})}if(_.length>0||te){let M=_[0]?.style.node||te?.component.node||x,W=_.length>0?"stylesShouldBeAboveUsage":"mainComponentShouldBeFirst";e.report({node:M,messageId:W,fix:v(_,te,x.body)})}},R;function v(x,C,F){return function*(O){x.sort((_,te)=>_.targetPosition-te.targetPosition);for(let{style:_}of x){let te=r.getCommentsBefore(_.node),M=_.node.range[0],W=_.node.range[1];te.length>0&&te[0]&&(M=te[0].range[0]),M===_.node.range[0]&&r.text.slice(0,M).trim().length===0&&(M=0),yield O.removeRange([M,W])}let G=new Map;for(let _ of x){let te=G.get(_.targetPosition)||[];te.push(_),G.set(_.targetPosition,te)}for(let[_,te]of G){let M=F[_];if(!M)continue;let W=r.getCommentsBefore(M),X=W.length>0&&W[0]?W[0].range[0]:M.range[0],ne=[];for(let{style:le}of te){let Ee=r.getCommentsBefore(le.node),be=r.getText(le.node);Ee.length>0&&(be=`${Ee.map(Se=>r.getText(Se)).join(`
|
|
46
|
+
`)}}}return{Program(f){s.push(...f.body)},TSTypeAliasDeclaration(f){if(s.some(h=>h.type===Se.ExportNamedDeclaration&&h.declaration===f?!0:h===f)){let h=a(f);h&&n.set(f.id.name,{node:f,name:f.id.name,statement:h})}},TSInterfaceDeclaration(f){if(s.some(h=>h.type===Se.ExportNamedDeclaration&&h.declaration===f?!0:h===f)){let h=a(f);h&&n.set(f.id.name,{node:f,name:f.id.name,statement:h})}},TSTypeReference(f){if(f.typeName.type===Se.Identifier){if(d(f))return;let E=i(f),h=p(f),m=l(f);y.push({typeName:f.typeName.name,node:f,inFunctionArgs:E,inFCProps:h,inGenericArgAtFunctionCall:m,usagePosition:f.range[0]})}},"Program:exit"(){let f=new Map;function E(m){if(!t.checkOnly||t.checkOnly.length===0)return!0;for(let A of t.checkOnly)if(A==="function-args"&&m.inFunctionArgs||A==="FC"&&m.inFCProps||A==="generic-args-at-fn-calls"&&m.inGenericArgAtFunctionCall)return!0;return!1}for(let m of y){let{typeName:A,node:I}=m;if(!n.has(A)||!E(m))continue;let o=a(I),S=n.get(A);if(!o||!S||o===S.statement)continue;f.has(A)||f.set(A,[]);let u=f.get(A);if(!u)return;u.includes(o)||u.push(o)}let h=[];for(let[m,A]of f)if(A.length>0){if(A.length===0)continue;let I=A[0];if(!I)continue;let o=Number.MAX_SAFE_INTEGER,S=!1;for(let T of A)T.range[0]<I.range[0]&&(I=T);for(let T of y)E(T)&&T.typeName===m&&a(T.node)===I&&T.usagePosition<o&&(o=T.usagePosition,S=T.inFunctionArgs);if(!!(t.checkOnly&&t.checkOnly.length>0)){let T=Number.MAX_SAFE_INTEGER;for(let R of y){if(R.typeName!==m)continue;let v=a(R.node);if(!v)continue;let x=s.indexOf(v);x!==-1&&x<T&&(T=x)}let w=s.indexOf(I);if(T!==Number.MAX_SAFE_INTEGER&&w!==-1&&T<w)continue}else{let T=Number.MAX_SAFE_INTEGER;for(let R of y){if(R.typeName!==m||c(R.node))continue;let v=a(R.node);if(!v)continue;let x=s.indexOf(v);x!==-1&&x<T&&(T=x)}let w=s.indexOf(I);if(T!==Number.MAX_SAFE_INTEGER&&w!==-1&&T<w)continue}h.push({typeName:m,firstUsage:I,firstUsagePosition:o,firstUsageInFunctionArgs:S})}h.length>0&&g(h)}}}});import{AST_NODE_TYPES as ee}from"@typescript-eslint/utils";import*as qe from"zod/v4";var xa=["tsx"],Ca=/^[A-Z][A-Za-z0-9]*$/,Ia=qe.object({extensions:qe.array(qe.string()).optional()}),En=X({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(Ia)]},defaultOptions:[{}],create(e,[t]){let r=e.getFilename(),n=t.extensions??xa,s=!1;for(let o of n)if(r.endsWith(o)){s=!0;break}if(!s)return{};let a=e.sourceCode,i=new Set,p=new Map;function l(o){return Ca.test(o)}function c(o){if(o.type!==ee.CallExpression)return!1;let S=o.callee;return S.type===ee.Identifier?S.name==="memo"||S.name==="forwardRef":S.type===ee.MemberExpression&&S.property.type===ee.Identifier?S.property.name==="memo"||S.property.name==="forwardRef":!1}function d(o){if(o.type===ee.JSXElement||o.type===ee.JSXFragment)return!0;if(o.type===ee.ArrayExpression){for(let S of o.elements)if(S&&(S.type===ee.JSXElement||S.type===ee.JSXFragment))return!0}return!1}function y(o){if(o.type!==ee.ArrowFunctionExpression)return!1;let S=o.body;if(S.type===ee.ArrowFunctionExpression){let u=S.body;if(d(u))return!0}return!1}function g(o){if(o.id.type!==ee.Identifier)return;let S=o.id.name,u=o.init;if(u){if(l(S)&&(u.type===ee.ArrowFunctionExpression||u.type===ee.FunctionExpression||c(u))){i.add(S);return}u.type===ee.Identifier&&p.set(S,u.name),l(S)||y(u)&&i.add(S)}}function b(o){if(o.type===ee.VariableDeclaration){for(let S of o.declarations)g(S);return}if(o.type===ee.FunctionDeclaration&&o.id){l(o.id.name)&&i.add(o.id.name);return}if(o.type===ee.ExportNamedDeclaration&&o.declaration){let S=o.declaration;if(S.type===ee.VariableDeclaration){for(let u of S.declarations)g(u);return}if(S.type===ee.FunctionDeclaration&&S.id){l(S.id.name)&&i.add(S.id.name);return}}}for(let o of a.ast.body)b(o);function f(o,S=new Set){if(i.has(o))return!0;if(S.has(o))return!1;S.add(o);let u=p.get(o);return u?f(u,S):!1}let E=[];function h(o,S,u){E.push({node:o,isType:S,isComponent:u})}for(let o of a.ast.body){if(o.type===ee.ExportNamedDeclaration){let S=o.exportKind==="type";if(o.declaration){let u=o.declaration;if(u.type===ee.TSTypeAliasDeclaration||u.type===ee.TSInterfaceDeclaration){h(u,!0,!1);continue}if(u.type===ee.VariableDeclaration){for(let T of u.declarations){if(T.id.type!==ee.Identifier)continue;let w=T.id.name,R=f(w);h(T,S,R)}continue}if(u.type===ee.FunctionDeclaration){let T=u.id?.name,w=T?f(T)||l(T):!1;h(u,S,w);continue}h(u,S,!1);continue}if(o.specifiers.length>0)for(let u of o.specifiers){if(u.local.type!==ee.Identifier)continue;let T=u.local.name,w=f(T);h(u,S,w)}continue}if(o.type===ee.ExportDefaultDeclaration){let S=o.declaration;if(S.type===ee.Identifier){let u=f(S.name)||l(S.name);h(o,!1,u);continue}if(S.type===ee.FunctionDeclaration||S.type===ee.ArrowFunctionExpression||S.type===ee.FunctionExpression||S.type===ee.CallExpression){h(o,!1,!0);continue}h(o,!1,!1);continue}}let m=!1;for(let o of E)if(!o.isType&&o.isComponent){m=!0;break}if(!m)return{};let A=[];for(let o of E)o.isType||A.push(o);let I=-1;for(let[o,S]of A.entries())if(S.isComponent){I=o;break}if(I===-1)return{};for(let[o,S]of A.entries())if(o!==I){e.report({node:S.node,messageId:"multipleExports"});break}return{}}});import{AST_NODE_TYPES as ze}from"@typescript-eslint/utils";import{z as bn}from"zod/v4";function gt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Aa(e){return e.callee.type===ze.Identifier?e.callee.name==="useState":e.callee.type===ze.MemberExpression&&e.callee.object.type===ze.Identifier&&e.callee.property.type===ze.Identifier?e.callee.object.name==="React"&&e.callee.property.name==="useState":!1}var wa=bn.object({ignorePrefixes:bn.array(bn.string()).optional()});function qr(e,t){for(let r of t)if(e.startsWith(r))return e.slice(r.length);return e}function Ra(e){return`set${gt(e)}`}var xn=X({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(wa)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[t]){return{VariableDeclarator(r){if(!r.init||r.init.type!==ze.CallExpression||!Aa(r.init)||r.id.type!==ze.ArrayPattern||r.id.elements.length!==2)return;let[n,s]=r.id.elements;if(!n||!s||n.type!==ze.Identifier||s.type!==ze.Identifier)return;let a=n.name,i=s.name,p=t.ignorePrefixes||[],l=qr(a,p),c=qr(i,p);if(l===""){if(!c.startsWith("set")){let y=`set${gt(a)}`;e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(a),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:y},fix:g=>g.replaceText(s,y)}]})}return}let d=Ra(l);c!==d&&e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(l),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:d},fix:y=>y.replaceText(s,d)}]})}}}});import{AST_NODE_TYPES as de}from"@typescript-eslint/utils";import{z as Ze}from"zod/v4";var Pa=Ze.object({name:Ze.string(),defaults:Ze.array(Ze.unknown())}),va=Ze.object({functions:Ze.array(Pa)});function St(e,t){if(e===t)return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object"||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>St(s,t[a]));let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s of r){if(!n.includes(s))return!1;let a=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(t,s);if(!a||!i)return!1;let p=a.value,l=i.value;if(!St(p,l))return!1}return!0}function Fa(e,t){let r=new Set;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return r;for(let n in e){if(!(n in t))continue;let s=Object.getOwnPropertyDescriptor(e,n),a=Object.getOwnPropertyDescriptor(t,n);s&&a&&St(s.value,a.value)&&r.add(n)}return r}function Zr(e){if(e.type===de.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case de.Literal:return e.value;case de.ObjectExpression:{let t={};for(let r of e.properties)r.type===de.Property&&r.key.type===de.Identifier&&!r.computed&&(r.value.type===de.Literal?t[r.key.name]=r.value.value:r.value.type===de.ObjectExpression?t[r.key.name]=Zr(r.value):t[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return t}case de.ArrayExpression:return e.elements.map(t=>{if(!(!t||t.type===de.SpreadElement))return t.type===de.Literal?t.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function ka(e){return e.type===de.Identifier?e.name:e.type===de.MemberExpression&&e.property.type===de.Identifier&&!e.computed?e.property.name:null}var Cn=X({name:"no-redundant-function-params",meta:{type:"suggestion",docs:{description:"Disallow calling functions with redundant default parameters"},messages:{redundantParams:"Function call has redundant parameters matching its default values and can be removed: {{details}}"},fixable:"code",schema:[J(va)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map;for(let n of t.functions)r.set(n.name,n.defaults);return{CallExpression(n){let s=ka(n.callee);if(!s)return;let a=r.get(s);if(!a)return;let i=n.arguments;if(i.length===0)return;let p=-1,l=!1,c=new Map,d=new Set,y=new Map,g=[];for(let f=0;f<i.length;f++){if(f>=a.length){p=f;continue}let E=a[f],h=i[f];if(!h||h.type===de.SpreadElement){p=f;continue}let m=Zr(h);if(E===void 0){p=f;continue}if(St(m,E)){h.type===de.ObjectExpression?(d.add(f),g.push({type:"object",position:f+1})):(y.set(f,m),g.push({type:"simple",position:f+1,value:m}));continue}if(h.type===de.ObjectExpression&&h.properties.length===0&&typeof E=="object"&&E!==null&&Object.keys(E).length>0){d.add(f),g.push({type:"object",position:f+1});continue}let A=Fa(m,E);if(A.size>0){let I=typeof E=="object"&&E!==null?Object.keys(E).length:0;if(h.type===de.ObjectExpression&&h.properties.length===A.size&&h.properties.length===I){d.add(f),g.push({type:"object",position:f+1});continue}else l=!0,c.set(f,A),g.push({type:"partialObject",position:f+1,redundantProperties:Array.from(A)}),p=f}else p=f}if(p<i.length-1||l||d.size>0){let f=function(){let h=[];for(let m of g)if(m.type==="simple")h.push(`Param ${m.position} with value ${JSON.stringify(m.value)}`);else if(m.type==="object")h.push(`Param ${m.position} (object)`);else{let A=m.redundantProperties||[],I=a?a[m.position-1]:void 0;if(typeof I=="object"&&I!==null){let o=I;for(let S of A)if(S in o){let u=Object.getOwnPropertyDescriptor(o,S);u&&h.push(`Param ${m.position} property "${S}" with value ${JSON.stringify(u.value)}`)}}}return{messageId:"redundantParams",data:{details:h.join(", ")}}};var b=f;let E=f();e.report({node:n,messageId:E.messageId,data:E.data,fix(h){let m=[];if(l)for(let[I,o]of c){let S=i[I];if(S&&S.type===de.ObjectExpression){let u=[];for(let w of S.properties)w.type===de.Property&&w.key.type===de.Identifier&&!w.computed&&o.has(w.key.name)||u.push(w);let T=u.map(w=>e.sourceCode.getText(w));m.push(h.replaceText(S,`{ ${T.join(", ")} }`))}}let A=-1;for(let I=i.length-1;I>=0;I--)if(!d.has(I)&&I<=p){A=I;break}if(A<i.length-1)if(A===-1){let I=e.sourceCode.getTokenAfter(n.callee),o=e.sourceCode.getLastToken(n);I&&o&&m.push(h.replaceTextRange([I.range[1],o.range[0]],""))}else{let I=i[A],o=e.sourceCode.getLastToken(n);o&&I&&m.push(h.replaceTextRange([I.range[1],o.range[0]],""))}return m.length>0?m:null}})}}}}});import{AST_NODE_TYPES as Re}from"@typescript-eslint/utils";function Oa(e){let t=e.parent;for(;t;){if(t.type===Re.AwaitExpression||t.type===Re.MemberExpression&&t.object===e&&t.property.type===Re.Identifier&&t.property.name==="then"||t.type===Re.ArrowFunctionExpression&&t.body===e)return!0;if(t.type===Re.ArrayExpression&&t.parent.type===Re.CallExpression){let r=t.parent;if(r.callee.type===Re.MemberExpression&&r.callee.object.type===Re.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===Re.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(t.parent)t=t.parent;else break}return!1}function Na(e){let{callee:t}=e;return t.type===Re.Identifier&&t.name==="require"||t.type===Re.MemberExpression&&t.object.type===Re.Identifier&&t.object.name==="require"}var In=X({name:"no-sync-dynamic-import",meta:{type:"problem",docs:{description:"Disallow synchronous dynamic imports and require statements, only allow async dynamic imports with await"},messages:{syncDynamicImport:"Synchronous dynamic import() is not allowed. Use regular import statement or await import() for dynamic imports.",requireNotAllowed:"require() statements are not allowed. Use ES6 import statements instead."},schema:[]},defaultOptions:[],create(e){return{ImportExpression(t){Oa(t)||e.report({node:t,messageId:"syncDynamicImport"})},TSImportType(t){e.report({node:t,messageId:"syncDynamicImport"})},CallExpression(t){Na(t)&&e.report({node:t,messageId:"requireNotAllowed"})}}}});import{AST_NODE_TYPES as N}from"@typescript-eslint/utils";import{z as An}from"zod/v4";var Da=An.object({mainComponentRegex:An.string().optional(),mainComponentSelector:An.string().optional()}),ja=/^[A-Z][A-Za-z0-9]*$/,wn=X({name:"sort-react-components-and-styles",meta:{type:"suggestion",docs:{description:"Sort React components and styles with styles placed above their first usage"},fixable:"code",schema:[J(Da)],messages:{stylesShouldBeAboveUsage:"Style definitions should be placed above the first component that uses them",mainComponentShouldBeFirst:"Main component should be placed before other components"}},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.mainComponentRegex?new RegExp(t.mainComponentRegex):void 0,s=t.mainComponentSelector,a=new Set,i=new Map,p=[],l=[],c=new Set;function d(x){let C=x.node;if(C.type===N.VariableDeclaration){for(let F of C.declarations)if(F.id.type===N.Identifier&&F.id.name===x.name&&F.init)return F.init}if(C.type===N.ExportNamedDeclaration){let F=C.declaration;if(F&&F.type===N.VariableDeclaration){for(let O of F.declarations)if(O.id.type===N.Identifier&&O.id.name===x.name&&O.init)return O.init}}return null}function y(x){let C=new Set;return ve(x,F=>(F.type===N.Identifier&&F.name!=="styled"&&F.name!=="css"&&C.add(F.name),!1),r),C}function g(x){return ja.test(x)}function b(x){if(x.type!==N.CallExpression)return!1;let C=x.callee;return C.type===N.Identifier?C.name==="memo"||C.name==="forwardRef":C.type===N.MemberExpression&&C.property.type===N.Identifier?C.property.name==="memo"||C.property.name==="forwardRef":!1}function f(x){if(x.type===N.JSXElement||x.type===N.JSXFragment)return!0;if(x.type===N.BlockStatement){for(let C of x.body)if(C.type===N.ReturnStatement&&C.argument)return f(C.argument)}if(x.type===N.ArrayExpression){for(let C of x.elements)if(C&&(C.type===N.JSXElement||C.type===N.JSXFragment))return!0}return!1}function E(x){if(x.type!==N.ArrowFunctionExpression)return!1;let C=x.body;if(C.type===N.ArrowFunctionExpression){let F=C.body;if(f(F))return!0}return!1}function h(x){if(x.type===N.TaggedTemplateExpression){let C=x.tag;if(C.type===N.MemberExpression&&C.object.type===N.Identifier&&C.object.name==="styled")return!0;if(C.type===N.CallExpression){let F=C.callee;if(F.type===N.Identifier&&F.name==="styled")return!0}}return!1}function m(x){if(x.type===N.TaggedTemplateExpression){let C=x.tag;if(C.type===N.Identifier&&C.name==="css")return!0}return!1}function A(x,C){if(x.id.type!==N.Identifier)return;let F=x.id.name,O=x.init;if(O){if(h(O)||m(O)){l.push({node:C,name:F});return}if((g(F)||O.type===N.ArrowFunctionExpression)&&(O.type===N.ArrowFunctionExpression||O.type===N.FunctionExpression||b(O))){if(O.type===N.ArrowFunctionExpression||O.type===N.FunctionExpression){if(f(O.body)){a.add(F);return}}else if(b(O)){a.add(F);return}}O.type===N.Identifier&&i.set(F,O.name),g(F)||E(O)&&a.add(F)}}function I(x){return x.type===N.ExportDefaultDeclaration||x.type===N.ExportNamedDeclaration}function o(x){if(x.type===N.FunctionDeclaration)return x.id?x.id.name:null;if(x.type===N.VariableDeclaration){let C=x.declarations[0];if(C&&C.id.type===N.Identifier)return C.id.name}if(x.type===N.ExportDefaultDeclaration){let C=x.declaration;if(C.type===N.FunctionDeclaration)return C.id?C.id.name:"default";if(C.type===N.Identifier)return C.name}if(x.type===N.ExportNamedDeclaration){let C=x.declaration;if(C&&C.type===N.FunctionDeclaration)return C.id?C.id.name:null;if(C&&C.type===N.VariableDeclaration){let F=C.declarations[0];if(F&&F.id.type===N.Identifier)return F.id.name}}return null}function S(x,C){return s?c.has(x):n?n.test(C):I(x)}function u(x){let C=new Set;ve(x.node,F=>{if(F.type===N.Identifier)for(let O of l)O.name===F.name&&(C.add(O.name),(O.firstUsagePosition===void 0||F.range[0]<O.firstUsagePosition)&&(O.firstUsagePosition=F.range[0]));if(F.type===N.JSXElement){let O=F.openingElement;if(O.name.type===N.JSXIdentifier)for(let G of l)G.name===O.name.name&&(C.add(G.name),(G.firstUsagePosition===void 0||O.name.range[0]<G.firstUsagePosition)&&(G.firstUsagePosition=O.name.range[0]))}return!1},r),x.usedStyles=C}function T(x){if(x.type===N.VariableDeclaration){for(let C of x.declarations)A(C,x);return}if(x.type===N.FunctionDeclaration){g(x.id.name)&&f(x.body)&&a.add(x.id.name);return}if(x.type===N.ExportNamedDeclaration&&x.declaration){let C=x.declaration;if(C.type===N.VariableDeclaration){for(let F of C.declarations)A(F,x);return}if(C.type===N.FunctionDeclaration&&C.id){g(C.id.name)&&f(C.body)&&a.add(C.id.name);return}}if(x.type===N.ExportDefaultDeclaration){let C=x.declaration;C.type===N.Identifier&&a.add(C.name),(C.type===N.FunctionDeclaration||C.type===N.ArrowFunctionExpression||C.type===N.FunctionExpression)&&(C.type===N.FunctionDeclaration?C.id?a.add(C.id.name):a.add("default"):f(C.body)&&a.add("default"))}}function w(x,C=new Set){if(a.has(x))return!0;if(C.has(x))return!1;C.add(x);let F=i.get(x);return F?w(F,C):!1}let R={};return s&&(R[s]=x=>{let C=x;for(;C.parent&&C.parent.type!==N.Program;)C=C.parent;C.parent&&(C.type===N.VariableDeclaration||C.type===N.FunctionDeclaration||C.type===N.ExportNamedDeclaration||C.type===N.ExportDefaultDeclaration)&&c.add(C)}),R["Program:exit"]=x=>{let C=0;for(let D of x.body){if(D.type===N.ImportDeclaration){C+=1;continue}break}for(let D of x.body)T(D);for(let D of x.body){let q=o(D);if(q&&w(q)){let V=S(D,q);p.push({node:D,name:q,isMainComponent:V,usedStyles:new Set})}}for(let D of p)u(D);let F=new Set;for(let D of l)F.add(D.name);let O=new Map;for(let D=0;D<x.body.length;D+=1){let q=x.body[D];for(let V of l)V.node===q&&O.set(V.name,D)}let G=new Map;for(let D of l){let q=d(D),V=new Set;if(q){let le=y(q);for(let pe of le)F.has(pe)&&pe!==D.name&&V.add(pe)}G.set(D.name,V)}let z=new Map;for(let D of l){let q=G.get(D.name);if(!q)continue;let V=O.get(D.name);if(V!==void 0)for(let le of q){let pe=z.get(le);(pe===void 0||V<pe)&&z.set(le,V)}}let te=[];for(let D of l){if(D.firstUsagePosition===void 0)continue;let q=x.body.indexOf(D.node),V=-1;for(let he of p){if(!he.usedStyles.has(D.name))continue;let be=x.body.indexOf(he.node);(V===-1||be<V)&&(V=be)}let le=z.get(D.name);if(le!==void 0&&(V===-1||le<V)&&(V=le),V===-1)continue;let pe=-1;for(let he of p){let be=x.body.indexOf(he.node);be<V&&be>pe&&(pe=be)}let Ce=q<V,$e=q>pe,ye=-1,Ge=G.get(D.name);if(Ge)for(let he of Ge){let be=O.get(he);be!==void 0&&be>ye&&(ye=be)}let Xe=q>ye;if(!(Ce&&$e&&Xe)){let he=pe+1;if(ye+1>he&&(he=ye+1),he<C&&(he=C),he>V)continue;te.push({style:D,targetPosition:he})}}let ie=null;if(p.length>1){let D=p.map(V=>({c:V,idx:x.body.indexOf(V.node)})).sort((V,le)=>V.idx-le.idx)[0]?.c,q=p.find(V=>V.isMainComponent)||null;D&&q&&D.node!==q.node&&(ie={component:q,targetBefore:D.node})}if(te.length>0||ie){let D=te[0]?.style.node||ie?.component.node||x,q=te.length>0?"stylesShouldBeAboveUsage":"mainComponentShouldBeFirst";e.report({node:D,messageId:q,fix:v(te,ie,x.body)})}},R;function v(x,C,F){return function*(O){x.sort((z,te)=>z.targetPosition-te.targetPosition);for(let{style:z}of x){let te=r.getCommentsBefore(z.node),ie=z.node.range[0],D=z.node.range[1];te.length>0&&te[0]&&(ie=te[0].range[0]),ie===z.node.range[0]&&r.text.slice(0,ie).trim().length===0&&(ie=0),yield O.removeRange([ie,D])}let G=new Map;for(let z of x){let te=G.get(z.targetPosition)||[];te.push(z),G.set(z.targetPosition,te)}for(let[z,te]of G){let ie=F[z];if(!ie)continue;let D=r.getCommentsBefore(ie),q=D.length>0&&D[0]?D[0].range[0]:ie.range[0],V=[];for(let{style:le}of te){let pe=r.getCommentsBefore(le.node),Ce=r.getText(le.node);pe.length>0&&(Ce=`${pe.map(ye=>r.getText(ye)).join(`
|
|
47
47
|
`)}
|
|
48
|
-
${
|
|
48
|
+
${Ce}`),V.push(Ce)}yield O.insertTextBeforeRange([q,q],`${V.join(`
|
|
49
49
|
|
|
50
50
|
`)}
|
|
51
51
|
|
|
52
|
-
`)}if(C){let{component:
|
|
52
|
+
`)}if(C){let{component:z,targetBefore:te}=C,ie=r.getCommentsBefore(z.node),D=z.node.range[0],q=z.node.range[1];ie.length>0&&ie[0]&&(D=ie[0].range[0]),D===z.node.range[0]&&r.text.slice(0,D).trim().length===0&&(D=0);let V=r.getCommentsBefore(te),le=V.length>0&&V[0]?V[0].range[0]:te.range[0],pe=(()=>{let Ce=r.getText(z.node);return ie.length>0&&(Ce=`${ie.map(ye=>r.getText(ye)).join(`
|
|
53
53
|
`)}
|
|
54
|
-
${
|
|
55
|
-
`)}}}}});var
|
|
54
|
+
${Ce}`),Ce})();yield O.removeRange([D,q]),yield O.insertTextBeforeRange([le,le],`${pe}
|
|
55
|
+
`)}}}}});var Gr={[Zt.name]:Zt.rule,[kt.name]:kt.rule,[Ft.name]:Ft.rule,"rules-of-hooks":Br,"exhaustive-deps":Ln,"require-description":$r.rule,[Ot.name]:Ot.rule,[Dt.name]:Dt.rule,[Qt.name]:Qt.rule,[ht.name]:ht.rule,[vt.name]:vt.rule,[Mt.name]:Mt.rule,[Qe.name]:Qe.rule,[rn.name]:rn.rule,[jt.name]:jt.rule,[Nt.name]:Nt.rule,[$t.name]:$t.rule,[bt.name]:bt.rule,[pn.name]:pn.rule,[ln.name]:ln.rule,[fn.name]:fn.rule,[Rt.name]:Rt.rule,[Wt.name]:Wt.rule,[Jt.name]:Jt.rule,[Vt.name]:Vt.rule,[Ht.name]:Ht.rule,[Yt.name]:Yt.rule,[Xt.name]:Xt.rule,[Bt.name]:Bt.rule,[tn.name]:tn.rule,[Ut.name]:Ut.rule,[_t.name]:_t.rule,[Tn.name]:Tn.rule,[Gt.name]:Gt.rule,[mn.name]:mn.rule,[Sn.name]:Sn.rule,[hn.name]:hn.rule,[En.name]:En.rule,[xn.name]:xn.rule,[Cn.name]:Cn.rule,[In.name]:In.rule,[wn.name]:wn.rule,[Qe.name]:Qe.rule};var nf={rules:Gr};export{nf as extendedLintPlugin};
|