@ls-stack/extended-lint 0.45.3 → 0.45.4
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 +1 -1
- package/dist/extended-lint.mjs +1 -1
- package/package.json +1 -1
package/dist/extended-lint.js
CHANGED
|
@@ -12,5 +12,5 @@ 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 R=l.acquire(x),v=new Set,O=null;{let f=R.upper;for(;f&&(v.add(f),f.type!=="function");)f=f.upper;if(!f)return;O=f}let b=Array.isArray;function U(f){if(!b(f.defs))return!1;let y=f.defs[0];if(y==null||y.node.type!=="VariableDeclarator")return!1;let E=y.node.init;if(E==null)return!1;for(;E.type==="TSAsExpression";)E=E.expression;let I=y.node.parent;if(I==null&&(Qe(O.block,y.node.id),I=y.node.parent,I==null))return!1;if(I.kind==="const"&&E.type==="Literal"&&(typeof E.value=="string"||typeof E.value=="number"||E.value===null))return!0;if(E.type!=="CallExpression")return!1;let k=E.callee;if(k.type==="MemberExpression"&&k.object.name==="React"&&k.property!=null&&!k.computed&&(k=k.property),k.type!=="Identifier")return!1;let C=y.node.id,{name:j}=k;if(j==="useRef"&&C.type==="Identifier")return!0;if(ur(k)&&C.type==="Identifier"){for(let M of f.references)M!==C&&S.add(M.identifier);return!0}else if(j==="useState"||j==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&b(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(j==="useState"){let M=f.references,ee=0;for(let ae=0;ae<M.length;ae++){if(M[ae].isWrite()&&ee++,ee>1)return!1;c.set(M[ae].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(j==="useState"){let M=f.references;for(let ee=0;ee<M.length;ee++)p.add(M[ee].identifier)}return!1}}}else if(j==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function B(f){if(!b(f.defs))return!1;let y=f.defs[0];if(y==null||y.node==null||y.node.id==null)return!1;let E=y.node,I=O.childScopes,k=null,C;for(C=0;C<I.length;C++){let j=I[C],M=j.block;if(E.type==="FunctionDeclaration"&&M===E||E.type==="VariableDeclarator"&&M.parent===E){k=j;break}}if(k==null)return!1;for(C=0;C<k.through.length;C++){let j=k.through[C];if(j.resolved!=null&&v.has(j.resolved.scope)&&!oe(j.resolved))return!1}return!0}let oe=h(U,u),Ve=h(B,g),Ie=new Map;function fe(f){let y=f.from,E=!1;for(;y.block!==x;)y.type==="function"&&(E=y.block.parent!=null&&y.block.parent.type==="ReturnStatement"),y=y.upper;return E}let q=new Map,re=new Map;we(R);function we(f){for(let y of f.references){if(!y.resolved||!v.has(y.resolved.scope))continue;let E=Qe(x,y.identifier),I=Ut(E),k=ce(I,re);if(A&&I.type==="Identifier"&&(I.parent.type==="MemberExpression"||I.parent.type==="OptionalMemberExpression")&&!I.parent.computed&&I.parent.property.type==="Identifier"&&I.parent.property.name==="current"&&fe(y)&&Ie.set(k,{reference:y,dependencyNode:I}),I.parent.type==="TSTypeQuery"||I.parent.type==="TSTypeReference")continue;let C=y.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===x.parent)&&C.type!=="TypeParameter")if(q.has(k))q.get(k).references.push(y);else{let j=y.resolved,M=oe(j)||Ve(j);q.set(k,{isStable:M,references:[y]})}}for(let y of f.childScopes)we(y)}Ie.forEach(({reference:f,dependencyNode:y},E)=>{let I=f.resolved.references,k=!1;for(let C=0;C<I.length;C++){let{identifier:j}=I[C],{parent:M}=j;if(M!=null&&M.type==="MemberExpression"&&!M.computed&&M.property.type==="Identifier"&&M.property.name==="current"&&M.parent.type==="AssignmentExpression"&&M.parent.left===M){k=!0;break}}k||i({node:y.parent.property,message:`The ref value '${E}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${E}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let We=new Set;function jn(f,y){We.has(y)||(We.add(y),i({node:f,message:`Assignments to the '${y}' variable from inside React Hook ${r(d)} 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(d)}.`}))}let Ce=new Set;if(q.forEach(({isStable:f,references:y},E)=>{f&&Ce.add(E),y.forEach(I=>{I.writeExpr&&jn(I.writeExpr,E)})}),We.size>0)return;if(!N){let f=null;if(q.forEach(({isStable:y,references:E},I)=>{f||E.forEach(k=>{if(f)return;let C=k.identifier;if(!c.has(C))return;let M=k.from;for(;M.type!=="function";)M=M.upper;M.block===x&&(f=I)})}),f){let{suggestedDependencies:y}=Ge({dependencies:q,declaredDependencies:[],stableDependencies:Ce,externalDependencies:new Set,isEffect:!0});i({node:d,message:`React Hook ${m} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+y.join(", ")+`] as a second argument to the ${m} Hook.`,suggest:[{desc:`Add dependencies array: [${y.join(", ")}]`,fix(E){return E.insertTextAfter(x,`, [${y.join(", ")}]`)}}]})}return}let Ee=[],be=new Set;N.type!=="ArrayExpression"?i({node:N,message:`React Hook ${r(d)} 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.`}):N.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(d)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}S.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(k){return k.removeRange(f.range)}}]});let y;try{y=ce(f,re)}catch(k){if(/Unsupported node type/.test(k.message)){f.type==="Literal"?q.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(d)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw k}let E=f;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let I=!O.through.some(k=>k.identifier===E);Ee.push({key:y,node:f}),I||be.add(y)});let{suggestedDependencies:Ln,unnecessaryDependencies:Re,missingDependencies:me,duplicateDependencies:At}=Ge({dependencies:q,declaredDependencies:Ee,stableDependencies:Ce,externalDependencies:be,isEffect:A}),Ae=Ln;if(At.size+me.size+Re.size===0){if(t)return;ar({declaredDependencies:Ee,declaredDependenciesNode:N,componentScope:O,scope:R}).forEach(({construction:y,isUsedOutsideOfHook:E,depType:I})=>{let k=I==="function"?"useCallback":"useMemo",C=I==="function"?"definition":"initialization",j=`wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,M=E?`To fix this, ${j}`:`Move it inside the ${m} callback. Alternatively, ${j}`,ee=I==="conditional"||I==="logical expression"?"could make":"makes",ae=`The '${y.name.name}' ${I} ${ee} the dependencies of ${m} Hook (at line ${N.loc.start.line}) change on every render. ${M}`,kt;E&&y.type==="Variable"&&I==="function"&&(kt=[{desc:`Wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,fix(vt){let[_n,$n]=k==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[vt.insertTextBefore(y.node.init,_n),vt.insertTextAfter(y.node.init,$n)]}}]),i({node:y.node,message:ae,suggest:kt})});return}!A&&me.size>0&&(Ae=Ge({dependencies:q,declaredDependencies:[],stableDependencies:Ce,externalDependencies:be,isEffect:A}).suggestedDependencies);function Mn(){if(Ee.length===0)return!0;let f=Ee.map(E=>E.key),y=f.slice().sort();return f.join(",")===y.join(",")}Mn()&&Ae.sort();function He(f){let y=f.split("."),E="";for(let I=0;I<y.length;I++){if(I!==0){let k=y.slice(0,I+1).join("."),C=re.get(k)===!0;E+=C?"?.":"."}E+=y[I]}return E}function ze(f,y,E,I){return f.size===0?null:(f.size>1?"":y+" ")+E+" "+(f.size>1?"dependencies":"dependency")+": "+cr(Array.from(f).sort().map(k=>"'"+He(k)+"'"))+`. Either ${I} ${f.size>1?"them":"it"} or remove the dependency array.`}let ie="";if(Re.size>0){let f=null;if(Array.from(Re.keys()).forEach(y=>{f===null&&y.endsWith(".current")&&(f=y)}),f!==null)ie=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(be.size>0){let y=Array.from(be)[0];R.set.has(y)||(ie=` Outer scope values like '${y}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ie&&me.has("props")){let f=q.get("props");if(f==null)return;let y=f.references;if(!Array.isArray(y))return;let E=!0;for(let I=0;I<y.length;I++){let k=y[I],C=Qe(O.block,k.identifier);if(!C){E=!1;break}let j=C.parent;if(j==null){E=!1;break}if(j.type!=="MemberExpression"&&j.type!=="OptionalMemberExpression"){E=!1;break}}E&&(ie=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${m} call and refer to those specific props inside ${r(d)}.`)}if(!ie&&me.size>0){let f=null;me.forEach(y=>{if(f)return;let E=O.set.get(y),I=q.get(y);if(I.references[0].resolved!==E)return;let k=E.defs[0];if(k==null||k.name==null||k.type!=="Parameter")return;let C=!1,j;for(let M=0;M<I.references.length;M++)if(j=I.references[M].identifier,j!=null&&j.parent!=null&&(j.parent.type==="CallExpression"||j.parent.type==="OptionalCallExpression")&&j.parent.callee===j){C=!0;break}C&&(f=y)}),f!==null&&(ie=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ie&&me.size>0){let f=null;if(me.forEach(y=>{if(f!==null)return;let I=q.get(y).references,k,C;for(let j=0;j<I.length;j++){for(k=I[j].identifier,C=k.parent;C!=null&&C!==O.block;){if(C.type==="CallExpression"){let M=c.get(C.callee);if(M!=null){if(M.name===y)f={missingDep:y,setter:C.callee.name,form:"updater"};else if(p.has(k))f={missingDep:y,setter:C.callee.name,form:"reducer"};else{let ee=I[j].resolved;if(ee!=null){let ae=ee.defs[0];ae!=null&&ae.type==="Parameter"&&(f={missingDep:y,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":ie=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":ie=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":ie=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:N,message:`React Hook ${r(d)} has `+(ze(me,"a","missing","include")||ze(Re,"an","unnecessary","exclude")||ze(At,"a","duplicate","omit"))+ie,suggest:[{desc:`Update the dependencies array to be: [${Ae.map(He).join(", ")}]`,fix(f){return f.replaceText(N,`[${Ae.map(He).join(", ")}]`)}}]})}function w(x){let N=lr(x.callee,s);if(N===-1)return;let d=x.arguments[N],m=x.callee,A=Vt(m).name,R=x.arguments[N+1],v=/Effect($|[^a-z])/g.test(A);if(!d){i({node:m,message:`React Hook ${A} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!v)){if(!R&&!v){(A==="useMemo"||A==="useCallback")&&i({node:m,message:`React Hook ${A} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(d.type){case"FunctionExpression":case"ArrowFunctionExpression":T(d,R,m,A,v);return;case"Identifier":if(!R||R.elements&&R.elements.some(U=>U&&U.type==="Identifier"&&U.name===d.name))return;let O=n(x).set.get(d.name);if(O==null||O.defs==null)return;let b=O.defs[0];if(!b||!b.node||b.type!=="Variable"&&b.type!=="FunctionName")break;switch(b.node.type){case"FunctionDeclaration":T(b.node,R,m,A,v);return;case"VariableDeclarator":let U=b.node.init;if(!U)break;switch(U.type){case"ArrowFunctionExpression":case"FunctionExpression":T(U,R,m,A,v);return}break}break;default:i({node:m,message:`React Hook ${A} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:m,message:`React Hook ${A} has a missing dependency: '${d.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${d.name}]`,fix(O){return O.replaceText(R,`[${d.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let x of e.sourceCode.getAllComments())if(or.test(x.value))return t=!0,{CallExpression:N=>w(N,!0)}}return{CallExpression:x=>w(x)}}};function Ge({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,w)=>{let x=i(a,w);x.isUsed=!0,l(a,w,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:T})=>{let w=i(a,T);w.isSatisfiedRecursively=!0}),r.forEach(T=>{let w=i(a,T);w.isSatisfiedRecursively=!0});function i(T,w){let x=w.split("."),N=T;for(let d of x){let m=N.children.get(d);m||(m=s(),N.children.set(d,m)),N=m}return N}function l(T,w,x){let N=w.split("."),d=T;for(let m of N){let A=d.children.get(m);if(!A)return;x(A),d=A}}let c=new Set,p=new Set;u(a,c,p,T=>T);function u(T,w,x,N){T.children.forEach((d,m)=>{let A=N(m);if(d.isSatisfiedRecursively){d.isSubtreeUsed&&x.add(A);return}if(d.isUsed){w.add(A);return}u(d,w,x,R=>A+"."+R)})}let g=[],S=new Set,h=new Set;return t.forEach(({key:T})=>{p.has(T)?g.indexOf(T)===-1?g.push(T):h.add(T):S.add(T)}),c.forEach(T=>{g.push(T)}),{suggestedDependencies:g,unnecessaryDependencies:S,duplicateDependencies:h,missingDependencies:c}}function de(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 de(e.consequent)!=null||de(e.alternate)!=null?"conditional":null;case"LogicalExpression":return de(e.left)!=null||de(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return de(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return de(e.expression);case"TSAsExpression":return de(e.expression)}return null}function ar({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:s})=>{let i=r.variables.find(c=>c.name===s);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=de(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(s){let i=!1;for(let l=0;l<s.references.length;l++){let c=s.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==n&&p!=null;)p=p.upper;if(p!==n&&!Wt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}function Ut(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)?Ut(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ze(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function ce(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=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Ze(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Ze(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=ce(r.object,t),o=ce(r.property,null),a=`${n}.${o}`;return Ze(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Vt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function lr(e,t){let r=Vt(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=ce(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(n)?0:-1}else return-1}}function Qe(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),pr(n,t))return n;if(Wt(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(_t(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(s=>{_t(s)&&(s.parent=n,r.push(s))}))}return null}function cr(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 _t(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function pr(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 Wt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function ur(e){return!1}var ye=require("@typescript-eslint/utils");var J=ve(require("typescript")),fr=ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="improved-no-unnecessary-condition",mr=L({}),dr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],yr=new Set(dr),et={name:Ht,rule:fr({name:Ht,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[mr]},defaultOptions:[{}],create(e){let t=ye.ESLintUtils.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===ye.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&J.default.TypeFlags.Any||i.flags&J.default.TypeFlags.Unknown?null:i.flags&J.default.TypeFlags.StringLike?["string"]:i.flags&J.default.TypeFlags.NumberLike?["number"]:i.flags&J.default.TypeFlags.BigIntLike?["bigint"]:i.flags&J.default.TypeFlags.BooleanLike?["boolean"]:i.flags&J.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&J.default.TypeFlags.Undefined||i.flags&J.default.TypeFlags.Void?["undefined"]:i.flags&J.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&J.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&J.default.TypeFlags.NonPrimitive?["object"]:i.flags&J.default.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=r.getTypeAtLocation(l.expression);if(c.flags&J.default.TypeFlags.Any||c.flags&J.default.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let g of c.types){let S=o(g);if(S)p.push(...S);else return null}return p}let u=o(c);return u?(p.push(...u),p):null}function s(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(n(i.left)?(c=i.left,p=i.right.type===ye.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(c=i.right,p=i.left.type===ye.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!gr(p,yr))return;let u=a(c);if(!u)return;let g=i.operator==="!==",S=u.includes(p);u.length===1?S&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Se(c,e),type:p}}):!S&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Se(c,e),type:Array.from(u)[0]}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Se(c,e),actualType:Fe(u),conditionType:p}}):S&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Se(c,e),actualType:Fe(u),conditionType:p}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Se(c,e),actualType:Fe(u),conditionType:p}}):!S&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Se(c,e),type:Fe(u)}})}return{BinaryExpression:s}}})};function Fe(e){return Array.from(new Set(e)).join(" | ")||"never"}function Se(e,t){let r=e.argument;return r.type===ye.AST_NODE_TYPES.Identifier?r.name:t.sourceCode.getText(r)}function gr(e,t){return t.has(e)}var Ne=require("@typescript-eslint/utils");var Sr=Ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="no-call-with-explicit-generics",Tr=L({functions:z(F())}),hr=Sr({name:zt,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:[Tr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===Ne.AST_NODE_TYPES.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),tt={name:zt,rule:hr};var ge=require("@typescript-eslint/utils"),Er=ge.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="no-call-with-inferred-generics",br=Er({name:Yt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:o}=n;if(o.type!==ge.AST_NODE_TYPES.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(s||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&n.typeArguments?.params?.some(p=>!i&&p.type===ge.AST_NODE_TYPES.TSAnyKeyword||l&&p.type===ge.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===ge.AST_NODE_TYPES.Identifier&&l.includes(p.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),nt={name:Yt,rule:br};var Xt=require("@typescript-eslint/utils"),xr=Xt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="no-commented-out-code",Ir=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await "],wr=[") {","return;",/^\s*return\s+/,"if (","else {","else if (","for (","while (","switch (","case ","default:","/>","</","< ","},",": {"," } = ","={",/\w=("|'|`)/,");",/\w+:\s*('|"|`)/,/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,/\w+-\w+:/,/\w+_\w+:/,"&&","||","()",/\?\s+\w/,/:\s+\w/,/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,/^\s*\d+[,}]/,/^\s*\[[^\]]*\][,}]/,/^\s*\{[^}]*\}[,}]/,/\.\w+\(/,/\[\w+\]/,"?.(","??","=>",/^\s*(['"`]).+?\1\s*:/],Cr=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Bt=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Rr=xr({name:qt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,o){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||/^\s*[*\s]*$/.test(n))return!1;for(let s of Bt)if(a.startsWith(s))return!1;if(n.includes("https://"))return!1;if(o==="Block"){for(let s of Cr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of Ir)if(a.startsWith(s))return{wrongPattern:s};for(let s of wr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}function r(n,o){let a=n,s=a.trim();if(s.startsWith("`")&&(s.endsWith("`,")||s.endsWith("`;")||s.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let c=a.split(/```[\s\S]*?```/g);c.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=c.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(c=>/[a-zA-Z0-9]/.test(c))?i.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let s=r(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Bt.join(", ")}})}}}}}),rt={name:qt,rule:Rr};var De=require("@typescript-eslint/utils"),Ar=De.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-default-export",kr=Ar({name:Jt,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===De.TSESTree.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),it={name:Jt,rule:kr};var Kt=require("@typescript-eslint/utils"),vr=Kt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="no-leaked-text-in-jsx",Or=[",",";","[","]","(",")"],Pr=vr({name:Gt,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="";Or.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),st={name:Gt,rule:Pr};var pe=require("@typescript-eslint/utils"),Fr=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="no-non-camel-case-functions",Nr=/^[a-z][a-zA-Z0-9]*$/;function Zt(e){return e.typeName.type===pe.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===pe.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===pe.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var Dr=Fr({name:Qt,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&&!Nr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===pe.AST_NODE_TYPES.TSTypeReference?Zt(r):r.type===pe.AST_NODE_TYPES.TSUnionType&&r.types.some(o=>o.type===pe.AST_NODE_TYPES.TSTypeReference&&Zt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ot={name:Qt,rule:Dr};var V=require("@typescript-eslint/utils");var at=require("@typescript-eslint/utils");function Te(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Te(e.parent,t,r===1/0?r:r-1)}function*lt(e){yield e,e.parent&&(yield*lt(e.parent))}function ct(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function en(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===at.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===at.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var jr=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-optional-root-props",Lr=jr({name:tn,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let s=a.references[0];if(!s)return!1;for(let i of lt(s.identifier)){if("returnType"in i||i.type===V.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===V.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===V.TSESTree.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===V.TSESTree.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=Te(l.parent.parent,V.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=je(p,e.sourceCode);return u?!(u.parent.type===V.TSESTree.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===V.TSESTree.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===V.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===V.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let c=Te(l,V.TSESTree.AST_NODE_TYPES.VariableDeclaration);return c?!!je(c,e.sourceCode):!1}if(l.type===V.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!je(l,e.sourceCode)}return!1}function r(n){n.key.type!==V.TSESTree.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Te(n,V.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let s=e.sourceCode.getText(a);return o.replaceText(a,s.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===V.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Le(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Le(n)||!t(n)))for(let o of n.body.body)o.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==V.TSESTree.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==V.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=Te(n.parent,V.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=je(a,e.sourceCode);if(!(!s||s.parent.type===V.TSESTree.AST_NODE_TYPES.CallExpression&&s.parent.callee.type===V.TSESTree.AST_NODE_TYPES.Identifier&&s.parent.callee.name==="memo"))for(let l of o.members)l.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Le(e){return e?e.parent?.type===V.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===V.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function je(e,t){if(Le(e))return;let r;if(e.type===V.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===V.TSESTree.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===V.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(s=>s.identifiers.includes(r));if(!o)return;let a=o.references.filter(s=>s.identifier!==r);if(!(a.length!==1||!a[0])&&!Le(a[0].identifier.parent.parent))return a[0].identifier}var pt={name:tn,rule:Lr};var nn=require("@typescript-eslint/utils"),Me=ve(require("path"));var Mr=nn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rn="no-relative-imports",_r=L({find:F(),replacement:F()}),$r=L({aliases:z(_r),rootDir:P(F()),allowNotFoundAliases:P(le()),_dev_simulateFileName:P(F())}),Ur=Mr({name:rn,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:[$r]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=Me.default.dirname(i);return Me.default.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=Me.default.relative(i,s);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let u=l.replace(p,c);return{alias:c,newPath:u}}return null}return{ImportDeclaration(s){let i=s.source.value;if(!n(i))return;let l=o(i,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:s,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(s.source,`'${c.newPath}'`):void 0})}}}}),ut={name:rn,rule:Ur};var ue=require("@typescript-eslint/utils");var ft=ve(require("typescript")),Vr=ue.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="no-unnecessary-casting",Wr=L({additionalCastFunctions:P(z(L({name:F(),expectedType:Oe(["string","number"])})))}),mt={name:sn,rule:Vr({name:sn,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:[Wr],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=ue.ESLintUtils.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function s(p,u){switch(p.type){case ue.AST_NODE_TYPES.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case ue.AST_NODE_TYPES.TemplateLiteral:return u==="string";case ue.AST_NODE_TYPES.UnaryExpression:return u==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,u){return u==="number"?!!(p.flags&ft.TypeFlags.NumberLike):!!(p.flags&ft.TypeFlags.StringLike)}function l(p,u){return g=>g.replaceText(p,e.sourceCode.getText(u))}function c(p){if(!a||p.arguments.length!==1)return;let u=p.arguments[0];if(!u||u.type===ue.AST_NODE_TYPES.SpreadElement)return;let{callee:g}=p;if(g.type!==ue.AST_NODE_TYPES.Identifier)return;let S=g.name,h=n.find(w=>w.name===S);if(!h)return;if(s(u,h.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),h.expectedType)){let w,x;S==="Number"?w="unnecessaryNumberCasting":S==="String"?w="unnecessaryStringCasting":(w="unnecessaryCustomCasting",x={name:h.name,type:h.expectedType}),e.report({node:p,messageId:w,...x?{data:x}:{},fix:l(p,u)})}}return{CallExpression:c}}})};var xe=require("@typescript-eslint/utils"),ne=ve(require("zod/v4"));var Hr=ne.object({methods:ne.union([ne.array(ne.string()),ne.literal("array")])}),dt=se({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:[ne.toJSONSchema(Hr)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===xe.AST_NODE_TYPES.MemberExpression){let c=l.property;if(c.type===xe.AST_NODE_TYPES.Identifier)return c.name}return null}function s(i,l){if(i.type!==xe.AST_NODE_TYPES.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===xe.AST_NODE_TYPES.CallExpression){let p=a(c);p&&o(p)&&c.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(g){return g.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)s(l,i)},FunctionExpression(i){for(let l of i.params)s(l,i)}}}});var G=require("@typescript-eslint/utils");var yt=se({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===G.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==G.AST_NODE_TYPES.ObjectExpression||t.id.type===G.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===G.AST_NODE_TYPES.ExportNamedDeclaration)return;let r=new Map;for(let s of t.init.properties)s.type===G.AST_NODE_TYPES.Property&&s.key.type===G.AST_NODE_TYPES.Identifier&&r.set(s.key.name,s);if(r.size===0||t.id.type!==G.AST_NODE_TYPES.Identifier)return;let n=zr(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(s=>s.type!==G.AST_NODE_TYPES.Property?!1:s.value.type===G.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let s of n){if(s.identifier.parent.type!==G.AST_NODE_TYPES.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===G.AST_NODE_TYPES.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==G.AST_NODE_TYPES.Identifier)return;a.add(i.property.name)}if(i.parent.type===G.AST_NODE_TYPES.CallExpression&&o)return}for(let[s,i]of r)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function zr(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var W=require("@typescript-eslint/utils");var Yr=L({selectors:z(L({name:F(),selectorProp:P(F()),selectorArgPos:P(Z()),returnProp:P(F())}))}),Br=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-unused-selected-values",gt={name:on,rule:Br({name:on,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Yr]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===W.AST_NODE_TYPES.CallExpression&&(a=o.init),!a)return;let s=qr(a);if(!s)return;let i=n.get(s);if(!i)return;let l=Xr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=Jr(l);if(!c)return;let p=an(c.properties,void 0);if(!p)return;if(o.id.type===W.AST_NODE_TYPES.ObjectPattern){let S=an(o.id.properties,i.returnProp);if(!S)return;for(let[h,T]of p)S.has(h)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:h}});return}if(o.id.type!==W.AST_NODE_TYPES.Identifier||i.returnProp)return;let u=Kr(o,e.sourceCode);if(u.length===0)return;let g=new Set;for(let S of u){if(S.identifier.parent.type!==W.AST_NODE_TYPES.MemberExpression)return;let h=S.identifier.parent.property;if(h.type!==W.AST_NODE_TYPES.Identifier)return;g.add(h.name)}for(let[S,h]of p)g.has(S)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:S}})}}}})};function Xr(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===W.AST_NODE_TYPES.ArrowFunctionExpression||n.type===W.AST_NODE_TYPES.FunctionExpression)return n;if(r&&n.type===W.AST_NODE_TYPES.ObjectExpression){let o=n.properties.find(s=>s.type===W.AST_NODE_TYPES.Property&&s.key.type===W.AST_NODE_TYPES.Identifier&&s.key.name===r);if(o?.type!==W.AST_NODE_TYPES.Property)return null;let a=o.value;if(a.type===W.AST_NODE_TYPES.ArrowFunctionExpression||a.type===W.AST_NODE_TYPES.FunctionExpression)return a}return null}function qr(e){return e.callee.type===W.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===W.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===W.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Jr(e){if(e.body.type===W.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===W.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===W.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==W.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function an(e,t){let r=e;if(t){let o=e.find(a=>a.type===W.AST_NODE_TYPES.Property&&a.key.type===W.AST_NODE_TYPES.Identifier&&a.key.name===t);if(o?.type!==W.AST_NODE_TYPES.Property||o.value.type!==W.AST_NODE_TYPES.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==W.AST_NODE_TYPES.Property||o.key.type!==W.AST_NODE_TYPES.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function Kr(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var H=require("@typescript-eslint/utils");var St=se({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===H.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let i=Gr(a);i&&(n=i);return}let s=Zr(a,e.sourceCode);if(s){o=!0;for(let i of s)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function Gr(e){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==H.AST_NODE_TYPES.ObjectExpression)return null;let n=ct(r.properties,a=>a.type!==H.AST_NODE_TYPES.Property||a.key.type!==H.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===H.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===H.AST_NODE_TYPES.FunctionExpression?Qr(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===H.AST_NODE_TYPES.Property&&a.key.type===H.AST_NODE_TYPES.Identifier&&o.set(a.key.name,a);return o}function Zr(e,t){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==H.AST_NODE_TYPES.ObjectPattern||!ct(e.parent.id.properties,s=>s.type===H.AST_NODE_TYPES.Property&&s.key.type===H.AST_NODE_TYPES.Identifier&&s.key.name==="formFields"&&s))return null;let o=en(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==H.AST_NODE_TYPES.Identifier||s.parent.type===H.AST_NODE_TYPES.Property&&s.parent.parent.type===H.AST_NODE_TYPES.ObjectExpression&&s.parent.parent.parent.type===H.AST_NODE_TYPES.ReturnStatement||s.parent.type===H.AST_NODE_TYPES.ReturnStatement)return null;if(s.parent.type===H.AST_NODE_TYPES.MemberExpression){if(s.parent.object.type!==H.AST_NODE_TYPES.Identifier||s.parent.property.type!==H.AST_NODE_TYPES.Identifier)return null;a.add(s.parent.property.name)}}return a}function Qr(e){if(e.body.type===H.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===H.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===H.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var $=require("@typescript-eslint/utils");var ei=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function ln(e){let t=[];for(let r of e.members)r.type===$.AST_NODE_TYPES.TSPropertySignature&&r.key.type===$.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function cn(e,...t){for(let r of t)e.set(...r);return e}var ti=L({forceCheckOnFCPropTypesWithName:P(z(F()))}),pn="no-unused-type-props-in-args",Tt=null,ni=ei({name:pn,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[ti],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!Tt&&(Tt=r.map(i=>new RegExp(i)));function n(i,l,c,p,u=!0){let g=c.name,S=e.sourceCode.getScope(l).references.find(w=>w.identifier.name===g)?.resolved,h=i&&Tt?.some(w=>w.test(g));if(!S||!h&&S.references.filter(w=>w.isTypeReference).length>1)return;let T=S?.defs[0]?.node;if(!(u&&T?.parent?.type===$.AST_NODE_TYPES.ExportNamedDeclaration)){if(T?.type===$.AST_NODE_TYPES.TSTypeAliasDeclaration){o(i,l,p,T.typeAnnotation,!0);return}if(T?.type===$.AST_NODE_TYPES.TSInterfaceDeclaration){o(i,l,p,T.body,!0);return}}}function o(i,l,c,p,u){if(p.type===$.AST_NODE_TYPES.TSInterfaceBody){for(let g of p.body)g.type===$.AST_NODE_TYPES.TSPropertySignature&&g.key.type===$.AST_NODE_TYPES.Identifier&&c.set(g.key.name,g);return}if(p.type===$.AST_NODE_TYPES.TSTypeLiteral){cn(c,...ln(p));return}if(p.type===$.AST_NODE_TYPES.TSIntersectionType){for(let g of p.types)o(i,l,c,g,!0);return}u||p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier&&n(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let u=new Map;if(o(i,l,u,p.typeAnnotation.typeAnnotation,!1),u.size===0)continue;s(p,u)}else p.type===$.AST_NODE_TYPES.AssignmentPattern&&p.left.type===$.AST_NODE_TYPES.ObjectPattern&&a(i,l,[p.left])}function s(i,l){let c=[];if(i.properties.at(-1)?.type===$.AST_NODE_TYPES.RestElement)return;for(let S of i.properties)S.type===$.AST_NODE_TYPES.Property&&S.key.type===$.AST_NODE_TYPES.Identifier&&c.push(S.key.name);let u=[],g=[];for(let[S,h]of l)c.includes(S)||(g.push(S),u.push({node:h,messageId:"unusedObjectTypeProperty",data:{propertyName:S}}));for(let[S,h]of u.entries())e.report({...h,fix:S===u.length-1?T=>{let w=i.properties.at(-1),x=g.join(", ");return w?w?.type===$.AST_NODE_TYPES.RestElement?null:T.insertTextAfter(w,`, ${x}`):T.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${x}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let c=new Map,p=l.id.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===$.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(p){if(p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier)n(!0,i,p.typeName,c,!1);else if(p.type===$.AST_NODE_TYPES.TSTypeLiteral)cn(c,...ln(p));else if(p.type===$.AST_NODE_TYPES.TSIntersectionType)for(let u of p.types)u.type===$.AST_NODE_TYPES.TSTypeReference&&u.typeName.type===$.AST_NODE_TYPES.Identifier?n(!0,i,u.typeName,c,!1):o(!0,i,c,u,!0);if(c.size!==0&&l.init?.type===$.AST_NODE_TYPES.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===$.AST_NODE_TYPES.ObjectPattern&&s(u,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),ht={name:pn,rule:ni};var he=require("@typescript-eslint/utils"),ri=he.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="prefer-named-functions",un=new Map,ii=ri({name:fn,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=un.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),un.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===he.AST_NODE_TYPES.ArrowFunctionExpression&&n.id.type===he.AST_NODE_TYPES.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==he.AST_NODE_TYPES.BlockStatement)return;let a=n.parent,s=n.init.params,i=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(a,`${l.async?"async ":""}function ${o}(${s.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),Et={name:fn,rule:ii};var D=require("@typescript-eslint/utils");var si=L({disallowedFunctions:z(L({name:F(),allowUsingWithArgs:P(le()),hookAlternative:P(F()),message:P(F()),allowUseInside:P(z(F()))}))});function _e(e){return/^use[A-Z]/.test(e)}function mn(e){return/^[A-Z]/.test(e)}function oi(e){return e.type===D.AST_NODE_TYPES.Identifier?_e(e.name):e.type===D.AST_NODE_TYPES.MemberExpression&&e.property.type===D.AST_NODE_TYPES.Identifier?_e(e.property.name):!1}function dn(e,t){return e.type===D.AST_NODE_TYPES.Identifier?e.name===t:e.type===D.AST_NODE_TYPES.MemberExpression&&e.object.type===D.AST_NODE_TYPES.Identifier&&e.property.type===D.AST_NODE_TYPES.Identifier?e.object.name==="React"&&e.property.name===t:!1}function yn(e){return!!(e.parent&&e.parent.type===D.AST_NODE_TYPES.CallExpression&&dn(e.parent.callee,"forwardRef"))}function gn(e){return!!(e.parent&&e.parent.type===D.AST_NODE_TYPES.CallExpression&&dn(e.parent.callee,"memo"))}function bt(e){if(e.type===D.AST_NODE_TYPES.FunctionDeclaration||e.type===D.AST_NODE_TYPES.FunctionExpression&&e.id)return e.id||void 0;if(e.type===D.AST_NODE_TYPES.FunctionExpression||e.type===D.AST_NODE_TYPES.ArrowFunctionExpression){if(e.parent.type===D.AST_NODE_TYPES.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===D.AST_NODE_TYPES.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===D.AST_NODE_TYPES.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===D.AST_NODE_TYPES.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function ai(e){let t=e.parent,r=!1;for(;t;){if(t.type===D.AST_NODE_TYPES.FunctionDeclaration||t.type===D.AST_NODE_TYPES.FunctionExpression||t.type===D.AST_NODE_TYPES.ArrowFunctionExpression){let n=bt(t);if(n&&n.type===D.AST_NODE_TYPES.Identifier){if(mn(n.name)||_e(n.name))return!r;r=!0}else{if(yn(t)||gn(t))return!r;if(t.parent.type===D.AST_NODE_TYPES.CallExpression){let o=t.parent;oi(o.callee)||(r=!0)}else t.parent.type===D.AST_NODE_TYPES.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Sn(e){return e.callee.type===D.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===D.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===D.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function li(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===D.AST_NODE_TYPES.FunctionDeclaration||r.type===D.AST_NODE_TYPES.FunctionExpression||r.type===D.AST_NODE_TYPES.ArrowFunctionExpression){let n=bt(r);if(n&&n.type===D.AST_NODE_TYPES.Identifier&&t.includes(n.name))return!0}else if(r.type===D.AST_NODE_TYPES.CallExpression){let n=Sn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function ci(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===D.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function pi(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===D.AST_NODE_TYPES.FunctionDeclaration||n.type===D.AST_NODE_TYPES.FunctionExpression||n.type===D.AST_NODE_TYPES.ArrowFunctionExpression){let o=bt(n);if(o&&o.type===D.AST_NODE_TYPES.Identifier){if(mn(o.name)||_e(o.name)){r=!0;break}}else if(yn(n)||gn(n)){r=!0;break}}n=n.parent}return r?t.length===0?ai(e):!li(e,t):!1}var xt=se({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:[si],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=Sn(o);if(!a)return;let s=n.get(a);if(!s||s.allowUsingWithArgs&&ci(o))return;let i=s.allowUseInside||[];pi(o,i)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:s.message?` ${s.message}`:` use ${s.hookAlternative} instead`},suggest:s.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${s.hookAlternative}`,hookAlternative:s.hookAlternative},fix:l=>{let c=s.hookAlternative;return o.callee.type===D.AST_NODE_TYPES.Identifier?l.replaceText(o.callee,c):o.callee.type===D.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===D.AST_NODE_TYPES.Identifier?l.replaceText(o.callee.property,c):null}}]:[]})}}}});var Y=require("@typescript-eslint/utils");var ui=Y.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hn="prefer-single-line-if",fi=L({maxLineLength:P(Z()),maxNonSimpleConditionLength:P(Z())}),mi=ui({name:hn,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:[fi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==Y.AST_NODE_TYPES.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(a.type===Y.AST_NODE_TYPES.ReturnStatement){if(!bn(a))return}else if(!(a.type===Y.AST_NODE_TYPES.ContinueStatement||a.type===Y.AST_NODE_TYPES.BreakStatement))return;if(n.test.type===Y.AST_NODE_TYPES.LogicalExpression||n.test.type===Y.AST_NODE_TYPES.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=Tn(n.test);if(!u&&n.test.type===Y.AST_NODE_TYPES.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;Tn(g)&&(u=!0)}if(u&&(s=r.getText(n.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=r.getText(n.test));let i=r.getText(a);if(s.includes(`
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=l.acquire(x),v=new Set,O=null;{let f=R.upper;for(;f&&(v.add(f),f.type!=="function");)f=f.upper;if(!f)return;O=f}let b=Array.isArray;function U(f){if(!b(f.defs))return!1;let y=f.defs[0];if(y==null||y.node.type!=="VariableDeclarator")return!1;let E=y.node.init;if(E==null)return!1;for(;E.type==="TSAsExpression";)E=E.expression;let I=y.node.parent;if(I==null&&(Qe(O.block,y.node.id),I=y.node.parent,I==null))return!1;if(I.kind==="const"&&E.type==="Literal"&&(typeof E.value=="string"||typeof E.value=="number"||E.value===null))return!0;if(E.type!=="CallExpression")return!1;let k=E.callee;if(k.type==="MemberExpression"&&k.object.name==="React"&&k.property!=null&&!k.computed&&(k=k.property),k.type!=="Identifier")return!1;let C=y.node.id,{name:j}=k;if(j==="useRef"&&C.type==="Identifier")return!0;if(ur(k)&&C.type==="Identifier"){for(let M of f.references)M!==C&&S.add(M.identifier);return!0}else if(j==="useState"||j==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&b(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(j==="useState"){let M=f.references,ee=0;for(let ae=0;ae<M.length;ae++){if(M[ae].isWrite()&&ee++,ee>1)return!1;c.set(M[ae].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(j==="useState"){let M=f.references;for(let ee=0;ee<M.length;ee++)p.add(M[ee].identifier)}return!1}}}else if(j==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function B(f){if(!b(f.defs))return!1;let y=f.defs[0];if(y==null||y.node==null||y.node.id==null)return!1;let E=y.node,I=O.childScopes,k=null,C;for(C=0;C<I.length;C++){let j=I[C],M=j.block;if(E.type==="FunctionDeclaration"&&M===E||E.type==="VariableDeclarator"&&M.parent===E){k=j;break}}if(k==null)return!1;for(C=0;C<k.through.length;C++){let j=k.through[C];if(j.resolved!=null&&v.has(j.resolved.scope)&&!oe(j.resolved))return!1}return!0}let oe=h(U,u),Ve=h(B,g),Ie=new Map;function fe(f){let y=f.from,E=!1;for(;y.block!==x;)y.type==="function"&&(E=y.block.parent!=null&&y.block.parent.type==="ReturnStatement"),y=y.upper;return E}let q=new Map,re=new Map;we(R);function we(f){for(let y of f.references){if(!y.resolved||!v.has(y.resolved.scope))continue;let E=Qe(x,y.identifier),I=Ut(E),k=ce(I,re);if(A&&I.type==="Identifier"&&(I.parent.type==="MemberExpression"||I.parent.type==="OptionalMemberExpression")&&!I.parent.computed&&I.parent.property.type==="Identifier"&&I.parent.property.name==="current"&&fe(y)&&Ie.set(k,{reference:y,dependencyNode:I}),I.parent.type==="TSTypeQuery"||I.parent.type==="TSTypeReference")continue;let C=y.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===x.parent)&&C.type!=="TypeParameter")if(q.has(k))q.get(k).references.push(y);else{let j=y.resolved,M=oe(j)||Ve(j);q.set(k,{isStable:M,references:[y]})}}for(let y of f.childScopes)we(y)}Ie.forEach(({reference:f,dependencyNode:y},E)=>{let I=f.resolved.references,k=!1;for(let C=0;C<I.length;C++){let{identifier:j}=I[C],{parent:M}=j;if(M!=null&&M.type==="MemberExpression"&&!M.computed&&M.property.type==="Identifier"&&M.property.name==="current"&&M.parent.type==="AssignmentExpression"&&M.parent.left===M){k=!0;break}}k||i({node:y.parent.property,message:`The ref value '${E}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${E}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let We=new Set;function jn(f,y){We.has(y)||(We.add(y),i({node:f,message:`Assignments to the '${y}' variable from inside React Hook ${r(d)} 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(d)}.`}))}let Ce=new Set;if(q.forEach(({isStable:f,references:y},E)=>{f&&Ce.add(E),y.forEach(I=>{I.writeExpr&&jn(I.writeExpr,E)})}),We.size>0)return;if(!N){let f=null;if(q.forEach(({isStable:y,references:E},I)=>{f||E.forEach(k=>{if(f)return;let C=k.identifier;if(!c.has(C))return;let M=k.from;for(;M.type!=="function";)M=M.upper;M.block===x&&(f=I)})}),f){let{suggestedDependencies:y}=Ge({dependencies:q,declaredDependencies:[],stableDependencies:Ce,externalDependencies:new Set,isEffect:!0});i({node:d,message:`React Hook ${m} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+y.join(", ")+`] as a second argument to the ${m} Hook.`,suggest:[{desc:`Add dependencies array: [${y.join(", ")}]`,fix(E){return E.insertTextAfter(x,`, [${y.join(", ")}]`)}}]})}return}let Ee=[],be=new Set;N.type!=="ArrayExpression"?i({node:N,message:`React Hook ${r(d)} 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.`}):N.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(d)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}S.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(k){return k.removeRange(f.range)}}]});let y;try{y=ce(f,re)}catch(k){if(/Unsupported node type/.test(k.message)){f.type==="Literal"?q.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(d)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw k}let E=f;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let I=!O.through.some(k=>k.identifier===E);Ee.push({key:y,node:f}),I||be.add(y)});let{suggestedDependencies:Ln,unnecessaryDependencies:Re,missingDependencies:me,duplicateDependencies:At}=Ge({dependencies:q,declaredDependencies:Ee,stableDependencies:Ce,externalDependencies:be,isEffect:A}),Ae=Ln;if(At.size+me.size+Re.size===0){if(t)return;ar({declaredDependencies:Ee,declaredDependenciesNode:N,componentScope:O,scope:R}).forEach(({construction:y,isUsedOutsideOfHook:E,depType:I})=>{let k=I==="function"?"useCallback":"useMemo",C=I==="function"?"definition":"initialization",j=`wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,M=E?`To fix this, ${j}`:`Move it inside the ${m} callback. Alternatively, ${j}`,ee=I==="conditional"||I==="logical expression"?"could make":"makes",ae=`The '${y.name.name}' ${I} ${ee} the dependencies of ${m} Hook (at line ${N.loc.start.line}) change on every render. ${M}`,kt;E&&y.type==="Variable"&&I==="function"&&(kt=[{desc:`Wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,fix(vt){let[_n,$n]=k==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[vt.insertTextBefore(y.node.init,_n),vt.insertTextAfter(y.node.init,$n)]}}]),i({node:y.node,message:ae,suggest:kt})});return}!A&&me.size>0&&(Ae=Ge({dependencies:q,declaredDependencies:[],stableDependencies:Ce,externalDependencies:be,isEffect:A}).suggestedDependencies);function Mn(){if(Ee.length===0)return!0;let f=Ee.map(E=>E.key),y=f.slice().sort();return f.join(",")===y.join(",")}Mn()&&Ae.sort();function He(f){let y=f.split("."),E="";for(let I=0;I<y.length;I++){if(I!==0){let k=y.slice(0,I+1).join("."),C=re.get(k)===!0;E+=C?"?.":"."}E+=y[I]}return E}function ze(f,y,E,I){return f.size===0?null:(f.size>1?"":y+" ")+E+" "+(f.size>1?"dependencies":"dependency")+": "+cr(Array.from(f).sort().map(k=>"'"+He(k)+"'"))+`. Either ${I} ${f.size>1?"them":"it"} or remove the dependency array.`}let ie="";if(Re.size>0){let f=null;if(Array.from(Re.keys()).forEach(y=>{f===null&&y.endsWith(".current")&&(f=y)}),f!==null)ie=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(be.size>0){let y=Array.from(be)[0];R.set.has(y)||(ie=` Outer scope values like '${y}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ie&&me.has("props")){let f=q.get("props");if(f==null)return;let y=f.references;if(!Array.isArray(y))return;let E=!0;for(let I=0;I<y.length;I++){let k=y[I],C=Qe(O.block,k.identifier);if(!C){E=!1;break}let j=C.parent;if(j==null){E=!1;break}if(j.type!=="MemberExpression"&&j.type!=="OptionalMemberExpression"){E=!1;break}}E&&(ie=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${m} call and refer to those specific props inside ${r(d)}.`)}if(!ie&&me.size>0){let f=null;me.forEach(y=>{if(f)return;let E=O.set.get(y),I=q.get(y);if(I.references[0].resolved!==E)return;let k=E.defs[0];if(k==null||k.name==null||k.type!=="Parameter")return;let C=!1,j;for(let M=0;M<I.references.length;M++)if(j=I.references[M].identifier,j!=null&&j.parent!=null&&(j.parent.type==="CallExpression"||j.parent.type==="OptionalCallExpression")&&j.parent.callee===j){C=!0;break}C&&(f=y)}),f!==null&&(ie=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ie&&me.size>0){let f=null;if(me.forEach(y=>{if(f!==null)return;let I=q.get(y).references,k,C;for(let j=0;j<I.length;j++){for(k=I[j].identifier,C=k.parent;C!=null&&C!==O.block;){if(C.type==="CallExpression"){let M=c.get(C.callee);if(M!=null){if(M.name===y)f={missingDep:y,setter:C.callee.name,form:"updater"};else if(p.has(k))f={missingDep:y,setter:C.callee.name,form:"reducer"};else{let ee=I[j].resolved;if(ee!=null){let ae=ee.defs[0];ae!=null&&ae.type==="Parameter"&&(f={missingDep:y,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":ie=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":ie=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":ie=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:N,message:`React Hook ${r(d)} has `+(ze(me,"a","missing","include")||ze(Re,"an","unnecessary","exclude")||ze(At,"a","duplicate","omit"))+ie,suggest:[{desc:`Update the dependencies array to be: [${Ae.map(He).join(", ")}]`,fix(f){return f.replaceText(N,`[${Ae.map(He).join(", ")}]`)}}]})}function w(x){let N=lr(x.callee,s);if(N===-1)return;let d=x.arguments[N],m=x.callee,A=Vt(m).name,R=x.arguments[N+1],v=/Effect($|[^a-z])/g.test(A);if(!d){i({node:m,message:`React Hook ${A} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!v)){if(!R&&!v){(A==="useMemo"||A==="useCallback")&&i({node:m,message:`React Hook ${A} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(d.type){case"FunctionExpression":case"ArrowFunctionExpression":T(d,R,m,A,v);return;case"Identifier":if(!R||R.elements&&R.elements.some(U=>U&&U.type==="Identifier"&&U.name===d.name))return;let O=n(x).set.get(d.name);if(O==null||O.defs==null)return;let b=O.defs[0];if(!b||!b.node||b.type!=="Variable"&&b.type!=="FunctionName")break;switch(b.node.type){case"FunctionDeclaration":T(b.node,R,m,A,v);return;case"VariableDeclarator":let U=b.node.init;if(!U)break;switch(U.type){case"ArrowFunctionExpression":case"FunctionExpression":T(U,R,m,A,v);return}break}break;default:i({node:m,message:`React Hook ${A} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:m,message:`React Hook ${A} has a missing dependency: '${d.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${d.name}]`,fix(O){return O.replaceText(R,`[${d.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let x of e.sourceCode.getAllComments())if(or.test(x.value))return t=!0,{CallExpression:N=>w(N,!0)}}return{CallExpression:x=>w(x)}}};function Ge({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,w)=>{let x=i(a,w);x.isUsed=!0,l(a,w,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:T})=>{let w=i(a,T);w.isSatisfiedRecursively=!0}),r.forEach(T=>{let w=i(a,T);w.isSatisfiedRecursively=!0});function i(T,w){let x=w.split("."),N=T;for(let d of x){let m=N.children.get(d);m||(m=s(),N.children.set(d,m)),N=m}return N}function l(T,w,x){let N=w.split("."),d=T;for(let m of N){let A=d.children.get(m);if(!A)return;x(A),d=A}}let c=new Set,p=new Set;u(a,c,p,T=>T);function u(T,w,x,N){T.children.forEach((d,m)=>{let A=N(m);if(d.isSatisfiedRecursively){d.isSubtreeUsed&&x.add(A);return}if(d.isUsed){w.add(A);return}u(d,w,x,R=>A+"."+R)})}let g=[],S=new Set,h=new Set;return t.forEach(({key:T})=>{p.has(T)?g.indexOf(T)===-1?g.push(T):h.add(T):S.add(T)}),c.forEach(T=>{g.push(T)}),{suggestedDependencies:g,unnecessaryDependencies:S,duplicateDependencies:h,missingDependencies:c}}function de(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 de(e.consequent)!=null||de(e.alternate)!=null?"conditional":null;case"LogicalExpression":return de(e.left)!=null||de(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return de(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return de(e.expression);case"TSAsExpression":return de(e.expression)}return null}function ar({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:s})=>{let i=r.variables.find(c=>c.name===s);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=de(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(s){let i=!1;for(let l=0;l<s.references.length;l++){let c=s.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==n&&p!=null;)p=p.upper;if(p!==n&&!Wt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}function Ut(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)?Ut(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ze(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function ce(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=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Ze(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Ze(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=ce(r.object,t),o=ce(r.property,null),a=`${n}.${o}`;return Ze(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Vt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function lr(e,t){let r=Vt(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=ce(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(n)?0:-1}else return-1}}function Qe(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),pr(n,t))return n;if(Wt(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(_t(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(s=>{_t(s)&&(s.parent=n,r.push(s))}))}return null}function cr(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 _t(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function pr(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 Wt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function ur(e){return!1}var ye=require("@typescript-eslint/utils");var J=ve(require("typescript")),fr=ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="improved-no-unnecessary-condition",mr=L({}),dr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],yr=new Set(dr),et={name:Ht,rule:fr({name:Ht,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[mr]},defaultOptions:[{}],create(e){let t=ye.ESLintUtils.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===ye.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&J.default.TypeFlags.Any||i.flags&J.default.TypeFlags.Unknown?null:i.flags&J.default.TypeFlags.StringLike?["string"]:i.flags&J.default.TypeFlags.NumberLike?["number"]:i.flags&J.default.TypeFlags.BigIntLike?["bigint"]:i.flags&J.default.TypeFlags.BooleanLike?["boolean"]:i.flags&J.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&J.default.TypeFlags.Undefined||i.flags&J.default.TypeFlags.Void?["undefined"]:i.flags&J.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&J.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&J.default.TypeFlags.NonPrimitive?["object"]:i.flags&J.default.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=r.getTypeAtLocation(l.expression);if(c.flags&J.default.TypeFlags.Any||c.flags&J.default.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let g of c.types){let S=o(g);if(S)p.push(...S);else return null}return p}let u=o(c);return u?(p.push(...u),p):null}function s(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(n(i.left)?(c=i.left,p=i.right.type===ye.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(c=i.right,p=i.left.type===ye.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!gr(p,yr))return;let u=a(c);if(!u)return;let g=i.operator==="!==",S=u.includes(p);u.length===1?S&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Se(c,e),type:p}}):!S&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Se(c,e),type:Array.from(u)[0]}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Se(c,e),actualType:Fe(u),conditionType:p}}):S&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Se(c,e),actualType:Fe(u),conditionType:p}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Se(c,e),actualType:Fe(u),conditionType:p}}):!S&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Se(c,e),type:Fe(u)}})}return{BinaryExpression:s}}})};function Fe(e){return Array.from(new Set(e)).join(" | ")||"never"}function Se(e,t){let r=e.argument;return r.type===ye.AST_NODE_TYPES.Identifier?r.name:t.sourceCode.getText(r)}function gr(e,t){return t.has(e)}var Ne=require("@typescript-eslint/utils");var Sr=Ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="no-call-with-explicit-generics",Tr=L({functions:z(F())}),hr=Sr({name:zt,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:[Tr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===Ne.AST_NODE_TYPES.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),tt={name:zt,rule:hr};var ge=require("@typescript-eslint/utils"),Er=ge.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="no-call-with-inferred-generics",br=Er({name:Yt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:o}=n;if(o.type!==ge.AST_NODE_TYPES.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(s||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&n.typeArguments?.params?.some(p=>!i&&p.type===ge.AST_NODE_TYPES.TSAnyKeyword||l&&p.type===ge.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===ge.AST_NODE_TYPES.Identifier&&l.includes(p.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),nt={name:Yt,rule:br};var Xt=require("@typescript-eslint/utils"),xr=Xt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="no-commented-out-code",Ir=["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:"],wr=[") {","return;",/^\s*return\s+/,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",/\w=("|'|`)/,");",/\w+:\s*('|"|`)/,/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,/\w+-\w+:/,/\w+_\w+:/,"&&","||","()",/\?\s+\w/,/:\s+\w/,/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,/^\s*\d+[,}]/,/^\s*\[[^\]]*\][,}]/,/^\s*\{[^}]*\}[,}]/,/\.\w+\(/,/\[\w+\]/,"?.(","??","=>",/^\s*(['"`]).+?\1\s*:/],Cr=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Bt=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Rr=xr({name:qt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,o){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||/^\s*[*\s]*$/.test(n))return!1;for(let s of Bt)if(a.startsWith(s))return!1;if(n.includes("https://"))return!1;if(o==="Block"){for(let s of Cr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of Ir)if(a.startsWith(s))return{wrongPattern:s};for(let s of wr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}function r(n,o){let a=n,s=a.trim();if(s.startsWith("`")&&(s.endsWith("`,")||s.endsWith("`;")||s.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let c=a.split(/```[\s\S]*?```/g);c.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=c.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(c=>/[a-zA-Z0-9]/.test(c))?i.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let s=r(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Bt.join(", ")}})}}}}}),rt={name:qt,rule:Rr};var De=require("@typescript-eslint/utils"),Ar=De.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-default-export",kr=Ar({name:Jt,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===De.TSESTree.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),it={name:Jt,rule:kr};var Kt=require("@typescript-eslint/utils"),vr=Kt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="no-leaked-text-in-jsx",Or=[",",";","[","]","(",")"],Pr=vr({name:Gt,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="";Or.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),st={name:Gt,rule:Pr};var pe=require("@typescript-eslint/utils"),Fr=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="no-non-camel-case-functions",Nr=/^[a-z][a-zA-Z0-9]*$/;function Zt(e){return e.typeName.type===pe.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===pe.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===pe.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var Dr=Fr({name:Qt,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&&!Nr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===pe.AST_NODE_TYPES.TSTypeReference?Zt(r):r.type===pe.AST_NODE_TYPES.TSUnionType&&r.types.some(o=>o.type===pe.AST_NODE_TYPES.TSTypeReference&&Zt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ot={name:Qt,rule:Dr};var V=require("@typescript-eslint/utils");var at=require("@typescript-eslint/utils");function Te(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Te(e.parent,t,r===1/0?r:r-1)}function*lt(e){yield e,e.parent&&(yield*lt(e.parent))}function ct(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function en(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===at.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===at.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var jr=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-optional-root-props",Lr=jr({name:tn,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let s=a.references[0];if(!s)return!1;for(let i of lt(s.identifier)){if("returnType"in i||i.type===V.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===V.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===V.TSESTree.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===V.TSESTree.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=Te(l.parent.parent,V.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=je(p,e.sourceCode);return u?!(u.parent.type===V.TSESTree.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===V.TSESTree.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===V.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===V.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let c=Te(l,V.TSESTree.AST_NODE_TYPES.VariableDeclaration);return c?!!je(c,e.sourceCode):!1}if(l.type===V.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!je(l,e.sourceCode)}return!1}function r(n){n.key.type!==V.TSESTree.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Te(n,V.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let s=e.sourceCode.getText(a);return o.replaceText(a,s.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===V.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Le(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Le(n)||!t(n)))for(let o of n.body.body)o.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==V.TSESTree.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==V.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=Te(n.parent,V.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=je(a,e.sourceCode);if(!(!s||s.parent.type===V.TSESTree.AST_NODE_TYPES.CallExpression&&s.parent.callee.type===V.TSESTree.AST_NODE_TYPES.Identifier&&s.parent.callee.name==="memo"))for(let l of o.members)l.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Le(e){return e?e.parent?.type===V.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===V.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function je(e,t){if(Le(e))return;let r;if(e.type===V.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===V.TSESTree.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===V.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(s=>s.identifiers.includes(r));if(!o)return;let a=o.references.filter(s=>s.identifier!==r);if(!(a.length!==1||!a[0])&&!Le(a[0].identifier.parent.parent))return a[0].identifier}var pt={name:tn,rule:Lr};var nn=require("@typescript-eslint/utils"),Me=ve(require("path"));var Mr=nn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rn="no-relative-imports",_r=L({find:F(),replacement:F()}),$r=L({aliases:z(_r),rootDir:P(F()),allowNotFoundAliases:P(le()),_dev_simulateFileName:P(F())}),Ur=Mr({name:rn,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:[$r]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=Me.default.dirname(i);return Me.default.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=Me.default.relative(i,s);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let u=l.replace(p,c);return{alias:c,newPath:u}}return null}return{ImportDeclaration(s){let i=s.source.value;if(!n(i))return;let l=o(i,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:s,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(s.source,`'${c.newPath}'`):void 0})}}}}),ut={name:rn,rule:Ur};var ue=require("@typescript-eslint/utils");var ft=ve(require("typescript")),Vr=ue.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="no-unnecessary-casting",Wr=L({additionalCastFunctions:P(z(L({name:F(),expectedType:Oe(["string","number"])})))}),mt={name:sn,rule:Vr({name:sn,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:[Wr],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=ue.ESLintUtils.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function s(p,u){switch(p.type){case ue.AST_NODE_TYPES.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case ue.AST_NODE_TYPES.TemplateLiteral:return u==="string";case ue.AST_NODE_TYPES.UnaryExpression:return u==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,u){return u==="number"?!!(p.flags&ft.TypeFlags.NumberLike):!!(p.flags&ft.TypeFlags.StringLike)}function l(p,u){return g=>g.replaceText(p,e.sourceCode.getText(u))}function c(p){if(!a||p.arguments.length!==1)return;let u=p.arguments[0];if(!u||u.type===ue.AST_NODE_TYPES.SpreadElement)return;let{callee:g}=p;if(g.type!==ue.AST_NODE_TYPES.Identifier)return;let S=g.name,h=n.find(w=>w.name===S);if(!h)return;if(s(u,h.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),h.expectedType)){let w,x;S==="Number"?w="unnecessaryNumberCasting":S==="String"?w="unnecessaryStringCasting":(w="unnecessaryCustomCasting",x={name:h.name,type:h.expectedType}),e.report({node:p,messageId:w,...x?{data:x}:{},fix:l(p,u)})}}return{CallExpression:c}}})};var xe=require("@typescript-eslint/utils"),ne=ve(require("zod/v4"));var Hr=ne.object({methods:ne.union([ne.array(ne.string()),ne.literal("array")])}),dt=se({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:[ne.toJSONSchema(Hr)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===xe.AST_NODE_TYPES.MemberExpression){let c=l.property;if(c.type===xe.AST_NODE_TYPES.Identifier)return c.name}return null}function s(i,l){if(i.type!==xe.AST_NODE_TYPES.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===xe.AST_NODE_TYPES.CallExpression){let p=a(c);p&&o(p)&&c.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(g){return g.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)s(l,i)},FunctionExpression(i){for(let l of i.params)s(l,i)}}}});var G=require("@typescript-eslint/utils");var yt=se({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===G.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==G.AST_NODE_TYPES.ObjectExpression||t.id.type===G.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===G.AST_NODE_TYPES.ExportNamedDeclaration)return;let r=new Map;for(let s of t.init.properties)s.type===G.AST_NODE_TYPES.Property&&s.key.type===G.AST_NODE_TYPES.Identifier&&r.set(s.key.name,s);if(r.size===0||t.id.type!==G.AST_NODE_TYPES.Identifier)return;let n=zr(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(s=>s.type!==G.AST_NODE_TYPES.Property?!1:s.value.type===G.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let s of n){if(s.identifier.parent.type!==G.AST_NODE_TYPES.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===G.AST_NODE_TYPES.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==G.AST_NODE_TYPES.Identifier)return;a.add(i.property.name)}if(i.parent.type===G.AST_NODE_TYPES.CallExpression&&o)return}for(let[s,i]of r)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function zr(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var W=require("@typescript-eslint/utils");var Yr=L({selectors:z(L({name:F(),selectorProp:P(F()),selectorArgPos:P(Z()),returnProp:P(F())}))}),Br=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-unused-selected-values",gt={name:on,rule:Br({name:on,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Yr]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===W.AST_NODE_TYPES.CallExpression&&(a=o.init),!a)return;let s=qr(a);if(!s)return;let i=n.get(s);if(!i)return;let l=Xr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=Jr(l);if(!c)return;let p=an(c.properties,void 0);if(!p)return;if(o.id.type===W.AST_NODE_TYPES.ObjectPattern){let S=an(o.id.properties,i.returnProp);if(!S)return;for(let[h,T]of p)S.has(h)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:h}});return}if(o.id.type!==W.AST_NODE_TYPES.Identifier||i.returnProp)return;let u=Kr(o,e.sourceCode);if(u.length===0)return;let g=new Set;for(let S of u){if(S.identifier.parent.type!==W.AST_NODE_TYPES.MemberExpression)return;let h=S.identifier.parent.property;if(h.type!==W.AST_NODE_TYPES.Identifier)return;g.add(h.name)}for(let[S,h]of p)g.has(S)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:S}})}}}})};function Xr(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===W.AST_NODE_TYPES.ArrowFunctionExpression||n.type===W.AST_NODE_TYPES.FunctionExpression)return n;if(r&&n.type===W.AST_NODE_TYPES.ObjectExpression){let o=n.properties.find(s=>s.type===W.AST_NODE_TYPES.Property&&s.key.type===W.AST_NODE_TYPES.Identifier&&s.key.name===r);if(o?.type!==W.AST_NODE_TYPES.Property)return null;let a=o.value;if(a.type===W.AST_NODE_TYPES.ArrowFunctionExpression||a.type===W.AST_NODE_TYPES.FunctionExpression)return a}return null}function qr(e){return e.callee.type===W.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===W.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===W.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Jr(e){if(e.body.type===W.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===W.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===W.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==W.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function an(e,t){let r=e;if(t){let o=e.find(a=>a.type===W.AST_NODE_TYPES.Property&&a.key.type===W.AST_NODE_TYPES.Identifier&&a.key.name===t);if(o?.type!==W.AST_NODE_TYPES.Property||o.value.type!==W.AST_NODE_TYPES.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==W.AST_NODE_TYPES.Property||o.key.type!==W.AST_NODE_TYPES.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function Kr(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var H=require("@typescript-eslint/utils");var St=se({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===H.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let i=Gr(a);i&&(n=i);return}let s=Zr(a,e.sourceCode);if(s){o=!0;for(let i of s)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function Gr(e){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==H.AST_NODE_TYPES.ObjectExpression)return null;let n=ct(r.properties,a=>a.type!==H.AST_NODE_TYPES.Property||a.key.type!==H.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===H.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===H.AST_NODE_TYPES.FunctionExpression?Qr(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===H.AST_NODE_TYPES.Property&&a.key.type===H.AST_NODE_TYPES.Identifier&&o.set(a.key.name,a);return o}function Zr(e,t){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==H.AST_NODE_TYPES.ObjectPattern||!ct(e.parent.id.properties,s=>s.type===H.AST_NODE_TYPES.Property&&s.key.type===H.AST_NODE_TYPES.Identifier&&s.key.name==="formFields"&&s))return null;let o=en(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==H.AST_NODE_TYPES.Identifier||s.parent.type===H.AST_NODE_TYPES.Property&&s.parent.parent.type===H.AST_NODE_TYPES.ObjectExpression&&s.parent.parent.parent.type===H.AST_NODE_TYPES.ReturnStatement||s.parent.type===H.AST_NODE_TYPES.ReturnStatement)return null;if(s.parent.type===H.AST_NODE_TYPES.MemberExpression){if(s.parent.object.type!==H.AST_NODE_TYPES.Identifier||s.parent.property.type!==H.AST_NODE_TYPES.Identifier)return null;a.add(s.parent.property.name)}}return a}function Qr(e){if(e.body.type===H.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===H.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===H.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var $=require("@typescript-eslint/utils");var ei=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function ln(e){let t=[];for(let r of e.members)r.type===$.AST_NODE_TYPES.TSPropertySignature&&r.key.type===$.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function cn(e,...t){for(let r of t)e.set(...r);return e}var ti=L({forceCheckOnFCPropTypesWithName:P(z(F()))}),pn="no-unused-type-props-in-args",Tt=null,ni=ei({name:pn,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[ti],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!Tt&&(Tt=r.map(i=>new RegExp(i)));function n(i,l,c,p,u=!0){let g=c.name,S=e.sourceCode.getScope(l).references.find(w=>w.identifier.name===g)?.resolved,h=i&&Tt?.some(w=>w.test(g));if(!S||!h&&S.references.filter(w=>w.isTypeReference).length>1)return;let T=S?.defs[0]?.node;if(!(u&&T?.parent?.type===$.AST_NODE_TYPES.ExportNamedDeclaration)){if(T?.type===$.AST_NODE_TYPES.TSTypeAliasDeclaration){o(i,l,p,T.typeAnnotation,!0);return}if(T?.type===$.AST_NODE_TYPES.TSInterfaceDeclaration){o(i,l,p,T.body,!0);return}}}function o(i,l,c,p,u){if(p.type===$.AST_NODE_TYPES.TSInterfaceBody){for(let g of p.body)g.type===$.AST_NODE_TYPES.TSPropertySignature&&g.key.type===$.AST_NODE_TYPES.Identifier&&c.set(g.key.name,g);return}if(p.type===$.AST_NODE_TYPES.TSTypeLiteral){cn(c,...ln(p));return}if(p.type===$.AST_NODE_TYPES.TSIntersectionType){for(let g of p.types)o(i,l,c,g,!0);return}u||p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier&&n(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let u=new Map;if(o(i,l,u,p.typeAnnotation.typeAnnotation,!1),u.size===0)continue;s(p,u)}else p.type===$.AST_NODE_TYPES.AssignmentPattern&&p.left.type===$.AST_NODE_TYPES.ObjectPattern&&a(i,l,[p.left])}function s(i,l){let c=[];if(i.properties.at(-1)?.type===$.AST_NODE_TYPES.RestElement)return;for(let S of i.properties)S.type===$.AST_NODE_TYPES.Property&&S.key.type===$.AST_NODE_TYPES.Identifier&&c.push(S.key.name);let u=[],g=[];for(let[S,h]of l)c.includes(S)||(g.push(S),u.push({node:h,messageId:"unusedObjectTypeProperty",data:{propertyName:S}}));for(let[S,h]of u.entries())e.report({...h,fix:S===u.length-1?T=>{let w=i.properties.at(-1),x=g.join(", ");return w?w?.type===$.AST_NODE_TYPES.RestElement?null:T.insertTextAfter(w,`, ${x}`):T.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${x}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let c=new Map,p=l.id.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===$.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(p){if(p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier)n(!0,i,p.typeName,c,!1);else if(p.type===$.AST_NODE_TYPES.TSTypeLiteral)cn(c,...ln(p));else if(p.type===$.AST_NODE_TYPES.TSIntersectionType)for(let u of p.types)u.type===$.AST_NODE_TYPES.TSTypeReference&&u.typeName.type===$.AST_NODE_TYPES.Identifier?n(!0,i,u.typeName,c,!1):o(!0,i,c,u,!0);if(c.size!==0&&l.init?.type===$.AST_NODE_TYPES.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===$.AST_NODE_TYPES.ObjectPattern&&s(u,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),ht={name:pn,rule:ni};var he=require("@typescript-eslint/utils"),ri=he.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="prefer-named-functions",un=new Map,ii=ri({name:fn,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=un.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),un.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===he.AST_NODE_TYPES.ArrowFunctionExpression&&n.id.type===he.AST_NODE_TYPES.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==he.AST_NODE_TYPES.BlockStatement)return;let a=n.parent,s=n.init.params,i=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(a,`${l.async?"async ":""}function ${o}(${s.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),Et={name:fn,rule:ii};var D=require("@typescript-eslint/utils");var si=L({disallowedFunctions:z(L({name:F(),allowUsingWithArgs:P(le()),hookAlternative:P(F()),message:P(F()),allowUseInside:P(z(F()))}))});function _e(e){return/^use[A-Z]/.test(e)}function mn(e){return/^[A-Z]/.test(e)}function oi(e){return e.type===D.AST_NODE_TYPES.Identifier?_e(e.name):e.type===D.AST_NODE_TYPES.MemberExpression&&e.property.type===D.AST_NODE_TYPES.Identifier?_e(e.property.name):!1}function dn(e,t){return e.type===D.AST_NODE_TYPES.Identifier?e.name===t:e.type===D.AST_NODE_TYPES.MemberExpression&&e.object.type===D.AST_NODE_TYPES.Identifier&&e.property.type===D.AST_NODE_TYPES.Identifier?e.object.name==="React"&&e.property.name===t:!1}function yn(e){return!!(e.parent&&e.parent.type===D.AST_NODE_TYPES.CallExpression&&dn(e.parent.callee,"forwardRef"))}function gn(e){return!!(e.parent&&e.parent.type===D.AST_NODE_TYPES.CallExpression&&dn(e.parent.callee,"memo"))}function bt(e){if(e.type===D.AST_NODE_TYPES.FunctionDeclaration||e.type===D.AST_NODE_TYPES.FunctionExpression&&e.id)return e.id||void 0;if(e.type===D.AST_NODE_TYPES.FunctionExpression||e.type===D.AST_NODE_TYPES.ArrowFunctionExpression){if(e.parent.type===D.AST_NODE_TYPES.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===D.AST_NODE_TYPES.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===D.AST_NODE_TYPES.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===D.AST_NODE_TYPES.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function ai(e){let t=e.parent,r=!1;for(;t;){if(t.type===D.AST_NODE_TYPES.FunctionDeclaration||t.type===D.AST_NODE_TYPES.FunctionExpression||t.type===D.AST_NODE_TYPES.ArrowFunctionExpression){let n=bt(t);if(n&&n.type===D.AST_NODE_TYPES.Identifier){if(mn(n.name)||_e(n.name))return!r;r=!0}else{if(yn(t)||gn(t))return!r;if(t.parent.type===D.AST_NODE_TYPES.CallExpression){let o=t.parent;oi(o.callee)||(r=!0)}else t.parent.type===D.AST_NODE_TYPES.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Sn(e){return e.callee.type===D.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===D.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===D.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function li(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===D.AST_NODE_TYPES.FunctionDeclaration||r.type===D.AST_NODE_TYPES.FunctionExpression||r.type===D.AST_NODE_TYPES.ArrowFunctionExpression){let n=bt(r);if(n&&n.type===D.AST_NODE_TYPES.Identifier&&t.includes(n.name))return!0}else if(r.type===D.AST_NODE_TYPES.CallExpression){let n=Sn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function ci(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===D.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function pi(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===D.AST_NODE_TYPES.FunctionDeclaration||n.type===D.AST_NODE_TYPES.FunctionExpression||n.type===D.AST_NODE_TYPES.ArrowFunctionExpression){let o=bt(n);if(o&&o.type===D.AST_NODE_TYPES.Identifier){if(mn(o.name)||_e(o.name)){r=!0;break}}else if(yn(n)||gn(n)){r=!0;break}}n=n.parent}return r?t.length===0?ai(e):!li(e,t):!1}var xt=se({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:[si],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=Sn(o);if(!a)return;let s=n.get(a);if(!s||s.allowUsingWithArgs&&ci(o))return;let i=s.allowUseInside||[];pi(o,i)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:s.message?` ${s.message}`:` use ${s.hookAlternative} instead`},suggest:s.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${s.hookAlternative}`,hookAlternative:s.hookAlternative},fix:l=>{let c=s.hookAlternative;return o.callee.type===D.AST_NODE_TYPES.Identifier?l.replaceText(o.callee,c):o.callee.type===D.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===D.AST_NODE_TYPES.Identifier?l.replaceText(o.callee.property,c):null}}]:[]})}}}});var Y=require("@typescript-eslint/utils");var ui=Y.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hn="prefer-single-line-if",fi=L({maxLineLength:P(Z()),maxNonSimpleConditionLength:P(Z())}),mi=ui({name:hn,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:[fi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==Y.AST_NODE_TYPES.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(a.type===Y.AST_NODE_TYPES.ReturnStatement){if(!bn(a))return}else if(!(a.type===Y.AST_NODE_TYPES.ContinueStatement||a.type===Y.AST_NODE_TYPES.BreakStatement))return;if(n.test.type===Y.AST_NODE_TYPES.LogicalExpression||n.test.type===Y.AST_NODE_TYPES.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=Tn(n.test);if(!u&&n.test.type===Y.AST_NODE_TYPES.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;Tn(g)&&(u=!0)}if(u&&(s=r.getText(n.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=r.getText(n.test));let i=r.getText(a);if(s.includes(`
|
|
16
16
|
`))return;let l=r.getTokenAfter(n);if(l&&l.type===Y.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let u=r.getTokenAfter(l);if(u&&u.type===Y.AST_TOKEN_TYPES.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=di(r,n),p=`if (${s}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:u=>u.replaceText(n,p)})}}}});function Tn(e){return e.type===Y.AST_NODE_TYPES.CallExpression||e.type===Y.AST_NODE_TYPES.BinaryExpression||e.type===Y.AST_NODE_TYPES.MemberExpression&&En(e)}function En(e){return e.object.type===Y.AST_NODE_TYPES.MemberExpression?En(e.object):e.object.type!==Y.AST_NODE_TYPES.Identifier}function di(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function bn(e){if(!e.argument)return!0;let t=e.argument;return t.type===Y.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===Y.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===Y.AST_NODE_TYPES.Literal||t.type===Y.AST_NODE_TYPES.Identifier||t.type===Y.AST_NODE_TYPES.TemplateLiteral||t.type===Y.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===Y.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===Y.AST_NODE_TYPES.UnaryExpression?bn(t):!1}var It={name:hn,rule:mi};var K=require("@typescript-eslint/utils");var yi=K.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xn="react-compiler-migration",gi=L({disallowHooks:P(z(L({name:F(),replacement:F()}))),disallowMethods:P(z(L({name:F(),replacement:P(F()),requireTrueProp:P(F())})))}),Si=/eslint +react-compiler\/react-compiler: +\["error/;function Ti(e){return e.type===K.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===K.AST_NODE_TYPES.MemberExpression&&e.property.type===K.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var hi=yi({name:xn,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:[gi]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Si.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===K.AST_NODE_TYPES.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===K.AST_NODE_TYPES.MemberExpression&&n.callee.property.type===K.AST_NODE_TYPES.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let s=t.disallowHooks.find(i=>i.name===o);s&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:i=>i.replaceText(a,s.replacement)}]})}}if(t.disallowMethods?.length&&Ti(n.callee)){for(let o of n.arguments)if(o.type===K.AST_NODE_TYPES.ObjectExpression){for(let a of o.properties)if(a.type===K.AST_NODE_TYPES.Property&&a.key.type===K.AST_NODE_TYPES.Identifier){let s=a.key.name,i=t.disallowMethods.find(l=>l.name===s);if(i){if(i.requireTrueProp){let l=i.requireTrueProp,c=!1;for(let p of o.properties)if(p.type===K.AST_NODE_TYPES.Property&&p.key.type===K.AST_NODE_TYPES.Identifier&&p.key.name===l&&p.value.type===K.AST_NODE_TYPES.Literal&&p.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:l}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),wt={name:xn,rule:hi};var $e=require("@typescript-eslint/utils"),Ei=$e.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),In="require-description",bi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,xi=/^eslint-disable-(next-)?line$/u,Ii=Ei({name:In,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let o of r.getAllComments()){let a=wi(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Ri(o.loc),messageId:"missingDescription"}))}}}}}),wn={name:In,rule:Ii};function wi(e){let{text:t,description:r}=Ci(e.value);if(!t)return null;let n=bi.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=xi.test(o);if(e.type===$e.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let s=t.slice(n.index+o.length);return{kind:o,value:s.trim(),description:r}}function Ci(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Ri(e){return{start:{line:e.start.line,column:-1},end:e.end}}function An(e){return/^use[A-Z0-9]/.test(e)}function Ue(e){return e.type==="Identifier"?An(e.name):e.type==="MemberExpression"&&!e.computed&&Ue(e.property)?e.object.type==="Identifier":!1}function kn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function vn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function On(e){return!!(e.parent&&e.parent.callee&&vn(e.parent.callee,"forwardRef"))}function Pn(e){return!!(e.parent&&e.parent.callee&&vn(e.parent.callee,"memo"))}function Ct(e){for(;e;){let t=Nn(e);if(t&&(kn(t)||Ue(t))||On(e)||Pn(e))return!0;e=e.parent}return!1}function Cn(e){return!1}function Rt(e){return!1}var Ai=/eslint +react-compiler\/react-compiler: +\["error/,Fn={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(Ai.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,o=[],a=[],s=new WeakSet;function i(l){for(let c of l.references){let p=c.identifier.parent;if(p.type==="VariableDeclarator"&&p.init&&p.init.type==="CallExpression"&&p.init.callee&&Cn(p.init.callee))for(let u of c.resolved.references)u!==c&&s.add(u.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,c){let p=o.pop();if(p.size===0)return;let u=new Set;function g(m,A){let{cache:R}=g,v=R.get(m.id),O=new Set(A);if(O.has(m.id)){let b=[...O],U=b.slice(b.indexOf(m.id)+1);for(let B of U)u.add(B);return BigInt("0")}if(O.add(m.id),v!==void 0)return v;if(l.thrownSegments.includes(m))v=BigInt("0");else if(m.prevSegments.length===0)v=BigInt("1");else{v=BigInt("0");for(let b of m.prevSegments)v+=g(b,O)}return m.reachable&&v===BigInt("0")?R.delete(m.id):R.set(m.id,v),v}function S(m,A){let{cache:R}=S,v=R.get(m.id),O=new Set(A);if(O.has(m.id)){let b=Array.from(O),U=b.slice(b.indexOf(m.id)+1);for(let B of U)u.add(B);return BigInt("0")}if(O.add(m.id),v!==void 0)return v;if(l.thrownSegments.includes(m))v=BigInt("0");else if(m.nextSegments.length===0)v=BigInt("1");else{v=BigInt("0");for(let b of m.nextSegments)v+=S(b,O)}return R.set(m.id,v),v}function h(m){let{cache:A}=h,R=A.get(m.id);if(R===null)return 1/0;if(R!==void 0)return R;if(A.set(m.id,null),m.prevSegments.length===0)R=1;else{R=1/0;for(let v of m.prevSegments){let O=h(v);O<R&&(R=O)}R+=1}return A.set(m.id,R),R}g.cache=new Map,S.cache=new Map,h.cache=new Map;let T=S(l.initialSegment),w=Nn(c),x=Ct(c),N=w?kn(w)||Ue(w):On(c)||Pn(c),d=1/0;for(let m of l.finalSegments){if(!m.reachable)continue;let A=h(m);A<d&&(d=A)}for(let[m,A]of p){if(!m.reachable)continue;let R=m.nextSegments.length===0?d<=h(m):d<h(m),v=g(m)*S(m),O=u.has(m.id);for(let b of A)if(O&&!Rt(b)&&e.report({node:b,message:`React Hook "${t(b)}" 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.`}),N){if(c.async&&e.report({node:b,message:`React Hook "${t(b)}" cannot be called in an async function.`}),!O&&v!==T&&!Rt(b)){let B=`React Hook "${t(b)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:b,message:B})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let U=`React Hook "${t(b)}" 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:b,message:U})}else if(w){let U=`React Hook "${t(b)}" is called in function "${t(w)}" 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:b,message:U})}else if(c.type==="Program"){let U=`React Hook "${t(b)}" 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:b,message:U})}else if(x&&!Rt(b)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let B=c.parent;if(B.parent.type==="VariableDeclarator"&&An(B.parent.id.name))return}let U=`React Hook "${t(b)}" 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:b,message:U})}}},CallExpression(l){if(Ue(l.callee)){let c=Rn(o),p=Rn(a),u=c.get(p);u||(u=[],c.set(p,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Cn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&s.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(l){l===n&&(n=null)},FunctionDeclaration(l){Ct(l)&&i(r(l))},ArrowFunctionExpression(l){Ct(l)&&i(r(l))}}}};function Nn(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 Rn(e){return e[e.length-1]}var Dn={[ht.name]:ht.rule,[rt.name]:rt.rule,[nt.name]:nt.rule,"rules-of-hooks":Fn,"exhaustive-deps":$t,"require-description":wn.rule,[it.name]:it.rule,[ot.name]:ot.rule,[Et.name]:Et.rule,[qe.name]:qe.rule,[tt.name]:tt.rule,[ut.name]:ut.rule,[It.name]:It.rule,[pt.name]:pt.rule,[st.name]:st.rule,[Ke.name]:Ke.rule,[wt.name]:wt.rule,[Xe.name]:Xe.rule,[et.name]:et.rule,[mt.name]:mt.rule,[dt.name]:dt.rule,[gt.name]:gt.rule,[St.name]:St.rule,[yt.name]:yt.rule,[xt.name]:xt.rule};var ki={rules:Dn};0&&(module.exports={extendedLintPlugin});
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -12,5 +12,5 @@ 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 R=l.acquire(x),v=new Set,O=null;{let f=R.upper;for(;f&&(v.add(f),f.type!=="function");)f=f.upper;if(!f)return;O=f}let b=Array.isArray;function _(f){if(!b(f.defs))return!1;let y=f.defs[0];if(y==null||y.node.type!=="VariableDeclarator")return!1;let E=y.node.init;if(E==null)return!1;for(;E.type==="TSAsExpression";)E=E.expression;let I=y.node.parent;if(I==null&&(Be(O.block,y.node.id),I=y.node.parent,I==null))return!1;if(I.kind==="const"&&E.type==="Literal"&&(typeof E.value=="string"||typeof E.value=="number"||E.value===null))return!0;if(E.type!=="CallExpression")return!1;let k=E.callee;if(k.type==="MemberExpression"&&k.object.name==="React"&&k.property!=null&&!k.computed&&(k=k.property),k.type!=="Identifier")return!1;let C=y.node.id,{name:D}=k;if(D==="useRef"&&C.type==="Identifier")return!0;if(tr(k)&&C.type==="Identifier"){for(let M of f.references)M!==C&&S.add(M.identifier);return!0}else if(D==="useState"||D==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&b(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(D==="useState"){let M=f.references,Z=0;for(let ae=0;ae<M.length;ae++){if(M[ae].isWrite()&&Z++,Z>1)return!1;c.set(M[ae].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(D==="useState"){let M=f.references;for(let Z=0;Z<M.length;Z++)p.add(M[Z].identifier)}return!1}}}else if(D==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function Y(f){if(!b(f.defs))return!1;let y=f.defs[0];if(y==null||y.node==null||y.node.id==null)return!1;let E=y.node,I=O.childScopes,k=null,C;for(C=0;C<I.length;C++){let D=I[C],M=D.block;if(E.type==="FunctionDeclaration"&&M===E||E.type==="VariableDeclarator"&&M.parent===E){k=D;break}}if(k==null)return!1;for(C=0;C<k.through.length;C++){let D=k.through[C];if(D.resolved!=null&&v.has(D.resolved.scope)&&!oe(D.resolved))return!1}return!0}let oe=h(_,u),De=h(Y,g),he=new Map;function pe(f){let y=f.from,E=!1;for(;y.block!==x;)y.type==="function"&&(E=y.block.parent!=null&&y.block.parent.type==="ReturnStatement"),y=y.upper;return E}let X=new Map,re=new Map;Ee(R);function Ee(f){for(let y of f.references){if(!y.resolved||!v.has(y.resolved.scope))continue;let E=Be(x,y.identifier),I=Nt(E),k=ce(I,re);if(A&&I.type==="Identifier"&&(I.parent.type==="MemberExpression"||I.parent.type==="OptionalMemberExpression")&&!I.parent.computed&&I.parent.property.type==="Identifier"&&I.parent.property.name==="current"&&pe(y)&&he.set(k,{reference:y,dependencyNode:I}),I.parent.type==="TSTypeQuery"||I.parent.type==="TSTypeReference")continue;let C=y.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===x.parent)&&C.type!=="TypeParameter")if(X.has(k))X.get(k).references.push(y);else{let D=y.resolved,M=oe(D)||De(D);X.set(k,{isStable:M,references:[y]})}}for(let y of f.childScopes)Ee(y)}he.forEach(({reference:f,dependencyNode:y},E)=>{let I=f.resolved.references,k=!1;for(let C=0;C<I.length;C++){let{identifier:D}=I[C],{parent:M}=D;if(M!=null&&M.type==="MemberExpression"&&!M.computed&&M.property.type==="Identifier"&&M.property.name==="current"&&M.parent.type==="AssignmentExpression"&&M.parent.left===M){k=!0;break}}k||i({node:y.parent.property,message:`The ref value '${E}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${E}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let je=new Set;function vn(f,y){je.has(y)||(je.add(y),i({node:f,message:`Assignments to the '${y}' variable from inside React Hook ${r(d)} 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(d)}.`}))}let be=new Set;if(X.forEach(({isStable:f,references:y},E)=>{f&&be.add(E),y.forEach(I=>{I.writeExpr&&vn(I.writeExpr,E)})}),je.size>0)return;if(!N){let f=null;if(X.forEach(({isStable:y,references:E},I)=>{f||E.forEach(k=>{if(f)return;let C=k.identifier;if(!c.has(C))return;let M=k.from;for(;M.type!=="function";)M=M.upper;M.block===x&&(f=I)})}),f){let{suggestedDependencies:y}=ze({dependencies:X,declaredDependencies:[],stableDependencies:be,externalDependencies:new Set,isEffect:!0});i({node:d,message:`React Hook ${m} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+y.join(", ")+`] as a second argument to the ${m} Hook.`,suggest:[{desc:`Add dependencies array: [${y.join(", ")}]`,fix(E){return E.insertTextAfter(x,`, [${y.join(", ")}]`)}}]})}return}let ge=[],Se=new Set;N.type!=="ArrayExpression"?i({node:N,message:`React Hook ${r(d)} 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.`}):N.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(d)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}S.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(k){return k.removeRange(f.range)}}]});let y;try{y=ce(f,re)}catch(k){if(/Unsupported node type/.test(k.message)){f.type==="Literal"?X.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(d)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw k}let E=f;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let I=!O.through.some(k=>k.identifier===E);ge.push({key:y,node:f}),I||Se.add(y)});let{suggestedDependencies:On,unnecessaryDependencies:xe,missingDependencies:ue,duplicateDependencies:bt}=ze({dependencies:X,declaredDependencies:ge,stableDependencies:be,externalDependencies:Se,isEffect:A}),Ie=On;if(bt.size+ue.size+xe.size===0){if(t)return;Gn({declaredDependencies:ge,declaredDependenciesNode:N,componentScope:O,scope:R}).forEach(({construction:y,isUsedOutsideOfHook:E,depType:I})=>{let k=I==="function"?"useCallback":"useMemo",C=I==="function"?"definition":"initialization",D=`wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,M=E?`To fix this, ${D}`:`Move it inside the ${m} callback. Alternatively, ${D}`,Z=I==="conditional"||I==="logical expression"?"could make":"makes",ae=`The '${y.name.name}' ${I} ${Z} the dependencies of ${m} Hook (at line ${N.loc.start.line}) change on every render. ${M}`,xt;E&&y.type==="Variable"&&I==="function"&&(xt=[{desc:`Wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,fix(It){let[Fn,Nn]=k==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[It.insertTextBefore(y.node.init,Fn),It.insertTextAfter(y.node.init,Nn)]}}]),i({node:y.node,message:ae,suggest:xt})});return}!A&&ue.size>0&&(Ie=ze({dependencies:X,declaredDependencies:[],stableDependencies:be,externalDependencies:Se,isEffect:A}).suggestedDependencies);function Pn(){if(ge.length===0)return!0;let f=ge.map(E=>E.key),y=f.slice().sort();return f.join(",")===y.join(",")}Pn()&&Ie.sort();function Le(f){let y=f.split("."),E="";for(let I=0;I<y.length;I++){if(I!==0){let k=y.slice(0,I+1).join("."),C=re.get(k)===!0;E+=C?"?.":"."}E+=y[I]}return E}function Me(f,y,E,I){return f.size===0?null:(f.size>1?"":y+" ")+E+" "+(f.size>1?"dependencies":"dependency")+": "+Qn(Array.from(f).sort().map(k=>"'"+Le(k)+"'"))+`. Either ${I} ${f.size>1?"them":"it"} or remove the dependency array.`}let ie="";if(xe.size>0){let f=null;if(Array.from(xe.keys()).forEach(y=>{f===null&&y.endsWith(".current")&&(f=y)}),f!==null)ie=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Se.size>0){let y=Array.from(Se)[0];R.set.has(y)||(ie=` Outer scope values like '${y}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ie&&ue.has("props")){let f=X.get("props");if(f==null)return;let y=f.references;if(!Array.isArray(y))return;let E=!0;for(let I=0;I<y.length;I++){let k=y[I],C=Be(O.block,k.identifier);if(!C){E=!1;break}let D=C.parent;if(D==null){E=!1;break}if(D.type!=="MemberExpression"&&D.type!=="OptionalMemberExpression"){E=!1;break}}E&&(ie=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${m} call and refer to those specific props inside ${r(d)}.`)}if(!ie&&ue.size>0){let f=null;ue.forEach(y=>{if(f)return;let E=O.set.get(y),I=X.get(y);if(I.references[0].resolved!==E)return;let k=E.defs[0];if(k==null||k.name==null||k.type!=="Parameter")return;let C=!1,D;for(let M=0;M<I.references.length;M++)if(D=I.references[M].identifier,D!=null&&D.parent!=null&&(D.parent.type==="CallExpression"||D.parent.type==="OptionalCallExpression")&&D.parent.callee===D){C=!0;break}C&&(f=y)}),f!==null&&(ie=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ie&&ue.size>0){let f=null;if(ue.forEach(y=>{if(f!==null)return;let I=X.get(y).references,k,C;for(let D=0;D<I.length;D++){for(k=I[D].identifier,C=k.parent;C!=null&&C!==O.block;){if(C.type==="CallExpression"){let M=c.get(C.callee);if(M!=null){if(M.name===y)f={missingDep:y,setter:C.callee.name,form:"updater"};else if(p.has(k))f={missingDep:y,setter:C.callee.name,form:"reducer"};else{let Z=I[D].resolved;if(Z!=null){let ae=Z.defs[0];ae!=null&&ae.type==="Parameter"&&(f={missingDep:y,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":ie=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":ie=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":ie=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:N,message:`React Hook ${r(d)} has `+(Me(ue,"a","missing","include")||Me(xe,"an","unnecessary","exclude")||Me(bt,"a","duplicate","omit"))+ie,suggest:[{desc:`Update the dependencies array to be: [${Ie.map(Le).join(", ")}]`,fix(f){return f.replaceText(N,`[${Ie.map(Le).join(", ")}]`)}}]})}function w(x){let N=Zn(x.callee,s);if(N===-1)return;let d=x.arguments[N],m=x.callee,A=Dt(m).name,R=x.arguments[N+1],v=/Effect($|[^a-z])/g.test(A);if(!d){i({node:m,message:`React Hook ${A} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!v)){if(!R&&!v){(A==="useMemo"||A==="useCallback")&&i({node:m,message:`React Hook ${A} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(d.type){case"FunctionExpression":case"ArrowFunctionExpression":T(d,R,m,A,v);return;case"Identifier":if(!R||R.elements&&R.elements.some(_=>_&&_.type==="Identifier"&&_.name===d.name))return;let O=n(x).set.get(d.name);if(O==null||O.defs==null)return;let b=O.defs[0];if(!b||!b.node||b.type!=="Variable"&&b.type!=="FunctionName")break;switch(b.node.type){case"FunctionDeclaration":T(b.node,R,m,A,v);return;case"VariableDeclarator":let _=b.node.init;if(!_)break;switch(_.type){case"ArrowFunctionExpression":case"FunctionExpression":T(_,R,m,A,v);return}break}break;default:i({node:m,message:`React Hook ${A} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:m,message:`React Hook ${A} has a missing dependency: '${d.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${d.name}]`,fix(O){return O.replaceText(R,`[${d.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let x of e.sourceCode.getAllComments())if(Kn.test(x.value))return t=!0,{CallExpression:N=>w(N,!0)}}return{CallExpression:x=>w(x)}}};function ze({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,w)=>{let x=i(a,w);x.isUsed=!0,l(a,w,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:T})=>{let w=i(a,T);w.isSatisfiedRecursively=!0}),r.forEach(T=>{let w=i(a,T);w.isSatisfiedRecursively=!0});function i(T,w){let x=w.split("."),N=T;for(let d of x){let m=N.children.get(d);m||(m=s(),N.children.set(d,m)),N=m}return N}function l(T,w,x){let N=w.split("."),d=T;for(let m of N){let A=d.children.get(m);if(!A)return;x(A),d=A}}let c=new Set,p=new Set;u(a,c,p,T=>T);function u(T,w,x,N){T.children.forEach((d,m)=>{let A=N(m);if(d.isSatisfiedRecursively){d.isSubtreeUsed&&x.add(A);return}if(d.isUsed){w.add(A);return}u(d,w,x,R=>A+"."+R)})}let g=[],S=new Set,h=new Set;return t.forEach(({key:T})=>{p.has(T)?g.indexOf(T)===-1?g.push(T):h.add(T):S.add(T)}),c.forEach(T=>{g.push(T)}),{suggestedDependencies:g,unnecessaryDependencies:S,duplicateDependencies:h,missingDependencies:c}}function fe(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 fe(e.consequent)!=null||fe(e.alternate)!=null?"conditional":null;case"LogicalExpression":return fe(e.left)!=null||fe(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return fe(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return fe(e.expression);case"TSAsExpression":return fe(e.expression)}return null}function Gn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:s})=>{let i=r.variables.find(c=>c.name===s);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=fe(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(s){let i=!1;for(let l=0;l<s.references.length;l++){let c=s.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==n&&p!=null;)p=p.upper;if(p!==n&&!jt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}function Nt(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)?Nt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ye(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function ce(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=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Ye(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Ye(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=ce(r.object,t),o=ce(r.property,null),a=`${n}.${o}`;return Ye(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Dt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Zn(e,t){let r=Dt(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=ce(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(n)?0:-1}else return-1}}function Be(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),er(n,t))return n;if(jt(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(Pt(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(s=>{Pt(s)&&(s.parent=n,r.push(s))}))}return null}function Qn(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 Pt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function er(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 jt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function tr(e){return!1}import{AST_NODE_TYPES as Ae,ESLintUtils as Mt}from"@typescript-eslint/utils";import J from"typescript";var nr=Mt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="improved-no-unnecessary-condition",rr=j({}),ir=["string","number","bigint","boolean","symbol","undefined","object","function","never"],sr=new Set(ir),Xe={name:Lt,rule:nr({name:Lt,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[rr]},defaultOptions:[{}],create(e){let t=Mt.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===Ae.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&J.TypeFlags.Any||i.flags&J.TypeFlags.Unknown?null:i.flags&J.TypeFlags.StringLike?["string"]:i.flags&J.TypeFlags.NumberLike?["number"]:i.flags&J.TypeFlags.BigIntLike?["bigint"]:i.flags&J.TypeFlags.BooleanLike?["boolean"]:i.flags&J.TypeFlags.ESSymbolLike?["symbol"]:i.flags&J.TypeFlags.Undefined||i.flags&J.TypeFlags.Void?["undefined"]:i.flags&J.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&J.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&J.TypeFlags.NonPrimitive?["object"]:i.flags&J.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=r.getTypeAtLocation(l.expression);if(c.flags&J.TypeFlags.Any||c.flags&J.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let g of c.types){let S=o(g);if(S)p.push(...S);else return null}return p}let u=o(c);return u?(p.push(...u),p):null}function s(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(n(i.left)?(c=i.left,p=i.right.type===Ae.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(c=i.right,p=i.left.type===Ae.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!or(p,sr))return;let u=a(c);if(!u)return;let g=i.operator==="!==",S=u.includes(p);u.length===1?S&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:me(c,e),type:p}}):!S&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:me(c,e),type:Array.from(u)[0]}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:me(c,e),actualType:Re(u),conditionType:p}}):S&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:me(c,e),actualType:Re(u),conditionType:p}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:me(c,e),actualType:Re(u),conditionType:p}}):!S&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:me(c,e),type:Re(u)}})}return{BinaryExpression:s}}})};function Re(e){return Array.from(new Set(e)).join(" | ")||"never"}function me(e,t){let r=e.argument;return r.type===Ae.Identifier?r.name:t.sourceCode.getText(r)}function or(e,t){return t.has(e)}import{AST_NODE_TYPES as ar,ESLintUtils as lr}from"@typescript-eslint/utils";var cr=lr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="no-call-with-explicit-generics",pr=j({functions:V(F())}),ur=cr({name:_t,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:[pr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===ar.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),qe={name:_t,rule:ur};import{AST_NODE_TYPES as ke,ESLintUtils as fr}from"@typescript-eslint/utils";var mr=fr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="no-call-with-inferred-generics",dr=mr({name:$t,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:o}=n;if(o.type!==ke.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(s||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&n.typeArguments?.params?.some(p=>!i&&p.type===ke.TSAnyKeyword||l&&p.type===ke.TSTypeReference&&p.typeName.type===ke.Identifier&&l.includes(p.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),Je={name:$t,rule:dr};import{ESLintUtils as yr}from"@typescript-eslint/utils";var gr=yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vt="no-commented-out-code",Sr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await "],Tr=[") {","return;",/^\s*return\s+/,"if (","else {","else if (","for (","while (","switch (","case ","default:","/>","</","< ","},",": {"," } = ","={",/\w=("|'|`)/,");",/\w+:\s*('|"|`)/,/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,/\w+-\w+:/,/\w+_\w+:/,"&&","||","()",/\?\s+\w/,/:\s+\w/,/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,/^\s*\d+[,}]/,/^\s*\[[^\]]*\][,}]/,/^\s*\{[^}]*\}[,}]/,/\.\w+\(/,/\[\w+\]/,"?.(","??","=>",/^\s*(['"`]).+?\1\s*:/],hr=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Ut=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Er=gr({name:Vt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,o){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||/^\s*[*\s]*$/.test(n))return!1;for(let s of Ut)if(a.startsWith(s))return!1;if(n.includes("https://"))return!1;if(o==="Block"){for(let s of hr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of Sr)if(a.startsWith(s))return{wrongPattern:s};for(let s of Tr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}function r(n,o){let a=n,s=a.trim();if(s.startsWith("`")&&(s.endsWith("`,")||s.endsWith("`;")||s.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let c=a.split(/```[\s\S]*?```/g);c.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=c.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(c=>/[a-zA-Z0-9]/.test(c))?i.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let s=r(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Ut.join(", ")}})}}}}}),Ke={name:Vt,rule:Er};import{ESLintUtils as br,TSESTree as xr}from"@typescript-eslint/utils";var Ir=br.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="no-default-export",wr=Ir({name:Wt,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===xr.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Ge={name:Wt,rule:wr};import{ESLintUtils as Cr}from"@typescript-eslint/utils";var Rr=Cr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="no-leaked-text-in-jsx",Ar=[",",";","[","]","(",")"],kr=Rr({name:Ht,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="";Ar.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),Ze={name:Ht,rule:kr};import{AST_NODE_TYPES as de,ESLintUtils as vr}from"@typescript-eslint/utils";var Or=vr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="no-non-camel-case-functions",Pr=/^[a-z][a-zA-Z0-9]*$/;function zt(e){return e.typeName.type===de.TSQualifiedName&&e.typeName.left.type===de.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===de.Identifier&&e.typeName.right.name==="Element"}var Fr=Or({name:Yt,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&&!Pr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===de.TSTypeReference?zt(r):r.type===de.TSUnionType&&r.types.some(o=>o.type===de.TSTypeReference&&zt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Qe={name:Yt,rule:Fr};import{ESLintUtils as Nr,TSESTree as W}from"@typescript-eslint/utils";import{AST_NODE_TYPES as Bt}from"@typescript-eslint/utils";function ye(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:ye(e.parent,t,r===1/0?r:r-1)}function*et(e){yield e,e.parent&&(yield*et(e.parent))}function tt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function Xt(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Bt.Property&&a.identifiers[0]?.parent.key.type===Bt.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Dr=Nr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="no-optional-root-props",jr=Dr({name:qt,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let s=a.references[0];if(!s)return!1;for(let i of et(s.identifier)){if("returnType"in i||i.type===W.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===W.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===W.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===W.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=ye(l.parent.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=ve(p,e.sourceCode);return u?!(u.parent.type===W.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===W.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===W.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===W.AST_NODE_TYPES.ArrowFunctionExpression){let c=ye(l,W.AST_NODE_TYPES.VariableDeclaration);return c?!!ve(c,e.sourceCode):!1}if(l.type===W.AST_NODE_TYPES.FunctionDeclaration)return!!ve(l,e.sourceCode)}return!1}function r(n){n.key.type!==W.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=ye(n,W.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let s=e.sourceCode.getText(a);return o.replaceText(a,s.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===W.AST_NODE_TYPES.TSTypeLiteral&&!(Oe(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===W.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Oe(n)||!t(n)))for(let o of n.body.body)o.type===W.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==W.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==W.AST_NODE_TYPES.TSTypeLiteral)return;let a=ye(n.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=ve(a,e.sourceCode);if(!(!s||s.parent.type===W.AST_NODE_TYPES.CallExpression&&s.parent.callee.type===W.AST_NODE_TYPES.Identifier&&s.parent.callee.name==="memo"))for(let l of o.members)l.type===W.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Oe(e){return e?e.parent?.type===W.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===W.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function ve(e,t){if(Oe(e))return;let r;if(e.type===W.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===W.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===W.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(s=>s.identifiers.includes(r));if(!o)return;let a=o.references.filter(s=>s.identifier!==r);if(!(a.length!==1||!a[0])&&!Oe(a[0].identifier.parent.parent))return a[0].identifier}var nt={name:qt,rule:jr};import{ESLintUtils as Lr}from"@typescript-eslint/utils";import rt from"node:path";var Mr=Lr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-relative-imports",_r=j({find:F(),replacement:F()}),$r=j({aliases:V(_r),rootDir:P(F()),allowNotFoundAliases:P(le()),_dev_simulateFileName:P(F())}),Ur=Mr({name:Jt,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:[$r]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=rt.dirname(i);return rt.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=rt.relative(i,s);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let u=l.replace(p,c);return{alias:c,newPath:u}}return null}return{ImportDeclaration(s){let i=s.source.value;if(!n(i))return;let l=o(i,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:s,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(s.source,`'${c.newPath}'`):void 0})}}}}),it={name:Jt,rule:Ur};import{AST_NODE_TYPES as Te,ESLintUtils as Gt}from"@typescript-eslint/utils";import*as st from"typescript";var Vr=Gt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="no-unnecessary-casting",Wr=j({additionalCastFunctions:P(V(j({name:F(),expectedType:we(["string","number"])})))}),ot={name:Kt,rule:Vr({name:Kt,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:[Wr],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=Gt.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function s(p,u){switch(p.type){case Te.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case Te.TemplateLiteral:return u==="string";case Te.UnaryExpression:return u==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,u){return u==="number"?!!(p.flags&st.TypeFlags.NumberLike):!!(p.flags&st.TypeFlags.StringLike)}function l(p,u){return g=>g.replaceText(p,e.sourceCode.getText(u))}function c(p){if(!a||p.arguments.length!==1)return;let u=p.arguments[0];if(!u||u.type===Te.SpreadElement)return;let{callee:g}=p;if(g.type!==Te.Identifier)return;let S=g.name,h=n.find(w=>w.name===S);if(!h)return;if(s(u,h.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),h.expectedType)){let w,x;S==="Number"?w="unnecessaryNumberCasting":S==="String"?w="unnecessaryStringCasting":(w="unnecessaryCustomCasting",x={name:h.name,type:h.expectedType}),e.report({node:p,messageId:w,...x?{data:x}:{},fix:l(p,u)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as Pe}from"@typescript-eslint/utils";import*as te from"zod/v4";var Hr=te.object({methods:te.union([te.array(te.string()),te.literal("array")])}),at=se({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:[te.toJSONSchema(Hr)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===Pe.MemberExpression){let c=l.property;if(c.type===Pe.Identifier)return c.name}return null}function s(i,l){if(i.type!==Pe.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===Pe.CallExpression){let p=a(c);p&&o(p)&&c.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(g){return g.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)s(l,i)},FunctionExpression(i){for(let l of i.params)s(l,i)}}}});import{AST_NODE_TYPES as G}from"@typescript-eslint/utils";var lt=se({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===G.ObjectPattern||!t.init||t.init.type!==G.ObjectExpression||t.id.type===G.Identifier&&t.id.typeAnnotation||t.parent.parent.type===G.ExportNamedDeclaration)return;let r=new Map;for(let s of t.init.properties)s.type===G.Property&&s.key.type===G.Identifier&&r.set(s.key.name,s);if(r.size===0||t.id.type!==G.Identifier)return;let n=zr(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(s=>s.type!==G.Property?!1:s.value.type===G.FunctionExpression),a=new Set;for(let s of n){if(s.identifier.parent.type!==G.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===G.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==G.Identifier)return;a.add(i.property.name)}if(i.parent.type===G.CallExpression&&o)return}for(let[s,i]of r)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function zr(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as z,ESLintUtils as Yr}from"@typescript-eslint/utils";var Br=j({selectors:V(j({name:F(),selectorProp:P(F()),selectorArgPos:P(K()),returnProp:P(F())}))}),Xr=Yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-unused-selected-values",ct={name:Zt,rule:Xr({name:Zt,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Br]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===z.CallExpression&&(a=o.init),!a)return;let s=Jr(a);if(!s)return;let i=n.get(s);if(!i)return;let l=qr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=Kr(l);if(!c)return;let p=Qt(c.properties,void 0);if(!p)return;if(o.id.type===z.ObjectPattern){let S=Qt(o.id.properties,i.returnProp);if(!S)return;for(let[h,T]of p)S.has(h)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:h}});return}if(o.id.type!==z.Identifier||i.returnProp)return;let u=Gr(o,e.sourceCode);if(u.length===0)return;let g=new Set;for(let S of u){if(S.identifier.parent.type!==z.MemberExpression)return;let h=S.identifier.parent.property;if(h.type!==z.Identifier)return;g.add(h.name)}for(let[S,h]of p)g.has(S)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:S}})}}}})};function qr(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 o=n.properties.find(s=>s.type===z.Property&&s.key.type===z.Identifier&&s.key.name===r);if(o?.type!==z.Property)return null;let a=o.value;if(a.type===z.ArrowFunctionExpression||a.type===z.FunctionExpression)return a}return null}function Jr(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 Kr(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 Qt(e,t){let r=e;if(t){let o=e.find(a=>a.type===z.Property&&a.key.type===z.Identifier&&a.key.name===t);if(o?.type!==z.Property||o.value.type!==z.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==z.Property||o.key.type!==z.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function Gr(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as H}from"@typescript-eslint/utils";var pt=se({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===H.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let i=Zr(a);i&&(n=i);return}let s=Qr(a,e.sourceCode);if(s){o=!0;for(let i of s)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function Zr(e){if(!(e.callee.type===H.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==H.ObjectExpression)return null;let n=tt(r.properties,a=>a.type!==H.Property||a.key.type!==H.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.ObjectExpression?a.value:a.value.type===H.ArrowFunctionExpression||a.value.type===H.FunctionExpression?ei(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===H.Property&&a.key.type===H.Identifier&&o.set(a.key.name,a);return o}function Qr(e,t){if(!(e.callee.type===H.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.VariableDeclarator||e.parent.id.type!==H.ObjectPattern||!tt(e.parent.id.properties,s=>s.type===H.Property&&s.key.type===H.Identifier&&s.key.name==="formFields"&&s))return null;let o=Xt(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==H.Identifier||s.parent.type===H.Property&&s.parent.parent.type===H.ObjectExpression&&s.parent.parent.parent.type===H.ReturnStatement||s.parent.type===H.ReturnStatement)return null;if(s.parent.type===H.MemberExpression){if(s.parent.object.type!==H.Identifier||s.parent.property.type!==H.Identifier)return null;a.add(s.parent.property.name)}}return a}function ei(e){if(e.body.type===H.ObjectExpression)return e.body;if(e.body.type===H.BlockStatement){let t=e.body.body.filter(r=>r.type===H.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as U,ESLintUtils as ti}from"@typescript-eslint/utils";var ni=ti.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function en(e){let t=[];for(let r of e.members)r.type===U.TSPropertySignature&&r.key.type===U.Identifier&&t.push([r.key.name,r]);return t}function tn(e,...t){for(let r of t)e.set(...r);return e}var ri=j({forceCheckOnFCPropTypesWithName:P(V(F()))}),nn="no-unused-type-props-in-args",ut=null,ii=ni({name:nn,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:[ri],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!ut&&(ut=r.map(i=>new RegExp(i)));function n(i,l,c,p,u=!0){let g=c.name,S=e.sourceCode.getScope(l).references.find(w=>w.identifier.name===g)?.resolved,h=i&&ut?.some(w=>w.test(g));if(!S||!h&&S.references.filter(w=>w.isTypeReference).length>1)return;let T=S?.defs[0]?.node;if(!(u&&T?.parent?.type===U.ExportNamedDeclaration)){if(T?.type===U.TSTypeAliasDeclaration){o(i,l,p,T.typeAnnotation,!0);return}if(T?.type===U.TSInterfaceDeclaration){o(i,l,p,T.body,!0);return}}}function o(i,l,c,p,u){if(p.type===U.TSInterfaceBody){for(let g of p.body)g.type===U.TSPropertySignature&&g.key.type===U.Identifier&&c.set(g.key.name,g);return}if(p.type===U.TSTypeLiteral){tn(c,...en(p));return}if(p.type===U.TSIntersectionType){for(let g of p.types)o(i,l,c,g,!0);return}u||p.type===U.TSTypeReference&&p.typeName.type===U.Identifier&&n(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let u=new Map;if(o(i,l,u,p.typeAnnotation.typeAnnotation,!1),u.size===0)continue;s(p,u)}else p.type===U.AssignmentPattern&&p.left.type===U.ObjectPattern&&a(i,l,[p.left])}function s(i,l){let c=[];if(i.properties.at(-1)?.type===U.RestElement)return;for(let S of i.properties)S.type===U.Property&&S.key.type===U.Identifier&&c.push(S.key.name);let u=[],g=[];for(let[S,h]of l)c.includes(S)||(g.push(S),u.push({node:h,messageId:"unusedObjectTypeProperty",data:{propertyName:S}}));for(let[S,h]of u.entries())e.report({...h,fix:S===u.length-1?T=>{let w=i.properties.at(-1),x=g.join(", ");return w?w?.type===U.RestElement?null:T.insertTextAfter(w,`, ${x}`):T.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${x}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let c=new Map,p=l.id.type===U.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===U.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===U.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(p){if(p.type===U.TSTypeReference&&p.typeName.type===U.Identifier)n(!0,i,p.typeName,c,!1);else if(p.type===U.TSTypeLiteral)tn(c,...en(p));else if(p.type===U.TSIntersectionType)for(let u of p.types)u.type===U.TSTypeReference&&u.typeName.type===U.Identifier?n(!0,i,u.typeName,c,!1):o(!0,i,c,u,!0);if(c.size!==0&&l.init?.type===U.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===U.ObjectPattern&&s(u,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),ft={name:nn,rule:ii};import{AST_NODE_TYPES as mt,ESLintUtils as si}from"@typescript-eslint/utils";var oi=si.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="prefer-named-functions",rn=new Map,ai=oi({name:sn,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=rn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),rn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===mt.ArrowFunctionExpression&&n.id.type===mt.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==mt.BlockStatement)return;let a=n.parent,s=n.init.params,i=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(a,`${l.async?"async ":""}function ${o}(${s.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),dt={name:sn,rule:ai};import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";var li=j({disallowedFunctions:V(j({name:F(),allowUsingWithArgs:P(le()),hookAlternative:P(F()),message:P(F()),allowUseInside:P(V(F()))}))});function Fe(e){return/^use[A-Z]/.test(e)}function on(e){return/^[A-Z]/.test(e)}function ci(e){return e.type===L.Identifier?Fe(e.name):e.type===L.MemberExpression&&e.property.type===L.Identifier?Fe(e.property.name):!1}function an(e,t){return e.type===L.Identifier?e.name===t:e.type===L.MemberExpression&&e.object.type===L.Identifier&&e.property.type===L.Identifier?e.object.name==="React"&&e.property.name===t:!1}function ln(e){return!!(e.parent&&e.parent.type===L.CallExpression&&an(e.parent.callee,"forwardRef"))}function cn(e){return!!(e.parent&&e.parent.type===L.CallExpression&&an(e.parent.callee,"memo"))}function yt(e){if(e.type===L.FunctionDeclaration||e.type===L.FunctionExpression&&e.id)return e.id||void 0;if(e.type===L.FunctionExpression||e.type===L.ArrowFunctionExpression){if(e.parent.type===L.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===L.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===L.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===L.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function pi(e){let t=e.parent,r=!1;for(;t;){if(t.type===L.FunctionDeclaration||t.type===L.FunctionExpression||t.type===L.ArrowFunctionExpression){let n=yt(t);if(n&&n.type===L.Identifier){if(on(n.name)||Fe(n.name))return!r;r=!0}else{if(ln(t)||cn(t))return!r;if(t.parent.type===L.CallExpression){let o=t.parent;ci(o.callee)||(r=!0)}else t.parent.type===L.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function pn(e){return e.callee.type===L.Identifier?e.callee.name:e.callee.type===L.MemberExpression&&e.callee.property.type===L.Identifier?e.callee.property.name:null}function ui(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===L.FunctionDeclaration||r.type===L.FunctionExpression||r.type===L.ArrowFunctionExpression){let n=yt(r);if(n&&n.type===L.Identifier&&t.includes(n.name))return!0}else if(r.type===L.CallExpression){let n=pn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function fi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===L.Identifier&&t.name==="undefined")}function mi(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===L.FunctionDeclaration||n.type===L.FunctionExpression||n.type===L.ArrowFunctionExpression){let o=yt(n);if(o&&o.type===L.Identifier){if(on(o.name)||Fe(o.name)){r=!0;break}}else if(ln(n)||cn(n)){r=!0;break}}n=n.parent}return r?t.length===0?pi(e):!ui(e,t):!1}var gt=se({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:[li],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=pn(o);if(!a)return;let s=n.get(a);if(!s||s.allowUsingWithArgs&&fi(o))return;let i=s.allowUseInside||[];mi(o,i)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:s.message?` ${s.message}`:` use ${s.hookAlternative} instead`},suggest:s.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${s.hookAlternative}`,hookAlternative:s.hookAlternative},fix:l=>{let c=s.hookAlternative;return o.callee.type===L.Identifier?l.replaceText(o.callee,c):o.callee.type===L.MemberExpression&&o.callee.property.type===L.Identifier?l.replaceText(o.callee.property,c):null}}]:[]})}}}});import{AST_NODE_TYPES as B,AST_TOKEN_TYPES as un,ESLintUtils as di}from"@typescript-eslint/utils";var yi=di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="prefer-single-line-if",gi=j({maxLineLength:P(K()),maxNonSimpleConditionLength:P(K())}),Si=yi({name:mn,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:[gi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==B.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(a.type===B.ReturnStatement){if(!yn(a))return}else if(!(a.type===B.ContinueStatement||a.type===B.BreakStatement))return;if(n.test.type===B.LogicalExpression||n.test.type===B.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=fn(n.test);if(!u&&n.test.type===B.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;fn(g)&&(u=!0)}if(u&&(s=r.getText(n.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=r.getText(n.test));let i=r.getText(a);if(s.includes(`
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=l.acquire(x),v=new Set,O=null;{let f=R.upper;for(;f&&(v.add(f),f.type!=="function");)f=f.upper;if(!f)return;O=f}let b=Array.isArray;function _(f){if(!b(f.defs))return!1;let y=f.defs[0];if(y==null||y.node.type!=="VariableDeclarator")return!1;let E=y.node.init;if(E==null)return!1;for(;E.type==="TSAsExpression";)E=E.expression;let I=y.node.parent;if(I==null&&(Be(O.block,y.node.id),I=y.node.parent,I==null))return!1;if(I.kind==="const"&&E.type==="Literal"&&(typeof E.value=="string"||typeof E.value=="number"||E.value===null))return!0;if(E.type!=="CallExpression")return!1;let k=E.callee;if(k.type==="MemberExpression"&&k.object.name==="React"&&k.property!=null&&!k.computed&&(k=k.property),k.type!=="Identifier")return!1;let C=y.node.id,{name:D}=k;if(D==="useRef"&&C.type==="Identifier")return!0;if(tr(k)&&C.type==="Identifier"){for(let M of f.references)M!==C&&S.add(M.identifier);return!0}else if(D==="useState"||D==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&b(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(D==="useState"){let M=f.references,Z=0;for(let ae=0;ae<M.length;ae++){if(M[ae].isWrite()&&Z++,Z>1)return!1;c.set(M[ae].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(D==="useState"){let M=f.references;for(let Z=0;Z<M.length;Z++)p.add(M[Z].identifier)}return!1}}}else if(D==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function Y(f){if(!b(f.defs))return!1;let y=f.defs[0];if(y==null||y.node==null||y.node.id==null)return!1;let E=y.node,I=O.childScopes,k=null,C;for(C=0;C<I.length;C++){let D=I[C],M=D.block;if(E.type==="FunctionDeclaration"&&M===E||E.type==="VariableDeclarator"&&M.parent===E){k=D;break}}if(k==null)return!1;for(C=0;C<k.through.length;C++){let D=k.through[C];if(D.resolved!=null&&v.has(D.resolved.scope)&&!oe(D.resolved))return!1}return!0}let oe=h(_,u),De=h(Y,g),he=new Map;function pe(f){let y=f.from,E=!1;for(;y.block!==x;)y.type==="function"&&(E=y.block.parent!=null&&y.block.parent.type==="ReturnStatement"),y=y.upper;return E}let X=new Map,re=new Map;Ee(R);function Ee(f){for(let y of f.references){if(!y.resolved||!v.has(y.resolved.scope))continue;let E=Be(x,y.identifier),I=Nt(E),k=ce(I,re);if(A&&I.type==="Identifier"&&(I.parent.type==="MemberExpression"||I.parent.type==="OptionalMemberExpression")&&!I.parent.computed&&I.parent.property.type==="Identifier"&&I.parent.property.name==="current"&&pe(y)&&he.set(k,{reference:y,dependencyNode:I}),I.parent.type==="TSTypeQuery"||I.parent.type==="TSTypeReference")continue;let C=y.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===x.parent)&&C.type!=="TypeParameter")if(X.has(k))X.get(k).references.push(y);else{let D=y.resolved,M=oe(D)||De(D);X.set(k,{isStable:M,references:[y]})}}for(let y of f.childScopes)Ee(y)}he.forEach(({reference:f,dependencyNode:y},E)=>{let I=f.resolved.references,k=!1;for(let C=0;C<I.length;C++){let{identifier:D}=I[C],{parent:M}=D;if(M!=null&&M.type==="MemberExpression"&&!M.computed&&M.property.type==="Identifier"&&M.property.name==="current"&&M.parent.type==="AssignmentExpression"&&M.parent.left===M){k=!0;break}}k||i({node:y.parent.property,message:`The ref value '${E}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${E}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let je=new Set;function vn(f,y){je.has(y)||(je.add(y),i({node:f,message:`Assignments to the '${y}' variable from inside React Hook ${r(d)} 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(d)}.`}))}let be=new Set;if(X.forEach(({isStable:f,references:y},E)=>{f&&be.add(E),y.forEach(I=>{I.writeExpr&&vn(I.writeExpr,E)})}),je.size>0)return;if(!N){let f=null;if(X.forEach(({isStable:y,references:E},I)=>{f||E.forEach(k=>{if(f)return;let C=k.identifier;if(!c.has(C))return;let M=k.from;for(;M.type!=="function";)M=M.upper;M.block===x&&(f=I)})}),f){let{suggestedDependencies:y}=ze({dependencies:X,declaredDependencies:[],stableDependencies:be,externalDependencies:new Set,isEffect:!0});i({node:d,message:`React Hook ${m} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+y.join(", ")+`] as a second argument to the ${m} Hook.`,suggest:[{desc:`Add dependencies array: [${y.join(", ")}]`,fix(E){return E.insertTextAfter(x,`, [${y.join(", ")}]`)}}]})}return}let ge=[],Se=new Set;N.type!=="ArrayExpression"?i({node:N,message:`React Hook ${r(d)} 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.`}):N.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(d)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}S.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(k){return k.removeRange(f.range)}}]});let y;try{y=ce(f,re)}catch(k){if(/Unsupported node type/.test(k.message)){f.type==="Literal"?X.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(d)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw k}let E=f;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let I=!O.through.some(k=>k.identifier===E);ge.push({key:y,node:f}),I||Se.add(y)});let{suggestedDependencies:On,unnecessaryDependencies:xe,missingDependencies:ue,duplicateDependencies:bt}=ze({dependencies:X,declaredDependencies:ge,stableDependencies:be,externalDependencies:Se,isEffect:A}),Ie=On;if(bt.size+ue.size+xe.size===0){if(t)return;Gn({declaredDependencies:ge,declaredDependenciesNode:N,componentScope:O,scope:R}).forEach(({construction:y,isUsedOutsideOfHook:E,depType:I})=>{let k=I==="function"?"useCallback":"useMemo",C=I==="function"?"definition":"initialization",D=`wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,M=E?`To fix this, ${D}`:`Move it inside the ${m} callback. Alternatively, ${D}`,Z=I==="conditional"||I==="logical expression"?"could make":"makes",ae=`The '${y.name.name}' ${I} ${Z} the dependencies of ${m} Hook (at line ${N.loc.start.line}) change on every render. ${M}`,xt;E&&y.type==="Variable"&&I==="function"&&(xt=[{desc:`Wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,fix(It){let[Fn,Nn]=k==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[It.insertTextBefore(y.node.init,Fn),It.insertTextAfter(y.node.init,Nn)]}}]),i({node:y.node,message:ae,suggest:xt})});return}!A&&ue.size>0&&(Ie=ze({dependencies:X,declaredDependencies:[],stableDependencies:be,externalDependencies:Se,isEffect:A}).suggestedDependencies);function Pn(){if(ge.length===0)return!0;let f=ge.map(E=>E.key),y=f.slice().sort();return f.join(",")===y.join(",")}Pn()&&Ie.sort();function Le(f){let y=f.split("."),E="";for(let I=0;I<y.length;I++){if(I!==0){let k=y.slice(0,I+1).join("."),C=re.get(k)===!0;E+=C?"?.":"."}E+=y[I]}return E}function Me(f,y,E,I){return f.size===0?null:(f.size>1?"":y+" ")+E+" "+(f.size>1?"dependencies":"dependency")+": "+Qn(Array.from(f).sort().map(k=>"'"+Le(k)+"'"))+`. Either ${I} ${f.size>1?"them":"it"} or remove the dependency array.`}let ie="";if(xe.size>0){let f=null;if(Array.from(xe.keys()).forEach(y=>{f===null&&y.endsWith(".current")&&(f=y)}),f!==null)ie=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Se.size>0){let y=Array.from(Se)[0];R.set.has(y)||(ie=` Outer scope values like '${y}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ie&&ue.has("props")){let f=X.get("props");if(f==null)return;let y=f.references;if(!Array.isArray(y))return;let E=!0;for(let I=0;I<y.length;I++){let k=y[I],C=Be(O.block,k.identifier);if(!C){E=!1;break}let D=C.parent;if(D==null){E=!1;break}if(D.type!=="MemberExpression"&&D.type!=="OptionalMemberExpression"){E=!1;break}}E&&(ie=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${m} call and refer to those specific props inside ${r(d)}.`)}if(!ie&&ue.size>0){let f=null;ue.forEach(y=>{if(f)return;let E=O.set.get(y),I=X.get(y);if(I.references[0].resolved!==E)return;let k=E.defs[0];if(k==null||k.name==null||k.type!=="Parameter")return;let C=!1,D;for(let M=0;M<I.references.length;M++)if(D=I.references[M].identifier,D!=null&&D.parent!=null&&(D.parent.type==="CallExpression"||D.parent.type==="OptionalCallExpression")&&D.parent.callee===D){C=!0;break}C&&(f=y)}),f!==null&&(ie=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ie&&ue.size>0){let f=null;if(ue.forEach(y=>{if(f!==null)return;let I=X.get(y).references,k,C;for(let D=0;D<I.length;D++){for(k=I[D].identifier,C=k.parent;C!=null&&C!==O.block;){if(C.type==="CallExpression"){let M=c.get(C.callee);if(M!=null){if(M.name===y)f={missingDep:y,setter:C.callee.name,form:"updater"};else if(p.has(k))f={missingDep:y,setter:C.callee.name,form:"reducer"};else{let Z=I[D].resolved;if(Z!=null){let ae=Z.defs[0];ae!=null&&ae.type==="Parameter"&&(f={missingDep:y,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":ie=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":ie=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":ie=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:N,message:`React Hook ${r(d)} has `+(Me(ue,"a","missing","include")||Me(xe,"an","unnecessary","exclude")||Me(bt,"a","duplicate","omit"))+ie,suggest:[{desc:`Update the dependencies array to be: [${Ie.map(Le).join(", ")}]`,fix(f){return f.replaceText(N,`[${Ie.map(Le).join(", ")}]`)}}]})}function w(x){let N=Zn(x.callee,s);if(N===-1)return;let d=x.arguments[N],m=x.callee,A=Dt(m).name,R=x.arguments[N+1],v=/Effect($|[^a-z])/g.test(A);if(!d){i({node:m,message:`React Hook ${A} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!v)){if(!R&&!v){(A==="useMemo"||A==="useCallback")&&i({node:m,message:`React Hook ${A} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(d.type){case"FunctionExpression":case"ArrowFunctionExpression":T(d,R,m,A,v);return;case"Identifier":if(!R||R.elements&&R.elements.some(_=>_&&_.type==="Identifier"&&_.name===d.name))return;let O=n(x).set.get(d.name);if(O==null||O.defs==null)return;let b=O.defs[0];if(!b||!b.node||b.type!=="Variable"&&b.type!=="FunctionName")break;switch(b.node.type){case"FunctionDeclaration":T(b.node,R,m,A,v);return;case"VariableDeclarator":let _=b.node.init;if(!_)break;switch(_.type){case"ArrowFunctionExpression":case"FunctionExpression":T(_,R,m,A,v);return}break}break;default:i({node:m,message:`React Hook ${A} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:m,message:`React Hook ${A} has a missing dependency: '${d.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${d.name}]`,fix(O){return O.replaceText(R,`[${d.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let x of e.sourceCode.getAllComments())if(Kn.test(x.value))return t=!0,{CallExpression:N=>w(N,!0)}}return{CallExpression:x=>w(x)}}};function ze({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,w)=>{let x=i(a,w);x.isUsed=!0,l(a,w,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:T})=>{let w=i(a,T);w.isSatisfiedRecursively=!0}),r.forEach(T=>{let w=i(a,T);w.isSatisfiedRecursively=!0});function i(T,w){let x=w.split("."),N=T;for(let d of x){let m=N.children.get(d);m||(m=s(),N.children.set(d,m)),N=m}return N}function l(T,w,x){let N=w.split("."),d=T;for(let m of N){let A=d.children.get(m);if(!A)return;x(A),d=A}}let c=new Set,p=new Set;u(a,c,p,T=>T);function u(T,w,x,N){T.children.forEach((d,m)=>{let A=N(m);if(d.isSatisfiedRecursively){d.isSubtreeUsed&&x.add(A);return}if(d.isUsed){w.add(A);return}u(d,w,x,R=>A+"."+R)})}let g=[],S=new Set,h=new Set;return t.forEach(({key:T})=>{p.has(T)?g.indexOf(T)===-1?g.push(T):h.add(T):S.add(T)}),c.forEach(T=>{g.push(T)}),{suggestedDependencies:g,unnecessaryDependencies:S,duplicateDependencies:h,missingDependencies:c}}function fe(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 fe(e.consequent)!=null||fe(e.alternate)!=null?"conditional":null;case"LogicalExpression":return fe(e.left)!=null||fe(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return fe(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return fe(e.expression);case"TSAsExpression":return fe(e.expression)}return null}function Gn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:s})=>{let i=r.variables.find(c=>c.name===s);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=fe(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(s){let i=!1;for(let l=0;l<s.references.length;l++){let c=s.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==n&&p!=null;)p=p.upper;if(p!==n&&!jt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}function Nt(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)?Nt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ye(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function ce(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=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Ye(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Ye(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=ce(r.object,t),o=ce(r.property,null),a=`${n}.${o}`;return Ye(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Dt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Zn(e,t){let r=Dt(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=ce(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(n)?0:-1}else return-1}}function Be(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),er(n,t))return n;if(jt(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(Pt(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(s=>{Pt(s)&&(s.parent=n,r.push(s))}))}return null}function Qn(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 Pt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function er(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 jt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function tr(e){return!1}import{AST_NODE_TYPES as Ae,ESLintUtils as Mt}from"@typescript-eslint/utils";import J from"typescript";var nr=Mt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="improved-no-unnecessary-condition",rr=j({}),ir=["string","number","bigint","boolean","symbol","undefined","object","function","never"],sr=new Set(ir),Xe={name:Lt,rule:nr({name:Lt,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[rr]},defaultOptions:[{}],create(e){let t=Mt.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===Ae.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&J.TypeFlags.Any||i.flags&J.TypeFlags.Unknown?null:i.flags&J.TypeFlags.StringLike?["string"]:i.flags&J.TypeFlags.NumberLike?["number"]:i.flags&J.TypeFlags.BigIntLike?["bigint"]:i.flags&J.TypeFlags.BooleanLike?["boolean"]:i.flags&J.TypeFlags.ESSymbolLike?["symbol"]:i.flags&J.TypeFlags.Undefined||i.flags&J.TypeFlags.Void?["undefined"]:i.flags&J.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&J.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&J.TypeFlags.NonPrimitive?["object"]:i.flags&J.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=r.getTypeAtLocation(l.expression);if(c.flags&J.TypeFlags.Any||c.flags&J.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let g of c.types){let S=o(g);if(S)p.push(...S);else return null}return p}let u=o(c);return u?(p.push(...u),p):null}function s(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(n(i.left)?(c=i.left,p=i.right.type===Ae.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(c=i.right,p=i.left.type===Ae.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!or(p,sr))return;let u=a(c);if(!u)return;let g=i.operator==="!==",S=u.includes(p);u.length===1?S&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:me(c,e),type:p}}):!S&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:me(c,e),type:Array.from(u)[0]}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:me(c,e),actualType:Re(u),conditionType:p}}):S&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:me(c,e),actualType:Re(u),conditionType:p}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:me(c,e),actualType:Re(u),conditionType:p}}):!S&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:me(c,e),type:Re(u)}})}return{BinaryExpression:s}}})};function Re(e){return Array.from(new Set(e)).join(" | ")||"never"}function me(e,t){let r=e.argument;return r.type===Ae.Identifier?r.name:t.sourceCode.getText(r)}function or(e,t){return t.has(e)}import{AST_NODE_TYPES as ar,ESLintUtils as lr}from"@typescript-eslint/utils";var cr=lr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="no-call-with-explicit-generics",pr=j({functions:V(F())}),ur=cr({name:_t,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:[pr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===ar.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),qe={name:_t,rule:ur};import{AST_NODE_TYPES as ke,ESLintUtils as fr}from"@typescript-eslint/utils";var mr=fr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="no-call-with-inferred-generics",dr=mr({name:$t,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:o}=n;if(o.type!==ke.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(s||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&n.typeArguments?.params?.some(p=>!i&&p.type===ke.TSAnyKeyword||l&&p.type===ke.TSTypeReference&&p.typeName.type===ke.Identifier&&l.includes(p.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),Je={name:$t,rule:dr};import{ESLintUtils as yr}from"@typescript-eslint/utils";var gr=yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vt="no-commented-out-code",Sr=["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:"],Tr=[") {","return;",/^\s*return\s+/,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",/\w=("|'|`)/,");",/\w+:\s*('|"|`)/,/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,/\w+-\w+:/,/\w+_\w+:/,"&&","||","()",/\?\s+\w/,/:\s+\w/,/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,/^\s*\d+[,}]/,/^\s*\[[^\]]*\][,}]/,/^\s*\{[^}]*\}[,}]/,/\.\w+\(/,/\[\w+\]/,"?.(","??","=>",/^\s*(['"`]).+?\1\s*:/],hr=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Ut=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Er=gr({name:Vt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,o){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||/^\s*[*\s]*$/.test(n))return!1;for(let s of Ut)if(a.startsWith(s))return!1;if(n.includes("https://"))return!1;if(o==="Block"){for(let s of hr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of Sr)if(a.startsWith(s))return{wrongPattern:s};for(let s of Tr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}function r(n,o){let a=n,s=a.trim();if(s.startsWith("`")&&(s.endsWith("`,")||s.endsWith("`;")||s.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let c=a.split(/```[\s\S]*?```/g);c.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=c.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(c=>/[a-zA-Z0-9]/.test(c))?i.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let s=r(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Ut.join(", ")}})}}}}}),Ke={name:Vt,rule:Er};import{ESLintUtils as br,TSESTree as xr}from"@typescript-eslint/utils";var Ir=br.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="no-default-export",wr=Ir({name:Wt,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===xr.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Ge={name:Wt,rule:wr};import{ESLintUtils as Cr}from"@typescript-eslint/utils";var Rr=Cr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="no-leaked-text-in-jsx",Ar=[",",";","[","]","(",")"],kr=Rr({name:Ht,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="";Ar.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),Ze={name:Ht,rule:kr};import{AST_NODE_TYPES as de,ESLintUtils as vr}from"@typescript-eslint/utils";var Or=vr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="no-non-camel-case-functions",Pr=/^[a-z][a-zA-Z0-9]*$/;function zt(e){return e.typeName.type===de.TSQualifiedName&&e.typeName.left.type===de.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===de.Identifier&&e.typeName.right.name==="Element"}var Fr=Or({name:Yt,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&&!Pr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===de.TSTypeReference?zt(r):r.type===de.TSUnionType&&r.types.some(o=>o.type===de.TSTypeReference&&zt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Qe={name:Yt,rule:Fr};import{ESLintUtils as Nr,TSESTree as W}from"@typescript-eslint/utils";import{AST_NODE_TYPES as Bt}from"@typescript-eslint/utils";function ye(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:ye(e.parent,t,r===1/0?r:r-1)}function*et(e){yield e,e.parent&&(yield*et(e.parent))}function tt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function Xt(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Bt.Property&&a.identifiers[0]?.parent.key.type===Bt.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Dr=Nr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="no-optional-root-props",jr=Dr({name:qt,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let s=a.references[0];if(!s)return!1;for(let i of et(s.identifier)){if("returnType"in i||i.type===W.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===W.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===W.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===W.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=ye(l.parent.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=ve(p,e.sourceCode);return u?!(u.parent.type===W.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===W.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===W.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===W.AST_NODE_TYPES.ArrowFunctionExpression){let c=ye(l,W.AST_NODE_TYPES.VariableDeclaration);return c?!!ve(c,e.sourceCode):!1}if(l.type===W.AST_NODE_TYPES.FunctionDeclaration)return!!ve(l,e.sourceCode)}return!1}function r(n){n.key.type!==W.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=ye(n,W.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let s=e.sourceCode.getText(a);return o.replaceText(a,s.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===W.AST_NODE_TYPES.TSTypeLiteral&&!(Oe(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===W.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Oe(n)||!t(n)))for(let o of n.body.body)o.type===W.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==W.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==W.AST_NODE_TYPES.TSTypeLiteral)return;let a=ye(n.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=ve(a,e.sourceCode);if(!(!s||s.parent.type===W.AST_NODE_TYPES.CallExpression&&s.parent.callee.type===W.AST_NODE_TYPES.Identifier&&s.parent.callee.name==="memo"))for(let l of o.members)l.type===W.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Oe(e){return e?e.parent?.type===W.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===W.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function ve(e,t){if(Oe(e))return;let r;if(e.type===W.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===W.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===W.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(s=>s.identifiers.includes(r));if(!o)return;let a=o.references.filter(s=>s.identifier!==r);if(!(a.length!==1||!a[0])&&!Oe(a[0].identifier.parent.parent))return a[0].identifier}var nt={name:qt,rule:jr};import{ESLintUtils as Lr}from"@typescript-eslint/utils";import rt from"node:path";var Mr=Lr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-relative-imports",_r=j({find:F(),replacement:F()}),$r=j({aliases:V(_r),rootDir:P(F()),allowNotFoundAliases:P(le()),_dev_simulateFileName:P(F())}),Ur=Mr({name:Jt,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:[$r]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=rt.dirname(i);return rt.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=rt.relative(i,s);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let u=l.replace(p,c);return{alias:c,newPath:u}}return null}return{ImportDeclaration(s){let i=s.source.value;if(!n(i))return;let l=o(i,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:s,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(s.source,`'${c.newPath}'`):void 0})}}}}),it={name:Jt,rule:Ur};import{AST_NODE_TYPES as Te,ESLintUtils as Gt}from"@typescript-eslint/utils";import*as st from"typescript";var Vr=Gt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="no-unnecessary-casting",Wr=j({additionalCastFunctions:P(V(j({name:F(),expectedType:we(["string","number"])})))}),ot={name:Kt,rule:Vr({name:Kt,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:[Wr],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=Gt.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function s(p,u){switch(p.type){case Te.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case Te.TemplateLiteral:return u==="string";case Te.UnaryExpression:return u==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,u){return u==="number"?!!(p.flags&st.TypeFlags.NumberLike):!!(p.flags&st.TypeFlags.StringLike)}function l(p,u){return g=>g.replaceText(p,e.sourceCode.getText(u))}function c(p){if(!a||p.arguments.length!==1)return;let u=p.arguments[0];if(!u||u.type===Te.SpreadElement)return;let{callee:g}=p;if(g.type!==Te.Identifier)return;let S=g.name,h=n.find(w=>w.name===S);if(!h)return;if(s(u,h.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),h.expectedType)){let w,x;S==="Number"?w="unnecessaryNumberCasting":S==="String"?w="unnecessaryStringCasting":(w="unnecessaryCustomCasting",x={name:h.name,type:h.expectedType}),e.report({node:p,messageId:w,...x?{data:x}:{},fix:l(p,u)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as Pe}from"@typescript-eslint/utils";import*as te from"zod/v4";var Hr=te.object({methods:te.union([te.array(te.string()),te.literal("array")])}),at=se({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:[te.toJSONSchema(Hr)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===Pe.MemberExpression){let c=l.property;if(c.type===Pe.Identifier)return c.name}return null}function s(i,l){if(i.type!==Pe.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===Pe.CallExpression){let p=a(c);p&&o(p)&&c.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(g){return g.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)s(l,i)},FunctionExpression(i){for(let l of i.params)s(l,i)}}}});import{AST_NODE_TYPES as G}from"@typescript-eslint/utils";var lt=se({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===G.ObjectPattern||!t.init||t.init.type!==G.ObjectExpression||t.id.type===G.Identifier&&t.id.typeAnnotation||t.parent.parent.type===G.ExportNamedDeclaration)return;let r=new Map;for(let s of t.init.properties)s.type===G.Property&&s.key.type===G.Identifier&&r.set(s.key.name,s);if(r.size===0||t.id.type!==G.Identifier)return;let n=zr(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(s=>s.type!==G.Property?!1:s.value.type===G.FunctionExpression),a=new Set;for(let s of n){if(s.identifier.parent.type!==G.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===G.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==G.Identifier)return;a.add(i.property.name)}if(i.parent.type===G.CallExpression&&o)return}for(let[s,i]of r)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function zr(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as z,ESLintUtils as Yr}from"@typescript-eslint/utils";var Br=j({selectors:V(j({name:F(),selectorProp:P(F()),selectorArgPos:P(K()),returnProp:P(F())}))}),Xr=Yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-unused-selected-values",ct={name:Zt,rule:Xr({name:Zt,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Br]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===z.CallExpression&&(a=o.init),!a)return;let s=Jr(a);if(!s)return;let i=n.get(s);if(!i)return;let l=qr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=Kr(l);if(!c)return;let p=Qt(c.properties,void 0);if(!p)return;if(o.id.type===z.ObjectPattern){let S=Qt(o.id.properties,i.returnProp);if(!S)return;for(let[h,T]of p)S.has(h)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:h}});return}if(o.id.type!==z.Identifier||i.returnProp)return;let u=Gr(o,e.sourceCode);if(u.length===0)return;let g=new Set;for(let S of u){if(S.identifier.parent.type!==z.MemberExpression)return;let h=S.identifier.parent.property;if(h.type!==z.Identifier)return;g.add(h.name)}for(let[S,h]of p)g.has(S)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:S}})}}}})};function qr(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 o=n.properties.find(s=>s.type===z.Property&&s.key.type===z.Identifier&&s.key.name===r);if(o?.type!==z.Property)return null;let a=o.value;if(a.type===z.ArrowFunctionExpression||a.type===z.FunctionExpression)return a}return null}function Jr(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 Kr(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 Qt(e,t){let r=e;if(t){let o=e.find(a=>a.type===z.Property&&a.key.type===z.Identifier&&a.key.name===t);if(o?.type!==z.Property||o.value.type!==z.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==z.Property||o.key.type!==z.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function Gr(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as H}from"@typescript-eslint/utils";var pt=se({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===H.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let i=Zr(a);i&&(n=i);return}let s=Qr(a,e.sourceCode);if(s){o=!0;for(let i of s)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function Zr(e){if(!(e.callee.type===H.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==H.ObjectExpression)return null;let n=tt(r.properties,a=>a.type!==H.Property||a.key.type!==H.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.ObjectExpression?a.value:a.value.type===H.ArrowFunctionExpression||a.value.type===H.FunctionExpression?ei(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===H.Property&&a.key.type===H.Identifier&&o.set(a.key.name,a);return o}function Qr(e,t){if(!(e.callee.type===H.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.VariableDeclarator||e.parent.id.type!==H.ObjectPattern||!tt(e.parent.id.properties,s=>s.type===H.Property&&s.key.type===H.Identifier&&s.key.name==="formFields"&&s))return null;let o=Xt(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==H.Identifier||s.parent.type===H.Property&&s.parent.parent.type===H.ObjectExpression&&s.parent.parent.parent.type===H.ReturnStatement||s.parent.type===H.ReturnStatement)return null;if(s.parent.type===H.MemberExpression){if(s.parent.object.type!==H.Identifier||s.parent.property.type!==H.Identifier)return null;a.add(s.parent.property.name)}}return a}function ei(e){if(e.body.type===H.ObjectExpression)return e.body;if(e.body.type===H.BlockStatement){let t=e.body.body.filter(r=>r.type===H.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as U,ESLintUtils as ti}from"@typescript-eslint/utils";var ni=ti.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function en(e){let t=[];for(let r of e.members)r.type===U.TSPropertySignature&&r.key.type===U.Identifier&&t.push([r.key.name,r]);return t}function tn(e,...t){for(let r of t)e.set(...r);return e}var ri=j({forceCheckOnFCPropTypesWithName:P(V(F()))}),nn="no-unused-type-props-in-args",ut=null,ii=ni({name:nn,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:[ri],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!ut&&(ut=r.map(i=>new RegExp(i)));function n(i,l,c,p,u=!0){let g=c.name,S=e.sourceCode.getScope(l).references.find(w=>w.identifier.name===g)?.resolved,h=i&&ut?.some(w=>w.test(g));if(!S||!h&&S.references.filter(w=>w.isTypeReference).length>1)return;let T=S?.defs[0]?.node;if(!(u&&T?.parent?.type===U.ExportNamedDeclaration)){if(T?.type===U.TSTypeAliasDeclaration){o(i,l,p,T.typeAnnotation,!0);return}if(T?.type===U.TSInterfaceDeclaration){o(i,l,p,T.body,!0);return}}}function o(i,l,c,p,u){if(p.type===U.TSInterfaceBody){for(let g of p.body)g.type===U.TSPropertySignature&&g.key.type===U.Identifier&&c.set(g.key.name,g);return}if(p.type===U.TSTypeLiteral){tn(c,...en(p));return}if(p.type===U.TSIntersectionType){for(let g of p.types)o(i,l,c,g,!0);return}u||p.type===U.TSTypeReference&&p.typeName.type===U.Identifier&&n(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let u=new Map;if(o(i,l,u,p.typeAnnotation.typeAnnotation,!1),u.size===0)continue;s(p,u)}else p.type===U.AssignmentPattern&&p.left.type===U.ObjectPattern&&a(i,l,[p.left])}function s(i,l){let c=[];if(i.properties.at(-1)?.type===U.RestElement)return;for(let S of i.properties)S.type===U.Property&&S.key.type===U.Identifier&&c.push(S.key.name);let u=[],g=[];for(let[S,h]of l)c.includes(S)||(g.push(S),u.push({node:h,messageId:"unusedObjectTypeProperty",data:{propertyName:S}}));for(let[S,h]of u.entries())e.report({...h,fix:S===u.length-1?T=>{let w=i.properties.at(-1),x=g.join(", ");return w?w?.type===U.RestElement?null:T.insertTextAfter(w,`, ${x}`):T.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${x}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let c=new Map,p=l.id.type===U.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===U.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===U.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(p){if(p.type===U.TSTypeReference&&p.typeName.type===U.Identifier)n(!0,i,p.typeName,c,!1);else if(p.type===U.TSTypeLiteral)tn(c,...en(p));else if(p.type===U.TSIntersectionType)for(let u of p.types)u.type===U.TSTypeReference&&u.typeName.type===U.Identifier?n(!0,i,u.typeName,c,!1):o(!0,i,c,u,!0);if(c.size!==0&&l.init?.type===U.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===U.ObjectPattern&&s(u,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),ft={name:nn,rule:ii};import{AST_NODE_TYPES as mt,ESLintUtils as si}from"@typescript-eslint/utils";var oi=si.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="prefer-named-functions",rn=new Map,ai=oi({name:sn,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=rn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),rn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===mt.ArrowFunctionExpression&&n.id.type===mt.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==mt.BlockStatement)return;let a=n.parent,s=n.init.params,i=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(a,`${l.async?"async ":""}function ${o}(${s.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),dt={name:sn,rule:ai};import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";var li=j({disallowedFunctions:V(j({name:F(),allowUsingWithArgs:P(le()),hookAlternative:P(F()),message:P(F()),allowUseInside:P(V(F()))}))});function Fe(e){return/^use[A-Z]/.test(e)}function on(e){return/^[A-Z]/.test(e)}function ci(e){return e.type===L.Identifier?Fe(e.name):e.type===L.MemberExpression&&e.property.type===L.Identifier?Fe(e.property.name):!1}function an(e,t){return e.type===L.Identifier?e.name===t:e.type===L.MemberExpression&&e.object.type===L.Identifier&&e.property.type===L.Identifier?e.object.name==="React"&&e.property.name===t:!1}function ln(e){return!!(e.parent&&e.parent.type===L.CallExpression&&an(e.parent.callee,"forwardRef"))}function cn(e){return!!(e.parent&&e.parent.type===L.CallExpression&&an(e.parent.callee,"memo"))}function yt(e){if(e.type===L.FunctionDeclaration||e.type===L.FunctionExpression&&e.id)return e.id||void 0;if(e.type===L.FunctionExpression||e.type===L.ArrowFunctionExpression){if(e.parent.type===L.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===L.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===L.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===L.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function pi(e){let t=e.parent,r=!1;for(;t;){if(t.type===L.FunctionDeclaration||t.type===L.FunctionExpression||t.type===L.ArrowFunctionExpression){let n=yt(t);if(n&&n.type===L.Identifier){if(on(n.name)||Fe(n.name))return!r;r=!0}else{if(ln(t)||cn(t))return!r;if(t.parent.type===L.CallExpression){let o=t.parent;ci(o.callee)||(r=!0)}else t.parent.type===L.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function pn(e){return e.callee.type===L.Identifier?e.callee.name:e.callee.type===L.MemberExpression&&e.callee.property.type===L.Identifier?e.callee.property.name:null}function ui(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===L.FunctionDeclaration||r.type===L.FunctionExpression||r.type===L.ArrowFunctionExpression){let n=yt(r);if(n&&n.type===L.Identifier&&t.includes(n.name))return!0}else if(r.type===L.CallExpression){let n=pn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function fi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===L.Identifier&&t.name==="undefined")}function mi(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===L.FunctionDeclaration||n.type===L.FunctionExpression||n.type===L.ArrowFunctionExpression){let o=yt(n);if(o&&o.type===L.Identifier){if(on(o.name)||Fe(o.name)){r=!0;break}}else if(ln(n)||cn(n)){r=!0;break}}n=n.parent}return r?t.length===0?pi(e):!ui(e,t):!1}var gt=se({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:[li],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=pn(o);if(!a)return;let s=n.get(a);if(!s||s.allowUsingWithArgs&&fi(o))return;let i=s.allowUseInside||[];mi(o,i)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:s.message?` ${s.message}`:` use ${s.hookAlternative} instead`},suggest:s.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${s.hookAlternative}`,hookAlternative:s.hookAlternative},fix:l=>{let c=s.hookAlternative;return o.callee.type===L.Identifier?l.replaceText(o.callee,c):o.callee.type===L.MemberExpression&&o.callee.property.type===L.Identifier?l.replaceText(o.callee.property,c):null}}]:[]})}}}});import{AST_NODE_TYPES as B,AST_TOKEN_TYPES as un,ESLintUtils as di}from"@typescript-eslint/utils";var yi=di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="prefer-single-line-if",gi=j({maxLineLength:P(K()),maxNonSimpleConditionLength:P(K())}),Si=yi({name:mn,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:[gi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==B.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(a.type===B.ReturnStatement){if(!yn(a))return}else if(!(a.type===B.ContinueStatement||a.type===B.BreakStatement))return;if(n.test.type===B.LogicalExpression||n.test.type===B.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=fn(n.test);if(!u&&n.test.type===B.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;fn(g)&&(u=!0)}if(u&&(s=r.getText(n.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=r.getText(n.test));let i=r.getText(a);if(s.includes(`
|
|
16
16
|
`))return;let l=r.getTokenAfter(n);if(l&&l.type===un.Punctuator&&l.value==="}"){let u=r.getTokenAfter(l);if(u&&u.type===un.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=Ti(r,n),p=`if (${s}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:u=>u.replaceText(n,p)})}}}});function fn(e){return e.type===B.CallExpression||e.type===B.BinaryExpression||e.type===B.MemberExpression&&dn(e)}function dn(e){return e.object.type===B.MemberExpression?dn(e.object):e.object.type!==B.Identifier}function Ti(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function yn(e){if(!e.argument)return!0;let t=e.argument;return t.type===B.ArrayExpression&&t.elements.length===0||t.type===B.ObjectExpression&&t.properties.length===0||t.type===B.Literal||t.type===B.Identifier||t.type===B.TemplateLiteral||t.type===B.TaggedTemplateExpression?!0:t.type===B.CallExpression?t.arguments.length===0:t.type===B.UnaryExpression?yn(t):!1}var St={name:mn,rule:Si};import{AST_NODE_TYPES as ne,ESLintUtils as hi}from"@typescript-eslint/utils";var Ei=hi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn="react-compiler-migration",bi=j({disallowHooks:P(V(j({name:F(),replacement:F()}))),disallowMethods:P(V(j({name:F(),replacement:P(F()),requireTrueProp:P(F())})))}),xi=/eslint +react-compiler\/react-compiler: +\["error/;function Ii(e){return e.type===ne.Identifier?e.name.startsWith("use"):e.type===ne.MemberExpression&&e.property.type===ne.Identifier?e.property.name.startsWith("use"):!1}var wi=Ei({name:gn,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:[bi]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(xi.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===ne.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===ne.MemberExpression&&n.callee.property.type===ne.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let s=t.disallowHooks.find(i=>i.name===o);s&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:i=>i.replaceText(a,s.replacement)}]})}}if(t.disallowMethods?.length&&Ii(n.callee)){for(let o of n.arguments)if(o.type===ne.ObjectExpression){for(let a of o.properties)if(a.type===ne.Property&&a.key.type===ne.Identifier){let s=a.key.name,i=t.disallowMethods.find(l=>l.name===s);if(i){if(i.requireTrueProp){let l=i.requireTrueProp,c=!1;for(let p of o.properties)if(p.type===ne.Property&&p.key.type===ne.Identifier&&p.key.name===l&&p.value.type===ne.Literal&&p.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:l}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),Tt={name:gn,rule:wi};import{ESLintUtils as Ci,TSESTree as Ri}from"@typescript-eslint/utils";var Ai=Ci.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sn="require-description",ki=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,vi=/^eslint-disable-(next-)?line$/u,Oi=Ai({name:Sn,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let o of r.getAllComments()){let a=Pi(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Ni(o.loc),messageId:"missingDescription"}))}}}}}),Tn={name:Sn,rule:Oi};function Pi(e){let{text:t,description:r}=Fi(e.value);if(!t)return null;let n=ki.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=vi.test(o);if(e.type===Ri.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let s=t.slice(n.index+o.length);return{kind:o,value:s.trim(),description:r}}function Fi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Ni(e){return{start:{line:e.start.line,column:-1},end:e.end}}function bn(e){return/^use[A-Z0-9]/.test(e)}function Ne(e){return e.type==="Identifier"?bn(e.name):e.type==="MemberExpression"&&!e.computed&&Ne(e.property)?e.object.type==="Identifier":!1}function xn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function In(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function wn(e){return!!(e.parent&&e.parent.callee&&In(e.parent.callee,"forwardRef"))}function Cn(e){return!!(e.parent&&e.parent.callee&&In(e.parent.callee,"memo"))}function ht(e){for(;e;){let t=An(e);if(t&&(xn(t)||Ne(t))||wn(e)||Cn(e))return!0;e=e.parent}return!1}function hn(e){return!1}function Et(e){return!1}var Di=/eslint +react-compiler\/react-compiler: +\["error/,Rn={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(Di.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,o=[],a=[],s=new WeakSet;function i(l){for(let c of l.references){let p=c.identifier.parent;if(p.type==="VariableDeclarator"&&p.init&&p.init.type==="CallExpression"&&p.init.callee&&hn(p.init.callee))for(let u of c.resolved.references)u!==c&&s.add(u.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,c){let p=o.pop();if(p.size===0)return;let u=new Set;function g(m,A){let{cache:R}=g,v=R.get(m.id),O=new Set(A);if(O.has(m.id)){let b=[...O],_=b.slice(b.indexOf(m.id)+1);for(let Y of _)u.add(Y);return BigInt("0")}if(O.add(m.id),v!==void 0)return v;if(l.thrownSegments.includes(m))v=BigInt("0");else if(m.prevSegments.length===0)v=BigInt("1");else{v=BigInt("0");for(let b of m.prevSegments)v+=g(b,O)}return m.reachable&&v===BigInt("0")?R.delete(m.id):R.set(m.id,v),v}function S(m,A){let{cache:R}=S,v=R.get(m.id),O=new Set(A);if(O.has(m.id)){let b=Array.from(O),_=b.slice(b.indexOf(m.id)+1);for(let Y of _)u.add(Y);return BigInt("0")}if(O.add(m.id),v!==void 0)return v;if(l.thrownSegments.includes(m))v=BigInt("0");else if(m.nextSegments.length===0)v=BigInt("1");else{v=BigInt("0");for(let b of m.nextSegments)v+=S(b,O)}return R.set(m.id,v),v}function h(m){let{cache:A}=h,R=A.get(m.id);if(R===null)return 1/0;if(R!==void 0)return R;if(A.set(m.id,null),m.prevSegments.length===0)R=1;else{R=1/0;for(let v of m.prevSegments){let O=h(v);O<R&&(R=O)}R+=1}return A.set(m.id,R),R}g.cache=new Map,S.cache=new Map,h.cache=new Map;let T=S(l.initialSegment),w=An(c),x=ht(c),N=w?xn(w)||Ne(w):wn(c)||Cn(c),d=1/0;for(let m of l.finalSegments){if(!m.reachable)continue;let A=h(m);A<d&&(d=A)}for(let[m,A]of p){if(!m.reachable)continue;let R=m.nextSegments.length===0?d<=h(m):d<h(m),v=g(m)*S(m),O=u.has(m.id);for(let b of A)if(O&&!Et(b)&&e.report({node:b,message:`React Hook "${t(b)}" 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.`}),N){if(c.async&&e.report({node:b,message:`React Hook "${t(b)}" cannot be called in an async function.`}),!O&&v!==T&&!Et(b)){let Y=`React Hook "${t(b)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:b,message:Y})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let _=`React Hook "${t(b)}" 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:b,message:_})}else if(w){let _=`React Hook "${t(b)}" is called in function "${t(w)}" 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:b,message:_})}else if(c.type==="Program"){let _=`React Hook "${t(b)}" 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:b,message:_})}else if(x&&!Et(b)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let Y=c.parent;if(Y.parent.type==="VariableDeclarator"&&bn(Y.parent.id.name))return}let _=`React Hook "${t(b)}" 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:b,message:_})}}},CallExpression(l){if(Ne(l.callee)){let c=En(o),p=En(a),u=c.get(p);u||(u=[],c.set(p,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||hn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&s.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(l){l===n&&(n=null)},FunctionDeclaration(l){ht(l)&&i(r(l))},ArrowFunctionExpression(l){ht(l)&&i(r(l))}}}};function An(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 En(e){return e[e.length-1]}var kn={[ft.name]:ft.rule,[Ke.name]:Ke.rule,[Je.name]:Je.rule,"rules-of-hooks":Rn,"exhaustive-deps":Ft,"require-description":Tn.rule,[Ge.name]:Ge.rule,[Qe.name]:Qe.rule,[dt.name]:dt.rule,[Ve.name]:Ve.rule,[qe.name]:qe.rule,[it.name]:it.rule,[St.name]:St.rule,[nt.name]:nt.rule,[Ze.name]:Ze.rule,[He.name]:He.rule,[Tt.name]:Tt.rule,[Ue.name]:Ue.rule,[Xe.name]:Xe.rule,[ot.name]:ot.rule,[at.name]:at.rule,[ct.name]:ct.rule,[pt.name]:pt.rule,[lt.name]:lt.rule,[gt.name]:gt.rule};var zo={rules:kn};export{zo as extendedLintPlugin};
|