@ls-stack/extended-lint 0.25.0 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
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:
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 V=require("@typescript-eslint/utils");var rn=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tt="collapse-obj-with-single-prop",sn=M({maxLineLength:H(Z())}),on=rn({name:tt,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:[sn]},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(`
2
+ `)||n.getCommentsInside(u).length>0)return;l.endsWith(";")&&(l=l.slice(0,-1));let r=`{ ${l} }`,c=ln(n,u);t.maxLineLength&&r.length+c.length+(an(u,n)?1:0)>t.maxLineLength||e.report({node:u,messageId:"singleLineProp",fix:s=>s.replaceText(u,r)})}return{TSTypeLiteral:o,ObjectExpression:o}}});function an(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 ln(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var we={name:tt,rule:on};var cn=/eslint +react-compiler\/react-compiler: +\["error/,rt={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
3
 
3
4
  useEffect(() => {
4
5
  async function fetchData() {
@@ -9,6 +10,5 @@ useEffect(() => {
9
10
  fetchData();
10
11
  }, [someId]); // Or [] if effect doesn't need props or state
11
12
 
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});
13
+ 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&&(Ae(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(dn(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=Ae(g,p.identifier),h=it(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}=Re({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}=Re({dependencies:W,declaredDependencies:ie,stableDependencies:ae,externalDependencies:se,isEffect:b}),ce=Wt;if(Be.size+q.size+le.size===0){if(t)return;un({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=Re({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")+": "+fn(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=Ae(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=pn(g.callee,m);if(O===-1)return;let I=g.arguments[O],d=g.callee,b=st(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(cn.test(g.value))return t=!0,{CallExpression:O=>C(O,!0)}}return{CallExpression:g=>C(g)}}};function Re({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 un({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&&!ot(t,c.identifier))return!0}return!1}return o.map(([m,l])=>({construction:m.defs[0],depType:l,isUsedOutsideOfHook:u(m)}))}function it(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)?it(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ce(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 Ce(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 Ce(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 Ce(n,t,u),u}else throw new Error(`Unsupported node type: ${e.type}`)}function st(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function pn(e,t){let n=st(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 Ae(e,t){let n=[e],i=null;for(;n.length;){if(i=n.shift(),mn(i,t))return i;if(ot(i,t))for(let[o,u]of Object.entries(i))o!=="parent"&&(nt(u)?(u.parent=i,n.push(u)):Array.isArray(u)&&u.forEach(m=>{nt(m)&&(m.parent=i,n.push(m))}))}return null}function fn(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 nt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function mn(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 ot(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function dn(e){return!1}var fe=require("@typescript-eslint/utils");var yn=fe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),at="no-call-with-explicit-generics",gn=M({functions:Y(F())}),hn=yn({name:at,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:[gn]},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}})}}}}),ke={name:at,rule:hn};var Q=require("@typescript-eslint/utils"),Sn=Q.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lt="no-call-with-inferred-generics",Tn=Sn({name:lt,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}})}}}}),ve={name:lt,rule:Tn};var oe=require("@typescript-eslint/utils"),En=oe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ct="no-commented-out-code",bn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],xn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],In=En({name:ct,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 bn)if(i.startsWith(o))return{wrongPattern:o};for(let o of xn)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}})}}}}}),Pe={name:ct,rule:In};var me=require("@typescript-eslint/utils"),wn=me.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ut="no-default-export",Rn=wn({name:ut,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"})}}}}),Oe={name:ut,rule:Rn};var pt=require("@typescript-eslint/utils"),Cn=pt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ft="no-leaked-text-in-jsx",An=Cn({name:ft,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:ft,rule:An};var J=require("@typescript-eslint/utils"),kn=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dt="no-non-camel-case-functions",vn=/^[a-z][a-zA-Z0-9]*$/;function mt(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 Pn=kn({name:dt,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&&!vn.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===J.AST_NODE_TYPES.TSTypeReference?mt(n):n.type===J.AST_NODE_TYPES.TSUnionType&&n.types.some(o=>o.type===J.AST_NODE_TYPES.TSTypeReference&&mt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),_e={name:dt,rule:Pn};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 On=N.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yt="no-optional-root-props",Dn=On({name:yt,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)}}}}),Ne={name:yt,rule:Dn};var gt=require("@typescript-eslint/utils"),de=Kt(require("path"));var _n=gt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ht="no-relative-imports",$n=M({find:F(),replacement:F()}),Nn=M({aliases:Y($n),rootDir:H(F()),allowNotFoundAliases:H(pe()),_dev_simulateFileName:H(F())}),Ln=_n({name:ht,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:[Nn]},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})}}}}),Le={name:ht,rule:Ln};var _=require("@typescript-eslint/utils");var Fn=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function St(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 Tt(e,...t){for(let n of t)e.set(...n);return e}var jn=M({forceCheckOnFCPropTypesWithName:H(Y(F()))}),Et="no-unused-type-props-in-args",Fe=null,Mn=Fn({name:Et,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:[jn],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Fe&&(Fe=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&&Fe?.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){Tt(c,...St(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)Tt(c,...St(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)}}}}),je={name:Et,rule:Mn};var re=require("@typescript-eslint/utils"),Hn=re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xt="prefer-named-functions",bt=new Map,Wn=Hn({name:xt,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=bt.get(t.ignoreRegex);i?n=i:(n=new RegExp(t.ignoreRegex),bt.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)}`)}]})}}}}}),Me={name:xt,rule:Wn};var j=require("@typescript-eslint/utils");var Un=j.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wt="prefer-single-line-if",Yn=M({maxLineLength:H(Z()),maxNonSimpleConditionLength:H(Z())}),Vn=Un({name:wt,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:[Yn]},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=It(i.test);if(!f&&i.test.type===j.AST_NODE_TYPES.UnaryExpression&&i.test.operator==="!"){let R=i.test.argument;It(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(`
14
+ `))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=zn(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 It(e){return e.type===j.AST_NODE_TYPES.CallExpression||e.type===j.AST_NODE_TYPES.BinaryExpression||e.type===j.AST_NODE_TYPES.MemberExpression&&Rt(e)}function Rt(e){return e.object.type===j.AST_NODE_TYPES.MemberExpression?Rt(e.object):e.object.type!==j.AST_NODE_TYPES.Identifier}function zn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var He={name:wt,rule:Vn};var ye=require("@typescript-eslint/utils"),Bn=ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ct="require-description",Xn=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Gn=/^eslint-disable-(next-)?line$/u,Jn=Bn({name:Ct,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=qn(o);u!=null&&(i.has(u.kind)||u.description||e.report({loc:Zn(o.loc),messageId:"missingDescription"}))}}}}}),At={name:Ct,rule:Jn};function qn(e){let{text:t,description:n}=Kn(e.value);if(!t)return null;let i=Xn.exec(t);if(!i)return null;let o=i[1];if(!o)return null;let u=Gn.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 Kn(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Zn(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Pt(e){return/^use[A-Z0-9]/.test(e)}function ge(e){return e.type==="Identifier"?Pt(e.name):e.type==="MemberExpression"&&!e.computed&&ge(e.property)?e.object.type==="Identifier":!1}function Ot(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Dt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function _t(e){return!!(e.parent&&e.parent.callee&&Dt(e.parent.callee,"forwardRef"))}function $t(e){return!!(e.parent&&e.parent.callee&&Dt(e.parent.callee,"memo"))}function We(e){for(;e;){let t=Lt(e);if(t&&(Ot(t)||ge(t))||_t(e)||$t(e))return!0;e=e.parent}return!1}function kt(e){return!1}function Ue(e){return!1}var Qn=/eslint +react-compiler\/react-compiler: +\["error/,Nt={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(Qn.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&&kt(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=Lt(c),g=We(c),O=C?Ot(C)||ge(C):_t(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&&!Ue(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&&!Ue(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&&!Ue(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"&&Pt(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=vt(o),s=vt(u),f=c.get(s);f||(f=[],c.set(s,f)),f.push(r.callee)}r.callee.type==="Identifier"&&(r.callee.name==="useEffect"||kt(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){We(r)&&l(n(r))},ArrowFunctionExpression(r){We(r)&&l(n(r))}}}};function Lt(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 vt(e){return e[e.length-1]}var Ft={[je.name]:je.rule,[Pe.name]:Pe.rule,[ve.name]:ve.rule,"rules-of-hooks":Nt,"exhaustive-deps":rt,"require-description":At.rule,[Oe.name]:Oe.rule,[_e.name]:_e.rule,[Me.name]:Me.rule,[Ie.name]:Ie.rule,[ke.name]:ke.rule,[Le.name]:Le.rule,[He.name]:He.rule,[Ne.name]:Ne.rule,[De.name]:De.rule,[we.name]:we.rule};var er={rules:Ft};0&&(module.exports={extendedLintPlugin});
@@ -1,4 +1,5 @@
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:
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};import{AST_NODE_TYPES as ne,AST_TOKEN_TYPES as he,ESLintUtils as zt}from"@typescript-eslint/utils";var Bt=zt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qe="collapse-obj-with-single-prop",Xt=j({maxLineLength:M(q())}),Gt=Bt({name:qe,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:[Xt]},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===he.Punctuator&&i.value===",",R=i.type===he.Punctuator&&i.value===";";return!f&&!R}})?.loc.start.line===u.loc.end.line)return;let l=s(u);if(!l||l.includes(`
2
+ `)||n.getCommentsInside(u).length>0)return;l.endsWith(";")&&(l=l.slice(0,-1));let r=`{ ${l} }`,c=qt(n,u);t.maxLineLength&&r.length+c.length+(Jt(u,n)?1:0)>t.maxLineLength||e.report({node:u,messageId:"singleLineProp",fix:i=>i.replaceText(u,r)})}return{TSTypeLiteral:o,ObjectExpression:o}}});function Jt(e,t){let n=t.getTokenAfter(e);return n?.type===he.Punctuator&&(n.value===","||n.value===";")&&n.loc.start.line===e.loc.end.line}function qt(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Se={name:qe,rule:Gt};var Kt=/eslint +react-compiler\/react-compiler: +\["error/,Ze={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
3
 
3
4
  useEffect(() => {
4
5
  async function fetchData() {
@@ -9,6 +10,5 @@ useEffect(() => {
9
10
  fetchData();
10
11
  }, [someId]); // Or [] if effect doesn't need props or state
11
12
 
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};
13
+ 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&&(be(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(nn(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=be(g,p.identifier),h=Qe(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}=Te({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}=Te({dependencies:W,declaredDependencies:ee,stableDependencies:re,externalDependencies:te,isEffect:b}),se=Lt;if(Ue.size+G.size+ie.size===0){if(t)return;Zt({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=Te({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")+": "+en(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=be(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=Qt(g.callee,m);if(O===-1)return;let I=g.arguments[O],d=g.callee,b=et(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(Kt.test(g.value))return t=!0,{CallExpression:O=>C(O,!0)}}return{CallExpression:g=>C(g)}}};function Te({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 Zt({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&&!tt(t,c.identifier))return!0}return!1}return o.map(([m,l])=>({construction:m.defs[0],depType:l,isUsedOutsideOfHook:u(m)}))}function Qe(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?Qe(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ee(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 Ee(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 Ee(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 Ee(n,t,u),u}else throw new Error(`Unsupported node type: ${e.type}`)}function et(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Qt(e,t){let n=et(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 be(e,t){let n=[e],s=null;for(;n.length;){if(s=n.shift(),tn(s,t))return s;if(tt(s,t))for(let[o,u]of Object.entries(s))o!=="parent"&&(Ke(u)?(u.parent=s,n.push(u)):Array.isArray(u)&&u.forEach(m=>{Ke(m)&&(m.parent=s,n.push(m))}))}return null}function en(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 Ke(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function tn(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 tt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function nn(e){return!1}import{AST_NODE_TYPES as rn,ESLintUtils as sn}from"@typescript-eslint/utils";var on=sn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nt="no-call-with-explicit-generics",an=j({functions:Y(F())}),ln=on({name:nt,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:[an]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(s){let{callee:o}=s;o.type===rn.Identifier&&n.has(o.name)&&s.typeArguments&&e.report({node:s,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),xe={name:nt,rule:ln};import{AST_NODE_TYPES as ae,ESLintUtils as cn}from"@typescript-eslint/utils";var un=cn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rt="no-call-with-inferred-generics",pn=un({name:rt,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}})}}}}),Ie={name:rt,rule:pn};import{ESLintUtils as fn,TSESTree as it}from"@typescript-eslint/utils";var mn=fn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),st="no-commented-out-code",dn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],yn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],gn=mn({name:st,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let 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 dn)if(s.startsWith(o))return{wrongPattern:o};for(let o of yn)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===it.AST_TOKEN_TYPES.Line||o.type===it.AST_TOKEN_TYPES.Block){let u=t(o.value);u&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:u.wrongPattern}})}}}}}),we={name:st,rule:gn};import{ESLintUtils as hn,TSESTree as Sn}from"@typescript-eslint/utils";var Tn=hn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ot="no-default-export",En=Tn({name:ot,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===Sn.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Re={name:ot,rule:En};import{ESLintUtils as bn}from"@typescript-eslint/utils";var xn=bn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),at="no-leaked-text-in-jsx",In=xn({name:at,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}})}}}}),Ce={name:at,rule:In};import{AST_NODE_TYPES as Z,ESLintUtils as wn}from"@typescript-eslint/utils";var Rn=wn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ct="no-non-camel-case-functions",Cn=/^[a-z][a-zA-Z0-9]*$/;function lt(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 An=Rn({name:ct,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Cn.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===Z.TSTypeReference?lt(n):n.type===Z.TSUnionType&&n.types.some(o=>o.type===Z.TSTypeReference&&lt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Ae={name:ct,rule:An};import{ESLintUtils as kn,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*ke(e){yield e,e.parent&&(yield*ke(e.parent))}var vn=kn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ut="no-optional-root-props",Pn=vn({name:ut,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 ke(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)}}}}),ve={name:ut,rule:Pn};import{ESLintUtils as On}from"@typescript-eslint/utils";import Pe from"node:path";var Dn=On.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pt="no-relative-imports",_n=j({find:F(),replacement:F()}),$n=j({aliases:Y(_n),rootDir:M(F()),allowNotFoundAliases:M(oe()),_dev_simulateFileName:M(F())}),Nn=Dn({name:pt,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[$n]},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=Pe.dirname(l);return Pe.resolve(r,m)}function u(m){let l=t.rootDir??process.cwd(),r=Pe.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})}}}}),Oe={name:pt,rule:Nn};import{AST_NODE_TYPES as $,ESLintUtils as Ln}from"@typescript-eslint/utils";var Fn=Ln.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function ft(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 mt(e,...t){for(let n of t)e.set(...n);return e}var jn=j({forceCheckOnFCPropTypesWithName:M(Y(F()))}),dt="no-unused-type-props-in-args",De=null,Mn=Fn({name:dt,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[jn],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!De&&(De=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&&De?.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){mt(c,...ft(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)mt(c,...ft(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)}}}}),_e={name:dt,rule:Mn};import{AST_NODE_TYPES as $e,ESLintUtils as Hn}from"@typescript-eslint/utils";var Wn=Hn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gt="prefer-named-functions",yt=new Map,Un=Wn({name:gt,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let s=yt.get(t.ignoreRegex);s?n=s:(n=new RegExp(t.ignoreRegex),yt.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 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)}`)}]})}}}}}),Ne={name:gt,rule:Un};import{AST_NODE_TYPES as H,AST_TOKEN_TYPES as ht,ESLintUtils as Yn}from"@typescript-eslint/utils";var Vn=Yn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tt="prefer-single-line-if",zn=j({maxLineLength:M(q()),maxNonSimpleConditionLength:M(q())}),Bn=Vn({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:[zn]},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=St(s.test);if(!f&&s.test.type===H.UnaryExpression&&s.test.operator==="!"){let R=s.test.argument;St(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(`
14
+ `))return;let r=n.getTokenAfter(s);if(r&&r.type===ht.Punctuator&&r.value==="}"){let f=n.getTokenAfter(r);if(f&&f.type===ht.Keyword&&(f.value==="else"||f.value==="catch"))return}let c=Xn(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 St(e){return e.type===H.CallExpression||e.type===H.BinaryExpression||e.type===H.MemberExpression&&Et(e)}function Et(e){return e.object.type===H.MemberExpression?Et(e.object):e.object.type!==H.Identifier}function Xn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Le={name:Tt,rule:Bn};import{ESLintUtils as Gn,TSESTree as Jn}from"@typescript-eslint/utils";var qn=Gn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bt="require-description",Kn=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Zn=/^eslint-disable-(next-)?line$/u,Qn=qn({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,s=new Set(t.ignore||[]);return{Program(){for(let o of n.getAllComments()){let u=er(o);u!=null&&(s.has(u.kind)||u.description||e.report({loc:nr(o.loc),messageId:"missingDescription"}))}}}}}),xt={name:bt,rule:Qn};function er(e){let{text:t,description:n}=tr(e.value);if(!t)return null;let s=Kn.exec(t);if(!s)return null;let o=s[1];if(!o)return null;let u=Zn.test(o);if(e.type===Jn.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 tr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function nr(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Rt(e){return/^use[A-Z0-9]/.test(e)}function le(e){return e.type==="Identifier"?Rt(e.name):e.type==="MemberExpression"&&!e.computed&&le(e.property)?e.object.type==="Identifier":!1}function Ct(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function At(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function kt(e){return!!(e.parent&&e.parent.callee&&At(e.parent.callee,"forwardRef"))}function vt(e){return!!(e.parent&&e.parent.callee&&At(e.parent.callee,"memo"))}function Fe(e){for(;e;){let t=Ot(e);if(t&&(Ct(t)||le(t))||kt(e)||vt(e))return!0;e=e.parent}return!1}function It(e){return!1}function je(e){return!1}var rr=/eslint +react-compiler\/react-compiler: +\["error/,Pt={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(rr.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&&It(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=Ot(c),g=Fe(c),O=C?Ct(C)||le(C):kt(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 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&&!je(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&&!je(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&&!je(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"&&Rt(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=wt(o),i=wt(u),f=c.get(i);f||(f=[],c.set(i,f)),f.push(r.callee)}r.callee.type==="Identifier"&&(r.callee.name==="useEffect"||It(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){Fe(r)&&l(n(r))},ArrowFunctionExpression(r){Fe(r)&&l(n(r))}}}};function Ot(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 Dt={[_e.name]:_e.rule,[we.name]:we.rule,[Ie.name]:Ie.rule,"rules-of-hooks":Pt,"exhaustive-deps":Ze,"require-description":xt.rule,[Re.name]:Re.rule,[Ae.name]:Ae.rule,[Ne.name]:Ne.rule,[ge.name]:ge.rule,[xe.name]:xe.rule,[Oe.name]:Oe.rule,[Le.name]:Le.rule,[ve.name]:ve.rule,[Ce.name]:Ce.rule,[Se.name]:Se.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.25.0",
3
+ "version": "0.25.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"