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