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