@ls-stack/extended-lint 0.24.0 → 0.25.0

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