@ls-stack/extended-lint 0.20.1 → 0.21.1

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.
@@ -1,4 +1,4 @@
1
- "use strict";var Ot=Object.create;var ae=Object.defineProperty;var Pt=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var Ft=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var Lt=(e,t)=>{for(var n in t)ae(e,n,{get:t[n],enumerable:!0})},We=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of _t(t))!Mt.call(e,c)&&c!==n&&ae(e,c,{get:()=>t[c],enumerable:!(r=Pt(t,c))||r.enumerable});return e};var jt=(e,t,n)=>(n=e!=null?Ot(Ft(e)):{},We(t||!e||!e.__esModule?ae(n,"default",{value:e,enumerable:!0}):n,e)),Nt=e=>We(ae({},"__esModule",{value:!0}),e);var Pn={};Lt(Pn,{extendedLintPlugin:()=>On});module.exports=Nt(Pn);var J=require("@typescript-eslint/utils");var he=Symbol.for("optional");function j(e){return{...e,[he]:!0}}function Ue(e,t){return{enum:e,...t}}function ce(e){return{...e,type:"boolean"}}function M(e){return{...e,type:"string"}}function te(e){return{...e,type:"number"}}function Ve(e){return{...e,type:"integer"}}function U(e,t){return{...t,type:"array",items:e}}function L(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,c=[];for(r in e)e[r][he]?e[r][he]=void 0:c.push(r);c.length>0&&(n.required=c)}return n}function Se(...e){return{anyOf:e}}var Ht=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt=L({disallow:j(U(L({selector:M(),message:M(),replace:j(Se(M(),L({regex:M(),with:M()}))),replaceType:j(Ue(["suggestion","autofix"]))}))),__dev_simulateFileName:j(M()),mustMatchSyntax:j(U(L({includeRegex:M(),mustCallFn:U(L({anyCall:U(L({fn:M(),withArgs:U(L({atIndex:Ve(),literal:Se(M(),te(),ce())}))})),message:j(M())}))})))}),qe="advanced-no-restricted-syntax",Ut=Ht({name:qe,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Wt],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:c,disallow:m}=t,h=c??e.filename,a=[],i=new Set;for(let{includeRegex:o,mustCallFn:d}of r??[]){let D=Vt(h,new RegExp(o));if(!D)continue;let A=_=>{let E=_;for(let{name:I,value:g}of D)E=E.replaceAll(I,g);return E};for(let{anyCall:_,message:E}of d){let I=`Expected file to call the function: ${_.map(({fn:g})=>g).join(" or ")}`;i.add(I),a.push(g=>{let{callee:$}=g;if($.type===J.AST_NODE_TYPES.Identifier){for(let{fn:R,withArgs:f}of _)if($.name===R){i.delete(I);for(let x of f){let T=g.arguments[x.atIndex],w=typeof x.literal=="string"?A(x.literal):x.literal;if(!T){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${w}" at index ${x.atIndex}${E?`: ${A(E)}`:""}`}});continue}if(T.type!==J.AST_NODE_TYPES.Literal){e.report({node:T,messageId:"default",data:{message:`Argument at position ${x.atIndex} should the literal "${w}"${E?`: ${A(E)}`:""}`}});continue}T.value!==w&&e.report({node:T,messageId:"default",data:{message:`Argument should have the value "${w}"${E?`: ${A(E)}`:""}`},fix:O=>O.replaceText(T,typeof w=="string"?`'${w}'`:String(w))})}break}}})}}for(let{selector:o,message:d,replace:D,replaceType:A="suggestion"}of m??[]){if(o==="CallExpression"){a.push(_=>{u(D,_,d,A)});continue}n[o]=_=>{u(D,_,d,A)}}return a.length>0&&(n.CallExpression=o=>{if(o.type===J.AST_NODE_TYPES.CallExpression)for(let d of a)d(o)}),n["Program:exit"]=o=>{for(let d of i)e.report({node:o,messageId:"default",data:{message:`${d}`}})},n;function u(o,d,D,A){let _=E=>{if(!o)return null;if(typeof o=="string")return E.replaceText(d,o);{let I=new RegExp(o.regex),g=e.sourceCode.getText(d);return E.replaceText(d,g.replace(I,o.with))}};e.report({node:d,messageId:"default",data:{message:D},fix:o&&A==="autofix"?_:void 0,suggest:o&&A==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof o=="string"?o:o.with}"`},fix:_}]:void 0})}}});function Vt(e,t){let n=[],r=t.exec(e);if(!r)return null;let[c,...m]=r;n.push({name:"$0_lowercase",value:c.toLowerCase()}),n.push({name:"$0_capitalize",value:ze(c)}),n.push({name:"$0_uncapitalize",value:Be(c)}),n.push({name:"$0",value:c});for(let h=0;h<m.length;h++){let a=`$${h+1}`,i=m[h];n.push({name:`${a}_lowercase`,value:i.toLowerCase()}),n.push({name:`${a}_capitalize`,value:ze(i)}),n.push({name:`${a}_uncapitalize`,value:Be(i)}),n.push({name:a,value:i})}return n}function ze(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Be(e){return e.charAt(0).toLowerCase()+e.slice(1)}var be={name:qe,rule:Ut};var zt=/eslint +react-compiler\/react-compiler: +\["error/,Xe={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?g=>n(g):g=>e.sourceCode.getText(g),r=typeof e.getScope=="function"?()=>r():g=>e.sourceCode.getScope(g),c=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,m=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,h={additionalHooks:c,enableDangerousAutofixThisMayCauseInfiniteLoops:m};function a(g){m&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let i=e.getSourceCode().scopeManager,u=new WeakMap,o=new WeakSet,d=new WeakMap,D=new WeakMap,A=new WeakSet;function _(g,$){return function(R){if($.has(R))return $.get(R);let f=g(R);return $.set(R,f),f}}function E(g,$,R,f,x){x&&g.async&&a({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ "use strict";var Mt=Object.create;var ce=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Ht=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty;var Ut=(e,t)=>{for(var n in t)ce(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of jt(t))!Wt.call(e,c)&&c!==n&&ce(e,c,{get:()=>t[c],enumerable:!(i=Lt(t,c))||i.enumerable});return e};var Vt=(e,t,n)=>(n=e!=null?Mt(Ht(e)):{},Be(t||!e||!e.__esModule?ce(n,"default",{value:e,enumerable:!0}):n,e)),zt=e=>Be(ce({},"__esModule",{value:!0}),e);var Hn={};Ut(Hn,{extendedLintPlugin:()=>jn});module.exports=zt(Hn);var Z=require("@typescript-eslint/utils");var Ee=Symbol.for("optional");function L(e){return{...e,[Ee]:!0}}function Ge(e,t){return{enum:e,...t}}function le(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function ne(e){return{...e,type:"number"}}function qe(e){return{...e,type:"integer"}}function U(e,t){return{...t,type:"array",items:e}}function M(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let i,c=[];for(i in e)e[i][Ee]?e[i][Ee]=void 0:c.push(i);c.length>0&&(n.required=c)}return n}function be(...e){return{anyOf:e}}var Yt=Z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt=M({disallow:L(U(M({selector:F(),message:F(),replace:L(be(F(),M({regex:F(),with:F()}))),replaceType:L(Ge(["suggestion","autofix"]))}))),__dev_simulateFileName:L(F()),mustMatchSyntax:L(U(M({includeRegex:F(),mustCallFn:U(M({anyCall:U(M({fn:F(),withArgs:U(M({atIndex:qe(),literal:be(F(),ne(),le())}))})),message:L(F())}))})))}),Je="advanced-no-restricted-syntax",Gt=Yt({name:Je,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Bt],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:i,__dev_simulateFileName:c,disallow:p}=t,m=c??e.filename,o=[],r=new Set;for(let{includeRegex:a,mustCallFn:y}of i??[]){let D=qt(m,new RegExp(a));if(!D)continue;let A=_=>{let b=_;for(let{name:I,value:g}of D)b=b.replaceAll(I,g);return b};for(let{anyCall:_,message:b}of y){let I=`Expected file to call the function: ${_.map(({fn:g})=>g).join(" or ")}`;r.add(I),o.push(g=>{let{callee:$}=g;if($.type===Z.AST_NODE_TYPES.Identifier){for(let{fn:w,withArgs:f}of _)if($.name===w){r.delete(I);for(let T of f){let x=g.arguments[T.atIndex],R=typeof T.literal=="string"?A(T.literal):T.literal;if(!x){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${R}" at index ${T.atIndex}${b?`: ${A(b)}`:""}`}});continue}if(x.type!==Z.AST_NODE_TYPES.Literal){e.report({node:x,messageId:"default",data:{message:`Argument at position ${T.atIndex} should the literal "${R}"${b?`: ${A(b)}`:""}`}});continue}x.value!==R&&e.report({node:x,messageId:"default",data:{message:`Argument should have the value "${R}"${b?`: ${A(b)}`:""}`},fix:O=>O.replaceText(x,typeof R=="string"?`'${R}'`:String(R))})}break}}})}}for(let{selector:a,message:y,replace:D,replaceType:A="suggestion"}of p??[]){if(a==="CallExpression"){o.push(_=>{l(D,_,y,A)});continue}n[a]=_=>{l(D,_,y,A)}}return o.length>0&&(n.CallExpression=a=>{if(a.type===Z.AST_NODE_TYPES.CallExpression)for(let y of o)y(a)}),n["Program:exit"]=a=>{for(let y of r)e.report({node:a,messageId:"default",data:{message:`${y}`}})},n;function l(a,y,D,A){let _=b=>{if(!a)return null;if(typeof a=="string")return b.replaceText(y,a);{let I=new RegExp(a.regex),g=e.sourceCode.getText(y);return b.replaceText(y,g.replace(I,a.with))}};e.report({node:y,messageId:"default",data:{message:D},fix:a&&A==="autofix"?_:void 0,suggest:a&&A==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof a=="string"?a:a.with}"`},fix:_}]:void 0})}}});function qt(e,t){let n=[],i=t.exec(e);if(!i)return null;let[c,...p]=i;n.push({name:"$0_lowercase",value:c.toLowerCase()}),n.push({name:"$0_capitalize",value:Xe(c)}),n.push({name:"$0_uncapitalize",value:Ke(c)}),n.push({name:"$0",value:c});for(let m=0;m<p.length;m++){let o=`$${m+1}`,r=p[m];n.push({name:`${o}_lowercase`,value:r.toLowerCase()}),n.push({name:`${o}_capitalize`,value:Xe(r)}),n.push({name:`${o}_uncapitalize`,value:Ke(r)}),n.push({name:o,value:r})}return n}function Xe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ke(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Te={name:Je,rule:Gt};var Xt=/eslint +react-compiler\/react-compiler: +\["error/,Qe={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?g=>n(g):g=>e.sourceCode.getText(g),i=typeof e.getScope=="function"?()=>i():g=>e.sourceCode.getScope(g),c=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,p=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,m={additionalHooks:c,enableDangerousAutofixThisMayCauseInfiniteLoops:p};function o(g){p&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let r=e.getSourceCode().scopeManager,l=new WeakMap,a=new WeakSet,y=new WeakMap,D=new WeakMap,A=new WeakSet;function _(g,$){return function(w){if($.has(w))return $.get(w);let f=g(w);return $.set(w,f),f}}function b(g,$,w,f,T){T&&g.async&&o({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
2
2
 
3
3
  useEffect(() => {
4
4
  async function fetchData() {
@@ -9,5 +9,5 @@ useEffect(() => {
9
9
  fetchData();
10
10
  }, [someId]); // Or [] if effect doesn't need props or state
11
11
 
12
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let T=i.acquire(g),w=new Set,O=null;{let s=T.upper;for(;s&&(w.add(s),s.type!=="function");)s=s.upper;if(!s)return;O=s}let C=Array.isArray;function F(s){if(!C(s.defs))return!1;let l=s.defs[0];if(l==null||l.node.type!=="VariableDeclarator")return!1;let p=l.node.init;if(p==null)return!1;for(;p.type==="TSAsExpression";)p=p.expression;let y=l.node.parent;if(y==null&&(Te(O.block,l.node.id),y=l.node.parent,y==null))return!1;if(y.kind==="const"&&p.type==="Literal"&&(typeof p.value=="string"||typeof p.value=="number"||p.value===null))return!0;if(p.type!=="CallExpression")return!1;let b=p.callee;if(b.type==="MemberExpression"&&b.object.name==="React"&&b.property!=null&&!b.computed&&(b=b.property),b.type!=="Identifier")return!1;let S=l.node.id,{name:k}=b;if(k==="useRef"&&S.type==="Identifier")return!0;if(Yt(b)&&S.type==="Identifier"){for(let v of s.references)v!==S&&A.add(v.identifier);return!0}else if(k==="useState"||k==="useReducer"){if(S.type==="ArrayPattern"&&S.elements.length===2&&C(s.identifiers)){if(S.elements[1]===s.identifiers[0]){if(k==="useState"){let v=s.references,W=0;for(let B=0;B<v.length;B++){if(v[B].isWrite()&&W++,W>1)return!1;u.set(v[B].identifier,S.elements[0])}}return!0}else if(S.elements[0]===s.identifiers[0]){if(k==="useState"){let v=s.references;for(let W=0;W<v.length;W++)o.add(v[W].identifier)}return!1}}}else if(k==="useTransition"&&S.type==="ArrayPattern"&&S.elements.length===2&&Array.isArray(s.identifiers)&&S.elements[1]===s.identifiers[0])return!0;return!1}function z(s){if(!C(s.defs))return!1;let l=s.defs[0];if(l==null||l.node==null||l.node.id==null)return!1;let p=l.node,y=O.childScopes,b=null,S;for(S=0;S<y.length;S++){let k=y[S],v=k.block;if(p.type==="FunctionDeclaration"&&v===p||p.type==="VariableDeclarator"&&v.parent===p){b=k;break}}if(b==null)return!1;for(S=0;S<b.through.length;S++){let k=b.through[S];if(k.resolved!=null&&w.has(k.resolved.scope)&&!Fe(k.resolved))return!1}return!0}let Fe=_(F,d),It=_(z,D),Me=new Map;function Ct(s){let l=s.from,p=!1;for(;l.block!==g;)l.type==="function"&&(p=l.block.parent!=null&&l.block.parent.type==="ReturnStatement"),l=l.upper;return p}let H=new Map,me=new Map;Le(T);function Le(s){for(let l of s.references){if(!l.resolved||!w.has(l.resolved.scope))continue;let p=Te(g,l.identifier),y=Ye(p),b=q(y,me);if(x&&y.type==="Identifier"&&(y.parent.type==="MemberExpression"||y.parent.type==="OptionalMemberExpression")&&!y.parent.computed&&y.parent.property.type==="Identifier"&&y.parent.property.name==="current"&&Ct(l)&&Me.set(b,{reference:l,dependencyNode:y}),y.parent.type==="TSTypeQuery"||y.parent.type==="TSTypeReference")continue;let S=l.resolved.defs[0];if(S!=null&&!(S.node!=null&&S.node.init===g.parent)&&S.type!=="TypeParameter")if(H.has(b))H.get(b).references.push(l);else{let k=l.resolved,v=Fe(k)||It(k);H.set(b,{isStable:v,references:[l]})}}for(let l of s.childScopes)Le(l)}Me.forEach(({reference:s,dependencyNode:l},p)=>{let y=s.resolved.references,b=!1;for(let S=0;S<y.length;S++){let{identifier:k}=y[S],{parent:v}=k;if(v!=null&&v.type==="MemberExpression"&&!v.computed&&v.property.type==="Identifier"&&v.property.name==="current"&&v.parent.type==="AssignmentExpression"&&v.parent.left===v){b=!0;break}}b||a({node:l.parent.property,message:`The ref value '${p}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${p}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let de=new Set;function kt(s,l){de.has(l)||(de.add(l),a({node:s,message:`Assignments to the '${l}' variable from inside React Hook ${n(R)} 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 ${n(R)}.`}))}let ie=new Set;if(H.forEach(({isStable:s,references:l},p)=>{s&&ie.add(p),l.forEach(y=>{y.writeExpr&&kt(y.writeExpr,p)})}),de.size>0)return;if(!$){let s=null;if(H.forEach(({isStable:l,references:p},y)=>{s||p.forEach(b=>{if(s)return;let S=b.identifier;if(!u.has(S))return;let v=b.from;for(;v.type!=="function";)v=v.upper;v.block===g&&(s=y)})}),s){let{suggestedDependencies:l}=Ee({dependencies:H,declaredDependencies:[],stableDependencies:ie,externalDependencies:new Set,isEffect:!0});a({node:R,message:`React Hook ${f} contains a call to '${s}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+l.join(", ")+`] as a second argument to the ${f} Hook.`,suggest:[{desc:`Add dependencies array: [${l.join(", ")}]`,fix(p){return p.insertTextAfter(g,`, [${l.join(", ")}]`)}}]})}return}let Q=[],ee=new Set;$.type!=="ArrayExpression"?a({node:$,message:`React Hook ${n(R)} 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.`}):$.elements.forEach(s=>{if(s===null)return;if(s.type==="SpreadElement"){a({node:s,message:`React Hook ${n(R)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}A.has(s)&&a({node:s,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(s)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(s)}\``,fix(b){return b.removeRange(s.range)}}]});let l;try{l=q(s,me)}catch(b){if(/Unsupported node type/.test(b.message)){s.type==="Literal"?H.has(s.value)?a({node:s,message:`The ${s.raw} literal is not a valid dependency because it never changes. Did you mean to include ${s.value} in the array instead?`}):a({node:s,message:`The ${s.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):a({node:s,message:`React Hook ${n(R)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw b}let p=s;for(;p.type==="MemberExpression"||p.type==="OptionalMemberExpression"||p.type==="ChainExpression";)p=p.object||p.expression.object;let y=!O.through.some(b=>b.identifier===p);Q.push({key:l,node:s}),y||ee.add(l)});let{suggestedDependencies:vt,unnecessaryDependencies:se,missingDependencies:X,duplicateDependencies:je}=Ee({dependencies:H,declaredDependencies:Q,stableDependencies:ie,externalDependencies:ee,isEffect:x}),oe=vt;if(je.size+X.size+se.size===0){if(t)return;Bt({declaredDependencies:Q,declaredDependenciesNode:$,componentScope:O,scope:T}).forEach(({construction:l,isUsedOutsideOfHook:p,depType:y})=>{let b=y==="function"?"useCallback":"useMemo",S=y==="function"?"definition":"initialization",k=`wrap the ${S} of '${l.name.name}' in its own ${b}() Hook.`,v=p?`To fix this, ${k}`:`Move it inside the ${f} callback. Alternatively, ${k}`,W=y==="conditional"||y==="logical expression"?"could make":"makes",B=`The '${l.name.name}' ${y} ${W} the dependencies of ${f} Hook (at line ${$.loc.start.line}) change on every render. ${v}`,Ne;p&&l.type==="Variable"&&y==="function"&&(Ne=[{desc:`Wrap the ${S} of '${l.name.name}' in its own ${b}() Hook.`,fix(He){let[$t,Dt]=b==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[He.insertTextBefore(l.node.init,$t),He.insertTextAfter(l.node.init,Dt)]}}]),a({node:l.node,message:B,suggest:Ne})});return}!x&&X.size>0&&(oe=Ee({dependencies:H,declaredDependencies:[],stableDependencies:ie,externalDependencies:ee,isEffect:x}).suggestedDependencies);function At(){if(Q.length===0)return!0;let s=Q.map(p=>p.key),l=s.slice().sort();return s.join(",")===l.join(",")}At()&&oe.sort();function ge(s){let l=s.split("."),p="";for(let y=0;y<l.length;y++){if(y!==0){let b=l.slice(0,y+1).join("."),S=me.get(b)===!0;p+=S?"?.":"."}p+=l[y]}return p}function ye(s,l,p,y){return s.size===0?null:(s.size>1?"":l+" ")+p+" "+(s.size>1?"dependencies":"dependency")+": "+Gt(Array.from(s).sort().map(b=>"'"+ge(b)+"'"))+`. Either ${y} ${s.size>1?"them":"it"} or remove the dependency array.`}let V="";if(se.size>0){let s=null;if(Array.from(se.keys()).forEach(l=>{s===null&&l.endsWith(".current")&&(s=l)}),s!==null)V=` Mutable values like '${s}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ee.size>0){let l=Array.from(ee)[0];T.set.has(l)||(V=` Outer scope values like '${l}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!V&&X.has("props")){let s=H.get("props");if(s==null)return;let l=s.references;if(!Array.isArray(l))return;let p=!0;for(let y=0;y<l.length;y++){let b=l[y],S=Te(O.block,b.identifier);if(!S){p=!1;break}let k=S.parent;if(k==null){p=!1;break}if(k.type!=="MemberExpression"&&k.type!=="OptionalMemberExpression"){p=!1;break}}p&&(V=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${f} call and refer to those specific props inside ${n(R)}.`)}if(!V&&X.size>0){let s=null;X.forEach(l=>{if(s)return;let p=O.set.get(l),y=H.get(l);if(y.references[0].resolved!==p)return;let b=p.defs[0];if(b==null||b.name==null||b.type!=="Parameter")return;let S=!1,k;for(let v=0;v<y.references.length;v++)if(k=y.references[v].identifier,k!=null&&k.parent!=null&&(k.parent.type==="CallExpression"||k.parent.type==="OptionalCallExpression")&&k.parent.callee===k){S=!0;break}S&&(s=l)}),s!==null&&(V=` If '${s}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!V&&X.size>0){let s=null;if(X.forEach(l=>{if(s!==null)return;let y=H.get(l).references,b,S;for(let k=0;k<y.length;k++){for(b=y[k].identifier,S=b.parent;S!=null&&S!==O.block;){if(S.type==="CallExpression"){let v=u.get(S.callee);if(v!=null){if(v.name===l)s={missingDep:l,setter:S.callee.name,form:"updater"};else if(o.has(b))s={missingDep:l,setter:S.callee.name,form:"reducer"};else{let W=y[k].resolved;if(W!=null){let B=W.defs[0];B!=null&&B.type==="Parameter"&&(s={missingDep:l,setter:S.callee.name,form:"inlineReducer"})}}break}}S=S.parent}if(s!==null)break}}),s!==null)switch(s.form){case"reducer":V=` You can also replace multiple useState variables with useReducer if '${s.setter}' needs the current value of '${s.missingDep}'.`;break;case"inlineReducer":V=` If '${s.setter}' needs the current value of '${s.missingDep}', you can also switch to useReducer instead of useState and read '${s.missingDep}' in the reducer.`;break;case"updater":V=` You can also do a functional update '${s.setter}(${s.missingDep.slice(0,1)} => ...)' if you only need '${s.missingDep}' in the '${s.setter}' call.`;break;default:throw new Error("Unknown case.")}}a({node:$,message:`React Hook ${n(R)} has `+(ye(X,"a","missing","include")||ye(se,"an","unnecessary","exclude")||ye(je,"a","duplicate","omit"))+V,suggest:[{desc:`Update the dependencies array to be: [${oe.map(ge).join(", ")}]`,fix(s){return s.replaceText($,`[${oe.map(ge).join(", ")}]`)}}]})}function I(g){let $=qt(g.callee,h);if($===-1)return;let R=g.arguments[$],f=g.callee,x=Ke(f).name,T=g.arguments[$+1],w=/Effect($|[^a-z])/g.test(x);if(!R){a({node:f,message:`React Hook ${x} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!w)){if(!T&&!w){(x==="useMemo"||x==="useCallback")&&a({node:f,message:`React Hook ${x} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(R.type){case"FunctionExpression":case"ArrowFunctionExpression":E(R,T,f,x,w);return;case"Identifier":if(!T||T.elements&&T.elements.some(F=>F&&F.type==="Identifier"&&F.name===R.name))return;let O=r(g).set.get(R.name);if(O==null||O.defs==null)return;let C=O.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":E(C.node,T,f,x,w);return;case"VariableDeclarator":let F=C.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":E(F,T,f,x,w);return}break}break;default:a({node:f,message:`React Hook ${x} received a function whose dependencies are unknown. Pass an inline function instead.`});return}a({node:f,message:`React Hook ${x} has a missing dependency: '${R.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${R.name}]`,fix(O){return O.replaceText(T,`[${R.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(zt.test(g.value))return t=!0,{CallExpression:$=>I($,!0)}}return{CallExpression:g=>I(g)}}};function Ee({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:c}){let m=h();function h(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,I)=>{let g=a(m,I);g.isUsed=!0,i(m,I,$=>{$.isSubtreeUsed=!0})}),t.forEach(({key:E})=>{let I=a(m,E);I.isSatisfiedRecursively=!0}),n.forEach(E=>{let I=a(m,E);I.isSatisfiedRecursively=!0});function a(E,I){let g=I.split("."),$=E;for(let R of g){let f=$.children.get(R);f||(f=h(),$.children.set(R,f)),$=f}return $}function i(E,I,g){let $=I.split("."),R=E;for(let f of $){let x=R.children.get(f);if(!x)return;g(x),R=x}}let u=new Set,o=new Set;d(m,u,o,E=>E);function d(E,I,g,$){E.children.forEach((R,f)=>{let x=$(f);if(R.isSatisfiedRecursively){R.isSubtreeUsed&&g.add(x);return}if(R.isUsed){I.add(x);return}d(R,I,g,T=>x+"."+T)})}let D=[],A=new Set,_=new Set;return t.forEach(({key:E})=>{o.has(E)?D.indexOf(E)===-1?D.push(E):_.add(E):A.add(E)}),u.forEach(E=>{D.push(E)}),{suggestedDependencies:D,unnecessaryDependencies:A,duplicateDependencies:_,missingDependencies:u}}function Y(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 Y(e.consequent)!=null||Y(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Y(e.left)!=null||Y(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Y(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Y(e.expression);case"TSAsExpression":return Y(e.expression)}return null}function Bt({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let c=e.map(({key:h})=>{let a=n.variables.find(u=>u.name===h);if(a==null)return null;let i=a.defs[0];if(i==null)return null;if(i.type==="Variable"&&i.node.type==="VariableDeclarator"&&i.node.id.type==="Identifier"&&i.node.init!=null){let u=Y(i.node.init);if(u!=null)return[a,u]}return i.type==="FunctionName"&&i.node.type==="FunctionDeclaration"?[a,"function"]:i.type==="ClassName"&&i.node.type==="ClassDeclaration"?[a,"class"]:null}).filter(Boolean);function m(h){let a=!1;for(let i=0;i<h.references.length;i++){let u=h.references[i];if(u.writeExpr){if(a)return!0;a=!0;continue}let o=u.from;for(;o!==r&&o!=null;)o=o.upper;if(o!==r&&!Je(t,u.identifier))return!0}return!1}return c.map(([h,a])=>({construction:h.defs[0],depType:a,isUsedOutsideOfHook:m(h)}))}function Ye(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)?Ye(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function xe(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function q(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=q(e.object,t),r=q(e.property,null),c=`${n}.${r}`;return xe(e,t,c),c}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=q(e.object,t),r=q(e.property,null),c=`${n}.${r}`;return xe(e,t,c),c}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=q(n.object,t),c=q(n.property,null),m=`${r}.${c}`;return xe(n,t,m),m}else throw new Error(`Unsupported node type: ${e.type}`)}function Ke(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function qt(e,t){let n=Ke(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=q(n,null)}catch(c){if(/Unsupported node type/.test(c.message))return 0;throw c}return t.additionalHooks.test(r)?0:-1}else return-1}}function Te(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),Xt(r,t))return r;if(Je(r,t))for(let[c,m]of Object.entries(r))c!=="parent"&&(Ge(m)?(m.parent=r,n.push(m)):Array.isArray(m)&&m.forEach(h=>{Ge(h)&&(h.parent=r,n.push(h))}))}return null}function Gt(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Xt(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 Je(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Yt(e){return!1}var le=require("@typescript-eslint/utils");var Kt=le.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ze="no-call-with-explicit-generics",Jt=L({functions:U(M())}),Zt=Kt({name:Ze,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:[Jt]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:c}=r;c.type===le.AST_NODE_TYPES.Identifier&&n.has(c.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:c.name}})}}}}),Re={name:Ze,rule:Zt};var K=require("@typescript-eslint/utils"),Qt=K.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qe="no-call-with-inferred-generics",en=Qt({name:Qe,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 n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:c}=r;if(c.type!==K.AST_NODE_TYPES.Identifier)return;let m=n.get(c.name);if(!m)return;let{minGenerics:h=1,allowAny:a,disallowTypes:i=t.disallowTypes}=m;(r.typeArguments?.params.length||0)<(h||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:c.name,minGenerics:h||0}}),!(a&&!i)&&r.typeArguments?.params?.some(o=>!a&&o.type===K.AST_NODE_TYPES.TSAnyKeyword||i&&o.type===K.AST_NODE_TYPES.TSTypeReference&&o.typeName.type===K.AST_NODE_TYPES.Identifier&&i.includes(o.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:c.name}})}}}}),we={name:Qe,rule:en};var re=require("@typescript-eslint/utils"),tn=re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),et="no-commented-out-code",nn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],rn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],sn=tn({name:et,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let r=n.trimStart();if(n.startsWith("*")||r.startsWith("INFO:")||r.startsWith("TODO:")||r.startsWith("DOCS:")||r.startsWith("FIX:")||r.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let c of nn)if(r.startsWith(c))return{wrongPattern:c};for(let c of rn)if(typeof c=="string"){if(n.includes(c))return{wrongPattern:c}}else if(c.test(n))return{wrongPattern:`regex(${c.toString()})`};return!1}return{Program(){let r=e.sourceCode.getAllComments();for(let c of r)if(c.type===re.TSESTree.AST_TOKEN_TYPES.Line||c.type===re.TSESTree.AST_TOKEN_TYPES.Block){let m=t(c.value);m&&e.report({node:c,messageId:"commentedOutCode",data:{wrongPattern:m.wrongPattern}})}}}}}),Ie={name:et,rule:sn};var tt=require("@typescript-eslint/utils"),on=tt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nt="no-default-export",an=on({name:nt,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 n of t.specifiers)n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Ce={name:nt,rule:an};var G=require("@typescript-eslint/utils"),cn=G.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),it="no-non-camel-case-functions",ln=/^[a-z][a-zA-Z0-9]*$/;function rt(e){return e.typeName.type===G.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===G.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===G.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var un=cn({name:it,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&&!ln.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===G.AST_NODE_TYPES.TSTypeReference?rt(n):n.type===G.AST_NODE_TYPES.TSUnionType&&n.types.some(c=>c.type===G.AST_NODE_TYPES.TSTypeReference&&rt(c))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ke={name:it,rule:un};var st=require("@typescript-eslint/utils"),ue=jt(require("path"));var fn=st.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ot="no-relative-imports",pn=L({find:M(),replacement:M()}),mn=L({aliases:U(pn),rootDir:j(M()),allowNotFoundAliases:j(ce()),_dev_simulateFileName:j(M())}),dn=fn({name:ot,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:[mn]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(h){return h.startsWith(".")||h.startsWith("..")}function c(h,a){let i=ue.default.dirname(a);return ue.default.resolve(i,h)}function m(h){let a=t.rootDir??process.cwd(),i=ue.default.relative(a,h);if(i.startsWith("."))return null;i.startsWith("/")||(i=`/${i}`);for(let{find:u,replacement:o}of t.aliases)if(i.startsWith(o)){let d=i.replace(o,u);return{alias:u,newPath:d}}return null}return{ImportDeclaration(h){let a=h.source.value;if(!r(a))return;let i=c(a,n),u=m(i);!u&&t.allowNotFoundAliases||e.report({node:h,messageId:u?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:u?.alias},fix:u?o=>o.replaceText(h.source,`'${u.newPath}'`):void 0})}}}}),ve={name:ot,rule:dn};var P=require("@typescript-eslint/utils");var gn=P.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function at(e){let t=[];for(let n of e.members)n.type===P.AST_NODE_TYPES.TSPropertySignature&&n.key.type===P.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function ct(e,...t){for(let n of t)e.set(...n);return e}var yn=L({forceCheckOnFCPropTypesWithName:j(U(M()))}),lt="no-unused-type-props-in-args",Ae=null,hn=gn({name:lt,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:[yn],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Ae&&(Ae=n.map(a=>new RegExp(a)));function r(a,i,u,o,d=!0){let D=u.name,A=e.sourceCode.getScope(i).references.find(I=>I.identifier.name===D)?.resolved,_=a&&Ae?.some(I=>I.test(D));if(!A||!_&&A.references.filter(I=>I.isTypeReference).length>1)return;let E=A?.defs[0]?.node;if(!(d&&E?.parent?.type===P.AST_NODE_TYPES.ExportNamedDeclaration)){if(E?.type===P.AST_NODE_TYPES.TSTypeAliasDeclaration){c(a,i,o,E.typeAnnotation,!0);return}if(E?.type===P.AST_NODE_TYPES.TSInterfaceDeclaration){c(a,i,o,E.body,!0);return}}}function c(a,i,u,o,d){if(o.type===P.AST_NODE_TYPES.TSInterfaceBody){for(let D of o.body)D.type===P.AST_NODE_TYPES.TSPropertySignature&&D.key.type===P.AST_NODE_TYPES.Identifier&&u.set(D.key.name,D);return}if(o.type===P.AST_NODE_TYPES.TSTypeLiteral){ct(u,...at(o));return}if(o.type===P.AST_NODE_TYPES.TSIntersectionType){for(let D of o.types)c(a,i,u,D,!0);return}d||o.type===P.AST_NODE_TYPES.TSTypeReference&&o.typeName.type===P.AST_NODE_TYPES.Identifier&&r(a,i,o.typeName,u)}function m(a,i,u){for(let o of u)if(o.type==="ObjectPattern"&&o.typeAnnotation){let d=new Map;if(c(a,i,d,o.typeAnnotation.typeAnnotation,!1),d.size===0)continue;h(o,d)}else o.type===P.AST_NODE_TYPES.AssignmentPattern&&o.left.type===P.AST_NODE_TYPES.ObjectPattern&&m(a,i,[o.left])}function h(a,i){let u=[];if(a.properties.at(-1)?.type===P.AST_NODE_TYPES.RestElement)return;for(let A of a.properties)A.type===P.AST_NODE_TYPES.Property&&A.key.type===P.AST_NODE_TYPES.Identifier&&u.push(A.key.name);let d=[],D=[];for(let[A,_]of i)u.includes(A)||(D.push(A),d.push({node:_,messageId:"unusedObjectTypeProperty",data:{propertyName:A}}));for(let[A,_]of d.entries())e.report({..._,fix:A===d.length-1?E=>{let I=a.properties.at(-1),g=D.join(", ");return I?I?.type===P.AST_NODE_TYPES.RestElement?null:E.insertTextAfter(I,`, ${g}`):E.insertTextBeforeRange([a.range[0]+1,a.range[1]],`${g}`)}:void 0})}return{VariableDeclaration(a){let i=a.declarations[0];if(!i)return;let u=new Map,o=i.id.type===P.AST_NODE_TYPES.Identifier&&i.id.typeAnnotation?.typeAnnotation.type===P.AST_NODE_TYPES.TSTypeReference&&i.id.typeAnnotation.typeAnnotation.typeName.type===P.AST_NODE_TYPES.Identifier&&i.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&i.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(o){if(o.type===P.AST_NODE_TYPES.TSTypeReference&&o.typeName.type===P.AST_NODE_TYPES.Identifier)r(!0,a,o.typeName,u,!1);else if(o.type===P.AST_NODE_TYPES.TSTypeLiteral)ct(u,...at(o));else if(o.type===P.AST_NODE_TYPES.TSIntersectionType)for(let d of o.types)d.type===P.AST_NODE_TYPES.TSTypeReference&&d.typeName.type===P.AST_NODE_TYPES.Identifier?r(!0,a,d.typeName,u,!1):c(!0,a,u,d,!0);if(u.size!==0&&i.init?.type===P.AST_NODE_TYPES.ArrowFunctionExpression){let d=i.init.params[0];if(!d){e.report({node:i.init,messageId:"missingComponentParam"});return}d.type===P.AST_NODE_TYPES.ObjectPattern&&h(d,u)}}},FunctionDeclaration:function(a){m(!1,a,a.params)},ArrowFunctionExpression(a){m(!1,a,a.params)}}}}),$e={name:lt,rule:hn};var Z=require("@typescript-eslint/utils"),Sn=Z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ft="prefer-named-functions",ut=new Map,bn=Sn({name:ft,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 n=null;if(t.ignoreRegex){let r=ut.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),ut.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===Z.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===Z.AST_NODE_TYPES.Identifier){let c=r.id.name;if(r.id.typeAnnotation||n&&n.test(c)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==Z.AST_NODE_TYPES.BlockStatement)return;let m=r.parent,h=r.init.params,a=r.init.body,i=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:c,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:u=>u.replaceText(m,`${i.async?"async ":""}function ${c}(${h.map(o=>e.sourceCode.getText(o)).join(", ")||""}) ${e.sourceCode.getText(a)}`)}]})}}}}}),De={name:ft,rule:bn};var N=require("@typescript-eslint/utils");var En=N.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pt="prefer-single-line-if",xn=L({maxLineLength:j(te()),maxNonSimpleConditionLength:j(te())}),Tn=En({name:pt,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:[xn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==N.AST_NODE_TYPES.BlockStatement||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let m=r.consequent.body[0];if(m.type===N.AST_NODE_TYPES.ReturnStatement){if(!(!m.argument||m.argument.type===N.AST_NODE_TYPES.Literal||m.argument.type===N.AST_NODE_TYPES.Identifier))return}else if(!(m.type===N.AST_NODE_TYPES.ContinueStatement||m.type===N.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===N.AST_NODE_TYPES.LogicalExpression||r.test.type===N.AST_NODE_TYPES.ConditionalExpression)return;let h;if(t.maxNonSimpleConditionLength&&(r.test.type===N.AST_NODE_TYPES.CallExpression||r.test.type===N.AST_NODE_TYPES.BinaryExpression||r.test.type===N.AST_NODE_TYPES.MemberExpression)&&(h=n.getText(r.test),h.length>t.maxNonSimpleConditionLength))return;h||(h=n.getText(r.test));let a=n.getText(m);if(h.includes(`
13
- `))return;let i=n.getTokenAfter(r);if(i&&i.type===N.AST_TOKEN_TYPES.Punctuator&&i.value==="}")return;let u=Rn(n,r),o=`if (${h}) ${a}`;t.maxLineLength&&o.length+u.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:d=>d.replaceText(r,o)})}}}});function Rn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Oe={name:pt,rule:Tn};var fe=require("@typescript-eslint/utils"),wn=fe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mt="require-description",In=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Cn=/^eslint-disable-(next-)?line$/u,kn=wn({name:mt,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 n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let c of n.getAllComments()){let m=vn(c);m!=null&&(r.has(m.kind)||m.description||e.report({loc:$n(c.loc),messageId:"missingDescription"}))}}}}}),dt={name:mt,rule:kn};function vn(e){let{text:t,description:n}=An(e.value);if(!t)return null;let r=In.exec(t);if(!r)return null;let c=r[1];if(!c)return null;let m=Cn.test(c);if(e.type===fe.TSESTree.AST_TOKEN_TYPES.Line&&!m||m&&e.loc.start.line!==e.loc.end.line)return null;let h=t.slice(r.index+c.length);return{kind:c,value:h.trim(),description:n}}function An(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function $n(e){return{start:{line:e.start.line,column:-1},end:e.end}}function ht(e){return/^use[A-Z0-9]/.test(e)}function pe(e){return e.type==="Identifier"?ht(e.name):e.type==="MemberExpression"&&!e.computed&&pe(e.property)?e.object.type==="Identifier":!1}function St(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function bt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Et(e){return!!(e.parent&&e.parent.callee&&bt(e.parent.callee,"forwardRef"))}function xt(e){return!!(e.parent&&e.parent.callee&&bt(e.parent.callee,"memo"))}function Pe(e){for(;e;){let t=Rt(e);if(t&&(St(t)||pe(t))||Et(e)||xt(e))return!0;e=e.parent}return!1}function gt(e){return!1}function _e(e){return!1}var Dn=/eslint +react-compiler\/react-compiler: +\["error/,Tt={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 i of e.sourceCode.getAllComments())if(Dn.test(i.value))return{CallExpression(u){let o=null;u.callee.name==="useMemo"?o="useMemo":u.callee.name==="useCallback"&&(o="useCallback"),o&&e.report({node:u,message:`"${o}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?i=>t(i):i=>e.sourceCode.getText(i),n=typeof e.getScope=="function"?()=>n():i=>e.sourceCode.getScope(i),r=null,c=[],m=[],h=new WeakSet;function a(i){for(let u of i.references){let o=u.identifier.parent;if(o.type==="VariableDeclarator"&&o.init&&o.init.type==="CallExpression"&&o.init.callee&&gt(o.init.callee))for(let d of u.resolved.references)d!==u&&h.add(d.identifier)}}return{onCodePathSegmentStart:i=>m.push(i),onCodePathSegmentEnd:()=>m.pop(),onCodePathStart:()=>c.push(new Map),onCodePathEnd(i,u){let o=c.pop();if(o.size===0)return;let d=new Set;function D(f,x){let{cache:T}=D,w=T.get(f.id),O=new Set(x);if(O.has(f.id)){let C=[...O],F=C.slice(C.indexOf(f.id)+1);for(let z of F)d.add(z);return BigInt("0")}if(O.add(f.id),w!==void 0)return w;if(i.thrownSegments.includes(f))w=BigInt("0");else if(f.prevSegments.length===0)w=BigInt("1");else{w=BigInt("0");for(let C of f.prevSegments)w+=D(C,O)}return f.reachable&&w===BigInt("0")?T.delete(f.id):T.set(f.id,w),w}function A(f,x){let{cache:T}=A,w=T.get(f.id),O=new Set(x);if(O.has(f.id)){let C=Array.from(O),F=C.slice(C.indexOf(f.id)+1);for(let z of F)d.add(z);return BigInt("0")}if(O.add(f.id),w!==void 0)return w;if(i.thrownSegments.includes(f))w=BigInt("0");else if(f.nextSegments.length===0)w=BigInt("1");else{w=BigInt("0");for(let C of f.nextSegments)w+=A(C,O)}return T.set(f.id,w),w}function _(f){let{cache:x}=_,T=x.get(f.id);if(T===null)return 1/0;if(T!==void 0)return T;if(x.set(f.id,null),f.prevSegments.length===0)T=1;else{T=1/0;for(let w of f.prevSegments){let O=_(w);O<T&&(T=O)}T+=1}return x.set(f.id,T),T}D.cache=new Map,A.cache=new Map,_.cache=new Map;let E=A(i.initialSegment),I=Rt(u),g=Pe(u),$=I?St(I)||pe(I):Et(u)||xt(u),R=1/0;for(let f of i.finalSegments){if(!f.reachable)continue;let x=_(f);x<R&&(R=x)}for(let[f,x]of o){if(!f.reachable)continue;let T=f.nextSegments.length===0?R<=_(f):R<_(f),w=D(f)*A(f),O=d.has(f.id);for(let C of x)if(O&&!_e(C)&&e.report({node:C,message:`React Hook "${t(C)}" 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.`}),$){if(u.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!O&&w!==E&&!_e(C)){let z=`React Hook "${t(C)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(T?" Did you accidentally call a React Hook after an early return?":"");e.report({node:C,message:z})}}else if(u.parent&&(u.parent.type==="MethodDefinition"||u.parent.type==="ClassProperty")&&u.parent.value===u){let F=`React Hook "${t(C)}" 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:C,message:F})}else if(I){let F=`React Hook "${t(C)}" is called in function "${t(I)}" 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:C,message:F})}else if(u.type==="Program"){let F=`React Hook "${t(C)}" 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:C,message:F})}else if(g&&!_e(C)){if(u.parent.type==="CallExpression"&&u.parent.callee.type==="Identifier"&&u.parent.callee.name==="useCallback"){let z=u.parent;if(z.parent.type==="VariableDeclarator"&&ht(z.parent.id.name))return}let F=`React Hook "${t(C)}" 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:C,message:F})}}},CallExpression(i){if(pe(i.callee)){let u=yt(c),o=yt(m),d=u.get(o);d||(d=[],u.set(o,d)),d.push(i.callee)}i.callee.type==="Identifier"&&(i.callee.name==="useEffect"||gt(i.callee))&&i.arguments.length>0&&(r=i)},Identifier(i){r==null&&h.has(i)&&i.parent.type!=="CallExpression"&&e.report({node:i,message:`\`${t(i)}\` 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"(i){i===r&&(r=null)},FunctionDeclaration(i){Pe(i)&&a(n(i))},ArrowFunctionExpression(i){Pe(i)&&a(n(i))}}}};function Rt(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 yt(e){return e[e.length-1]}var wt={[$e.name]:$e.rule,[Ie.name]:Ie.rule,[we.name]:we.rule,"rules-of-hooks":Tt,"exhaustive-deps":Xe,"require-description":dt.rule,[Ce.name]:Ce.rule,[ke.name]:ke.rule,[De.name]:De.rule,[be.name]:be.rule,[Re.name]:Re.rule,[ve.name]:ve.rule,[Oe.name]:Oe.rule};var On={rules:wt};0&&(module.exports={extendedLintPlugin});
12
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let x=r.acquire(g),R=new Set,O=null;{let s=x.upper;for(;s&&(R.add(s),s.type!=="function");)s=s.upper;if(!s)return;O=s}let C=Array.isArray;function N(s){if(!C(s.defs))return!1;let u=s.defs[0];if(u==null||u.node.type!=="VariableDeclarator")return!1;let d=u.node.init;if(d==null)return!1;for(;d.type==="TSAsExpression";)d=d.expression;let h=u.node.parent;if(h==null&&(Re(O.block,u.node.id),h=u.node.parent,h==null))return!1;if(h.kind==="const"&&d.type==="Literal"&&(typeof d.value=="string"||typeof d.value=="number"||d.value===null))return!0;if(d.type!=="CallExpression")return!1;let E=d.callee;if(E.type==="MemberExpression"&&E.object.name==="React"&&E.property!=null&&!E.computed&&(E=E.property),E.type!=="Identifier")return!1;let S=u.node.id,{name:k}=E;if(k==="useRef"&&S.type==="Identifier")return!0;if(en(E)&&S.type==="Identifier"){for(let v of s.references)v!==S&&A.add(v.identifier);return!0}else if(k==="useState"||k==="useReducer"){if(S.type==="ArrayPattern"&&S.elements.length===2&&C(s.identifiers)){if(S.elements[1]===s.identifiers[0]){if(k==="useState"){let v=s.references,W=0;for(let B=0;B<v.length;B++){if(v[B].isWrite()&&W++,W>1)return!1;l.set(v[B].identifier,S.elements[0])}}return!0}else if(S.elements[0]===s.identifiers[0]){if(k==="useState"){let v=s.references;for(let W=0;W<v.length;W++)a.add(v[W].identifier)}return!1}}}else if(k==="useTransition"&&S.type==="ArrayPattern"&&S.elements.length===2&&Array.isArray(s.identifiers)&&S.elements[1]===s.identifiers[0])return!0;return!1}function Y(s){if(!C(s.defs))return!1;let u=s.defs[0];if(u==null||u.node==null||u.node.id==null)return!1;let d=u.node,h=O.childScopes,E=null,S;for(S=0;S<h.length;S++){let k=h[S],v=k.block;if(d.type==="FunctionDeclaration"&&v===d||d.type==="VariableDeclarator"&&v.parent===d){E=k;break}}if(E==null)return!1;for(S=0;S<E.through.length;S++){let k=E.through[S];if(k.resolved!=null&&R.has(k.resolved.scope)&&!He(k.resolved))return!1}return!0}let He=_(N,y),$t=_(Y,D),We=new Map;function Dt(s){let u=s.from,d=!1;for(;u.block!==g;)u.type==="function"&&(d=u.block.parent!=null&&u.block.parent.type==="ReturnStatement"),u=u.upper;return d}let H=new Map,ye=new Map;Ue(x);function Ue(s){for(let u of s.references){if(!u.resolved||!R.has(u.resolved.scope))continue;let d=Re(g,u.identifier),h=et(d),E=G(h,ye);if(T&&h.type==="Identifier"&&(h.parent.type==="MemberExpression"||h.parent.type==="OptionalMemberExpression")&&!h.parent.computed&&h.parent.property.type==="Identifier"&&h.parent.property.name==="current"&&Dt(u)&&We.set(E,{reference:u,dependencyNode:h}),h.parent.type==="TSTypeQuery"||h.parent.type==="TSTypeReference")continue;let S=u.resolved.defs[0];if(S!=null&&!(S.node!=null&&S.node.init===g.parent)&&S.type!=="TypeParameter")if(H.has(E))H.get(E).references.push(u);else{let k=u.resolved,v=He(k)||$t(k);H.set(E,{isStable:v,references:[u]})}}for(let u of s.childScopes)Ue(u)}We.forEach(({reference:s,dependencyNode:u},d)=>{let h=s.resolved.references,E=!1;for(let S=0;S<h.length;S++){let{identifier:k}=h[S],{parent:v}=k;if(v!=null&&v.type==="MemberExpression"&&!v.computed&&v.property.type==="Identifier"&&v.property.name==="current"&&v.parent.type==="AssignmentExpression"&&v.parent.left===v){E=!0;break}}E||o({node:u.parent.property,message:`The ref value '${d}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${d}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ge=new Set;function Ot(s,u){ge.has(u)||(ge.add(u),o({node:s,message:`Assignments to the '${u}' variable from inside React Hook ${n(w)} 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 ${n(w)}.`}))}let se=new Set;if(H.forEach(({isStable:s,references:u},d)=>{s&&se.add(d),u.forEach(h=>{h.writeExpr&&Ot(h.writeExpr,d)})}),ge.size>0)return;if(!$){let s=null;if(H.forEach(({isStable:u,references:d},h)=>{s||d.forEach(E=>{if(s)return;let S=E.identifier;if(!l.has(S))return;let v=E.from;for(;v.type!=="function";)v=v.upper;v.block===g&&(s=h)})}),s){let{suggestedDependencies:u}=xe({dependencies:H,declaredDependencies:[],stableDependencies:se,externalDependencies:new Set,isEffect:!0});o({node:w,message:`React Hook ${f} contains a call to '${s}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+u.join(", ")+`] as a second argument to the ${f} Hook.`,suggest:[{desc:`Add dependencies array: [${u.join(", ")}]`,fix(d){return d.insertTextAfter(g,`, [${u.join(", ")}]`)}}]})}return}let ee=[],te=new Set;$.type!=="ArrayExpression"?o({node:$,message:`React Hook ${n(w)} 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.`}):$.elements.forEach(s=>{if(s===null)return;if(s.type==="SpreadElement"){o({node:s,message:`React Hook ${n(w)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}A.has(s)&&o({node:s,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(s)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(s)}\``,fix(E){return E.removeRange(s.range)}}]});let u;try{u=G(s,ye)}catch(E){if(/Unsupported node type/.test(E.message)){s.type==="Literal"?H.has(s.value)?o({node:s,message:`The ${s.raw} literal is not a valid dependency because it never changes. Did you mean to include ${s.value} in the array instead?`}):o({node:s,message:`The ${s.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):o({node:s,message:`React Hook ${n(w)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw E}let d=s;for(;d.type==="MemberExpression"||d.type==="OptionalMemberExpression"||d.type==="ChainExpression";)d=d.object||d.expression.object;let h=!O.through.some(E=>E.identifier===d);ee.push({key:u,node:s}),h||te.add(u)});let{suggestedDependencies:Pt,unnecessaryDependencies:oe,missingDependencies:X,duplicateDependencies:Ve}=xe({dependencies:H,declaredDependencies:ee,stableDependencies:se,externalDependencies:te,isEffect:T}),ae=Pt;if(Ve.size+X.size+oe.size===0){if(t)return;Kt({declaredDependencies:ee,declaredDependenciesNode:$,componentScope:O,scope:x}).forEach(({construction:u,isUsedOutsideOfHook:d,depType:h})=>{let E=h==="function"?"useCallback":"useMemo",S=h==="function"?"definition":"initialization",k=`wrap the ${S} of '${u.name.name}' in its own ${E}() Hook.`,v=d?`To fix this, ${k}`:`Move it inside the ${f} callback. Alternatively, ${k}`,W=h==="conditional"||h==="logical expression"?"could make":"makes",B=`The '${u.name.name}' ${h} ${W} the dependencies of ${f} Hook (at line ${$.loc.start.line}) change on every render. ${v}`,ze;d&&u.type==="Variable"&&h==="function"&&(ze=[{desc:`Wrap the ${S} of '${u.name.name}' in its own ${E}() Hook.`,fix(Ye){let[Nt,Ft]=E==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Ye.insertTextBefore(u.node.init,Nt),Ye.insertTextAfter(u.node.init,Ft)]}}]),o({node:u.node,message:B,suggest:ze})});return}!T&&X.size>0&&(ae=xe({dependencies:H,declaredDependencies:[],stableDependencies:se,externalDependencies:te,isEffect:T}).suggestedDependencies);function _t(){if(ee.length===0)return!0;let s=ee.map(d=>d.key),u=s.slice().sort();return s.join(",")===u.join(",")}_t()&&ae.sort();function he(s){let u=s.split("."),d="";for(let h=0;h<u.length;h++){if(h!==0){let E=u.slice(0,h+1).join("."),S=ye.get(E)===!0;d+=S?"?.":"."}d+=u[h]}return d}function Se(s,u,d,h){return s.size===0?null:(s.size>1?"":u+" ")+d+" "+(s.size>1?"dependencies":"dependency")+": "+Zt(Array.from(s).sort().map(E=>"'"+he(E)+"'"))+`. Either ${h} ${s.size>1?"them":"it"} or remove the dependency array.`}let z="";if(oe.size>0){let s=null;if(Array.from(oe.keys()).forEach(u=>{s===null&&u.endsWith(".current")&&(s=u)}),s!==null)z=` Mutable values like '${s}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(te.size>0){let u=Array.from(te)[0];x.set.has(u)||(z=` Outer scope values like '${u}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!z&&X.has("props")){let s=H.get("props");if(s==null)return;let u=s.references;if(!Array.isArray(u))return;let d=!0;for(let h=0;h<u.length;h++){let E=u[h],S=Re(O.block,E.identifier);if(!S){d=!1;break}let k=S.parent;if(k==null){d=!1;break}if(k.type!=="MemberExpression"&&k.type!=="OptionalMemberExpression"){d=!1;break}}d&&(z=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${f} call and refer to those specific props inside ${n(w)}.`)}if(!z&&X.size>0){let s=null;X.forEach(u=>{if(s)return;let d=O.set.get(u),h=H.get(u);if(h.references[0].resolved!==d)return;let E=d.defs[0];if(E==null||E.name==null||E.type!=="Parameter")return;let S=!1,k;for(let v=0;v<h.references.length;v++)if(k=h.references[v].identifier,k!=null&&k.parent!=null&&(k.parent.type==="CallExpression"||k.parent.type==="OptionalCallExpression")&&k.parent.callee===k){S=!0;break}S&&(s=u)}),s!==null&&(z=` If '${s}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!z&&X.size>0){let s=null;if(X.forEach(u=>{if(s!==null)return;let h=H.get(u).references,E,S;for(let k=0;k<h.length;k++){for(E=h[k].identifier,S=E.parent;S!=null&&S!==O.block;){if(S.type==="CallExpression"){let v=l.get(S.callee);if(v!=null){if(v.name===u)s={missingDep:u,setter:S.callee.name,form:"updater"};else if(a.has(E))s={missingDep:u,setter:S.callee.name,form:"reducer"};else{let W=h[k].resolved;if(W!=null){let B=W.defs[0];B!=null&&B.type==="Parameter"&&(s={missingDep:u,setter:S.callee.name,form:"inlineReducer"})}}break}}S=S.parent}if(s!==null)break}}),s!==null)switch(s.form){case"reducer":z=` You can also replace multiple useState variables with useReducer if '${s.setter}' needs the current value of '${s.missingDep}'.`;break;case"inlineReducer":z=` If '${s.setter}' needs the current value of '${s.missingDep}', you can also switch to useReducer instead of useState and read '${s.missingDep}' in the reducer.`;break;case"updater":z=` You can also do a functional update '${s.setter}(${s.missingDep.slice(0,1)} => ...)' if you only need '${s.missingDep}' in the '${s.setter}' call.`;break;default:throw new Error("Unknown case.")}}o({node:$,message:`React Hook ${n(w)} has `+(Se(X,"a","missing","include")||Se(oe,"an","unnecessary","exclude")||Se(Ve,"a","duplicate","omit"))+z,suggest:[{desc:`Update the dependencies array to be: [${ae.map(he).join(", ")}]`,fix(s){return s.replaceText($,`[${ae.map(he).join(", ")}]`)}}]})}function I(g){let $=Jt(g.callee,m);if($===-1)return;let w=g.arguments[$],f=g.callee,T=tt(f).name,x=g.arguments[$+1],R=/Effect($|[^a-z])/g.test(T);if(!w){o({node:f,message:`React Hook ${T} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!R)){if(!x&&!R){(T==="useMemo"||T==="useCallback")&&o({node:f,message:`React Hook ${T} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(w.type){case"FunctionExpression":case"ArrowFunctionExpression":b(w,x,f,T,R);return;case"Identifier":if(!x||x.elements&&x.elements.some(N=>N&&N.type==="Identifier"&&N.name===w.name))return;let O=i(g).set.get(w.name);if(O==null||O.defs==null)return;let C=O.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":b(C.node,x,f,T,R);return;case"VariableDeclarator":let N=C.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":b(N,x,f,T,R);return}break}break;default:o({node:f,message:`React Hook ${T} received a function whose dependencies are unknown. Pass an inline function instead.`});return}o({node:f,message:`React Hook ${T} has a missing dependency: '${w.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${w.name}]`,fix(O){return O.replaceText(x,`[${w.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(Xt.test(g.value))return t=!0,{CallExpression:$=>I($,!0)}}return{CallExpression:g=>I(g)}}};function xe({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:i,isEffect:c}){let p=m();function m(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((b,I)=>{let g=o(p,I);g.isUsed=!0,r(p,I,$=>{$.isSubtreeUsed=!0})}),t.forEach(({key:b})=>{let I=o(p,b);I.isSatisfiedRecursively=!0}),n.forEach(b=>{let I=o(p,b);I.isSatisfiedRecursively=!0});function o(b,I){let g=I.split("."),$=b;for(let w of g){let f=$.children.get(w);f||(f=m(),$.children.set(w,f)),$=f}return $}function r(b,I,g){let $=I.split("."),w=b;for(let f of $){let T=w.children.get(f);if(!T)return;g(T),w=T}}let l=new Set,a=new Set;y(p,l,a,b=>b);function y(b,I,g,$){b.children.forEach((w,f)=>{let T=$(f);if(w.isSatisfiedRecursively){w.isSubtreeUsed&&g.add(T);return}if(w.isUsed){I.add(T);return}y(w,I,g,x=>T+"."+x)})}let D=[],A=new Set,_=new Set;return t.forEach(({key:b})=>{a.has(b)?D.indexOf(b)===-1?D.push(b):_.add(b):A.add(b)}),l.forEach(b=>{D.push(b)}),{suggestedDependencies:D,unnecessaryDependencies:A,duplicateDependencies:_,missingDependencies:l}}function K(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 K(e.consequent)!=null||K(e.alternate)!=null?"conditional":null;case"LogicalExpression":return K(e.left)!=null||K(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return K(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return K(e.expression);case"TSAsExpression":return K(e.expression)}return null}function Kt({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:i}){let c=e.map(({key:m})=>{let o=n.variables.find(l=>l.name===m);if(o==null)return null;let r=o.defs[0];if(r==null)return null;if(r.type==="Variable"&&r.node.type==="VariableDeclarator"&&r.node.id.type==="Identifier"&&r.node.init!=null){let l=K(r.node.init);if(l!=null)return[o,l]}return r.type==="FunctionName"&&r.node.type==="FunctionDeclaration"?[o,"function"]:r.type==="ClassName"&&r.node.type==="ClassDeclaration"?[o,"class"]:null}).filter(Boolean);function p(m){let o=!1;for(let r=0;r<m.references.length;r++){let l=m.references[r];if(l.writeExpr){if(o)return!0;o=!0;continue}let a=l.from;for(;a!==i&&a!=null;)a=a.upper;if(a!==i&&!nt(t,l.identifier))return!0}return!1}return c.map(([m,o])=>({construction:m.defs[0],depType:o,isUsedOutsideOfHook:p(m)}))}function et(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)?et(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function we(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function G(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=G(e.object,t),i=G(e.property,null),c=`${n}.${i}`;return we(e,t,c),c}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=G(e.object,t),i=G(e.property,null),c=`${n}.${i}`;return we(e,t,c),c}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let i=G(n.object,t),c=G(n.property,null),p=`${i}.${c}`;return we(n,t,p),p}else throw new Error(`Unsupported node type: ${e.type}`)}function tt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Jt(e,t){let n=tt(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let i;try{i=G(n,null)}catch(c){if(/Unsupported node type/.test(c.message))return 0;throw c}return t.additionalHooks.test(i)?0:-1}else return-1}}function Re(e,t){let n=[e],i=null;for(;n.length;){if(i=n.shift(),Qt(i,t))return i;if(nt(i,t))for(let[c,p]of Object.entries(i))c!=="parent"&&(Ze(p)?(p.parent=i,n.push(p)):Array.isArray(p)&&p.forEach(m=>{Ze(m)&&(m.parent=i,n.push(m))}))}return null}function Zt(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Ze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Qt(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 nt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function en(e){return!1}var ue=require("@typescript-eslint/utils");var tn=ue.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rt="no-call-with-explicit-generics",nn=M({functions:U(F())}),rn=tn({name:rt,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:[nn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(i){let{callee:c}=i;c.type===ue.AST_NODE_TYPES.Identifier&&n.has(c.name)&&i.typeArguments&&e.report({node:i,messageId:"noExplicitGenerics",data:{functionName:c.name}})}}}}),Ie={name:rt,rule:rn};var J=require("@typescript-eslint/utils"),sn=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),it="no-call-with-inferred-generics",on=sn({name:it,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 n=new Map(t.functions.map(i=>[i.name,i]));return{CallExpression(i){let{callee:c}=i;if(c.type!==J.AST_NODE_TYPES.Identifier)return;let p=n.get(c.name);if(!p)return;let{minGenerics:m=1,allowAny:o,disallowTypes:r=t.disallowTypes}=p;(i.typeArguments?.params.length||0)<(m||0)&&e.report({node:i,messageId:"missingGenericDeclaration",data:{functionName:c.name,minGenerics:m||0}}),!(o&&!r)&&i.typeArguments?.params?.some(a=>!o&&a.type===J.AST_NODE_TYPES.TSAnyKeyword||r&&a.type===J.AST_NODE_TYPES.TSTypeReference&&a.typeName.type===J.AST_NODE_TYPES.Identifier&&r.includes(a.typeName.name))&&e.report({node:i,messageId:"anyUsedInGenerics",data:{functionName:c.name}})}}}}),Ce={name:it,rule:on};var ie=require("@typescript-eslint/utils"),an=ie.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),st="no-commented-out-code",cn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],ln=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],un=an({name:st,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let i=n.trimStart();if(n.startsWith("*")||i.startsWith("INFO:")||i.startsWith("TODO:")||i.startsWith("DOCS:")||i.startsWith("FIX:")||i.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let c of cn)if(i.startsWith(c))return{wrongPattern:c};for(let c of ln)if(typeof c=="string"){if(n.includes(c))return{wrongPattern:c}}else if(c.test(n))return{wrongPattern:`regex(${c.toString()})`};return!1}return{Program(){let i=e.sourceCode.getAllComments();for(let c of i)if(c.type===ie.TSESTree.AST_TOKEN_TYPES.Line||c.type===ie.TSESTree.AST_TOKEN_TYPES.Block){let p=t(c.value);p&&e.report({node:c,messageId:"commentedOutCode",data:{wrongPattern:p.wrongPattern}})}}}}}),ke={name:st,rule:un};var pe=require("@typescript-eslint/utils"),pn=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ot="no-default-export",fn=pn({name:ot,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 n of t.specifiers)n.exported.type===pe.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ve={name:ot,rule:fn};var q=require("@typescript-eslint/utils"),mn=q.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ct="no-non-camel-case-functions",dn=/^[a-z][a-zA-Z0-9]*$/;function at(e){return e.typeName.type===q.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===q.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===q.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var yn=mn({name:ct,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&&!dn.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===q.AST_NODE_TYPES.TSTypeReference?at(n):n.type===q.AST_NODE_TYPES.TSUnionType&&n.types.some(c=>c.type===q.AST_NODE_TYPES.TSTypeReference&&at(c))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Ae={name:ct,rule:yn};var V=require("@typescript-eslint/utils");function $e(e,t){if(e.parent)return e.type===t?e:$e(e.parent,t)}function*De(e){yield e,e.parent&&(yield*De(e.parent))}var gn=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lt="no-optional-root-props",hn=gn({name:lt,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.'},schema:[],fixable:"code"},defaultOptions:[],create(e){function t(p){return p.parent.type===V.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration}let n=new Set;function i(p){if(n.has(p))return!1;n.add(p);let o=e.sourceCode.getDeclaredVariables(p)[0];if(!o||o.references.length!==1)return!1;let r=o.references[0];if(!r)return!1;for(let l of De(r.identifier)){if("returnType"in l||l.type===V.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;if(l.type===V.TSESTree.AST_NODE_TYPES.TSTypeAliasDeclaration||l.type===V.TSESTree.AST_NODE_TYPES.TSInterfaceDeclaration)return i(l)}return!0}function c(p){p.key.type!==V.TSESTree.AST_NODE_TYPES.Identifier||!p.optional||e.report({node:p.key,messageId:"optionalNotAllowed",data:{propertyName:p.key.name},fix:m=>{let o=$e(p,V.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!o)return null;let r=e.sourceCode.getText(o);return m.replaceText(o,r.replace("?:",": undefined |"))}})}return{TSTypeAliasDeclaration(p){if(p.typeAnnotation.type===V.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(t(p)||!i(p)))for(let m of p.typeAnnotation.members)m.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&c(m)},TSInterfaceDeclaration(p){if(!(t(p)||!i(p)))for(let m of p.body.body)m.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&c(m)}}}}),Oe={name:lt,rule:hn};var ut=require("@typescript-eslint/utils"),fe=Vt(require("path"));var Sn=ut.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pt="no-relative-imports",En=M({find:F(),replacement:F()}),bn=M({aliases:U(En),rootDir:L(F()),allowNotFoundAliases:L(le()),_dev_simulateFileName:L(F())}),Tn=Sn({name:pt,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:[bn]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function i(m){return m.startsWith(".")||m.startsWith("..")}function c(m,o){let r=fe.default.dirname(o);return fe.default.resolve(r,m)}function p(m){let o=t.rootDir??process.cwd(),r=fe.default.relative(o,m);if(r.startsWith("."))return null;r.startsWith("/")||(r=`/${r}`);for(let{find:l,replacement:a}of t.aliases)if(r.startsWith(a)){let y=r.replace(a,l);return{alias:l,newPath:y}}return null}return{ImportDeclaration(m){let o=m.source.value;if(!i(o))return;let r=c(o,n),l=p(r);!l&&t.allowNotFoundAliases||e.report({node:m,messageId:l?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:l?.alias},fix:l?a=>a.replaceText(m.source,`'${l.newPath}'`):void 0})}}}}),Pe={name:pt,rule:Tn};var P=require("@typescript-eslint/utils");var xn=P.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function ft(e){let t=[];for(let n of e.members)n.type===P.AST_NODE_TYPES.TSPropertySignature&&n.key.type===P.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function mt(e,...t){for(let n of t)e.set(...n);return e}var wn=M({forceCheckOnFCPropTypesWithName:L(U(F()))}),dt="no-unused-type-props-in-args",_e=null,Rn=xn({name:dt,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:[wn],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!_e&&(_e=n.map(o=>new RegExp(o)));function i(o,r,l,a,y=!0){let D=l.name,A=e.sourceCode.getScope(r).references.find(I=>I.identifier.name===D)?.resolved,_=o&&_e?.some(I=>I.test(D));if(!A||!_&&A.references.filter(I=>I.isTypeReference).length>1)return;let b=A?.defs[0]?.node;if(!(y&&b?.parent?.type===P.AST_NODE_TYPES.ExportNamedDeclaration)){if(b?.type===P.AST_NODE_TYPES.TSTypeAliasDeclaration){c(o,r,a,b.typeAnnotation,!0);return}if(b?.type===P.AST_NODE_TYPES.TSInterfaceDeclaration){c(o,r,a,b.body,!0);return}}}function c(o,r,l,a,y){if(a.type===P.AST_NODE_TYPES.TSInterfaceBody){for(let D of a.body)D.type===P.AST_NODE_TYPES.TSPropertySignature&&D.key.type===P.AST_NODE_TYPES.Identifier&&l.set(D.key.name,D);return}if(a.type===P.AST_NODE_TYPES.TSTypeLiteral){mt(l,...ft(a));return}if(a.type===P.AST_NODE_TYPES.TSIntersectionType){for(let D of a.types)c(o,r,l,D,!0);return}y||a.type===P.AST_NODE_TYPES.TSTypeReference&&a.typeName.type===P.AST_NODE_TYPES.Identifier&&i(o,r,a.typeName,l)}function p(o,r,l){for(let a of l)if(a.type==="ObjectPattern"&&a.typeAnnotation){let y=new Map;if(c(o,r,y,a.typeAnnotation.typeAnnotation,!1),y.size===0)continue;m(a,y)}else a.type===P.AST_NODE_TYPES.AssignmentPattern&&a.left.type===P.AST_NODE_TYPES.ObjectPattern&&p(o,r,[a.left])}function m(o,r){let l=[];if(o.properties.at(-1)?.type===P.AST_NODE_TYPES.RestElement)return;for(let A of o.properties)A.type===P.AST_NODE_TYPES.Property&&A.key.type===P.AST_NODE_TYPES.Identifier&&l.push(A.key.name);let y=[],D=[];for(let[A,_]of r)l.includes(A)||(D.push(A),y.push({node:_,messageId:"unusedObjectTypeProperty",data:{propertyName:A}}));for(let[A,_]of y.entries())e.report({..._,fix:A===y.length-1?b=>{let I=o.properties.at(-1),g=D.join(", ");return I?I?.type===P.AST_NODE_TYPES.RestElement?null:b.insertTextAfter(I,`, ${g}`):b.insertTextBeforeRange([o.range[0]+1,o.range[1]],`${g}`)}:void 0})}return{VariableDeclaration(o){let r=o.declarations[0];if(!r)return;let l=new Map,a=r.id.type===P.AST_NODE_TYPES.Identifier&&r.id.typeAnnotation?.typeAnnotation.type===P.AST_NODE_TYPES.TSTypeReference&&r.id.typeAnnotation.typeAnnotation.typeName.type===P.AST_NODE_TYPES.Identifier&&r.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&r.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(a){if(a.type===P.AST_NODE_TYPES.TSTypeReference&&a.typeName.type===P.AST_NODE_TYPES.Identifier)i(!0,o,a.typeName,l,!1);else if(a.type===P.AST_NODE_TYPES.TSTypeLiteral)mt(l,...ft(a));else if(a.type===P.AST_NODE_TYPES.TSIntersectionType)for(let y of a.types)y.type===P.AST_NODE_TYPES.TSTypeReference&&y.typeName.type===P.AST_NODE_TYPES.Identifier?i(!0,o,y.typeName,l,!1):c(!0,o,l,y,!0);if(l.size!==0&&r.init?.type===P.AST_NODE_TYPES.ArrowFunctionExpression){let y=r.init.params[0];if(!y){e.report({node:r.init,messageId:"missingComponentParam"});return}y.type===P.AST_NODE_TYPES.ObjectPattern&&m(y,l)}}},FunctionDeclaration:function(o){p(!1,o,o.params)},ArrowFunctionExpression(o){p(!1,o,o.params)}}}}),Ne={name:dt,rule:Rn};var Q=require("@typescript-eslint/utils"),In=Q.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gt="prefer-named-functions",yt=new Map,Cn=In({name:gt,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 n=null;if(t.ignoreRegex){let i=yt.get(t.ignoreRegex);i?n=i:(n=new RegExp(t.ignoreRegex),yt.set(t.ignoreRegex,n))}return{VariableDeclarator(i){if(i.init&&i.init.type===Q.AST_NODE_TYPES.ArrowFunctionExpression&&i.id.type===Q.AST_NODE_TYPES.Identifier){let c=i.id.name;if(i.id.typeAnnotation||n&&n.test(c)||!t.disallowArrowFnWithImplicitReturns&&i.init.body.type!==Q.AST_NODE_TYPES.BlockStatement)return;let p=i.parent,m=i.init.params,o=i.init.body,r=i.init;e.report({node:i.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:c,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:l=>l.replaceText(p,`${r.async?"async ":""}function ${c}(${m.map(a=>e.sourceCode.getText(a)).join(", ")||""}) ${e.sourceCode.getText(o)}`)}]})}}}}}),Fe={name:gt,rule:Cn};var j=require("@typescript-eslint/utils");var kn=j.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ht="prefer-single-line-if",vn=M({maxLineLength:L(ne()),maxNonSimpleConditionLength:L(ne())}),An=kn({name:ht,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:[vn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(i){if(i.consequent.type!==j.AST_NODE_TYPES.BlockStatement||n.getCommentsInside(i.consequent).length>0||i.alternate||i.consequent.body.length!==1)return;let p=i.consequent.body[0];if(p.type===j.AST_NODE_TYPES.ReturnStatement){if(!(!p.argument||p.argument.type===j.AST_NODE_TYPES.Literal||p.argument.type===j.AST_NODE_TYPES.Identifier))return}else if(!(p.type===j.AST_NODE_TYPES.ContinueStatement||p.type===j.AST_NODE_TYPES.BreakStatement))return;if(i.test.type===j.AST_NODE_TYPES.LogicalExpression||i.test.type===j.AST_NODE_TYPES.ConditionalExpression)return;let m;if(t.maxNonSimpleConditionLength&&(i.test.type===j.AST_NODE_TYPES.CallExpression||i.test.type===j.AST_NODE_TYPES.BinaryExpression||i.test.type===j.AST_NODE_TYPES.MemberExpression)&&(m=n.getText(i.test),m.length>t.maxNonSimpleConditionLength))return;m||(m=n.getText(i.test));let o=n.getText(p);if(m.includes(`
13
+ `))return;let r=n.getTokenAfter(i);if(r&&r.type===j.AST_TOKEN_TYPES.Punctuator&&r.value==="}")return;let l=$n(n,i),a=`if (${m}) ${o}`;t.maxLineLength&&a.length+l.length>t.maxLineLength||e.report({node:i,messageId:"noSingleLineCurly",fix:y=>y.replaceText(i,a)})}}}});function $n(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Me={name:ht,rule:An};var me=require("@typescript-eslint/utils"),Dn=me.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),St="require-description",On=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Pn=/^eslint-disable-(next-)?line$/u,_n=Dn({name:St,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 n=e.sourceCode,i=new Set(t.ignore||[]);return{Program(){for(let c of n.getAllComments()){let p=Nn(c);p!=null&&(i.has(p.kind)||p.description||e.report({loc:Mn(c.loc),messageId:"missingDescription"}))}}}}}),Et={name:St,rule:_n};function Nn(e){let{text:t,description:n}=Fn(e.value);if(!t)return null;let i=On.exec(t);if(!i)return null;let c=i[1];if(!c)return null;let p=Pn.test(c);if(e.type===me.TSESTree.AST_TOKEN_TYPES.Line&&!p||p&&e.loc.start.line!==e.loc.end.line)return null;let m=t.slice(i.index+c.length);return{kind:c,value:m.trim(),description:n}}function Fn(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Mn(e){return{start:{line:e.start.line,column:-1},end:e.end}}function xt(e){return/^use[A-Z0-9]/.test(e)}function de(e){return e.type==="Identifier"?xt(e.name):e.type==="MemberExpression"&&!e.computed&&de(e.property)?e.object.type==="Identifier":!1}function wt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Rt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function It(e){return!!(e.parent&&e.parent.callee&&Rt(e.parent.callee,"forwardRef"))}function Ct(e){return!!(e.parent&&e.parent.callee&&Rt(e.parent.callee,"memo"))}function Le(e){for(;e;){let t=vt(e);if(t&&(wt(t)||de(t))||It(e)||Ct(e))return!0;e=e.parent}return!1}function bt(e){return!1}function je(e){return!1}var Ln=/eslint +react-compiler\/react-compiler: +\["error/,kt={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 r of e.sourceCode.getAllComments())if(Ln.test(r.value))return{CallExpression(l){let a=null;l.callee.name==="useMemo"?a="useMemo":l.callee.name==="useCallback"&&(a="useCallback"),a&&e.report({node:l,message:`"${a}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?r=>t(r):r=>e.sourceCode.getText(r),n=typeof e.getScope=="function"?()=>n():r=>e.sourceCode.getScope(r),i=null,c=[],p=[],m=new WeakSet;function o(r){for(let l of r.references){let a=l.identifier.parent;if(a.type==="VariableDeclarator"&&a.init&&a.init.type==="CallExpression"&&a.init.callee&&bt(a.init.callee))for(let y of l.resolved.references)y!==l&&m.add(y.identifier)}}return{onCodePathSegmentStart:r=>p.push(r),onCodePathSegmentEnd:()=>p.pop(),onCodePathStart:()=>c.push(new Map),onCodePathEnd(r,l){let a=c.pop();if(a.size===0)return;let y=new Set;function D(f,T){let{cache:x}=D,R=x.get(f.id),O=new Set(T);if(O.has(f.id)){let C=[...O],N=C.slice(C.indexOf(f.id)+1);for(let Y of N)y.add(Y);return BigInt("0")}if(O.add(f.id),R!==void 0)return R;if(r.thrownSegments.includes(f))R=BigInt("0");else if(f.prevSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let C of f.prevSegments)R+=D(C,O)}return f.reachable&&R===BigInt("0")?x.delete(f.id):x.set(f.id,R),R}function A(f,T){let{cache:x}=A,R=x.get(f.id),O=new Set(T);if(O.has(f.id)){let C=Array.from(O),N=C.slice(C.indexOf(f.id)+1);for(let Y of N)y.add(Y);return BigInt("0")}if(O.add(f.id),R!==void 0)return R;if(r.thrownSegments.includes(f))R=BigInt("0");else if(f.nextSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let C of f.nextSegments)R+=A(C,O)}return x.set(f.id,R),R}function _(f){let{cache:T}=_,x=T.get(f.id);if(x===null)return 1/0;if(x!==void 0)return x;if(T.set(f.id,null),f.prevSegments.length===0)x=1;else{x=1/0;for(let R of f.prevSegments){let O=_(R);O<x&&(x=O)}x+=1}return T.set(f.id,x),x}D.cache=new Map,A.cache=new Map,_.cache=new Map;let b=A(r.initialSegment),I=vt(l),g=Le(l),$=I?wt(I)||de(I):It(l)||Ct(l),w=1/0;for(let f of r.finalSegments){if(!f.reachable)continue;let T=_(f);T<w&&(w=T)}for(let[f,T]of a){if(!f.reachable)continue;let x=f.nextSegments.length===0?w<=_(f):w<_(f),R=D(f)*A(f),O=y.has(f.id);for(let C of T)if(O&&!je(C)&&e.report({node:C,message:`React Hook "${t(C)}" 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.`}),$){if(l.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!O&&R!==b&&!je(C)){let Y=`React Hook "${t(C)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(x?" Did you accidentally call a React Hook after an early return?":"");e.report({node:C,message:Y})}}else if(l.parent&&(l.parent.type==="MethodDefinition"||l.parent.type==="ClassProperty")&&l.parent.value===l){let N=`React Hook "${t(C)}" 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:C,message:N})}else if(I){let N=`React Hook "${t(C)}" is called in function "${t(I)}" 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:C,message:N})}else if(l.type==="Program"){let N=`React Hook "${t(C)}" 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:C,message:N})}else if(g&&!je(C)){if(l.parent.type==="CallExpression"&&l.parent.callee.type==="Identifier"&&l.parent.callee.name==="useCallback"){let Y=l.parent;if(Y.parent.type==="VariableDeclarator"&&xt(Y.parent.id.name))return}let N=`React Hook "${t(C)}" 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:C,message:N})}}},CallExpression(r){if(de(r.callee)){let l=Tt(c),a=Tt(p),y=l.get(a);y||(y=[],l.set(a,y)),y.push(r.callee)}r.callee.type==="Identifier"&&(r.callee.name==="useEffect"||bt(r.callee))&&r.arguments.length>0&&(i=r)},Identifier(r){i==null&&m.has(r)&&r.parent.type!=="CallExpression"&&e.report({node:r,message:`\`${t(r)}\` 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"(r){r===i&&(i=null)},FunctionDeclaration(r){Le(r)&&o(n(r))},ArrowFunctionExpression(r){Le(r)&&o(n(r))}}}};function vt(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 Tt(e){return e[e.length-1]}var At={[Ne.name]:Ne.rule,[ke.name]:ke.rule,[Ce.name]:Ce.rule,"rules-of-hooks":kt,"exhaustive-deps":Qe,"require-description":Et.rule,[ve.name]:ve.rule,[Ae.name]:Ae.rule,[Fe.name]:Fe.rule,[Te.name]:Te.rule,[Ie.name]:Ie.rule,[Pe.name]:Pe.rule,[Me.name]:Me.rule,[Oe.name]:Oe.rule};var jn={rules:At};0&&(module.exports={extendedLintPlugin});
@@ -1,4 +1,4 @@
1
- import{AST_NODE_TYPES as pe,ESLintUtils as Ct}from"@typescript-eslint/utils";var ue=Symbol.for("optional");function j(e){return{...e,[ue]:!0}}function Le(e,t){return{enum:e,...t}}function re(e){return{...e,type:"boolean"}}function M(e){return{...e,type:"string"}}function Z(e){return{...e,type:"number"}}function je(e){return{...e,type:"integer"}}function W(e,t){return{...t,type:"array",items:e}}function L(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let i,l=[];for(i in e)e[i][ue]?e[i][ue]=void 0:l.push(i);l.length>0&&(n.required=l)}return n}function fe(...e){return{anyOf:e}}var kt=Ct.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt=L({disallow:j(W(L({selector:M(),message:M(),replace:j(fe(M(),L({regex:M(),with:M()}))),replaceType:j(Le(["suggestion","autofix"]))}))),__dev_simulateFileName:j(M()),mustMatchSyntax:j(W(L({includeRegex:M(),mustCallFn:W(L({anyCall:W(L({fn:M(),withArgs:W(L({atIndex:je(),literal:fe(M(),Z(),re())}))})),message:j(M())}))})))}),We="advanced-no-restricted-syntax",At=kt({name:We,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[vt],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:i,__dev_simulateFileName:l,disallow:m}=t,h=l??e.filename,a=[],r=new Set;for(let{includeRegex:o,mustCallFn:d}of i??[]){let D=$t(h,new RegExp(o));if(!D)continue;let A=P=>{let E=P;for(let{name:I,value:g}of D)E=E.replaceAll(I,g);return E};for(let{anyCall:P,message:E}of d){let I=`Expected file to call the function: ${P.map(({fn:g})=>g).join(" or ")}`;r.add(I),a.push(g=>{let{callee:$}=g;if($.type===pe.Identifier){for(let{fn:R,withArgs:f}of P)if($.name===R){r.delete(I);for(let x of f){let T=g.arguments[x.atIndex],w=typeof x.literal=="string"?A(x.literal):x.literal;if(!T){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${w}" at index ${x.atIndex}${E?`: ${A(E)}`:""}`}});continue}if(T.type!==pe.Literal){e.report({node:T,messageId:"default",data:{message:`Argument at position ${x.atIndex} should the literal "${w}"${E?`: ${A(E)}`:""}`}});continue}T.value!==w&&e.report({node:T,messageId:"default",data:{message:`Argument should have the value "${w}"${E?`: ${A(E)}`:""}`},fix:O=>O.replaceText(T,typeof w=="string"?`'${w}'`:String(w))})}break}}})}}for(let{selector:o,message:d,replace:D,replaceType:A="suggestion"}of m??[]){if(o==="CallExpression"){a.push(P=>{u(D,P,d,A)});continue}n[o]=P=>{u(D,P,d,A)}}return a.length>0&&(n.CallExpression=o=>{if(o.type===pe.CallExpression)for(let d of a)d(o)}),n["Program:exit"]=o=>{for(let d of r)e.report({node:o,messageId:"default",data:{message:`${d}`}})},n;function u(o,d,D,A){let P=E=>{if(!o)return null;if(typeof o=="string")return E.replaceText(d,o);{let I=new RegExp(o.regex),g=e.sourceCode.getText(d);return E.replaceText(d,g.replace(I,o.with))}};e.report({node:d,messageId:"default",data:{message:D},fix:o&&A==="autofix"?P:void 0,suggest:o&&A==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof o=="string"?o:o.with}"`},fix:P}]:void 0})}}});function $t(e,t){let n=[],i=t.exec(e);if(!i)return null;let[l,...m]=i;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:Ne(l)}),n.push({name:"$0_uncapitalize",value:He(l)}),n.push({name:"$0",value:l});for(let h=0;h<m.length;h++){let a=`$${h+1}`,r=m[h];n.push({name:`${a}_lowercase`,value:r.toLowerCase()}),n.push({name:`${a}_capitalize`,value:Ne(r)}),n.push({name:`${a}_uncapitalize`,value:He(r)}),n.push({name:a,value:r})}return n}function Ne(e){return e.charAt(0).toUpperCase()+e.slice(1)}function He(e){return e.charAt(0).toLowerCase()+e.slice(1)}var me={name:We,rule:At};var Dt=/eslint +react-compiler\/react-compiler: +\["error/,Ve={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?g=>n(g):g=>e.sourceCode.getText(g),i=typeof e.getScope=="function"?()=>i():g=>e.sourceCode.getScope(g),l=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,m=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,h={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:m};function a(g){m&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let r=e.getSourceCode().scopeManager,u=new WeakMap,o=new WeakSet,d=new WeakMap,D=new WeakMap,A=new WeakSet;function P(g,$){return function(R){if($.has(R))return $.get(R);let f=g(R);return $.set(R,f),f}}function E(g,$,R,f,x){x&&g.async&&a({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ import{AST_NODE_TYPES as me,ESLintUtils as Dt}from"@typescript-eslint/utils";var pe=Symbol.for("optional");function L(e){return{...e,[pe]:!0}}function We(e,t){return{enum:e,...t}}function ie(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function Q(e){return{...e,type:"number"}}function Ue(e){return{...e,type:"integer"}}function W(e,t){return{...t,type:"array",items:e}}function M(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let i,u=[];for(i in e)e[i][pe]?e[i][pe]=void 0:u.push(i);u.length>0&&(n.required=u)}return n}function fe(...e){return{anyOf:e}}var Ot=Dt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt=M({disallow:L(W(M({selector:F(),message:F(),replace:L(fe(F(),M({regex:F(),with:F()}))),replaceType:L(We(["suggestion","autofix"]))}))),__dev_simulateFileName:L(F()),mustMatchSyntax:L(W(M({includeRegex:F(),mustCallFn:W(M({anyCall:W(M({fn:F(),withArgs:W(M({atIndex:Ue(),literal:fe(F(),Q(),ie())}))})),message:L(F())}))})))}),Ye="advanced-no-restricted-syntax",_t=Ot({name:Ye,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Pt],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:i,__dev_simulateFileName:u,disallow:p}=t,m=u??e.filename,o=[],r=new Set;for(let{includeRegex:a,mustCallFn:y}of i??[]){let D=Nt(m,new RegExp(a));if(!D)continue;let A=P=>{let b=P;for(let{name:I,value:g}of D)b=b.replaceAll(I,g);return b};for(let{anyCall:P,message:b}of y){let I=`Expected file to call the function: ${P.map(({fn:g})=>g).join(" or ")}`;r.add(I),o.push(g=>{let{callee:$}=g;if($.type===me.Identifier){for(let{fn:w,withArgs:f}of P)if($.name===w){r.delete(I);for(let T of f){let x=g.arguments[T.atIndex],R=typeof T.literal=="string"?A(T.literal):T.literal;if(!x){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${R}" at index ${T.atIndex}${b?`: ${A(b)}`:""}`}});continue}if(x.type!==me.Literal){e.report({node:x,messageId:"default",data:{message:`Argument at position ${T.atIndex} should the literal "${R}"${b?`: ${A(b)}`:""}`}});continue}x.value!==R&&e.report({node:x,messageId:"default",data:{message:`Argument should have the value "${R}"${b?`: ${A(b)}`:""}`},fix:O=>O.replaceText(x,typeof R=="string"?`'${R}'`:String(R))})}break}}})}}for(let{selector:a,message:y,replace:D,replaceType:A="suggestion"}of p??[]){if(a==="CallExpression"){o.push(P=>{c(D,P,y,A)});continue}n[a]=P=>{c(D,P,y,A)}}return o.length>0&&(n.CallExpression=a=>{if(a.type===me.CallExpression)for(let y of o)y(a)}),n["Program:exit"]=a=>{for(let y of r)e.report({node:a,messageId:"default",data:{message:`${y}`}})},n;function c(a,y,D,A){let P=b=>{if(!a)return null;if(typeof a=="string")return b.replaceText(y,a);{let I=new RegExp(a.regex),g=e.sourceCode.getText(y);return b.replaceText(y,g.replace(I,a.with))}};e.report({node:y,messageId:"default",data:{message:D},fix:a&&A==="autofix"?P:void 0,suggest:a&&A==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof a=="string"?a:a.with}"`},fix:P}]:void 0})}}});function Nt(e,t){let n=[],i=t.exec(e);if(!i)return null;let[u,...p]=i;n.push({name:"$0_lowercase",value:u.toLowerCase()}),n.push({name:"$0_capitalize",value:Ve(u)}),n.push({name:"$0_uncapitalize",value:ze(u)}),n.push({name:"$0",value:u});for(let m=0;m<p.length;m++){let o=`$${m+1}`,r=p[m];n.push({name:`${o}_lowercase`,value:r.toLowerCase()}),n.push({name:`${o}_capitalize`,value:Ve(r)}),n.push({name:`${o}_uncapitalize`,value:ze(r)}),n.push({name:o,value:r})}return n}function Ve(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ze(e){return e.charAt(0).toLowerCase()+e.slice(1)}var de={name:Ye,rule:_t};var Ft=/eslint +react-compiler\/react-compiler: +\["error/,Ge={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?g=>n(g):g=>e.sourceCode.getText(g),i=typeof e.getScope=="function"?()=>i():g=>e.sourceCode.getScope(g),u=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,p=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,m={additionalHooks:u,enableDangerousAutofixThisMayCauseInfiniteLoops:p};function o(g){p&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let r=e.getSourceCode().scopeManager,c=new WeakMap,a=new WeakSet,y=new WeakMap,D=new WeakMap,A=new WeakSet;function P(g,$){return function(w){if($.has(w))return $.get(w);let f=g(w);return $.set(w,f),f}}function b(g,$,w,f,T){T&&g.async&&o({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
2
2
 
3
3
  useEffect(() => {
4
4
  async function fetchData() {
@@ -9,5 +9,5 @@ useEffect(() => {
9
9
  fetchData();
10
10
  }, [someId]); // Or [] if effect doesn't need props or state
11
11
 
12
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let T=r.acquire(g),w=new Set,O=null;{let s=T.upper;for(;s&&(w.add(s),s.type!=="function");)s=s.upper;if(!s)return;O=s}let C=Array.isArray;function F(s){if(!C(s.defs))return!1;let c=s.defs[0];if(c==null||c.node.type!=="VariableDeclarator")return!1;let p=c.node.init;if(p==null)return!1;for(;p.type==="TSAsExpression";)p=p.expression;let y=c.node.parent;if(y==null&&(ye(O.block,c.node.id),y=c.node.parent,y==null))return!1;if(y.kind==="const"&&p.type==="Literal"&&(typeof p.value=="string"||typeof p.value=="number"||p.value===null))return!0;if(p.type!=="CallExpression")return!1;let b=p.callee;if(b.type==="MemberExpression"&&b.object.name==="React"&&b.property!=null&&!b.computed&&(b=b.property),b.type!=="Identifier")return!1;let S=c.node.id,{name:k}=b;if(k==="useRef"&&S.type==="Identifier")return!0;if(Mt(b)&&S.type==="Identifier"){for(let v of s.references)v!==S&&A.add(v.identifier);return!0}else if(k==="useState"||k==="useReducer"){if(S.type==="ArrayPattern"&&S.elements.length===2&&C(s.identifiers)){if(S.elements[1]===s.identifiers[0]){if(k==="useState"){let v=s.references,H=0;for(let B=0;B<v.length;B++){if(v[B].isWrite()&&H++,H>1)return!1;u.set(v[B].identifier,S.elements[0])}}return!0}else if(S.elements[0]===s.identifiers[0]){if(k==="useState"){let v=s.references;for(let H=0;H<v.length;H++)o.add(v[H].identifier)}return!1}}}else if(k==="useTransition"&&S.type==="ArrayPattern"&&S.elements.length===2&&Array.isArray(s.identifiers)&&S.elements[1]===s.identifiers[0])return!0;return!1}function z(s){if(!C(s.defs))return!1;let c=s.defs[0];if(c==null||c.node==null||c.node.id==null)return!1;let p=c.node,y=O.childScopes,b=null,S;for(S=0;S<y.length;S++){let k=y[S],v=k.block;if(p.type==="FunctionDeclaration"&&v===p||p.type==="VariableDeclarator"&&v.parent===p){b=k;break}}if(b==null)return!1;for(S=0;S<b.through.length;S++){let k=b.through[S];if(k.resolved!=null&&w.has(k.resolved.scope)&&!De(k.resolved))return!1}return!0}let De=P(F,d),bt=P(z,D),Oe=new Map;function Et(s){let c=s.from,p=!1;for(;c.block!==g;)c.type==="function"&&(p=c.block.parent!=null&&c.block.parent.type==="ReturnStatement"),c=c.upper;return p}let N=new Map,oe=new Map;Pe(T);function Pe(s){for(let c of s.references){if(!c.resolved||!w.has(c.resolved.scope))continue;let p=ye(g,c.identifier),y=ze(p),b=q(y,oe);if(x&&y.type==="Identifier"&&(y.parent.type==="MemberExpression"||y.parent.type==="OptionalMemberExpression")&&!y.parent.computed&&y.parent.property.type==="Identifier"&&y.parent.property.name==="current"&&Et(c)&&Oe.set(b,{reference:c,dependencyNode:y}),y.parent.type==="TSTypeQuery"||y.parent.type==="TSTypeReference")continue;let S=c.resolved.defs[0];if(S!=null&&!(S.node!=null&&S.node.init===g.parent)&&S.type!=="TypeParameter")if(N.has(b))N.get(b).references.push(c);else{let k=c.resolved,v=De(k)||bt(k);N.set(b,{isStable:v,references:[c]})}}for(let c of s.childScopes)Pe(c)}Oe.forEach(({reference:s,dependencyNode:c},p)=>{let y=s.resolved.references,b=!1;for(let S=0;S<y.length;S++){let{identifier:k}=y[S],{parent:v}=k;if(v!=null&&v.type==="MemberExpression"&&!v.computed&&v.property.type==="Identifier"&&v.property.name==="current"&&v.parent.type==="AssignmentExpression"&&v.parent.left===v){b=!0;break}}b||a({node:c.parent.property,message:`The ref value '${p}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${p}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ae=new Set;function xt(s,c){ae.has(c)||(ae.add(c),a({node:s,message:`Assignments to the '${c}' variable from inside React Hook ${n(R)} 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 ${n(R)}.`}))}let ee=new Set;if(N.forEach(({isStable:s,references:c},p)=>{s&&ee.add(p),c.forEach(y=>{y.writeExpr&&xt(y.writeExpr,p)})}),ae.size>0)return;if(!$){let s=null;if(N.forEach(({isStable:c,references:p},y)=>{s||p.forEach(b=>{if(s)return;let S=b.identifier;if(!u.has(S))return;let v=b.from;for(;v.type!=="function";)v=v.upper;v.block===g&&(s=y)})}),s){let{suggestedDependencies:c}=de({dependencies:N,declaredDependencies:[],stableDependencies:ee,externalDependencies:new Set,isEffect:!0});a({node:R,message:`React Hook ${f} contains a call to '${s}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+c.join(", ")+`] as a second argument to the ${f} Hook.`,suggest:[{desc:`Add dependencies array: [${c.join(", ")}]`,fix(p){return p.insertTextAfter(g,`, [${c.join(", ")}]`)}}]})}return}let K=[],J=new Set;$.type!=="ArrayExpression"?a({node:$,message:`React Hook ${n(R)} 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.`}):$.elements.forEach(s=>{if(s===null)return;if(s.type==="SpreadElement"){a({node:s,message:`React Hook ${n(R)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}A.has(s)&&a({node:s,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(s)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(s)}\``,fix(b){return b.removeRange(s.range)}}]});let c;try{c=q(s,oe)}catch(b){if(/Unsupported node type/.test(b.message)){s.type==="Literal"?N.has(s.value)?a({node:s,message:`The ${s.raw} literal is not a valid dependency because it never changes. Did you mean to include ${s.value} in the array instead?`}):a({node:s,message:`The ${s.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):a({node:s,message:`React Hook ${n(R)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw b}let p=s;for(;p.type==="MemberExpression"||p.type==="OptionalMemberExpression"||p.type==="ChainExpression";)p=p.object||p.expression.object;let y=!O.through.some(b=>b.identifier===p);K.push({key:c,node:s}),y||J.add(c)});let{suggestedDependencies:Tt,unnecessaryDependencies:te,missingDependencies:G,duplicateDependencies:_e}=de({dependencies:N,declaredDependencies:K,stableDependencies:ee,externalDependencies:J,isEffect:x}),ne=Tt;if(_e.size+G.size+te.size===0){if(t)return;Ot({declaredDependencies:K,declaredDependenciesNode:$,componentScope:O,scope:T}).forEach(({construction:c,isUsedOutsideOfHook:p,depType:y})=>{let b=y==="function"?"useCallback":"useMemo",S=y==="function"?"definition":"initialization",k=`wrap the ${S} of '${c.name.name}' in its own ${b}() Hook.`,v=p?`To fix this, ${k}`:`Move it inside the ${f} callback. Alternatively, ${k}`,H=y==="conditional"||y==="logical expression"?"could make":"makes",B=`The '${c.name.name}' ${y} ${H} the dependencies of ${f} Hook (at line ${$.loc.start.line}) change on every render. ${v}`,Fe;p&&c.type==="Variable"&&y==="function"&&(Fe=[{desc:`Wrap the ${S} of '${c.name.name}' in its own ${b}() Hook.`,fix(Me){let[wt,It]=b==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Me.insertTextBefore(c.node.init,wt),Me.insertTextAfter(c.node.init,It)]}}]),a({node:c.node,message:B,suggest:Fe})});return}!x&&G.size>0&&(ne=de({dependencies:N,declaredDependencies:[],stableDependencies:ee,externalDependencies:J,isEffect:x}).suggestedDependencies);function Rt(){if(K.length===0)return!0;let s=K.map(p=>p.key),c=s.slice().sort();return s.join(",")===c.join(",")}Rt()&&ne.sort();function ce(s){let c=s.split("."),p="";for(let y=0;y<c.length;y++){if(y!==0){let b=c.slice(0,y+1).join("."),S=oe.get(b)===!0;p+=S?"?.":"."}p+=c[y]}return p}function le(s,c,p,y){return s.size===0?null:(s.size>1?"":c+" ")+p+" "+(s.size>1?"dependencies":"dependency")+": "+_t(Array.from(s).sort().map(b=>"'"+ce(b)+"'"))+`. Either ${y} ${s.size>1?"them":"it"} or remove the dependency array.`}let U="";if(te.size>0){let s=null;if(Array.from(te.keys()).forEach(c=>{s===null&&c.endsWith(".current")&&(s=c)}),s!==null)U=` Mutable values like '${s}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(J.size>0){let c=Array.from(J)[0];T.set.has(c)||(U=` Outer scope values like '${c}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!U&&G.has("props")){let s=N.get("props");if(s==null)return;let c=s.references;if(!Array.isArray(c))return;let p=!0;for(let y=0;y<c.length;y++){let b=c[y],S=ye(O.block,b.identifier);if(!S){p=!1;break}let k=S.parent;if(k==null){p=!1;break}if(k.type!=="MemberExpression"&&k.type!=="OptionalMemberExpression"){p=!1;break}}p&&(U=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${f} call and refer to those specific props inside ${n(R)}.`)}if(!U&&G.size>0){let s=null;G.forEach(c=>{if(s)return;let p=O.set.get(c),y=N.get(c);if(y.references[0].resolved!==p)return;let b=p.defs[0];if(b==null||b.name==null||b.type!=="Parameter")return;let S=!1,k;for(let v=0;v<y.references.length;v++)if(k=y.references[v].identifier,k!=null&&k.parent!=null&&(k.parent.type==="CallExpression"||k.parent.type==="OptionalCallExpression")&&k.parent.callee===k){S=!0;break}S&&(s=c)}),s!==null&&(U=` If '${s}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!U&&G.size>0){let s=null;if(G.forEach(c=>{if(s!==null)return;let y=N.get(c).references,b,S;for(let k=0;k<y.length;k++){for(b=y[k].identifier,S=b.parent;S!=null&&S!==O.block;){if(S.type==="CallExpression"){let v=u.get(S.callee);if(v!=null){if(v.name===c)s={missingDep:c,setter:S.callee.name,form:"updater"};else if(o.has(b))s={missingDep:c,setter:S.callee.name,form:"reducer"};else{let H=y[k].resolved;if(H!=null){let B=H.defs[0];B!=null&&B.type==="Parameter"&&(s={missingDep:c,setter:S.callee.name,form:"inlineReducer"})}}break}}S=S.parent}if(s!==null)break}}),s!==null)switch(s.form){case"reducer":U=` You can also replace multiple useState variables with useReducer if '${s.setter}' needs the current value of '${s.missingDep}'.`;break;case"inlineReducer":U=` If '${s.setter}' needs the current value of '${s.missingDep}', you can also switch to useReducer instead of useState and read '${s.missingDep}' in the reducer.`;break;case"updater":U=` You can also do a functional update '${s.setter}(${s.missingDep.slice(0,1)} => ...)' if you only need '${s.missingDep}' in the '${s.setter}' call.`;break;default:throw new Error("Unknown case.")}}a({node:$,message:`React Hook ${n(R)} has `+(le(G,"a","missing","include")||le(te,"an","unnecessary","exclude")||le(_e,"a","duplicate","omit"))+U,suggest:[{desc:`Update the dependencies array to be: [${ne.map(ce).join(", ")}]`,fix(s){return s.replaceText($,`[${ne.map(ce).join(", ")}]`)}}]})}function I(g){let $=Pt(g.callee,h);if($===-1)return;let R=g.arguments[$],f=g.callee,x=Be(f).name,T=g.arguments[$+1],w=/Effect($|[^a-z])/g.test(x);if(!R){a({node:f,message:`React Hook ${x} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!w)){if(!T&&!w){(x==="useMemo"||x==="useCallback")&&a({node:f,message:`React Hook ${x} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(R.type){case"FunctionExpression":case"ArrowFunctionExpression":E(R,T,f,x,w);return;case"Identifier":if(!T||T.elements&&T.elements.some(F=>F&&F.type==="Identifier"&&F.name===R.name))return;let O=i(g).set.get(R.name);if(O==null||O.defs==null)return;let C=O.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":E(C.node,T,f,x,w);return;case"VariableDeclarator":let F=C.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":E(F,T,f,x,w);return}break}break;default:a({node:f,message:`React Hook ${x} received a function whose dependencies are unknown. Pass an inline function instead.`});return}a({node:f,message:`React Hook ${x} has a missing dependency: '${R.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${R.name}]`,fix(O){return O.replaceText(T,`[${R.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(Dt.test(g.value))return t=!0,{CallExpression:$=>I($,!0)}}return{CallExpression:g=>I(g)}}};function de({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:i,isEffect:l}){let m=h();function h(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((E,I)=>{let g=a(m,I);g.isUsed=!0,r(m,I,$=>{$.isSubtreeUsed=!0})}),t.forEach(({key:E})=>{let I=a(m,E);I.isSatisfiedRecursively=!0}),n.forEach(E=>{let I=a(m,E);I.isSatisfiedRecursively=!0});function a(E,I){let g=I.split("."),$=E;for(let R of g){let f=$.children.get(R);f||(f=h(),$.children.set(R,f)),$=f}return $}function r(E,I,g){let $=I.split("."),R=E;for(let f of $){let x=R.children.get(f);if(!x)return;g(x),R=x}}let u=new Set,o=new Set;d(m,u,o,E=>E);function d(E,I,g,$){E.children.forEach((R,f)=>{let x=$(f);if(R.isSatisfiedRecursively){R.isSubtreeUsed&&g.add(x);return}if(R.isUsed){I.add(x);return}d(R,I,g,T=>x+"."+T)})}let D=[],A=new Set,P=new Set;return t.forEach(({key:E})=>{o.has(E)?D.indexOf(E)===-1?D.push(E):P.add(E):A.add(E)}),u.forEach(E=>{D.push(E)}),{suggestedDependencies:D,unnecessaryDependencies:A,duplicateDependencies:P,missingDependencies:u}}function X(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 X(e.consequent)!=null||X(e.alternate)!=null?"conditional":null;case"LogicalExpression":return X(e.left)!=null||X(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return X(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return X(e.expression);case"TSAsExpression":return X(e.expression)}return null}function Ot({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:i}){let l=e.map(({key:h})=>{let a=n.variables.find(u=>u.name===h);if(a==null)return null;let r=a.defs[0];if(r==null)return null;if(r.type==="Variable"&&r.node.type==="VariableDeclarator"&&r.node.id.type==="Identifier"&&r.node.init!=null){let u=X(r.node.init);if(u!=null)return[a,u]}return r.type==="FunctionName"&&r.node.type==="FunctionDeclaration"?[a,"function"]:r.type==="ClassName"&&r.node.type==="ClassDeclaration"?[a,"class"]:null}).filter(Boolean);function m(h){let a=!1;for(let r=0;r<h.references.length;r++){let u=h.references[r];if(u.writeExpr){if(a)return!0;a=!0;continue}let o=u.from;for(;o!==i&&o!=null;)o=o.upper;if(o!==i&&!qe(t,u.identifier))return!0}return!1}return l.map(([h,a])=>({construction:h.defs[0],depType:a,isUsedOutsideOfHook:m(h)}))}function ze(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)?ze(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function ge(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function q(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=q(e.object,t),i=q(e.property,null),l=`${n}.${i}`;return ge(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=q(e.object,t),i=q(e.property,null),l=`${n}.${i}`;return ge(e,t,l),l}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let i=q(n.object,t),l=q(n.property,null),m=`${i}.${l}`;return ge(n,t,m),m}else throw new Error(`Unsupported node type: ${e.type}`)}function Be(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Pt(e,t){let n=Be(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let i;try{i=q(n,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(i)?0:-1}else return-1}}function ye(e,t){let n=[e],i=null;for(;n.length;){if(i=n.shift(),Ft(i,t))return i;if(qe(i,t))for(let[l,m]of Object.entries(i))l!=="parent"&&(Ue(m)?(m.parent=i,n.push(m)):Array.isArray(m)&&m.forEach(h=>{Ue(h)&&(h.parent=i,n.push(h))}))}return null}function _t(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Ft(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 qe(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Mt(e){return!1}import{AST_NODE_TYPES as Lt,ESLintUtils as jt}from"@typescript-eslint/utils";var Nt=jt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ge="no-call-with-explicit-generics",Ht=L({functions:W(M())}),Wt=Nt({name:Ge,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:[Ht]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(i){let{callee:l}=i;l.type===Lt.Identifier&&n.has(l.name)&&i.typeArguments&&e.report({node:i,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),he={name:Ge,rule:Wt};import{AST_NODE_TYPES as ie,ESLintUtils as Ut}from"@typescript-eslint/utils";var Vt=Ut.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xe="no-call-with-inferred-generics",zt=Vt({name:Xe,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 n=new Map(t.functions.map(i=>[i.name,i]));return{CallExpression(i){let{callee:l}=i;if(l.type!==ie.Identifier)return;let m=n.get(l.name);if(!m)return;let{minGenerics:h=1,allowAny:a,disallowTypes:r=t.disallowTypes}=m;(i.typeArguments?.params.length||0)<(h||0)&&e.report({node:i,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:h||0}}),!(a&&!r)&&i.typeArguments?.params?.some(o=>!a&&o.type===ie.TSAnyKeyword||r&&o.type===ie.TSTypeReference&&o.typeName.type===ie.Identifier&&r.includes(o.typeName.name))&&e.report({node:i,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),Se={name:Xe,rule:zt};import{ESLintUtils as Bt,TSESTree as Ye}from"@typescript-eslint/utils";var qt=Bt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ke="no-commented-out-code",Gt=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Xt=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],Yt=qt({name:Ke,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let i=n.trimStart();if(n.startsWith("*")||i.startsWith("INFO:")||i.startsWith("TODO:")||i.startsWith("DOCS:")||i.startsWith("FIX:")||i.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let l of Gt)if(i.startsWith(l))return{wrongPattern:l};for(let l of Xt)if(typeof l=="string"){if(n.includes(l))return{wrongPattern:l}}else if(l.test(n))return{wrongPattern:`regex(${l.toString()})`};return!1}return{Program(){let i=e.sourceCode.getAllComments();for(let l of i)if(l.type===Ye.AST_TOKEN_TYPES.Line||l.type===Ye.AST_TOKEN_TYPES.Block){let m=t(l.value);m&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:m.wrongPattern}})}}}}}),be={name:Ke,rule:Yt};import{ESLintUtils as Kt}from"@typescript-eslint/utils";var Jt=Kt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Je="no-default-export",Zt=Jt({name:Je,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 n of t.specifiers)n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Ee={name:Je,rule:Zt};import{AST_NODE_TYPES as Y,ESLintUtils as Qt}from"@typescript-eslint/utils";var en=Qt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qe="no-non-camel-case-functions",tn=/^[a-z][a-zA-Z0-9]*$/;function Ze(e){return e.typeName.type===Y.TSQualifiedName&&e.typeName.left.type===Y.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===Y.Identifier&&e.typeName.right.name==="Element"}var nn=en({name:Qe,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&&!tn.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===Y.TSTypeReference?Ze(n):n.type===Y.TSUnionType&&n.types.some(l=>l.type===Y.TSTypeReference&&Ze(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),xe={name:Qe,rule:nn};import{ESLintUtils as rn}from"@typescript-eslint/utils";import Te from"node:path";var sn=rn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),et="no-relative-imports",on=L({find:M(),replacement:M()}),an=L({aliases:W(on),rootDir:j(M()),allowNotFoundAliases:j(re()),_dev_simulateFileName:j(M())}),cn=sn({name:et,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:[an]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function i(h){return h.startsWith(".")||h.startsWith("..")}function l(h,a){let r=Te.dirname(a);return Te.resolve(r,h)}function m(h){let a=t.rootDir??process.cwd(),r=Te.relative(a,h);if(r.startsWith("."))return null;r.startsWith("/")||(r=`/${r}`);for(let{find:u,replacement:o}of t.aliases)if(r.startsWith(o)){let d=r.replace(o,u);return{alias:u,newPath:d}}return null}return{ImportDeclaration(h){let a=h.source.value;if(!i(a))return;let r=l(a,n),u=m(r);!u&&t.allowNotFoundAliases||e.report({node:h,messageId:u?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:u?.alias},fix:u?o=>o.replaceText(h.source,`'${u.newPath}'`):void 0})}}}}),Re={name:et,rule:cn};import{AST_NODE_TYPES as _,ESLintUtils as ln}from"@typescript-eslint/utils";var un=ln.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function tt(e){let t=[];for(let n of e.members)n.type===_.TSPropertySignature&&n.key.type===_.Identifier&&t.push([n.key.name,n]);return t}function nt(e,...t){for(let n of t)e.set(...n);return e}var fn=L({forceCheckOnFCPropTypesWithName:j(W(M()))}),rt="no-unused-type-props-in-args",we=null,pn=un({name:rt,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:[fn],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!we&&(we=n.map(a=>new RegExp(a)));function i(a,r,u,o,d=!0){let D=u.name,A=e.sourceCode.getScope(r).references.find(I=>I.identifier.name===D)?.resolved,P=a&&we?.some(I=>I.test(D));if(!A||!P&&A.references.filter(I=>I.isTypeReference).length>1)return;let E=A?.defs[0]?.node;if(!(d&&E?.parent?.type===_.ExportNamedDeclaration)){if(E?.type===_.TSTypeAliasDeclaration){l(a,r,o,E.typeAnnotation,!0);return}if(E?.type===_.TSInterfaceDeclaration){l(a,r,o,E.body,!0);return}}}function l(a,r,u,o,d){if(o.type===_.TSInterfaceBody){for(let D of o.body)D.type===_.TSPropertySignature&&D.key.type===_.Identifier&&u.set(D.key.name,D);return}if(o.type===_.TSTypeLiteral){nt(u,...tt(o));return}if(o.type===_.TSIntersectionType){for(let D of o.types)l(a,r,u,D,!0);return}d||o.type===_.TSTypeReference&&o.typeName.type===_.Identifier&&i(a,r,o.typeName,u)}function m(a,r,u){for(let o of u)if(o.type==="ObjectPattern"&&o.typeAnnotation){let d=new Map;if(l(a,r,d,o.typeAnnotation.typeAnnotation,!1),d.size===0)continue;h(o,d)}else o.type===_.AssignmentPattern&&o.left.type===_.ObjectPattern&&m(a,r,[o.left])}function h(a,r){let u=[];if(a.properties.at(-1)?.type===_.RestElement)return;for(let A of a.properties)A.type===_.Property&&A.key.type===_.Identifier&&u.push(A.key.name);let d=[],D=[];for(let[A,P]of r)u.includes(A)||(D.push(A),d.push({node:P,messageId:"unusedObjectTypeProperty",data:{propertyName:A}}));for(let[A,P]of d.entries())e.report({...P,fix:A===d.length-1?E=>{let I=a.properties.at(-1),g=D.join(", ");return I?I?.type===_.RestElement?null:E.insertTextAfter(I,`, ${g}`):E.insertTextBeforeRange([a.range[0]+1,a.range[1]],`${g}`)}:void 0})}return{VariableDeclaration(a){let r=a.declarations[0];if(!r)return;let u=new Map,o=r.id.type===_.Identifier&&r.id.typeAnnotation?.typeAnnotation.type===_.TSTypeReference&&r.id.typeAnnotation.typeAnnotation.typeName.type===_.Identifier&&r.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&r.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(o){if(o.type===_.TSTypeReference&&o.typeName.type===_.Identifier)i(!0,a,o.typeName,u,!1);else if(o.type===_.TSTypeLiteral)nt(u,...tt(o));else if(o.type===_.TSIntersectionType)for(let d of o.types)d.type===_.TSTypeReference&&d.typeName.type===_.Identifier?i(!0,a,d.typeName,u,!1):l(!0,a,u,d,!0);if(u.size!==0&&r.init?.type===_.ArrowFunctionExpression){let d=r.init.params[0];if(!d){e.report({node:r.init,messageId:"missingComponentParam"});return}d.type===_.ObjectPattern&&h(d,u)}}},FunctionDeclaration:function(a){m(!1,a,a.params)},ArrowFunctionExpression(a){m(!1,a,a.params)}}}}),Ie={name:rt,rule:pn};import{AST_NODE_TYPES as Ce,ESLintUtils as mn}from"@typescript-eslint/utils";var dn=mn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),st="prefer-named-functions",it=new Map,gn=dn({name:st,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 n=null;if(t.ignoreRegex){let i=it.get(t.ignoreRegex);i?n=i:(n=new RegExp(t.ignoreRegex),it.set(t.ignoreRegex,n))}return{VariableDeclarator(i){if(i.init&&i.init.type===Ce.ArrowFunctionExpression&&i.id.type===Ce.Identifier){let l=i.id.name;if(i.id.typeAnnotation||n&&n.test(l)||!t.disallowArrowFnWithImplicitReturns&&i.init.body.type!==Ce.BlockStatement)return;let m=i.parent,h=i.init.params,a=i.init.body,r=i.init;e.report({node:i.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:u=>u.replaceText(m,`${r.async?"async ":""}function ${l}(${h.map(o=>e.sourceCode.getText(o)).join(", ")||""}) ${e.sourceCode.getText(a)}`)}]})}}}}}),ke={name:st,rule:gn};import{AST_NODE_TYPES as V,AST_TOKEN_TYPES as yn,ESLintUtils as hn}from"@typescript-eslint/utils";var Sn=hn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ot="prefer-single-line-if",bn=L({maxLineLength:j(Z()),maxNonSimpleConditionLength:j(Z())}),En=Sn({name:ot,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:[bn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(i){if(i.consequent.type!==V.BlockStatement||n.getCommentsInside(i.consequent).length>0||i.alternate||i.consequent.body.length!==1)return;let m=i.consequent.body[0];if(m.type===V.ReturnStatement){if(!(!m.argument||m.argument.type===V.Literal||m.argument.type===V.Identifier))return}else if(!(m.type===V.ContinueStatement||m.type===V.BreakStatement))return;if(i.test.type===V.LogicalExpression||i.test.type===V.ConditionalExpression)return;let h;if(t.maxNonSimpleConditionLength&&(i.test.type===V.CallExpression||i.test.type===V.BinaryExpression||i.test.type===V.MemberExpression)&&(h=n.getText(i.test),h.length>t.maxNonSimpleConditionLength))return;h||(h=n.getText(i.test));let a=n.getText(m);if(h.includes(`
13
- `))return;let r=n.getTokenAfter(i);if(r&&r.type===yn.Punctuator&&r.value==="}")return;let u=xn(n,i),o=`if (${h}) ${a}`;t.maxLineLength&&o.length+u.length>t.maxLineLength||e.report({node:i,messageId:"noSingleLineCurly",fix:d=>d.replaceText(i,o)})}}}});function xn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var ve={name:ot,rule:En};import{ESLintUtils as Tn,TSESTree as Rn}from"@typescript-eslint/utils";var wn=Tn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),at="require-description",In=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Cn=/^eslint-disable-(next-)?line$/u,kn=wn({name:at,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 n=e.sourceCode,i=new Set(t.ignore||[]);return{Program(){for(let l of n.getAllComments()){let m=vn(l);m!=null&&(i.has(m.kind)||m.description||e.report({loc:$n(l.loc),messageId:"missingDescription"}))}}}}}),ct={name:at,rule:kn};function vn(e){let{text:t,description:n}=An(e.value);if(!t)return null;let i=In.exec(t);if(!i)return null;let l=i[1];if(!l)return null;let m=Cn.test(l);if(e.type===Rn.AST_TOKEN_TYPES.Line&&!m||m&&e.loc.start.line!==e.loc.end.line)return null;let h=t.slice(i.index+l.length);return{kind:l,value:h.trim(),description:n}}function An(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function $n(e){return{start:{line:e.start.line,column:-1},end:e.end}}function ft(e){return/^use[A-Z0-9]/.test(e)}function se(e){return e.type==="Identifier"?ft(e.name):e.type==="MemberExpression"&&!e.computed&&se(e.property)?e.object.type==="Identifier":!1}function pt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function mt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function dt(e){return!!(e.parent&&e.parent.callee&&mt(e.parent.callee,"forwardRef"))}function gt(e){return!!(e.parent&&e.parent.callee&&mt(e.parent.callee,"memo"))}function Ae(e){for(;e;){let t=ht(e);if(t&&(pt(t)||se(t))||dt(e)||gt(e))return!0;e=e.parent}return!1}function lt(e){return!1}function $e(e){return!1}var Dn=/eslint +react-compiler\/react-compiler: +\["error/,yt={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 r of e.sourceCode.getAllComments())if(Dn.test(r.value))return{CallExpression(u){let o=null;u.callee.name==="useMemo"?o="useMemo":u.callee.name==="useCallback"&&(o="useCallback"),o&&e.report({node:u,message:`"${o}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?r=>t(r):r=>e.sourceCode.getText(r),n=typeof e.getScope=="function"?()=>n():r=>e.sourceCode.getScope(r),i=null,l=[],m=[],h=new WeakSet;function a(r){for(let u of r.references){let o=u.identifier.parent;if(o.type==="VariableDeclarator"&&o.init&&o.init.type==="CallExpression"&&o.init.callee&&lt(o.init.callee))for(let d of u.resolved.references)d!==u&&h.add(d.identifier)}}return{onCodePathSegmentStart:r=>m.push(r),onCodePathSegmentEnd:()=>m.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(r,u){let o=l.pop();if(o.size===0)return;let d=new Set;function D(f,x){let{cache:T}=D,w=T.get(f.id),O=new Set(x);if(O.has(f.id)){let C=[...O],F=C.slice(C.indexOf(f.id)+1);for(let z of F)d.add(z);return BigInt("0")}if(O.add(f.id),w!==void 0)return w;if(r.thrownSegments.includes(f))w=BigInt("0");else if(f.prevSegments.length===0)w=BigInt("1");else{w=BigInt("0");for(let C of f.prevSegments)w+=D(C,O)}return f.reachable&&w===BigInt("0")?T.delete(f.id):T.set(f.id,w),w}function A(f,x){let{cache:T}=A,w=T.get(f.id),O=new Set(x);if(O.has(f.id)){let C=Array.from(O),F=C.slice(C.indexOf(f.id)+1);for(let z of F)d.add(z);return BigInt("0")}if(O.add(f.id),w!==void 0)return w;if(r.thrownSegments.includes(f))w=BigInt("0");else if(f.nextSegments.length===0)w=BigInt("1");else{w=BigInt("0");for(let C of f.nextSegments)w+=A(C,O)}return T.set(f.id,w),w}function P(f){let{cache:x}=P,T=x.get(f.id);if(T===null)return 1/0;if(T!==void 0)return T;if(x.set(f.id,null),f.prevSegments.length===0)T=1;else{T=1/0;for(let w of f.prevSegments){let O=P(w);O<T&&(T=O)}T+=1}return x.set(f.id,T),T}D.cache=new Map,A.cache=new Map,P.cache=new Map;let E=A(r.initialSegment),I=ht(u),g=Ae(u),$=I?pt(I)||se(I):dt(u)||gt(u),R=1/0;for(let f of r.finalSegments){if(!f.reachable)continue;let x=P(f);x<R&&(R=x)}for(let[f,x]of o){if(!f.reachable)continue;let T=f.nextSegments.length===0?R<=P(f):R<P(f),w=D(f)*A(f),O=d.has(f.id);for(let C of x)if(O&&!$e(C)&&e.report({node:C,message:`React Hook "${t(C)}" 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.`}),$){if(u.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!O&&w!==E&&!$e(C)){let z=`React Hook "${t(C)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(T?" Did you accidentally call a React Hook after an early return?":"");e.report({node:C,message:z})}}else if(u.parent&&(u.parent.type==="MethodDefinition"||u.parent.type==="ClassProperty")&&u.parent.value===u){let F=`React Hook "${t(C)}" 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:C,message:F})}else if(I){let F=`React Hook "${t(C)}" is called in function "${t(I)}" 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:C,message:F})}else if(u.type==="Program"){let F=`React Hook "${t(C)}" 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:C,message:F})}else if(g&&!$e(C)){if(u.parent.type==="CallExpression"&&u.parent.callee.type==="Identifier"&&u.parent.callee.name==="useCallback"){let z=u.parent;if(z.parent.type==="VariableDeclarator"&&ft(z.parent.id.name))return}let F=`React Hook "${t(C)}" 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:C,message:F})}}},CallExpression(r){if(se(r.callee)){let u=ut(l),o=ut(m),d=u.get(o);d||(d=[],u.set(o,d)),d.push(r.callee)}r.callee.type==="Identifier"&&(r.callee.name==="useEffect"||lt(r.callee))&&r.arguments.length>0&&(i=r)},Identifier(r){i==null&&h.has(r)&&r.parent.type!=="CallExpression"&&e.report({node:r,message:`\`${t(r)}\` 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"(r){r===i&&(i=null)},FunctionDeclaration(r){Ae(r)&&a(n(r))},ArrowFunctionExpression(r){Ae(r)&&a(n(r))}}}};function ht(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 ut(e){return e[e.length-1]}var St={[Ie.name]:Ie.rule,[be.name]:be.rule,[Se.name]:Se.rule,"rules-of-hooks":yt,"exhaustive-deps":Ve,"require-description":ct.rule,[Ee.name]:Ee.rule,[xe.name]:xe.rule,[ke.name]:ke.rule,[me.name]:me.rule,[he.name]:he.rule,[Re.name]:Re.rule,[ve.name]:ve.rule};var Ir={rules:St};export{Ir as extendedLintPlugin};
12
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let x=r.acquire(g),R=new Set,O=null;{let s=x.upper;for(;s&&(R.add(s),s.type!=="function");)s=s.upper;if(!s)return;O=s}let C=Array.isArray;function N(s){if(!C(s.defs))return!1;let l=s.defs[0];if(l==null||l.node.type!=="VariableDeclarator")return!1;let d=l.node.init;if(d==null)return!1;for(;d.type==="TSAsExpression";)d=d.expression;let h=l.node.parent;if(h==null&&(he(O.block,l.node.id),h=l.node.parent,h==null))return!1;if(h.kind==="const"&&d.type==="Literal"&&(typeof d.value=="string"||typeof d.value=="number"||d.value===null))return!0;if(d.type!=="CallExpression")return!1;let E=d.callee;if(E.type==="MemberExpression"&&E.object.name==="React"&&E.property!=null&&!E.computed&&(E=E.property),E.type!=="Identifier")return!1;let S=l.node.id,{name:k}=E;if(k==="useRef"&&S.type==="Identifier")return!0;if(Wt(E)&&S.type==="Identifier"){for(let v of s.references)v!==S&&A.add(v.identifier);return!0}else if(k==="useState"||k==="useReducer"){if(S.type==="ArrayPattern"&&S.elements.length===2&&C(s.identifiers)){if(S.elements[1]===s.identifiers[0]){if(k==="useState"){let v=s.references,H=0;for(let Y=0;Y<v.length;Y++){if(v[Y].isWrite()&&H++,H>1)return!1;c.set(v[Y].identifier,S.elements[0])}}return!0}else if(S.elements[0]===s.identifiers[0]){if(k==="useState"){let v=s.references;for(let H=0;H<v.length;H++)a.add(v[H].identifier)}return!1}}}else if(k==="useTransition"&&S.type==="ArrayPattern"&&S.elements.length===2&&Array.isArray(s.identifiers)&&S.elements[1]===s.identifiers[0])return!0;return!1}function z(s){if(!C(s.defs))return!1;let l=s.defs[0];if(l==null||l.node==null||l.node.id==null)return!1;let d=l.node,h=O.childScopes,E=null,S;for(S=0;S<h.length;S++){let k=h[S],v=k.block;if(d.type==="FunctionDeclaration"&&v===d||d.type==="VariableDeclarator"&&v.parent===d){E=k;break}}if(E==null)return!1;for(S=0;S<E.through.length;S++){let k=E.through[S];if(k.resolved!=null&&R.has(k.resolved.scope)&&!Ne(k.resolved))return!1}return!0}let Ne=P(N,y),Rt=P(z,D),Fe=new Map;function It(s){let l=s.from,d=!1;for(;l.block!==g;)l.type==="function"&&(d=l.block.parent!=null&&l.block.parent.type==="ReturnStatement"),l=l.upper;return d}let j=new Map,ae=new Map;Me(x);function Me(s){for(let l of s.references){if(!l.resolved||!R.has(l.resolved.scope))continue;let d=he(g,l.identifier),h=qe(d),E=B(h,ae);if(T&&h.type==="Identifier"&&(h.parent.type==="MemberExpression"||h.parent.type==="OptionalMemberExpression")&&!h.parent.computed&&h.parent.property.type==="Identifier"&&h.parent.property.name==="current"&&It(l)&&Fe.set(E,{reference:l,dependencyNode:h}),h.parent.type==="TSTypeQuery"||h.parent.type==="TSTypeReference")continue;let S=l.resolved.defs[0];if(S!=null&&!(S.node!=null&&S.node.init===g.parent)&&S.type!=="TypeParameter")if(j.has(E))j.get(E).references.push(l);else{let k=l.resolved,v=Ne(k)||Rt(k);j.set(E,{isStable:v,references:[l]})}}for(let l of s.childScopes)Me(l)}Fe.forEach(({reference:s,dependencyNode:l},d)=>{let h=s.resolved.references,E=!1;for(let S=0;S<h.length;S++){let{identifier:k}=h[S],{parent:v}=k;if(v!=null&&v.type==="MemberExpression"&&!v.computed&&v.property.type==="Identifier"&&v.property.name==="current"&&v.parent.type==="AssignmentExpression"&&v.parent.left===v){E=!0;break}}E||o({node:l.parent.property,message:`The ref value '${d}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${d}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ce=new Set;function Ct(s,l){ce.has(l)||(ce.add(l),o({node:s,message:`Assignments to the '${l}' variable from inside React Hook ${n(w)} 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 ${n(w)}.`}))}let te=new Set;if(j.forEach(({isStable:s,references:l},d)=>{s&&te.add(d),l.forEach(h=>{h.writeExpr&&Ct(h.writeExpr,d)})}),ce.size>0)return;if(!$){let s=null;if(j.forEach(({isStable:l,references:d},h)=>{s||d.forEach(E=>{if(s)return;let S=E.identifier;if(!c.has(S))return;let v=E.from;for(;v.type!=="function";)v=v.upper;v.block===g&&(s=h)})}),s){let{suggestedDependencies:l}=ye({dependencies:j,declaredDependencies:[],stableDependencies:te,externalDependencies:new Set,isEffect:!0});o({node:w,message:`React Hook ${f} contains a call to '${s}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+l.join(", ")+`] as a second argument to the ${f} Hook.`,suggest:[{desc:`Add dependencies array: [${l.join(", ")}]`,fix(d){return d.insertTextAfter(g,`, [${l.join(", ")}]`)}}]})}return}let J=[],Z=new Set;$.type!=="ArrayExpression"?o({node:$,message:`React Hook ${n(w)} 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.`}):$.elements.forEach(s=>{if(s===null)return;if(s.type==="SpreadElement"){o({node:s,message:`React Hook ${n(w)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}A.has(s)&&o({node:s,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(s)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(s)}\``,fix(E){return E.removeRange(s.range)}}]});let l;try{l=B(s,ae)}catch(E){if(/Unsupported node type/.test(E.message)){s.type==="Literal"?j.has(s.value)?o({node:s,message:`The ${s.raw} literal is not a valid dependency because it never changes. Did you mean to include ${s.value} in the array instead?`}):o({node:s,message:`The ${s.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):o({node:s,message:`React Hook ${n(w)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw E}let d=s;for(;d.type==="MemberExpression"||d.type==="OptionalMemberExpression"||d.type==="ChainExpression";)d=d.object||d.expression.object;let h=!O.through.some(E=>E.identifier===d);J.push({key:l,node:s}),h||Z.add(l)});let{suggestedDependencies:kt,unnecessaryDependencies:ne,missingDependencies:q,duplicateDependencies:Le}=ye({dependencies:j,declaredDependencies:J,stableDependencies:te,externalDependencies:Z,isEffect:T}),re=kt;if(Le.size+q.size+ne.size===0){if(t)return;Mt({declaredDependencies:J,declaredDependenciesNode:$,componentScope:O,scope:x}).forEach(({construction:l,isUsedOutsideOfHook:d,depType:h})=>{let E=h==="function"?"useCallback":"useMemo",S=h==="function"?"definition":"initialization",k=`wrap the ${S} of '${l.name.name}' in its own ${E}() Hook.`,v=d?`To fix this, ${k}`:`Move it inside the ${f} callback. Alternatively, ${k}`,H=h==="conditional"||h==="logical expression"?"could make":"makes",Y=`The '${l.name.name}' ${h} ${H} the dependencies of ${f} Hook (at line ${$.loc.start.line}) change on every render. ${v}`,je;d&&l.type==="Variable"&&h==="function"&&(je=[{desc:`Wrap the ${S} of '${l.name.name}' in its own ${E}() Hook.`,fix(He){let[At,$t]=E==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[He.insertTextBefore(l.node.init,At),He.insertTextAfter(l.node.init,$t)]}}]),o({node:l.node,message:Y,suggest:je})});return}!T&&q.size>0&&(re=ye({dependencies:j,declaredDependencies:[],stableDependencies:te,externalDependencies:Z,isEffect:T}).suggestedDependencies);function vt(){if(J.length===0)return!0;let s=J.map(d=>d.key),l=s.slice().sort();return s.join(",")===l.join(",")}vt()&&re.sort();function le(s){let l=s.split("."),d="";for(let h=0;h<l.length;h++){if(h!==0){let E=l.slice(0,h+1).join("."),S=ae.get(E)===!0;d+=S?"?.":"."}d+=l[h]}return d}function ue(s,l,d,h){return s.size===0?null:(s.size>1?"":l+" ")+d+" "+(s.size>1?"dependencies":"dependency")+": "+jt(Array.from(s).sort().map(E=>"'"+le(E)+"'"))+`. Either ${h} ${s.size>1?"them":"it"} or remove the dependency array.`}let U="";if(ne.size>0){let s=null;if(Array.from(ne.keys()).forEach(l=>{s===null&&l.endsWith(".current")&&(s=l)}),s!==null)U=` Mutable values like '${s}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Z.size>0){let l=Array.from(Z)[0];x.set.has(l)||(U=` Outer scope values like '${l}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!U&&q.has("props")){let s=j.get("props");if(s==null)return;let l=s.references;if(!Array.isArray(l))return;let d=!0;for(let h=0;h<l.length;h++){let E=l[h],S=he(O.block,E.identifier);if(!S){d=!1;break}let k=S.parent;if(k==null){d=!1;break}if(k.type!=="MemberExpression"&&k.type!=="OptionalMemberExpression"){d=!1;break}}d&&(U=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${f} call and refer to those specific props inside ${n(w)}.`)}if(!U&&q.size>0){let s=null;q.forEach(l=>{if(s)return;let d=O.set.get(l),h=j.get(l);if(h.references[0].resolved!==d)return;let E=d.defs[0];if(E==null||E.name==null||E.type!=="Parameter")return;let S=!1,k;for(let v=0;v<h.references.length;v++)if(k=h.references[v].identifier,k!=null&&k.parent!=null&&(k.parent.type==="CallExpression"||k.parent.type==="OptionalCallExpression")&&k.parent.callee===k){S=!0;break}S&&(s=l)}),s!==null&&(U=` If '${s}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!U&&q.size>0){let s=null;if(q.forEach(l=>{if(s!==null)return;let h=j.get(l).references,E,S;for(let k=0;k<h.length;k++){for(E=h[k].identifier,S=E.parent;S!=null&&S!==O.block;){if(S.type==="CallExpression"){let v=c.get(S.callee);if(v!=null){if(v.name===l)s={missingDep:l,setter:S.callee.name,form:"updater"};else if(a.has(E))s={missingDep:l,setter:S.callee.name,form:"reducer"};else{let H=h[k].resolved;if(H!=null){let Y=H.defs[0];Y!=null&&Y.type==="Parameter"&&(s={missingDep:l,setter:S.callee.name,form:"inlineReducer"})}}break}}S=S.parent}if(s!==null)break}}),s!==null)switch(s.form){case"reducer":U=` You can also replace multiple useState variables with useReducer if '${s.setter}' needs the current value of '${s.missingDep}'.`;break;case"inlineReducer":U=` If '${s.setter}' needs the current value of '${s.missingDep}', you can also switch to useReducer instead of useState and read '${s.missingDep}' in the reducer.`;break;case"updater":U=` You can also do a functional update '${s.setter}(${s.missingDep.slice(0,1)} => ...)' if you only need '${s.missingDep}' in the '${s.setter}' call.`;break;default:throw new Error("Unknown case.")}}o({node:$,message:`React Hook ${n(w)} has `+(ue(q,"a","missing","include")||ue(ne,"an","unnecessary","exclude")||ue(Le,"a","duplicate","omit"))+U,suggest:[{desc:`Update the dependencies array to be: [${re.map(le).join(", ")}]`,fix(s){return s.replaceText($,`[${re.map(le).join(", ")}]`)}}]})}function I(g){let $=Lt(g.callee,m);if($===-1)return;let w=g.arguments[$],f=g.callee,T=Xe(f).name,x=g.arguments[$+1],R=/Effect($|[^a-z])/g.test(T);if(!w){o({node:f,message:`React Hook ${T} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!R)){if(!x&&!R){(T==="useMemo"||T==="useCallback")&&o({node:f,message:`React Hook ${T} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(w.type){case"FunctionExpression":case"ArrowFunctionExpression":b(w,x,f,T,R);return;case"Identifier":if(!x||x.elements&&x.elements.some(N=>N&&N.type==="Identifier"&&N.name===w.name))return;let O=i(g).set.get(w.name);if(O==null||O.defs==null)return;let C=O.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":b(C.node,x,f,T,R);return;case"VariableDeclarator":let N=C.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":b(N,x,f,T,R);return}break}break;default:o({node:f,message:`React Hook ${T} received a function whose dependencies are unknown. Pass an inline function instead.`});return}o({node:f,message:`React Hook ${T} has a missing dependency: '${w.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${w.name}]`,fix(O){return O.replaceText(x,`[${w.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(Ft.test(g.value))return t=!0,{CallExpression:$=>I($,!0)}}return{CallExpression:g=>I(g)}}};function ye({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:i,isEffect:u}){let p=m();function m(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((b,I)=>{let g=o(p,I);g.isUsed=!0,r(p,I,$=>{$.isSubtreeUsed=!0})}),t.forEach(({key:b})=>{let I=o(p,b);I.isSatisfiedRecursively=!0}),n.forEach(b=>{let I=o(p,b);I.isSatisfiedRecursively=!0});function o(b,I){let g=I.split("."),$=b;for(let w of g){let f=$.children.get(w);f||(f=m(),$.children.set(w,f)),$=f}return $}function r(b,I,g){let $=I.split("."),w=b;for(let f of $){let T=w.children.get(f);if(!T)return;g(T),w=T}}let c=new Set,a=new Set;y(p,c,a,b=>b);function y(b,I,g,$){b.children.forEach((w,f)=>{let T=$(f);if(w.isSatisfiedRecursively){w.isSubtreeUsed&&g.add(T);return}if(w.isUsed){I.add(T);return}y(w,I,g,x=>T+"."+x)})}let D=[],A=new Set,P=new Set;return t.forEach(({key:b})=>{a.has(b)?D.indexOf(b)===-1?D.push(b):P.add(b):A.add(b)}),c.forEach(b=>{D.push(b)}),{suggestedDependencies:D,unnecessaryDependencies:A,duplicateDependencies:P,missingDependencies:c}}function X(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 X(e.consequent)!=null||X(e.alternate)!=null?"conditional":null;case"LogicalExpression":return X(e.left)!=null||X(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return X(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return X(e.expression);case"TSAsExpression":return X(e.expression)}return null}function Mt({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:i}){let u=e.map(({key:m})=>{let o=n.variables.find(c=>c.name===m);if(o==null)return null;let r=o.defs[0];if(r==null)return null;if(r.type==="Variable"&&r.node.type==="VariableDeclarator"&&r.node.id.type==="Identifier"&&r.node.init!=null){let c=X(r.node.init);if(c!=null)return[o,c]}return r.type==="FunctionName"&&r.node.type==="FunctionDeclaration"?[o,"function"]:r.type==="ClassName"&&r.node.type==="ClassDeclaration"?[o,"class"]:null}).filter(Boolean);function p(m){let o=!1;for(let r=0;r<m.references.length;r++){let c=m.references[r];if(c.writeExpr){if(o)return!0;o=!0;continue}let a=c.from;for(;a!==i&&a!=null;)a=a.upper;if(a!==i&&!Ke(t,c.identifier))return!0}return!1}return u.map(([m,o])=>({construction:m.defs[0],depType:o,isUsedOutsideOfHook:p(m)}))}function qe(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)?qe(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function ge(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function B(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=B(e.object,t),i=B(e.property,null),u=`${n}.${i}`;return ge(e,t,u),u}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=B(e.object,t),i=B(e.property,null),u=`${n}.${i}`;return ge(e,t,u),u}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let i=B(n.object,t),u=B(n.property,null),p=`${i}.${u}`;return ge(n,t,p),p}else throw new Error(`Unsupported node type: ${e.type}`)}function Xe(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Lt(e,t){let n=Xe(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let i;try{i=B(n,null)}catch(u){if(/Unsupported node type/.test(u.message))return 0;throw u}return t.additionalHooks.test(i)?0:-1}else return-1}}function he(e,t){let n=[e],i=null;for(;n.length;){if(i=n.shift(),Ht(i,t))return i;if(Ke(i,t))for(let[u,p]of Object.entries(i))u!=="parent"&&(Be(p)?(p.parent=i,n.push(p)):Array.isArray(p)&&p.forEach(m=>{Be(m)&&(m.parent=i,n.push(m))}))}return null}function jt(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Be(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Ht(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 Ke(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Wt(e){return!1}import{AST_NODE_TYPES as Ut,ESLintUtils as Vt}from"@typescript-eslint/utils";var zt=Vt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Je="no-call-with-explicit-generics",Yt=M({functions:W(F())}),Bt=zt({name:Je,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:[Yt]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(i){let{callee:u}=i;u.type===Ut.Identifier&&n.has(u.name)&&i.typeArguments&&e.report({node:i,messageId:"noExplicitGenerics",data:{functionName:u.name}})}}}}),Se={name:Je,rule:Bt};import{AST_NODE_TYPES as se,ESLintUtils as Gt}from"@typescript-eslint/utils";var qt=Gt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ze="no-call-with-inferred-generics",Xt=qt({name:Ze,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 n=new Map(t.functions.map(i=>[i.name,i]));return{CallExpression(i){let{callee:u}=i;if(u.type!==se.Identifier)return;let p=n.get(u.name);if(!p)return;let{minGenerics:m=1,allowAny:o,disallowTypes:r=t.disallowTypes}=p;(i.typeArguments?.params.length||0)<(m||0)&&e.report({node:i,messageId:"missingGenericDeclaration",data:{functionName:u.name,minGenerics:m||0}}),!(o&&!r)&&i.typeArguments?.params?.some(a=>!o&&a.type===se.TSAnyKeyword||r&&a.type===se.TSTypeReference&&a.typeName.type===se.Identifier&&r.includes(a.typeName.name))&&e.report({node:i,messageId:"anyUsedInGenerics",data:{functionName:u.name}})}}}}),Ee={name:Ze,rule:Xt};import{ESLintUtils as Kt,TSESTree as Qe}from"@typescript-eslint/utils";var Jt=Kt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),et="no-commented-out-code",Zt=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Qt=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],en=Jt({name:et,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let i=n.trimStart();if(n.startsWith("*")||i.startsWith("INFO:")||i.startsWith("TODO:")||i.startsWith("DOCS:")||i.startsWith("FIX:")||i.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let u of Zt)if(i.startsWith(u))return{wrongPattern:u};for(let u of Qt)if(typeof u=="string"){if(n.includes(u))return{wrongPattern:u}}else if(u.test(n))return{wrongPattern:`regex(${u.toString()})`};return!1}return{Program(){let i=e.sourceCode.getAllComments();for(let u of i)if(u.type===Qe.AST_TOKEN_TYPES.Line||u.type===Qe.AST_TOKEN_TYPES.Block){let p=t(u.value);p&&e.report({node:u,messageId:"commentedOutCode",data:{wrongPattern:p.wrongPattern}})}}}}}),be={name:et,rule:en};import{ESLintUtils as tn,TSESTree as nn}from"@typescript-eslint/utils";var rn=tn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tt="no-default-export",sn=rn({name:tt,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 n of t.specifiers)n.exported.type===nn.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Te={name:tt,rule:sn};import{AST_NODE_TYPES as K,ESLintUtils as on}from"@typescript-eslint/utils";var an=on.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rt="no-non-camel-case-functions",cn=/^[a-z][a-zA-Z0-9]*$/;function nt(e){return e.typeName.type===K.TSQualifiedName&&e.typeName.left.type===K.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===K.Identifier&&e.typeName.right.name==="Element"}var ln=an({name:rt,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&&!cn.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===K.TSTypeReference?nt(n):n.type===K.TSUnionType&&n.types.some(u=>u.type===K.TSTypeReference&&nt(u))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),xe={name:rt,rule:ln};import{ESLintUtils as un,TSESTree as G}from"@typescript-eslint/utils";function we(e,t){if(e.parent)return e.type===t?e:we(e.parent,t)}function*Re(e){yield e,e.parent&&(yield*Re(e.parent))}var pn=un.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),it="no-optional-root-props",fn=pn({name:it,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.'},schema:[],fixable:"code"},defaultOptions:[],create(e){function t(p){return p.parent.type===G.AST_NODE_TYPES.ExportNamedDeclaration}let n=new Set;function i(p){if(n.has(p))return!1;n.add(p);let o=e.sourceCode.getDeclaredVariables(p)[0];if(!o||o.references.length!==1)return!1;let r=o.references[0];if(!r)return!1;for(let c of Re(r.identifier)){if("returnType"in c||c.type===G.AST_NODE_TYPES.ExportNamedDeclaration)return!1;if(c.type===G.AST_NODE_TYPES.TSTypeAliasDeclaration||c.type===G.AST_NODE_TYPES.TSInterfaceDeclaration)return i(c)}return!0}function u(p){p.key.type!==G.AST_NODE_TYPES.Identifier||!p.optional||e.report({node:p.key,messageId:"optionalNotAllowed",data:{propertyName:p.key.name},fix:m=>{let o=we(p,G.AST_NODE_TYPES.TSPropertySignature);if(!o)return null;let r=e.sourceCode.getText(o);return m.replaceText(o,r.replace("?:",": undefined |"))}})}return{TSTypeAliasDeclaration(p){if(p.typeAnnotation.type===G.AST_NODE_TYPES.TSTypeLiteral&&!(t(p)||!i(p)))for(let m of p.typeAnnotation.members)m.type===G.AST_NODE_TYPES.TSPropertySignature&&u(m)},TSInterfaceDeclaration(p){if(!(t(p)||!i(p)))for(let m of p.body.body)m.type===G.AST_NODE_TYPES.TSPropertySignature&&u(m)}}}}),Ie={name:it,rule:fn};import{ESLintUtils as mn}from"@typescript-eslint/utils";import Ce from"node:path";var dn=mn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),st="no-relative-imports",yn=M({find:F(),replacement:F()}),gn=M({aliases:W(yn),rootDir:L(F()),allowNotFoundAliases:L(ie()),_dev_simulateFileName:L(F())}),hn=dn({name:st,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:[gn]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function i(m){return m.startsWith(".")||m.startsWith("..")}function u(m,o){let r=Ce.dirname(o);return Ce.resolve(r,m)}function p(m){let o=t.rootDir??process.cwd(),r=Ce.relative(o,m);if(r.startsWith("."))return null;r.startsWith("/")||(r=`/${r}`);for(let{find:c,replacement:a}of t.aliases)if(r.startsWith(a)){let y=r.replace(a,c);return{alias:c,newPath:y}}return null}return{ImportDeclaration(m){let o=m.source.value;if(!i(o))return;let r=u(o,n),c=p(r);!c&&t.allowNotFoundAliases||e.report({node:m,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?a=>a.replaceText(m.source,`'${c.newPath}'`):void 0})}}}}),ke={name:st,rule:hn};import{AST_NODE_TYPES as _,ESLintUtils as Sn}from"@typescript-eslint/utils";var En=Sn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function ot(e){let t=[];for(let n of e.members)n.type===_.TSPropertySignature&&n.key.type===_.Identifier&&t.push([n.key.name,n]);return t}function at(e,...t){for(let n of t)e.set(...n);return e}var bn=M({forceCheckOnFCPropTypesWithName:L(W(F()))}),ct="no-unused-type-props-in-args",ve=null,Tn=En({name:ct,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:[bn],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!ve&&(ve=n.map(o=>new RegExp(o)));function i(o,r,c,a,y=!0){let D=c.name,A=e.sourceCode.getScope(r).references.find(I=>I.identifier.name===D)?.resolved,P=o&&ve?.some(I=>I.test(D));if(!A||!P&&A.references.filter(I=>I.isTypeReference).length>1)return;let b=A?.defs[0]?.node;if(!(y&&b?.parent?.type===_.ExportNamedDeclaration)){if(b?.type===_.TSTypeAliasDeclaration){u(o,r,a,b.typeAnnotation,!0);return}if(b?.type===_.TSInterfaceDeclaration){u(o,r,a,b.body,!0);return}}}function u(o,r,c,a,y){if(a.type===_.TSInterfaceBody){for(let D of a.body)D.type===_.TSPropertySignature&&D.key.type===_.Identifier&&c.set(D.key.name,D);return}if(a.type===_.TSTypeLiteral){at(c,...ot(a));return}if(a.type===_.TSIntersectionType){for(let D of a.types)u(o,r,c,D,!0);return}y||a.type===_.TSTypeReference&&a.typeName.type===_.Identifier&&i(o,r,a.typeName,c)}function p(o,r,c){for(let a of c)if(a.type==="ObjectPattern"&&a.typeAnnotation){let y=new Map;if(u(o,r,y,a.typeAnnotation.typeAnnotation,!1),y.size===0)continue;m(a,y)}else a.type===_.AssignmentPattern&&a.left.type===_.ObjectPattern&&p(o,r,[a.left])}function m(o,r){let c=[];if(o.properties.at(-1)?.type===_.RestElement)return;for(let A of o.properties)A.type===_.Property&&A.key.type===_.Identifier&&c.push(A.key.name);let y=[],D=[];for(let[A,P]of r)c.includes(A)||(D.push(A),y.push({node:P,messageId:"unusedObjectTypeProperty",data:{propertyName:A}}));for(let[A,P]of y.entries())e.report({...P,fix:A===y.length-1?b=>{let I=o.properties.at(-1),g=D.join(", ");return I?I?.type===_.RestElement?null:b.insertTextAfter(I,`, ${g}`):b.insertTextBeforeRange([o.range[0]+1,o.range[1]],`${g}`)}:void 0})}return{VariableDeclaration(o){let r=o.declarations[0];if(!r)return;let c=new Map,a=r.id.type===_.Identifier&&r.id.typeAnnotation?.typeAnnotation.type===_.TSTypeReference&&r.id.typeAnnotation.typeAnnotation.typeName.type===_.Identifier&&r.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&r.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(a){if(a.type===_.TSTypeReference&&a.typeName.type===_.Identifier)i(!0,o,a.typeName,c,!1);else if(a.type===_.TSTypeLiteral)at(c,...ot(a));else if(a.type===_.TSIntersectionType)for(let y of a.types)y.type===_.TSTypeReference&&y.typeName.type===_.Identifier?i(!0,o,y.typeName,c,!1):u(!0,o,c,y,!0);if(c.size!==0&&r.init?.type===_.ArrowFunctionExpression){let y=r.init.params[0];if(!y){e.report({node:r.init,messageId:"missingComponentParam"});return}y.type===_.ObjectPattern&&m(y,c)}}},FunctionDeclaration:function(o){p(!1,o,o.params)},ArrowFunctionExpression(o){p(!1,o,o.params)}}}}),Ae={name:ct,rule:Tn};import{AST_NODE_TYPES as $e,ESLintUtils as xn}from"@typescript-eslint/utils";var wn=xn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ut="prefer-named-functions",lt=new Map,Rn=wn({name:ut,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 n=null;if(t.ignoreRegex){let i=lt.get(t.ignoreRegex);i?n=i:(n=new RegExp(t.ignoreRegex),lt.set(t.ignoreRegex,n))}return{VariableDeclarator(i){if(i.init&&i.init.type===$e.ArrowFunctionExpression&&i.id.type===$e.Identifier){let u=i.id.name;if(i.id.typeAnnotation||n&&n.test(u)||!t.disallowArrowFnWithImplicitReturns&&i.init.body.type!==$e.BlockStatement)return;let p=i.parent,m=i.init.params,o=i.init.body,r=i.init;e.report({node:i.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:u,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(p,`${r.async?"async ":""}function ${u}(${m.map(a=>e.sourceCode.getText(a)).join(", ")||""}) ${e.sourceCode.getText(o)}`)}]})}}}}}),De={name:ut,rule:Rn};import{AST_NODE_TYPES as V,AST_TOKEN_TYPES as In,ESLintUtils as Cn}from"@typescript-eslint/utils";var kn=Cn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pt="prefer-single-line-if",vn=M({maxLineLength:L(Q()),maxNonSimpleConditionLength:L(Q())}),An=kn({name:pt,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:[vn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(i){if(i.consequent.type!==V.BlockStatement||n.getCommentsInside(i.consequent).length>0||i.alternate||i.consequent.body.length!==1)return;let p=i.consequent.body[0];if(p.type===V.ReturnStatement){if(!(!p.argument||p.argument.type===V.Literal||p.argument.type===V.Identifier))return}else if(!(p.type===V.ContinueStatement||p.type===V.BreakStatement))return;if(i.test.type===V.LogicalExpression||i.test.type===V.ConditionalExpression)return;let m;if(t.maxNonSimpleConditionLength&&(i.test.type===V.CallExpression||i.test.type===V.BinaryExpression||i.test.type===V.MemberExpression)&&(m=n.getText(i.test),m.length>t.maxNonSimpleConditionLength))return;m||(m=n.getText(i.test));let o=n.getText(p);if(m.includes(`
13
+ `))return;let r=n.getTokenAfter(i);if(r&&r.type===In.Punctuator&&r.value==="}")return;let c=$n(n,i),a=`if (${m}) ${o}`;t.maxLineLength&&a.length+c.length>t.maxLineLength||e.report({node:i,messageId:"noSingleLineCurly",fix:y=>y.replaceText(i,a)})}}}});function $n(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Oe={name:pt,rule:An};import{ESLintUtils as Dn,TSESTree as On}from"@typescript-eslint/utils";var Pn=Dn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ft="require-description",_n=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Nn=/^eslint-disable-(next-)?line$/u,Fn=Pn({name:ft,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 n=e.sourceCode,i=new Set(t.ignore||[]);return{Program(){for(let u of n.getAllComments()){let p=Mn(u);p!=null&&(i.has(p.kind)||p.description||e.report({loc:jn(u.loc),messageId:"missingDescription"}))}}}}}),mt={name:ft,rule:Fn};function Mn(e){let{text:t,description:n}=Ln(e.value);if(!t)return null;let i=_n.exec(t);if(!i)return null;let u=i[1];if(!u)return null;let p=Nn.test(u);if(e.type===On.AST_TOKEN_TYPES.Line&&!p||p&&e.loc.start.line!==e.loc.end.line)return null;let m=t.slice(i.index+u.length);return{kind:u,value:m.trim(),description:n}}function Ln(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function jn(e){return{start:{line:e.start.line,column:-1},end:e.end}}function gt(e){return/^use[A-Z0-9]/.test(e)}function oe(e){return e.type==="Identifier"?gt(e.name):e.type==="MemberExpression"&&!e.computed&&oe(e.property)?e.object.type==="Identifier":!1}function ht(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function St(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Et(e){return!!(e.parent&&e.parent.callee&&St(e.parent.callee,"forwardRef"))}function bt(e){return!!(e.parent&&e.parent.callee&&St(e.parent.callee,"memo"))}function Pe(e){for(;e;){let t=xt(e);if(t&&(ht(t)||oe(t))||Et(e)||bt(e))return!0;e=e.parent}return!1}function dt(e){return!1}function _e(e){return!1}var Hn=/eslint +react-compiler\/react-compiler: +\["error/,Tt={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 r of e.sourceCode.getAllComments())if(Hn.test(r.value))return{CallExpression(c){let a=null;c.callee.name==="useMemo"?a="useMemo":c.callee.name==="useCallback"&&(a="useCallback"),a&&e.report({node:c,message:`"${a}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?r=>t(r):r=>e.sourceCode.getText(r),n=typeof e.getScope=="function"?()=>n():r=>e.sourceCode.getScope(r),i=null,u=[],p=[],m=new WeakSet;function o(r){for(let c of r.references){let a=c.identifier.parent;if(a.type==="VariableDeclarator"&&a.init&&a.init.type==="CallExpression"&&a.init.callee&&dt(a.init.callee))for(let y of c.resolved.references)y!==c&&m.add(y.identifier)}}return{onCodePathSegmentStart:r=>p.push(r),onCodePathSegmentEnd:()=>p.pop(),onCodePathStart:()=>u.push(new Map),onCodePathEnd(r,c){let a=u.pop();if(a.size===0)return;let y=new Set;function D(f,T){let{cache:x}=D,R=x.get(f.id),O=new Set(T);if(O.has(f.id)){let C=[...O],N=C.slice(C.indexOf(f.id)+1);for(let z of N)y.add(z);return BigInt("0")}if(O.add(f.id),R!==void 0)return R;if(r.thrownSegments.includes(f))R=BigInt("0");else if(f.prevSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let C of f.prevSegments)R+=D(C,O)}return f.reachable&&R===BigInt("0")?x.delete(f.id):x.set(f.id,R),R}function A(f,T){let{cache:x}=A,R=x.get(f.id),O=new Set(T);if(O.has(f.id)){let C=Array.from(O),N=C.slice(C.indexOf(f.id)+1);for(let z of N)y.add(z);return BigInt("0")}if(O.add(f.id),R!==void 0)return R;if(r.thrownSegments.includes(f))R=BigInt("0");else if(f.nextSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let C of f.nextSegments)R+=A(C,O)}return x.set(f.id,R),R}function P(f){let{cache:T}=P,x=T.get(f.id);if(x===null)return 1/0;if(x!==void 0)return x;if(T.set(f.id,null),f.prevSegments.length===0)x=1;else{x=1/0;for(let R of f.prevSegments){let O=P(R);O<x&&(x=O)}x+=1}return T.set(f.id,x),x}D.cache=new Map,A.cache=new Map,P.cache=new Map;let b=A(r.initialSegment),I=xt(c),g=Pe(c),$=I?ht(I)||oe(I):Et(c)||bt(c),w=1/0;for(let f of r.finalSegments){if(!f.reachable)continue;let T=P(f);T<w&&(w=T)}for(let[f,T]of a){if(!f.reachable)continue;let x=f.nextSegments.length===0?w<=P(f):w<P(f),R=D(f)*A(f),O=y.has(f.id);for(let C of T)if(O&&!_e(C)&&e.report({node:C,message:`React Hook "${t(C)}" 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.`}),$){if(c.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!O&&R!==b&&!_e(C)){let z=`React Hook "${t(C)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(x?" Did you accidentally call a React Hook after an early return?":"");e.report({node:C,message:z})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let N=`React Hook "${t(C)}" 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:C,message:N})}else if(I){let N=`React Hook "${t(C)}" is called in function "${t(I)}" 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:C,message:N})}else if(c.type==="Program"){let N=`React Hook "${t(C)}" 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:C,message:N})}else if(g&&!_e(C)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let z=c.parent;if(z.parent.type==="VariableDeclarator"&&gt(z.parent.id.name))return}let N=`React Hook "${t(C)}" 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:C,message:N})}}},CallExpression(r){if(oe(r.callee)){let c=yt(u),a=yt(p),y=c.get(a);y||(y=[],c.set(a,y)),y.push(r.callee)}r.callee.type==="Identifier"&&(r.callee.name==="useEffect"||dt(r.callee))&&r.arguments.length>0&&(i=r)},Identifier(r){i==null&&m.has(r)&&r.parent.type!=="CallExpression"&&e.report({node:r,message:`\`${t(r)}\` 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"(r){r===i&&(i=null)},FunctionDeclaration(r){Pe(r)&&o(n(r))},ArrowFunctionExpression(r){Pe(r)&&o(n(r))}}}};function xt(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 yt(e){return e[e.length-1]}var wt={[Ae.name]:Ae.rule,[be.name]:be.rule,[Ee.name]:Ee.rule,"rules-of-hooks":Tt,"exhaustive-deps":Ge,"require-description":mt.rule,[Te.name]:Te.rule,[xe.name]:xe.rule,[De.name]:De.rule,[de.name]:de.rule,[Se.name]:Se.rule,[ke.name]:ke.rule,[Oe.name]:Oe.rule,[Ie.name]:Ie.rule};var jr={rules:wt};export{jr as extendedLintPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ls-stack/extended-lint",
3
- "version": "0.20.1",
3
+ "version": "0.21.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -20,24 +20,24 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@ls-stack/eslint-cfg": "^0.1.3",
23
- "@ls-stack/utils": "^1.8.0",
23
+ "@ls-stack/utils": "^2.4.0",
24
24
  "@types/eslint": "^9.6.1",
25
- "@types/node": "^22.5.0",
26
- "@typescript-eslint/parser": "^8.2.0",
27
- "@typescript-eslint/rule-tester": "^8.2.0",
28
- "@vitest/ui": "^2.0.5",
29
- "eslint": "^9.16.0",
25
+ "@types/node": "^22.13.0",
26
+ "@typescript-eslint/parser": "^8.22.0",
27
+ "@typescript-eslint/rule-tester": "^8.22.0",
28
+ "@vitest/ui": "^3.0.4",
29
+ "eslint": "^9.19.0",
30
30
  "tschema": "^3.2.0",
31
31
  "tsm": "^2.3.0",
32
- "tsup": "^8.2.4",
33
- "typescript": "^5.5.4",
34
- "vite": "^5.4.2",
35
- "vitest": "^2.0.5"
32
+ "tsup": "^8.3.6",
33
+ "typescript": "^5.7.3",
34
+ "vite": "^6.0.11",
35
+ "vitest": "^3.0.4"
36
36
  },
37
37
  "dependencies": {
38
- "@typescript-eslint/utils": "^8.2.0",
38
+ "@typescript-eslint/utils": "^8.22.0",
39
39
  "escape-string-regexp": "^5.0.0",
40
- "espree": "^10.1.0",
40
+ "espree": "^10.3.0",
41
41
  "esutils": "^2.0.3"
42
42
  },
43
43
  "peerDependencies": {
@@ -50,6 +50,7 @@
50
50
  "test:ui": "vitest --ui",
51
51
  "build": "pnpm test && pnpm lint && pnpm run build:no-test",
52
52
  "build:no-test": "tsup --minify --dts",
53
+ "run-in-test-project": "pnpm build && node --experimental-strip-types ./debug/runInTestProject.ts",
53
54
  "pre-publish": "./scripts/check-if-is-sync.sh && pnpm build",
54
55
  "npm-publish": "pnpm publish --access=public"
55
56
  }