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