@ls-stack/extended-lint 0.62.2 → 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(
|
|
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 N(T){if(!R(T.defs))return!1;let C=T.defs[0];if(C==null||C.node.type!=="VariableDeclarator")return!1;let k=C.node.init;if(k==null)return!1;for(;k.type==="TSAsExpression";)k=k.expression;let F=C.node.parent;if(F==null&&(st(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 O=k.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let P=C.node.id,{name:M}=O;if(M==="useRef"&&P.type==="Identifier")return!0;if(Pr(O)&&P.type==="Identifier"){for(let L of T.references)L!==P&&d.add(L.identifier);return!0}else if(M==="useState"||M==="useReducer"){if(P.type==="ArrayPattern"&&P.elements.length===2&&R(T.identifiers)){if(P.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,P.elements[0])}}return!0}else if(P.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"&&P.type==="ArrayPattern"&&P.elements.length===2&&Array.isArray(T.identifiers)&&P.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,O=null,P;for(P=0;P<F.length;P++){let M=F[P],L=M.block;if(k.type==="FunctionDeclaration"&&L===k||k.type==="VariableDeclarator"&&L.parent===k){O=M;break}}if(O==null)return!1;for(P=0;P<O.through.length;P++){let M=O.through[P];if(M.resolved!=null&&I.has(M.resolved.scope)&&!G(M.resolved))return!1}return!0}let G=y(N,m),B=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 Y=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=st(u,C.identifier),F=rn(k),O=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(O,{reference:C,dependencyNode:F}),F.parent.type==="TSTypeQuery"||F.parent.type==="TSTypeReference")continue;let P=C.resolved.defs[0];if(P!=null&&!(P.node!=null&&P.node.init===u.parent)&&P.type!=="TypeParameter")if(Y.has(O))Y.get(O).references.push(C);else{let M=C.resolved,L=G(M)||B(M);Y.set(O,{isStable:L,references:[C]})}}for(let C of T.childScopes)ke(C)}Q.forEach(({reference:T,dependencyNode:C},k)=>{let F=T.resolved.references,O=!1;for(let P=0;P<F.length;P++){let{identifier:M}=F[P],{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){O=!0;break}}O||s({node:C.parent.property,message:`The ref value '${k}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${k}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let re=new Set;function xe(T,C){re.has(C)||(re.add(C),s({node:T,message:`Assignments to the '${C}' variable from inside React Hook ${r(b)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${r(b)}.`}))}let le=new Set;if(Y.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(Y.forEach(({isStable:C,references:k},F)=>{T||k.forEach(O=>{if(T)return;let P=O.identifier;if(!p.has(P))return;let L=O.from;for(;L.type!=="function";)L=L.upper;L.block===u&&(T=F)})}),T){let{suggestedDependencies:C}=rt({dependencies:Y,declaredDependencies:[],stableDependencies:le,externalDependencies:new Set,isEffect:!0});s({node:b,message:`React Hook ${g} contains a call to '${T}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+C.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${C.join(", ")}]`,fix(k){return k.insertTextAfter(u,`, [${C.join(", ")}]`)}}]})}return}let Re=[],Ne=new Set;x.type!=="ArrayExpression"?s({node:x,message:`React Hook ${r(b)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):x.elements.forEach(T=>{if(T===null)return;if(T.type==="SpreadElement"){s({node:T,message:`React Hook ${r(b)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}d.has(T)&&s({node:T,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(T)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(T)}\``,fix(O){return O.removeRange(T.range)}}]});let C;try{C=Te(T,me)}catch(O){if(/Unsupported node type/.test(O.message)){T.type==="Literal"?Y.has(T.value)?s({node:T,message:`The ${T.raw} literal is not a valid dependency because it never changes. Did you mean to include ${T.value} in the array instead?`}):s({node:T,message:`The ${T.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:T,message:`React Hook ${r(b)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let k=T;for(;k.type==="MemberExpression"||k.type==="OptionalMemberExpression"||k.type==="ChainExpression";)k=k.object||k.expression.object;let F=!w.through.some(O=>O.identifier===k);Re.push({key:C,node:T}),F||Ne.add(C)});let{suggestedDependencies:mr,unnecessaryDependencies:$e,missingDependencies:be,duplicateDependencies:Yt}=rt({dependencies:Y,declaredDependencies:Re,stableDependencies:le,externalDependencies:Ne,isEffect:A}),Ue=mr;if(Yt.size+be.size+$e.size===0){if(t)return;wr({declaredDependencies:Re,declaredDependenciesNode:x,componentScope:w,scope:S}).forEach(({construction:C,isUsedOutsideOfHook:k,depType:F})=>{let O=F==="function"?"useCallback":"useMemo",P=F==="function"?"definition":"initialization",M=`wrap the ${P} of '${C.name.name}' in its own ${O}() 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}`,Xt;k&&C.type==="Variable"&&F==="function"&&(Xt=[{desc:`Wrap the ${P} of '${C.name.name}' in its own ${O}() Hook.`,fix(Bt){let[yr,gr]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Bt.insertTextBefore(C.node.init,yr),Bt.insertTextAfter(C.node.init,gr)]}}]),s({node:C.node,message:Se,suggest:Xt})});return}!A&&be.size>0&&(Ue=rt({dependencies:Y,declaredDependencies:[],stableDependencies:le,externalDependencies:Ne,isEffect:A}).suggestedDependencies);function dr(){if(Re.length===0)return!0;let T=Re.map(k=>k.key),C=T.slice().sort();return T.join(",")===C.join(",")}dr()&&Ue.sort();function Ke(T){let C=T.split("."),k="";for(let F=0;F<C.length;F++){if(F!==0){let O=C.slice(0,F+1).join("."),P=me.get(O)===!0;k+=P?"?.":"."}k+=C[F]}return k}function Qe(T,C,k,F){return T.size===0?null:(T.size>1?"":C+" ")+k+" "+(T.size>1?"dependencies":"dependency")+": "+kr(Array.from(T).sort().map(O=>"'"+Ke(O)+"'"))+`. Either ${F} ${T.size>1?"them":"it"} or remove the dependency array.`}let ue="";if($e.size>0){let T=null;if(Array.from($e.keys()).forEach(C=>{T===null&&C.endsWith(".current")&&(T=C)}),T!==null)ue=` Mutable values like '${T}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(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=Y.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 O=C[F],P=st(w.block,O.identifier);if(!P){k=!1;break}let M=P.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=Y.get(C);if(F.references[0].resolved!==k)return;let O=k.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let P=!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){P=!0;break}P&&(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=Y.get(C).references,O,P;for(let M=0;M<F.length;M++){for(O=F[M].identifier,P=O.parent;P!=null&&P!==w.block;){if(P.type==="CallExpression"){let L=p.get(P.callee);if(L!=null){if(L.name===C)T={missingDep:C,setter:P.callee.name,form:"updater"};else if(c.has(O))T={missingDep:C,setter:P.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:P.callee.name,form:"inlineReducer"})}}break}}P=P.parent}if(T!==null)break}}),T!==null)switch(T.form){case"reducer":ue=` You can also replace multiple useState variables with useReducer if '${T.setter}' needs the current value of '${T.missingDep}'.`;break;case"inlineReducer":ue=` If '${T.setter}' needs the current value of '${T.missingDep}', you can also switch to useReducer instead of useState and read '${T.missingDep}' in the reducer.`;break;case"updater":ue=` You can also do a functional update '${T.setter}(${T.missingDep.slice(0,1)} => ...)' if you only need '${T.missingDep}' in the '${T.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:x,message:`React Hook ${r(b)} has `+(Qe(be,"a","missing","include")||Qe($e,"an","unnecessary","exclude")||Qe(Yt,"a","duplicate","omit"))+ue,suggest:[{desc:`Update the dependencies array to be: [${Ue.map(Ke).join(", ")}]`,fix(T){return T.replaceText(x,`[${Ue.map(Ke).join(", ")}]`)}}]})}function h(u){let x=vr(u.callee,i);if(x===-1)return;let b=u.arguments[x],g=u.callee,A=sn(g).name,S=u.arguments[x+1],I=/Effect($|[^a-z])/g.test(A);if(!b){s({node:g,message:`React Hook ${A} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!I)){if(!S&&!I){(A==="useMemo"||A==="useCallback")&&s({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(N=>N&&N.type==="Identifier"&&N.name===b.name))return;let w=n(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 N=R.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":E(N,S,g,A,I);return}break}break;default:s({node:g,message:`React Hook ${A} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({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(Ar.test(u.value))return t=!0,{CallExpression:x=>h(x,!0)}}return{CallExpression:u=>h(u)}}};function rt({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,h)=>{let u=s(a,h);u.isUsed=!0,l(a,h,x=>{x.isSubtreeUsed=!0})}),t.forEach(({key:E})=>{let h=s(a,E);h.isSatisfiedRecursively=!0}),r.forEach(E=>{let h=s(a,E);h.isSatisfiedRecursively=!0});function s(E,h){let 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(a,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 t.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 wr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:i})=>{let s=r.variables.find(p=>p.name===i);if(s==null)return null;let l=s.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let p=Ce(l.node.init);if(p!=null)return[s,p]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[s,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function a(i){let s=!1;for(let l=0;l<i.references.length;l++){let p=i.references[l];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!on(t,p.identifier))return!0}return!1}return o.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:a(i)}))}function rn(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?rn(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function it(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function Te(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=Te(e.object,t),n=Te(e.property,null),o=`${r}.${n}`;return it(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Te(e.object,t),n=Te(e.property,null),o=`${r}.${n}`;return it(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=Te(r.object,t),o=Te(r.property,null),a=`${n}.${o}`;return it(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function sn(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function vr(e,t){let r=sn(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let n;try{n=Te(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(n)?0:-1}else return-1}}function st(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),Fr(n,t))return n;if(on(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(tn(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(i=>{tn(i)&&(i.parent=n,r.push(i))}))}return null}function kr(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function tn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Fr(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function on(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Pr(e){return!1}import{AST_NODE_TYPES as We,ESLintUtils as ln}from"@typescript-eslint/utils";import ie from"typescript";import{z as Or}from"zod/v4";var Nr=ln.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="improved-no-unnecessary-condition",Dr=Or.object({}),Mr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],jr=new Set(Mr),ot={name:an,rule:Nr({name:an,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:[$(Dr)]},defaultOptions:[{}],create(e){let t=ln.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(s){return s.type===We.UnaryExpression&&s.operator==="typeof"}function o(s){return s.flags&ie.TypeFlags.Any||s.flags&ie.TypeFlags.Unknown?null:s.flags&ie.TypeFlags.StringLike?["string"]:s.flags&ie.TypeFlags.NumberLike?["number"]:s.flags&ie.TypeFlags.BigIntLike?["bigint"]:s.flags&ie.TypeFlags.BooleanLike?["boolean"]:s.flags&ie.TypeFlags.ESSymbolLike?["symbol"]:s.flags&ie.TypeFlags.Undefined||s.flags&ie.TypeFlags.Void?["undefined"]:s.flags&ie.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&ie.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&ie.TypeFlags.NonPrimitive?["object"]:s.flags&ie.TypeFlags.Never?["never"]:null}function a(s){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(s),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=o(f);if(d)c.push(...d);else return null}return c}let m=o(p);return m?(c.push(...m),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(n(s.left)?(p=s.left,c=s.right.type===We.Literal&&typeof s.right.value=="string"?s.right.value:null):n(s.right)&&(p=s.right,c=s.left.type===We.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!Lr(c,jr))return;let m=a(p);if(!m)return;let f=s.operator==="!==",d=m.includes(c);m.length===1?d&&!f?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Fe(p,e),type:c}}):!d&&f?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Fe(p,e),type:Array.from(m)[0]}}):!d&&!f?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Fe(p,e),actualType:ze(m),conditionType:c}}):d&&f&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Fe(p,e),actualType:ze(m),conditionType:c}}):!d&&!f?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Fe(p,e),actualType:ze(m),conditionType:c}}):!d&&f&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Fe(p,e),type:ze(m)}})}return{BinaryExpression:i}}})};function ze(e){return Array.from(new Set(e)).join(" | ")||"never"}function Fe(e,t){let r=e.argument;return r.type===We.Identifier?r.name:t.sourceCode.getText(r)}function Lr(e,t){return t.has(e)}import{AST_NODE_TYPES as _r,ESLintUtils as $r}from"@typescript-eslint/utils";import{z as at}from"zod/v4";var Ur=$r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-call-with-explicit-generics",zr=at.object({functions:at.array(at.string())}),Wr=Ur({name:pn,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:[$(zr)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===_r.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),lt={name:pn,rule:Wr};import{AST_NODE_TYPES as Ve,ESLintUtils as Vr}from"@typescript-eslint/utils";var Hr=Vr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cn="no-call-with-inferred-generics",Jr=Hr({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,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:o}=n;if(o.type!==Ve.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:i=1,allowAny:s,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(s&&!l)&&n.typeArguments?.params.some(c=>!s&&c.type===Ve.TSAnyKeyword||l&&c.type===Ve.TSTypeReference&&c.typeName.type===Ve.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),pt={name:cn,rule:Jr};import{ESLintUtils as Yr}from"@typescript-eslint/utils";var Xr=Yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-commented-out-code",Br=["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:"],qr=/^\s*return\s+/,Gr=/\w=("|'|`)/,Zr=/\w+:\s*('|"|`)/,Kr=/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,Qr=/\w+-\w+:/,ei=/\w+_\w+:/,ti=/\?\s+\w/,ni=/:\s+\w/,ri=/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,ii=/^\s*\d+[,}]/,si=/^\s*\[[^\]]*\][,}]/,oi=/^\s*\{[^}]*\}[,}]/,ai=/\.\w+\(/,li=/\[\w+\]/,pi=/^\s*(['"`]).+?\1\s*:/,ci=/^<[A-Z]\w*(\s|>|\/)/,ui=/^<[a-z]+(\s|>|\/)/,fi=/<[A-Z]\w*(\s.*)?>/,mi=/<\/[A-Z]\w*>/,di=/<[a-z]+(\s.*)?>/,yi=/<\/[a-z]+>/,gi=/^\s*[*\s]*$/,Si=/^[a-zA-Z]/,Ti=/^[A-Z][A-Za-z]*(?:\s+\d+)?(?:\s+[a-z]+)*:\s+[A-Za-z]/,hi=/```[\s\S]*?```/g,Ei=/`[^`]*`/g,un=/[a-zA-Z0-9]/,xi=/\.[A-Za-z_][A-Za-z0-9_]*\(/,bi=/[{}[\]()`=<>]/,Ci=/:\s*(['"`[{(]|\w+\s*=>)/,Ii=/\bif\s*\(|\belse\b|=>/,q={returnStatement:qr,stringAssignment:Gr,objectPropertyWithQuotes:Zr,computedPropertyAssignment:Kr,kebabCaseProperty:Qr,snakeCaseProperty:ei,ternaryOperator:ti,colonWithWord:ni,quotedString:ri,numberWithComma:ii,arrayWithComma:si,objectWithComma:oi,methodCall:ai,arrayAccess:li,quotedPropertyKey:pi,jsxSelfClosing:ci,jsxElement:ui,jsxOpeningTag:fi,jsxClosingTag:mi,htmlOpeningTag:di,htmlClosingTag:yi,jsdocComment:gi};function Ri(e){if(e.includes(":")){let r=e.split(":")[0]?.trim();if(r&&Si.test(r)&&r.includes(" "))return!0}let t=e.trim();return t.length===0||xi.test(t)||bi.test(t)||Ci.test(t)||Ii.test(t)?!1:!!(t.includes(":")&&Ti.test(t))}var Ai=[") {","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],wi=["/>","</",q.jsxSelfClosing,q.jsxElement,q.jsxOpeningTag,q.jsxClosingTag,q.htmlOpeningTag,q.htmlClosingTag],fn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],vi=Xr({name:mn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,o){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||q.jsdocComment.test(n))return!1;for(let i of fn)if(a.startsWith(i))return!1;if(n.includes("https://")||Ri(a))return!1;if(o==="Block"){for(let i of wi)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Br)if(a.startsWith(i))return{wrongPattern:i};for(let i of Ai)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,o){let a=n,i=a.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let p=a.split(hi);p.some(m=>un.test(m))&&(a=p.join(""))}if(!a.includes("`"))return a;let s=a.split(Ei);return s.some(p=>un.test(p))?s.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let i=r(a.value,a.type),s=t(i,a.type);s&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:fn.join(", ")}})}}}}}),ct={name:mn,rule:vi};import{ESLintUtils as ki,TSESTree as Fi}from"@typescript-eslint/utils";var Pi=ki.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="no-default-export",Oi=Pi({name:dn,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.type===Fi.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ut={name:dn,rule:Oi};import{ESLintUtils as Ni}from"@typescript-eslint/utils";var Di=Ni.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yn="no-leaked-text-in-jsx",Mi=[",",";","[","]","(",")"],ji=Di({name:yn,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let r=t.value.trim();if(!r)return;let n="";Mi.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),ft={name:yn,rule:ji};import{AST_NODE_TYPES as De,ESLintUtils as Li}from"@typescript-eslint/utils";var _i=Li.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sn="no-non-camel-case-functions",$i=/^(\$?[a-z][a-zA-Z0-9]*)$/;function gn(e){if(e.typeName.type!==De.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===De.Identifier&&t.name==="JSX"&&r.name==="Element"}var Ui=_i({name:Sn,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!$i.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===De.TSTypeReference?gn(r):r.type===De.TSUnionType&&r.types.some(o=>o.type===De.TSTypeReference&&gn(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),mt={name:Sn,rule:Ui};import{ESLintUtils as Wi,TSESTree as H}from"@typescript-eslint/utils";import{AST_NODE_TYPES as Tn}from"@typescript-eslint/utils";function Pe(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Pe(e.parent,t,r===1/0?r:r-1)}function*dt(e){yield e,e.parent&&(yield*dt(e.parent))}function yt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function En(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Tn.Property&&a.identifiers[0].parent.key.type===Tn.Identifier&&a.identifiers[0].parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}function hn(e){return e===null||typeof e!="object"||!("type"in e)?!1:typeof e.type=="string"}function zi(e,t){return e[t]}function xn(e,t,r){let n=r.visitorKeys,o=new Set;function a(i){if(o.has(i))return!1;if(o.add(i),t(i)===!0)return!0;let l=n[i.type];if(l)for(let p of l){let c=zi(i,p);if(c){if(Array.isArray(c)){for(let m of c)if(hn(m)&&a(m))return!0}else if(hn(c)&&a(c))return!0}}return!1}a(e)}var Vi=Wi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bn="no-optional-root-props",Hi=Vi({name:bn,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let i=a.references[0];if(!i)return!1;for(let s of dt(i.identifier)){if("returnType"in s||s.type===H.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=s.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=He(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(s.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?!!He(p,e.sourceCode):!1}if(l.type===H.AST_NODE_TYPES.FunctionDeclaration)return!!He(l,e.sourceCode)}return!1}function r(n){n.key.type!==H.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Pe(n,H.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let i=e.sourceCode.getText(a);return o.replaceText(a,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===H.AST_NODE_TYPES.TSTypeLiteral&&!(Je(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===H.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Je(n)||!t(n)))for(let o of n.body.body)o.type===H.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==H.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==H.AST_NODE_TYPES.TSTypeLiteral)return;let a=Pe(n.parent,H.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let i=He(a,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 o.members)l.type===H.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Je(e){return e?e.parent?.type===H.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===H.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function He(e,t){if(Je(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 n=t.getScope(e);e.type===H.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(i=>i.identifiers.includes(r));if(!o)return;let a=o.references.filter(i=>i.identifier!==r);if(!(a.length!==1||!a[0])&&!Je(a[0].identifier.parent.parent))return a[0].identifier}var gt={name:bn,rule:Hi};import{AST_NODE_TYPES as Ye}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 t=new Set;function r(n){return n?n.type===Ye.Identifier?t.has(n.name):n.type===Ye.MemberExpression?r(n.object):!1:!1}return{ImportDeclaration(n){for(let o of n.specifiers)t.add(o.local.name)},ExportNamedDeclaration(n){if(n.source){e.report({node:n,messageId:"noReexport"});return}if(n.declaration?.type===Ye.VariableDeclaration)for(let o of n.declaration.declarations)r(o.init)&&e.report({node:n,messageId:"noReexport"});n.specifiers.length>0&&e.report({node:n,messageId:"noReexport"})},ExportDefaultDeclaration(n){n.declaration.type===Ye.Identifier&&t.has(n.declaration.name)&&e.report({node:n,messageId:"noReexport"})},ExportAllDeclaration(n){e.report({node:n,messageId:"noReexport"})}}}});import{ESLintUtils as Ji}from"@typescript-eslint/utils";import St from"path";import{z as Ie}from"zod/v4";var Yi=Ji.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cn="no-relative-imports",Xi=Ie.object({find:Ie.string(),replacement:Ie.string()}),Bi=Ie.object({aliases:Ie.array(Xi),rootDir:Ie.string().optional(),allowNotFoundAliases:Ie.boolean().optional(),_dev_simulateFileName:Ie.string().optional()}),qi=Yi({name:Cn,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[$(Bi)]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function o(i,s){let l=St.dirname(s);return St.resolve(l,i)}function a(i){let s=t.rootDir??process.cwd(),l=St.relative(s,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let m=l.replace(c,p);return{alias:p,newPath:m}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!n(s))return;let l=o(s,r),p=a(l);!p&&t.allowNotFoundAliases||e.report({node:i,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(i.source,`'${p.newPath}'`):void 0})}}}}),Tt={name:Cn,rule:qi};import{AST_NODE_TYPES as Z}from"@typescript-eslint/utils";import{z as In}from"zod/v4";var Gi=In.object({customMessage:In.string().optional()}),ht=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:[$(Gi)],messages:{noStaticStyleProp:"Static style props are not allowed use css instead.{{customMessage}}"}},defaultOptions:[{}],create(e,[t]){function r(n){switch(n.type){case Z.Literal:return!0;case Z.ObjectExpression:return n.properties.every(o=>o.type===Z.Property?o.computed||o.value.type===Z.Identifier&&o.key.type===Z.Identifier&&o.key.name===o.value.name?!1:r(o.value):!1);case Z.ArrayExpression:return n.elements.every(o=>o?o.type===Z.SpreadElement?!1:r(o):!0);case Z.TemplateLiteral:return n.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(n){if(n.name.type===Z.JSXIdentifier&&n.name.name==="style"&&n.value){let o=null;n.value.type===Z.JSXExpressionContainer?n.value.expression.type!==Z.JSXEmptyExpression&&(o=n.value.expression):n.value.type===Z.Literal&&(o=n.value),o&&r(o)&&e.report({node:n,messageId:"noStaticStyleProp",data:{customMessage:t.customMessage?` ${t.customMessage}`:""}})}}}}});import{AST_NODE_TYPES as Xe}from"@typescript-eslint/utils";import*as we from"zod/v4";var Zi=we.object({alternativeMsgs:we.object({inArrayFind:we.string().optional(),inArrayFilter:we.string().optional()}).optional(),__dev_simulateFileName:we.string().optional()});function Ki(e){return e.typeAnnotation.type!==Xe.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}var Qi=/(typeGuards|type-guards)\.(ts|tsx)$/;function es(e){return Qi.test(e)}function ts(e){let t=e.parent;for(;t;){if(t.type===Xe.CallExpression&&t.callee.type===Xe.MemberExpression&&t.callee.property.type===Xe.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var Et=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:[$(Zi)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(es(r))return{};function n(o){if(!Ki(o))return;let a=ts(o);if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let s=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:s,data:{message:i}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as Oe}from"@typescript-eslint/utils";var ns="no-unnecessary-async-on-jsx-props";function rs(e){if(e.body.type!==Oe.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==Oe.ExpressionStatement?!1:r.expression.type===Oe.AwaitExpression}var xt=V({name:ns,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(r){rs(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let o=e.sourceCode,a=[],i=o.getFirstToken(r,l=>l.value==="async");if(i){let l=o.getTokenAfter(i);l?a.push(n.replaceTextRange([i.range[0],l.range[0]],"")):a.push(n.remove(i))}function s(l){if(l.type===Oe.AwaitExpression){let p=o.getFirstToken(l);if(p&&p.value==="await"){let c=o.getTokenAfter(p);c?a.push(n.replaceTextRange([p.range[0],c.range[0]],"")):a.push(n.remove(p))}}if(l.type===Oe.BlockStatement)for(let p of l.body)s(p);else l.type===Oe.ExpressionStatement&&s(l.expression)}return s(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as je,ESLintUtils as An}from"@typescript-eslint/utils";import*as bt from"typescript";import Le from"zod/v4";var is=An.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rn="no-unnecessary-casting",ss=Le.object({additionalCastFunctions:Le.array(Le.object({name:Le.string(),expectedType:Le.enum(["string","number"])})).optional()}),Ct={name:Rn,rule:is({name:Rn,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[$(ss)],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=An.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.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 s(c,m){return m==="number"?!!(c.flags&bt.TypeFlags.NumberLike):!!(c.flags&bt.TypeFlags.StringLike)}function l(c,m){return f=>f.replaceText(c,e.sourceCode.getText(m))}function p(c){if(!a||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=n.find(h=>h.name===d);if(!y)return;if(i(m,y.expectedType)||s(a.getTypeAtLocation(o.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 Be}from"@typescript-eslint/utils";import*as de from"zod/v4";var os=de.object({methods:de.union([de.array(de.string()),de.literal("array")])}),It=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:[$(os)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(s){return Array.isArray(r)?r.includes(s):n.has(s)}function a(s){let{callee:l}=s;if(l.type===Be.MemberExpression){let p=l.property;if(p.type===Be.Identifier)return p.name}return null}function i(s,l){if(s.type!==Be.Identifier||!s.typeAnnotation)return;let p=l.parent;if(p.type===Be.CallExpression){let c=a(p);c&&o(c)&&p.arguments.indexOf(l)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(f){return s.typeAnnotation?f.remove(s.typeAnnotation):null}})}}return{ArrowFunctionExpression(s){for(let l of s.params)i(l,s)},FunctionExpression(s){for(let l of s.params)i(l,s)}}}});import{AST_NODE_TYPES as ae}from"@typescript-eslint/utils";var Rt=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(t){if(t.id.type===ae.ObjectPattern||!t.init||t.init.type!==ae.ObjectExpression||t.id.type===ae.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ae.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===ae.Property&&i.key.type===ae.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==ae.Identifier)return;let n=as(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(i=>i.type!==ae.Property?!1:i.value.type===ae.FunctionExpression),a=new Set;for(let i of n){if(i.identifier.parent.type!==ae.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===ae.Literal&&typeof s.property.value=="string")a.add(s.property.value);else return;else{if(s.property.type!==ae.Identifier)return;a.add(s.property.name)}if(s.parent.type===ae.CallExpression&&o)return}for(let[i,s]of r)a.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function as(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as X,ESLintUtils as ls}from"@typescript-eslint/utils";import{z as ve}from"zod/v4";var ps=ve.object({selectors:ve.array(ve.object({name:ve.string(),selectorProp:ve.string().optional(),selectorArgPos:ve.number().optional(),returnProp:ve.string().optional()}))}),cs=ls.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wn="no-unused-selected-values",At={name:wn,rule:cs({name:wn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[$(ps)]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===X.CallExpression&&(a=o.init),!a)return;let i=fs(a);if(!i)return;let s=n.get(i);if(!s)return;let l=us(a,s.selectorArgPos??0,s.selectorProp);if(!l)return;let p=ms(l);if(!p)return;let c=vn(p.properties,void 0);if(!c)return;if(o.id.type===X.ObjectPattern){let d=vn(o.id.properties,s.returnProp);if(!d)return;for(let[y,E]of c)d.has(y)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:y}});return}if(o.id.type!==X.Identifier||s.returnProp)return;let m=ds(o,e.sourceCode);if(m.length===0)return;let f=new Set;for(let d of m){if(d.identifier.parent.type!==X.MemberExpression)return;let y=d.identifier.parent.property;if(y.type!==X.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 us(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===X.ArrowFunctionExpression||n.type===X.FunctionExpression)return n;if(r&&n.type===X.ObjectExpression){let o=n.properties.find(i=>i.type===X.Property&&i.key.type===X.Identifier&&i.key.name===r);if(o?.type!==X.Property)return null;let a=o.value;if(a.type===X.ArrowFunctionExpression||a.type===X.FunctionExpression)return a}return null}function fs(e){return e.callee.type===X.Identifier?e.callee.name:e.callee.type===X.MemberExpression&&e.callee.property.type===X.Identifier?e.callee.property.name:null}function ms(e){if(e.body.type===X.ObjectExpression)return e.body;if(e.body.type===X.BlockStatement){let t=e.body.body.filter(r=>r.type===X.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==X.ObjectExpression?null:t[0].argument}return null}function vn(e,t){let r=e;if(t){let o=e.find(a=>a.type===X.Property&&a.key.type===X.Identifier&&a.key.name===t);if(o?.type!==X.Property||o.value.type!==X.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==X.Property||o.key.type!==X.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function ds(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as J}from"@typescript-eslint/utils";var wt=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(a=>a.type===J.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let s=ys(a);s&&(n=s);return}let i=gs(a,e.sourceCode);if(i){o=!0;for(let s of i)n.delete(s);if(n.size!==0)for(let[s,l]of n)e.report({node:l,messageId:"unusedField",data:{name:s}})}}}}});function ys(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 n=yt(r.properties,a=>a.type!==J.Property||a.key.type!==J.Identifier||a.key.name!=="initialConfig"?null:a.value.type===J.ObjectExpression?a.value:a.value.type===J.ArrowFunctionExpression||a.value.type===J.FunctionExpression?Ss(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===J.Property&&a.key.type===J.Identifier&&o.set(a.key.name,a);return o}function gs(e,t){if(!(e.callee.type===J.Identifier&&e.callee.name==="useFormState")||e.parent.type!==J.VariableDeclarator||e.parent.id.type!==J.ObjectPattern||!yt(e.parent.id.properties,i=>i.type===J.Property&&i.key.type===J.Identifier&&i.key.name==="formFields"&&i))return null;let o=En(e.parent,"formFields",t),a=new Set;for(let{identifier:i}of o){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;a.add(i.parent.property.name)}}return a}function Ss(e){if(e.body.type===J.ObjectExpression)return e.body;if(e.body.type===J.BlockStatement){let t=e.body.body.filter(r=>r.type===J.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==J.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as z,ESLintUtils as Ts}from"@typescript-eslint/utils";import{z as qe}from"zod/v4";var hs=Ts.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function kn(e){let t=[];for(let r of e.members)r.type===z.TSPropertySignature&&r.key.type===z.Identifier&&t.push([r.key.name,r]);return t}function Fn(e,...t){for(let r of t)e.set(...r);return e}var Es=qe.object({forceCheckOnFCPropTypesWithName:qe.array(qe.string()).optional(),alwaysCheckFunctionOptionTypes:qe.boolean().optional()}),Pn="no-unused-type-props-in-args",vt=null,xs=hs({name:Pn,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:[$(Es)],fixable:"code"},defaultOptions:[{alwaysCheckFunctionOptionTypes:!0}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r,alwaysCheckFunctionOptionTypes:n=!0}=t;r&&!vt&&(vt=r.map(l=>new RegExp(l)));function o(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&&vt?.some(g=>g.test(y)),u=d&&n;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){a(l,p,m,x.typeAnnotation,!0,d);return}if(x.type===z.TSInterfaceDeclaration){a(l,p,m,x.body,!0,d);return}}}function a(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){Fn(c,...kn(m));return}if(m.type===z.TSIntersectionType){for(let y of m.types)a(l,p,c,y,!0,d);return}f||m.type===z.TSTypeReference&&m.typeName.type===z.Identifier&&o(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(a(l,p,d,f.typeAnnotation.typeAnnotation,!1,m),d.size===0)continue;s(f,d)}else f.type===z.AssignmentPattern&&f.left.type===z.ObjectPattern&&i(l,p,[f.left],m)}function s(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)o(!0,l,m.typeName,c,!1);else if(m.type===z.TSTypeLiteral)Fn(c,...kn(m));else if(m.type===z.TSIntersectionType)for(let f of m.types)f.type===z.TSTypeReference&&f.typeName.type===z.Identifier?o(!0,l,f.typeName,c,!1):a(!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&&s(f,c)}}},FunctionDeclaration(l){i(!1,l,l.params,n)},ArrowFunctionExpression(l){i(!1,l,l.params,n)}}}}),kt={name:Pn,rule:xs};import{AST_NODE_TYPES as fe}from"@typescript-eslint/utils";var Ft=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 t=new Set;function r(n){return n.callee.type===fe.Identifier?t.has(n.callee.name):n.callee.type===fe.MemberExpression&&n.callee.object.type===fe.Identifier&&n.callee.property.type===fe.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let o of n.specifiers)o.type===fe.ImportSpecifier&&o.imported.type===fe.Identifier&&o.imported.name==="useRef"&&t.add(o.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===fe.CallExpression&&r(n.init)&&n.id.type===fe.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let i=!1;for(let s of a.references){let p=s.identifier.parent;if(p!==n&&!(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:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});import{AST_NODE_TYPES as Pt,ESLintUtils as bs}from"@typescript-eslint/utils";var Cs=bs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nn="prefer-named-functions",On=new Map,Is=Cs({name:Nn,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let r=null;if(t.ignoreRegex){let n=On.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),On.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Pt.ArrowFunctionExpression&&n.id.type===Pt.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Pt.BlockStatement)return;let a=n.parent,i=n.init.params,s=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(a,`${l.async?"async ":""}function ${o}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),Ot={name:Nn,rule:Is};import{AST_NODE_TYPES as j}from"@typescript-eslint/utils";import{z as he}from"zod/v4";var Rs=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()}))}),As=/^use[A-Z]/,ws=/^[A-Z]/;function Ge(e){return As.test(e)}function Dn(e){return ws.test(e)}function vs(e){return e.type===j.Identifier?Ge(e.name):e.type===j.MemberExpression&&e.property.type===j.Identifier?Ge(e.property.name):!1}function Mn(e,t){return e.type===j.Identifier?e.name===t:e.type===j.MemberExpression&&e.object.type===j.Identifier&&e.property.type===j.Identifier?e.object.name==="React"&&e.property.name===t:!1}function jn(e){return!!(e.parent&&e.parent.type===j.CallExpression&&Mn(e.parent.callee,"forwardRef"))}function Ln(e){return!!(e.parent&&e.parent.type===j.CallExpression&&Mn(e.parent.callee,"memo"))}function Nt(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 ks(e){let t=e.parent,r=!1;for(;t;){if(t.type===j.FunctionDeclaration||t.type===j.FunctionExpression||t.type===j.ArrowFunctionExpression){let n=Nt(t);if(n&&n.type===j.Identifier){if(Dn(n.name)||Ge(n.name))return!r;r=!0}else{if(jn(t)||Ln(t))return!r;if(t.parent.type===j.CallExpression){let o=t.parent;vs(o.callee)||(r=!0)}else t.parent.type===j.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function _n(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 Fs(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===j.FunctionDeclaration||r.type===j.FunctionExpression||r.type===j.ArrowFunctionExpression){let n=Nt(r);if(n&&n.type===j.Identifier&&t.includes(n.name))return!0}else if(r.type===j.CallExpression){let n=_n(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Ps(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===j.Identifier&&t.name==="undefined")}function Os(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===j.FunctionDeclaration||n.type===j.FunctionExpression||n.type===j.ArrowFunctionExpression){let o=Nt(n);if(o&&o.type===j.Identifier){if(Dn(o.name)||Ge(o.name)){r=!0;break}}else if(jn(n)||Ln(n)){r=!0;break}}n=n.parent}return r?t.length===0?ks(e):!Fs(e,t):!1}var Dt=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:[$(Rs)],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=_n(o);if(!a)return;let i=n.get(a);if(!i||i.allowUsingWithArgs&&Ps(o))return;let s=i.allowUseInside||[];Os(o,s)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:l=>{let p=i.hookAlternative;return p?o.callee.type===j.Identifier?l.replaceText(o.callee,p):o.callee.type===j.MemberExpression&&o.callee.property.type===j.Identifier?l.replaceText(o.callee.property,p):null:null}}]:[]})}}}});import{AST_NODE_TYPES as K,AST_TOKEN_TYPES as $n,ESLintUtils as Ns}from"@typescript-eslint/utils";import Mt from"zod/v4";var Ds=Ns.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zn="prefer-single-line-if",Ms=Mt.object({maxLineLength:Mt.number().optional(),maxNonSimpleConditionLength:Mt.number().optional()}),js=Ds({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:[$(Ms)]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==K.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(!a)return;if(a.type===K.ReturnStatement){if(!Vn(a))return}else if(!(a.type===K.ContinueStatement||a.type===K.BreakStatement))return;if(n.test.type===K.LogicalExpression||n.test.type===K.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let m=Un(n.test);if(!m&&n.test.type===K.UnaryExpression&&n.test.operator==="!"){let f=n.test.argument;Un(f)&&(m=!0)}if(m&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let s=r.getText(a);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
|
-
`)}}]})}}}}}),Lt={name:Zn,rule:Ys};import{AST_NODE_TYPES as ce,ESLintUtils as Xs}from"@typescript-eslint/utils";import{z as ge}from"zod/v4";var Bs=Xs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qn="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()}),Gs=/eslint +react-compiler\/react-compiler: +\["error/;function Zs(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 Ks=Bs({name:Qn,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,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Gs.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===ce.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===ce.MemberExpression&&n.callee.property.type===ce.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let i=t.disallowHooks.find(s=>s.name===o);i&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(a,i.replacement)}]})}}if(t.disallowMethods?.length&&Zs(n.callee)){for(let o of n.arguments)if(o.type===ce.ObjectExpression){for(let a of o.properties)if(a.type===ce.Property&&a.key.type===ce.Identifier){let i=a.key.name,s=t.disallowMethods.find(l=>l.name===i);if(s){if(s.requireTrueProp){let l=s.requireTrueProp,p=!1;for(let c of o.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:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:l}});continue}}s.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:l=>s.replacement?l.replaceText(a.key,s.replacement):null}]})}}}}}}:{}}}),_t={name:Qn,rule:Ks};import{ESLintUtils as Qs,TSESTree as eo}from"@typescript-eslint/utils";var to=Qs.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),er="require-description",no=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ro=/^eslint-disable-(next-)?line$/u,io=to({name:er,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let o of r.getAllComments()){let a=so(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:lo(o.loc),messageId:"missingDescription"}))}}}}}),tr={name:er,rule:io};function so(e){let{text:t,description:r}=ao(e.value);if(!t)return null;let n=no.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=ro.test(o);if(e.type===eo.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+o.length);return{kind:o,value:i.trim(),description:r}}var oo=/\s-{2,}\s/u;function ao(e){let t=e.split(oo);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function lo(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 po=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()}))}),$t=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:[$(po)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,s,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=s.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 o(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 a={};for(let i of t.varsToCheck)i.selector&&(a[i.selector]=s=>{if(s.type===U.VariableDeclarator&&s.id.type===U.Identifier&&r.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:o(s)}),s.type===U.VariableDeclarator&&s.id.type===U.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(s.id,l,i.errorMsg,o(s))}});for(let i of t.varsToCheck)if(i.fromFnCall){let s=i.fromFnCall;if(s.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${s.slice(2)}"]`;a[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];n(f.id,d,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[l,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;a[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];n(d.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;a[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];n(m.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...a,"Program:exit"(){for(let[i,{props:s,errorMsg:l,node:p,fnName:c}]of r){let f=e.sourceCode.getScope(p).set.get(i);if(f){let d=new Set(s);for(let y of f.references){let E=y.identifier,h=E.parent;if(!(h.type===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&&!s.includes(h.property.name))){d.clear();break}}}if(d.size>0){let y=Array.from(d);if(y.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:y[0],fnName: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 ir(e){return/^use[A-Z0-9]/.test(e)}function Ze(e){return e.type==="Identifier"?ir(e.name):e.type==="MemberExpression"&&!e.computed&&Ze(e.property)?e.object.type==="Identifier":!1}function sr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function or(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function ar(e){return!!(e.parent&&e.parent.callee&&or(e.parent.callee,"forwardRef"))}function lr(e){return!!(e.parent&&e.parent.callee&&or(e.parent.callee,"memo"))}function Ut(e){for(;e;){let t=cr(e);if(t&&(sr(t)||Ze(t))||ar(e)||lr(e))return!0;e=e.parent}return!1}function nr(e){return!1}function zt(e){return!1}var co=/eslint +react-compiler\/react-compiler: +\["error/,pr={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(co.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 t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,o=[],a=[],i=new WeakSet;function s(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&&nr(c.init.callee))for(let m of p.resolved.references)m!==p&&i.add(m.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,p){let c=o.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],N=R.slice(R.indexOf(g.id)+1);for(let _ of N)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),N=R.slice(R.indexOf(g.id)+1);for(let _ of N)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=cr(p),u=Ut(p),x=h?sr(h)||Ze(h):ar(p)||lr(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&&!zt(R)&&e.report({node:R,message:`React Hook "${t(R)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),x){if(p.async&&e.report({node:R,message:`React Hook "${t(R)}" cannot be called in an async function.`}),!w&&I!==E&&!zt(R)){let _=`React Hook "${t(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 N=`React Hook "${t(R)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:R,message:N})}else if(h){let N=`React Hook "${t(R)}" is called in function "${t(h)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:R,message:N})}else if(p.type==="Program"){let N=`React Hook "${t(R)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:R,message:N})}else if(u&&!zt(R)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let _=p.parent;if(_.parent.type==="VariableDeclarator"&&ir(_.parent.id.name))return}let N=`React Hook "${t(R)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:R,message:N})}}},CallExpression(l){if(Ze(l.callee)){let p=rr(o),c=rr(a),m=p.get(c);m||(m=[],p.set(c,m)),m.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||nr(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(l){l===n&&(n=null)},FunctionDeclaration(l){Ut(l)&&s(r(l))},ArrowFunctionExpression(l){Ut(l)&&s(r(l))}}}};function cr(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 rr(e){return e[e.length-1]}import{AST_NODE_TYPES as te,AST_TOKEN_TYPES as uo}from"@typescript-eslint/utils";import*as se from"zod/v4";var fo=/^\s+$/,Wt=/\r?\n/,mo=/^(\s*)/,yo=/^(\s*)\S/,go=/\r?\n/,So=se.object({indent:se.union([se.string().regex(fo),se.number().int().min(1)]).optional(),tags:se.array(se.string()).optional(),functions:se.array(se.string()).optional(),comments:se.array(se.string()).optional()}),Vt=V({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[$(So)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:o=["outdent","dedent","gql","sql","html","styled"],indent:a}=e.options[0],i=r.map(u=>u.toLowerCase());function s(u){let x=u.split(Wt),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(mo);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};
|