@ls-stack/extended-lint 0.33.1 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";var en=Object.create;var me=Object.defineProperty;var tn=Object.getOwnPropertyDescriptor;var nn=Object.getOwnPropertyNames;var rn=Object.getPrototypeOf,sn=Object.prototype.hasOwnProperty;var on=(e,t)=>{for(var n in t)me(e,n,{get:t[n],enumerable:!0})},Qe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of nn(t))!sn.call(e,a)&&a!==n&&me(e,a,{get:()=>t[a],enumerable:!(r=tn(t,a))||r.enumerable});return e};var an=(e,t,n)=>(n=e!=null?en(rn(e)):{},Qe(t||!e||!e.__esModule?me(n,"default",{value:e,enumerable:!0}):n,e)),ln=e=>Qe(me({},"__esModule",{value:!0}),e);var xr={};on(xr,{extendedLintPlugin:()=>br});module.exports=ln(xr);var U=require("@typescript-eslint/utils");var Ie=Symbol.for("optional");function L(e){return{...e,[Ie]:!0}}function et(e,t){return{enum:e,...t}}function re(e){return{...e,type:"boolean"}}function M(e){return{...e,type:"string"}}function X(e){return{...e,type:"number"}}function tt(e){return{...e,type:"integer"}}function Y(e,t){return{...t,type:"array",items:e}}function W(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,a=[];for(r in e)e[r][Ie]?e[r][Ie]=void 0:a.push(r);a.length>0&&(n.required=a)}return n}function we(...e){return{anyOf:e}}var cn=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rt="react-compiler-extra",pn=W({runOnlyWithEnableCompilerDirective:L(re())}),un=/eslint +react-compiler\/react-compiler: +\["error/;function fn(e){return e.type===U.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===U.AST_NODE_TYPES.MemberExpression&&e.property.type===U.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var mn=/\bthis[.[]/;function nt(e){return mn.test(e)}var dn=cn({name:rt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[pn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let u of e.sourceCode.getAllComments())if(un.test(u.value)){n=!0;break}if(!n)return{}}function r(u){for(let c of u.properties)if(c.type===U.AST_NODE_TYPES.Property&&c.method&&c.value.type===U.AST_NODE_TYPES.FunctionExpression){let l=e.sourceCode,s=l.getText(c.key),o=c.value,i=l.getText(o.body);if(nt(i))e.report({node:c,messageId:"thisKeywordInMethod"});else{let f=o.params.map(I=>l.getText(I)).join(", "),T="";o.generator?T=`${s}: function* (${f}) ${i}`:T=`${s}: (${f}) => ${i}`,e.report({node:c,messageId:"objectMethodIsNotSupported",fix:I=>I.replaceText(c,T)})}}}function a(u){for(let c of u.properties)if(c.type===U.AST_NODE_TYPES.Property&&c.value.type===U.AST_NODE_TYPES.ObjectExpression){for(let l of c.value.properties)if(l.type===U.AST_NODE_TYPES.Property&&l.method&&l.value.type===U.AST_NODE_TYPES.FunctionExpression){let o=e.sourceCode.getText(l.value.body);nt(o)&&e.report({node:l,messageId:"thisKeywordInMethod"})}}}return{CallExpression(u){if(fn(u.callee))for(let c of u.arguments){if(c.type===U.AST_NODE_TYPES.ObjectExpression&&(r(c),a(c)),c.type===U.AST_NODE_TYPES.ArrowFunctionExpression&&(c.body.type===U.AST_NODE_TYPES.ObjectExpression&&(r(c.body),a(c.body)),c.body.type===U.AST_NODE_TYPES.BlockStatement))for(let l of c.body.body)l.type===U.AST_NODE_TYPES.ReturnStatement&&l.argument?.type===U.AST_NODE_TYPES.ObjectExpression&&(r(l.argument),a(l.argument));if(c.type===U.AST_NODE_TYPES.FunctionExpression)for(let l of c.body.body)l.type===U.AST_NODE_TYPES.ReturnStatement&&l.argument?.type===U.AST_NODE_TYPES.ObjectExpression&&(r(l.argument),a(l.argument))}}}}}),Ce={name:rt,rule:dn};var ie=require("@typescript-eslint/utils");var yn=ie.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn=W({disallow:L(Y(W({selector:M(),message:M(),replace:L(we(M(),W({regex:M(),with:M()}))),replaceType:L(et(["suggestion","autofix"]))}))),__dev_simulateFileName:L(M()),mustMatchSyntax:L(Y(W({includeRegex:M(),mustCallFn:Y(W({anyCall:Y(W({fn:M(),withArgs:Y(W({atIndex:tt(),literal:we(M(),X(),re())}))})),message:L(M())}))})))}),ot="advanced-no-restricted-syntax",hn=yn({name:ot,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[gn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:a,disallow:u}=t,c=a??e.filename,l=[],s=new Set;for(let{includeRegex:i,mustCallFn:f}of r??[]){let T=Sn(c,new RegExp(i));if(!T)continue;let I=b=>{let d=b;for(let{name:x,value:g}of T)d=d.replaceAll(x,g);return d};for(let{anyCall:b,message:d}of f){let x=`Expected file to call the function: ${b.map(({fn:g})=>g).join(" or ")}`;s.add(x),l.push(g=>{let{callee:D}=g;if(D.type===ie.AST_NODE_TYPES.Identifier){for(let{fn:v,withArgs:y}of b)if(D.name===v){s.delete(x);for(let C of y){let R=g.arguments[C.atIndex],k=typeof C.literal=="string"?I(C.literal):C.literal;if(!R){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${C.atIndex}${d?`: ${I(d)}`:""}`}});continue}if(R.type!==ie.AST_NODE_TYPES.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${C.atIndex} should the literal "${k}"${d?`: ${I(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${I(d)}`:""}`},fix:$=>$.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:i,message:f,replace:T,replaceType:I="suggestion"}of u??[]){if(i==="CallExpression"){l.push(b=>{o(T,b,f,I)});continue}n[i]=b=>{o(T,b,f,I)}}return l.length>0&&(n.CallExpression=i=>{if(i.type===ie.AST_NODE_TYPES.CallExpression)for(let f of l)f(i)}),n["Program:exit"]=i=>{for(let f of s)e.report({node:i,messageId:"default",data:{message:`${f}`}})},n;function o(i,f,T,I){let b=d=>{if(!i)return null;if(typeof i=="string")return d.replaceText(f,i);{let x=new RegExp(i.regex),g=e.sourceCode.getText(f);return d.replaceText(f,g.replace(x,i.with))}};e.report({node:f,messageId:"default",data:{message:T},fix:i&&I==="autofix"?b:void 0,suggest:i&&I==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:b}]:void 0})}}});function Sn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[a,...u]=r;n.push({name:"$0_lowercase",value:a.toLowerCase()}),n.push({name:"$0_capitalize",value:it(a)}),n.push({name:"$0_uncapitalize",value:st(a)}),n.push({name:"$0",value:a});for(let c=0;c<u.length;c++){let l=`$${c+1}`,s=u[c];n.push({name:`${l}_lowercase`,value:s.toLowerCase()}),n.push({name:`${l}_capitalize`,value:it(s)}),n.push({name:`${l}_uncapitalize`,value:st(s)}),n.push({name:l,value:s})}return n}function it(e){return e.charAt(0).toUpperCase()+e.slice(1)}function st(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Re={name:ot,rule:hn};var _=require("@typescript-eslint/utils");var Tn=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lt="collapse-simple-objs-in-one-line",En=W({maxLineLength:L(X()),maxProperties:L(X()),nestedObjMaxLineLength:L(X()),nestedObjMaxProperties:L(X()),ignoreTypesWithSuffix:L(Y(M()))}),bn=Tn({name:lt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[En]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],a=t.maxProperties??2,u=t.nestedObjMaxLineLength??t.maxLineLength,c=t.nestedObjMaxProperties??3;function l(o){if(o.type===_.AST_NODE_TYPES.ObjectExpression){let i=o.parent.type===_.AST_NODE_TYPES.Property,f=i?c:a,T=o.properties.length;if(T>f)return!1;if(T===1){let b=o.properties[0];return b.type===_.AST_NODE_TYPES.Property&&(b.value.type===_.AST_NODE_TYPES.ObjectExpression||b.value.type===_.AST_NODE_TYPES.ArrayExpression)?!1:{text:n.getText(b),isNested:i,propsSize:T}}let I=[];for(let b of o.properties){if(b.type===_.AST_NODE_TYPES.Property){let d=b.value.type;if(!(d===_.AST_NODE_TYPES.Literal||d===_.AST_NODE_TYPES.Identifier||d===_.AST_NODE_TYPES.TemplateLiteral||d===_.AST_NODE_TYPES.TaggedTemplateExpression))return!1}I.push(n.getText(b))}return{text:I.join(", "),isNested:i,propsSize:T}}else{let i=o.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,f=i?c:a,T=o.members.length;if(T>f)return!1;if(r.length>0&&o.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let b=o.parent.id.name;if(r.some(d=>b.endsWith(d)))return!1}if(T===1){let b=o.members[0];return b.type===_.AST_NODE_TYPES.TSPropertySignature&&b.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(b),isNested:i,propsSize:1}}if(o.parent.type===_.AST_NODE_TYPES.TSIntersectionType||o.parent.type===_.AST_NODE_TYPES.TSUnionType)return!1;let I=[];for(let b of o.members){if(b.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let d=b.typeAnnotation?.typeAnnotation;if(!d||d.type===_.AST_NODE_TYPES.TSTypeLiteral||!at(d.type))return!1;if(d.type===_.AST_NODE_TYPES.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let g=d.typeArguments.params[0];if(!at(g.type))return!1}let x=n.getText(b).trim();(x.endsWith(";")||x.endsWith(","))&&(x=x.slice(0,-1)),I.push(x)}return{text:I.join("; "),isNested:i,propsSize:T}}}function s(o){if(o.loc.start.line===o.loc.end.line||o.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer&&n.getTokenAfter(o,{filter:x=>{let g=x.type===_.AST_TOKEN_TYPES.Punctuator&&x.value===",",D=x.type===_.AST_TOKEN_TYPES.Punctuator&&x.value===";";return!g&&!D}})?.loc.start.line===o.loc.end.line)return;let i=l(o);if(!i)return;let f=i.text;if(f.includes(`
2
- `)||n.getCommentsInside(o).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let T=`{ ${f} }`,I=In(n,o),b=i.isNested&&i.propsSize>2?u:t.maxLineLength;b&&T.length+I.length+(xn(o,n)?1:0)>b||e.report({node:o,messageId:"singleLineProp",fix:d=>d.replaceText(o,T)})}return{TSTypeLiteral:s,ObjectExpression:s}}});function at(e){return e===_.AST_NODE_TYPES.TSLiteralType||e===_.AST_NODE_TYPES.TSTypeReference||e===_.AST_NODE_TYPES.TSNumberKeyword||e===_.AST_NODE_TYPES.TSStringKeyword||e===_.AST_NODE_TYPES.TSBooleanKeyword||e===_.AST_NODE_TYPES.TSNullKeyword||e===_.AST_NODE_TYPES.TSUndefinedKeyword}function xn(e,t){let n=t.getTokenAfter(e);return n?.type===_.AST_TOKEN_TYPES.Punctuator&&(n.value===","||n.value===";"||n.value==="}")&&n.loc.start.line===e.loc.end.line}function In(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var ve={name:lt,rule:bn};var wn=/eslint +react-compiler\/react-compiler: +\["error/,pt={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?g=>n(g):g=>e.sourceCode.getText(g),r=typeof e.getScope=="function"?()=>r():g=>e.sourceCode.getScope(g),a=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,c={additionalHooks:a,enableDangerousAutofixThisMayCauseInfiniteLoops:u};function l(g){u&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let s=e.getSourceCode().scopeManager,o=new WeakMap,i=new WeakSet,f=new WeakMap,T=new WeakMap,I=new WeakSet;function b(g,D){return function(v){if(D.has(v))return D.get(v);let y=g(v);return D.set(v,y),y}}function d(g,D,v,y,C){C&&g.async&&l({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ "use strict";var ln=Object.create;var ge=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var un=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty;var mn=(e,t)=>{for(var n in t)ge(e,n,{get:t[n],enumerable:!0})},it=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of pn(t))!fn.call(e,l)&&l!==n&&ge(e,l,{get:()=>t[l],enumerable:!(o=cn(t,l))||o.enumerable});return e};var st=(e,t,n)=>(n=e!=null?ln(un(e)):{},it(t||!e||!e.__esModule?ge(n,"default",{value:e,enumerable:!0}):n,e)),dn=e=>it(ge({},"__esModule",{value:!0}),e);var Dr={};mn(Dr,{extendedLintPlugin:()=>Nr});module.exports=dn(Dr);var H=require("@typescript-eslint/utils");var ve=Symbol.for("optional");function L(e){return{...e,[ve]:!0}}function ot(e,t){return{enum:e,...t}}function se(e){return{...e,type:"boolean"}}function j(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function at(e){return{...e,type:"integer"}}function V(e,t){return{...t,type:"array",items:e}}function F(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let o,l=[];for(o in e)e[o][ve]?e[o][ve]=void 0:l.push(o);l.length>0&&(n.required=l)}return n}function ke(...e){return{anyOf:e}}var yn=H.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ct="react-compiler-extra",gn=F({runOnlyWithEnableCompilerDirective:L(se())}),hn=/eslint +react-compiler\/react-compiler: +\["error/;function Tn(e){return e.type===H.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===H.AST_NODE_TYPES.MemberExpression&&e.property.type===H.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Sn=/\bthis[.[]/;function lt(e){return Sn.test(e)}var En=yn({name:ct,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[gn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(hn.test(f.value)){n=!0;break}if(!n)return{}}function o(f){for(let c of f.properties)if(c.type===H.AST_NODE_TYPES.Property&&c.method&&c.value.type===H.AST_NODE_TYPES.FunctionExpression){let r=e.sourceCode,a=r.getText(c.key),s=c.value,i=r.getText(s.body);if(lt(i))e.report({node:c,messageId:"thisKeywordInMethod"});else{let p=s.params.map(h=>r.getText(h)).join(", "),g="";s.generator?g=`${a}: function* (${p}) ${i}`:g=`${a}: (${p}) => ${i}`,e.report({node:c,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(c,g)})}}}function l(f){for(let c of f.properties)if(c.type===H.AST_NODE_TYPES.Property&&c.value.type===H.AST_NODE_TYPES.ObjectExpression){for(let r of c.value.properties)if(r.type===H.AST_NODE_TYPES.Property&&r.method&&r.value.type===H.AST_NODE_TYPES.FunctionExpression){let s=e.sourceCode.getText(r.value.body);lt(s)&&e.report({node:r,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(Tn(f.callee))for(let c of f.arguments){if(c.type===H.AST_NODE_TYPES.ObjectExpression&&(o(c),l(c)),c.type===H.AST_NODE_TYPES.ArrowFunctionExpression&&(c.body.type===H.AST_NODE_TYPES.ObjectExpression&&(o(c.body),l(c.body)),c.body.type===H.AST_NODE_TYPES.BlockStatement))for(let r of c.body.body)r.type===H.AST_NODE_TYPES.ReturnStatement&&r.argument?.type===H.AST_NODE_TYPES.ObjectExpression&&(o(r.argument),l(r.argument));if(c.type===H.AST_NODE_TYPES.FunctionExpression)for(let r of c.body.body)r.type===H.AST_NODE_TYPES.ReturnStatement&&r.argument?.type===H.AST_NODE_TYPES.ObjectExpression&&(o(r.argument),l(r.argument))}}}}}),Ae={name:ct,rule:En};var oe=require("@typescript-eslint/utils");var bn=oe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xn=F({disallow:L(V(F({selector:j(),message:j(),replace:L(ke(j(),F({regex:j(),with:j()}))),replaceType:L(ot(["suggestion","autofix"]))}))),__dev_simulateFileName:L(j()),mustMatchSyntax:L(V(F({includeRegex:j(),mustCallFn:V(F({anyCall:V(F({fn:j(),withArgs:V(F({atIndex:at(),literal:ke(j(),J(),se())}))})),message:L(j())}))})))}),ft="advanced-no-restricted-syntax",In=bn({name:ft,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[xn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:o,__dev_simulateFileName:l,disallow:f}=t,c=l??e.filename,r=[],a=new Set;for(let{includeRegex:i,mustCallFn:p}of o??[]){let g=wn(c,new RegExp(i));if(!g)continue;let h=x=>{let d=x;for(let{name:I,value:T}of g)d=d.replaceAll(I,T);return d};for(let{anyCall:x,message:d}of p){let I=`Expected file to call the function: ${x.map(({fn:T})=>T).join(" or ")}`;a.add(I),r.push(T=>{let{callee:N}=T;if(N.type===oe.AST_NODE_TYPES.Identifier){for(let{fn:v,withArgs:y}of x)if(N.name===v){a.delete(I);for(let C of y){let R=T.arguments[C.atIndex],k=typeof C.literal=="string"?h(C.literal):C.literal;if(!R){e.report({node:T,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${C.atIndex}${d?`: ${h(d)}`:""}`}});continue}if(R.type!==oe.AST_NODE_TYPES.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${C.atIndex} should the literal "${k}"${d?`: ${h(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${h(d)}`:""}`},fix:_=>_.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:i,message:p,replace:g,replaceType:h="suggestion"}of f??[]){if(i==="CallExpression"){r.push(x=>{s(g,x,p,h)});continue}n[i]=x=>{s(g,x,p,h)}}return r.length>0&&(n.CallExpression=i=>{if(i.type===oe.AST_NODE_TYPES.CallExpression)for(let p of r)p(i)}),n["Program:exit"]=i=>{for(let p of a)e.report({node:i,messageId:"default",data:{message:`${p}`}})},n;function s(i,p,g,h){let x=d=>{if(!i)return null;if(typeof i=="string")return d.replaceText(p,i);{let I=new RegExp(i.regex),T=e.sourceCode.getText(p);return d.replaceText(p,T.replace(I,i.with))}};e.report({node:p,messageId:"default",data:{message:g},fix:i&&h==="autofix"?x:void 0,suggest:i&&h==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:x}]:void 0})}}});function wn(e,t){let n=[],o=t.exec(e);if(!o)return null;let[l,...f]=o;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:pt(l)}),n.push({name:"$0_uncapitalize",value:ut(l)}),n.push({name:"$0",value:l});for(let c=0;c<f.length;c++){let r=`$${c+1}`,a=f[c];n.push({name:`${r}_lowercase`,value:a.toLowerCase()}),n.push({name:`${r}_capitalize`,value:pt(a)}),n.push({name:`${r}_uncapitalize`,value:ut(a)}),n.push({name:r,value:a})}return n}function pt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ut(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Oe={name:ft,rule:In};var D=require("@typescript-eslint/utils");var Cn=D.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dt="collapse-simple-objs-in-one-line",Rn=F({maxLineLength:L(J()),maxProperties:L(J()),nestedObjMaxLineLength:L(J()),nestedObjMaxProperties:L(J()),ignoreTypesWithSuffix:L(V(j()))}),vn=Cn({name:dt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[Rn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,o=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,c=t.nestedObjMaxProperties??3;function r(s){if(s.type===D.AST_NODE_TYPES.ObjectExpression){let i=s.parent.type===D.AST_NODE_TYPES.Property,p=i?c:l,g=s.properties.length;if(g>p)return!1;if(g===1){let x=s.properties[0];return x.type===D.AST_NODE_TYPES.Property&&(x.value.type===D.AST_NODE_TYPES.ObjectExpression||x.value.type===D.AST_NODE_TYPES.ArrayExpression)?!1:{text:n.getText(x),isNested:i,propsSize:g}}let h=[];for(let x of s.properties){if(x.type===D.AST_NODE_TYPES.Property){let d=x.value.type;if(!(d===D.AST_NODE_TYPES.Literal||d===D.AST_NODE_TYPES.Identifier||d===D.AST_NODE_TYPES.TemplateLiteral||d===D.AST_NODE_TYPES.TaggedTemplateExpression))return!1}h.push(n.getText(x))}return{text:h.join(", "),isNested:i,propsSize:g}}else{let i=s.parent.parent?.type===D.AST_NODE_TYPES.TSPropertySignature,p=i?c:l,g=s.members.length;if(g>p)return!1;if(o.length>0&&s.parent.type===D.AST_NODE_TYPES.TSTypeAliasDeclaration){let x=s.parent.id.name;if(o.some(d=>x.endsWith(d)))return!1}if(g===1){let x=s.members[0];return x.type===D.AST_NODE_TYPES.TSPropertySignature&&x.typeAnnotation?.typeAnnotation.type===D.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(x),isNested:i,propsSize:1}}if(s.parent.type===D.AST_NODE_TYPES.TSIntersectionType||s.parent.type===D.AST_NODE_TYPES.TSUnionType)return!1;let h=[];for(let x of s.members){if(x.type!==D.AST_NODE_TYPES.TSPropertySignature)return!1;let d=x.typeAnnotation?.typeAnnotation;if(!d||d.type===D.AST_NODE_TYPES.TSTypeLiteral||!mt(d.type))return!1;if(d.type===D.AST_NODE_TYPES.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let T=d.typeArguments.params[0];if(!mt(T.type))return!1}let I=n.getText(x).trim();(I.endsWith(";")||I.endsWith(","))&&(I=I.slice(0,-1)),h.push(I)}return{text:h.join("; "),isNested:i,propsSize:g}}}function a(s){if(s.loc.start.line===s.loc.end.line||s.parent.type!==D.AST_NODE_TYPES.JSXExpressionContainer&&n.getTokenAfter(s,{filter:I=>{let T=I.type===D.AST_TOKEN_TYPES.Punctuator&&I.value===",",N=I.type===D.AST_TOKEN_TYPES.Punctuator&&I.value===";";return!T&&!N}})?.loc.start.line===s.loc.end.line)return;let i=r(s);if(!i)return;let p=i.text;if(p.includes(`
2
+ `)||n.getCommentsInside(s).length>0)return;p.endsWith(";")&&(p=p.slice(0,-1));let g=`{ ${p} }`,h=An(n,s),x=i.isNested&&i.propsSize>2?f:t.maxLineLength;x&&g.length+h.length+(kn(s,n)?1:0)>x||e.report({node:s,messageId:"singleLineProp",fix:d=>d.replaceText(s,g)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function mt(e){return e===D.AST_NODE_TYPES.TSLiteralType||e===D.AST_NODE_TYPES.TSTypeReference||e===D.AST_NODE_TYPES.TSNumberKeyword||e===D.AST_NODE_TYPES.TSStringKeyword||e===D.AST_NODE_TYPES.TSBooleanKeyword||e===D.AST_NODE_TYPES.TSNullKeyword||e===D.AST_NODE_TYPES.TSUndefinedKeyword}function kn(e,t){let n=t.getTokenAfter(e);return n?.type===D.AST_TOKEN_TYPES.Punctuator&&(n.value===","||n.value===";"||n.value==="}")&&n.loc.start.line===e.loc.end.line}function An(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Pe={name:dt,rule:vn};var On=/eslint +react-compiler\/react-compiler: +\["error/,gt={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"?T=>n(T):T=>e.sourceCode.getText(T),o=typeof e.getScope=="function"?()=>o():T=>e.sourceCode.getScope(T),l=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,f=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,c={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:f};function r(T){f&&Array.isArray(T.suggest)&&T.suggest.length>0&&(T.fix=T.suggest[0].fix),e.report(T)}let a=e.getSourceCode().scopeManager,s=new WeakMap,i=new WeakSet,p=new WeakMap,g=new WeakMap,h=new WeakSet;function x(T,N){return function(v){if(N.has(v))return N.get(v);let y=T(v);return N.set(v,y),y}}function d(T,N,v,y,C){C&&T.async&&r({node:T,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
3
3
 
4
4
  useEffect(() => {
5
5
  async function fetchData() {
@@ -10,5 +10,5 @@ useEffect(() => {
10
10
  fetchData();
11
11
  }, [someId]); // Or [] if effect doesn't need props or state
12
12
 
13
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=s.acquire(g),k=new Set,$=null;{let p=R.upper;for(;p&&(k.add(p),p.type!=="function");)p=p.upper;if(!p)return;$=p}let A=Array.isArray;function H(p){if(!A(p.defs))return!1;let m=p.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let h=m.node.init;if(h==null)return!1;for(;h.type==="TSAsExpression";)h=h.expression;let S=m.node.parent;if(S==null&&(Oe($.block,m.node.id),S=m.node.parent,S==null))return!1;if(S.kind==="const"&&h.type==="Literal"&&(typeof h.value=="string"||typeof h.value=="number"||h.value===null))return!0;if(h.type!=="CallExpression")return!1;let w=h.callee;if(w.type==="MemberExpression"&&w.object.name==="React"&&w.property!=null&&!w.computed&&(w=w.property),w.type!=="Identifier")return!1;let E=m.node.id,{name:O}=w;if(O==="useRef"&&E.type==="Identifier")return!0;if(An(w)&&E.type==="Identifier"){for(let P of p.references)P!==E&&I.add(P.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(E.type==="ArrayPattern"&&E.elements.length===2&&A(p.identifiers)){if(E.elements[1]===p.identifiers[0]){if(O==="useState"){let P=p.references,q=0;for(let J=0;J<P.length;J++){if(P[J].isWrite()&&q++,q>1)return!1;o.set(P[J].identifier,E.elements[0])}}return!0}else if(E.elements[0]===p.identifiers[0]){if(O==="useState"){let P=p.references;for(let q=0;q<P.length;q++)i.add(P[q].identifier)}return!1}}}else if(O==="useTransition"&&E.type==="ArrayPattern"&&E.elements.length===2&&Array.isArray(p.identifiers)&&E.elements[1]===p.identifiers[0])return!0;return!1}function K(p){if(!A(p.defs))return!1;let m=p.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let h=m.node,S=$.childScopes,w=null,E;for(E=0;E<S.length;E++){let O=S[E],P=O.block;if(h.type==="FunctionDeclaration"&&P===h||h.type==="VariableDeclarator"&&P.parent===h){w=O;break}}if(w==null)return!1;for(E=0;E<w.through.length;E++){let O=w.through[E];if(O.resolved!=null&&k.has(O.resolved.scope)&&!Be(O.resolved))return!1}return!0}let Be=b(H,f),Bt=b(K,T),Ke=new Map;function Kt(p){let m=p.from,h=!1;for(;m.block!==g;)m.type==="function"&&(h=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return h}let z=new Map,Te=new Map;Xe(R);function Xe(p){for(let m of p.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let h=Oe(g,m.identifier),S=ut(h),w=G(S,Te);if(C&&S.type==="Identifier"&&(S.parent.type==="MemberExpression"||S.parent.type==="OptionalMemberExpression")&&!S.parent.computed&&S.parent.property.type==="Identifier"&&S.parent.property.name==="current"&&Kt(m)&&Ke.set(w,{reference:m,dependencyNode:S}),S.parent.type==="TSTypeQuery"||S.parent.type==="TSTypeReference")continue;let E=m.resolved.defs[0];if(E!=null&&!(E.node!=null&&E.node.init===g.parent)&&E.type!=="TypeParameter")if(z.has(w))z.get(w).references.push(m);else{let O=m.resolved,P=Be(O)||Bt(O);z.set(w,{isStable:P,references:[m]})}}for(let m of p.childScopes)Xe(m)}Ke.forEach(({reference:p,dependencyNode:m},h)=>{let S=p.resolved.references,w=!1;for(let E=0;E<S.length;E++){let{identifier:O}=S[E],{parent:P}=O;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){w=!0;break}}w||l({node:m.parent.property,message:`The ref value '${h}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${h}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Ee=new Set;function Xt(p,m){Ee.has(m)||(Ee.add(m),l({node:p,message:`Assignments to the '${m}' variable from inside React Hook ${n(v)} 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(v)}.`}))}let pe=new Set;if(z.forEach(({isStable:p,references:m},h)=>{p&&pe.add(h),m.forEach(S=>{S.writeExpr&&Xt(S.writeExpr,h)})}),Ee.size>0)return;if(!D){let p=null;if(z.forEach(({isStable:m,references:h},S)=>{p||h.forEach(w=>{if(p)return;let E=w.identifier;if(!o.has(E))return;let P=w.from;for(;P.type!=="function";)P=P.upper;P.block===g&&(p=S)})}),p){let{suggestedDependencies:m}=ke({dependencies:z,declaredDependencies:[],stableDependencies:pe,externalDependencies:new Set,isEffect:!0});l({node:v,message:`React Hook ${y} contains a call to '${p}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${y} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(h){return h.insertTextAfter(g,`, [${m.join(", ")}]`)}}]})}return}let ae=[],le=new Set;D.type!=="ArrayExpression"?l({node:D,message:`React Hook ${n(v)} 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.`}):D.elements.forEach(p=>{if(p===null)return;if(p.type==="SpreadElement"){l({node:p,message:`React Hook ${n(v)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}I.has(p)&&l({node:p,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(p)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(p)}\``,fix(w){return w.removeRange(p.range)}}]});let m;try{m=G(p,Te)}catch(w){if(/Unsupported node type/.test(w.message)){p.type==="Literal"?z.has(p.value)?l({node:p,message:`The ${p.raw} literal is not a valid dependency because it never changes. Did you mean to include ${p.value} in the array instead?`}):l({node:p,message:`The ${p.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):l({node:p,message:`React Hook ${n(v)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw w}let h=p;for(;h.type==="MemberExpression"||h.type==="OptionalMemberExpression"||h.type==="ChainExpression";)h=h.object||h.expression.object;let S=!$.through.some(w=>w.identifier===h);ae.push({key:m,node:p}),S||le.add(m)});let{suggestedDependencies:Jt,unnecessaryDependencies:ue,missingDependencies:Q,duplicateDependencies:Je}=ke({dependencies:z,declaredDependencies:ae,stableDependencies:pe,externalDependencies:le,isEffect:C}),fe=Jt;if(Je.size+Q.size+ue.size===0){if(t)return;Cn({declaredDependencies:ae,declaredDependenciesNode:D,componentScope:$,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:h,depType:S})=>{let w=S==="function"?"useCallback":"useMemo",E=S==="function"?"definition":"initialization",O=`wrap the ${E} of '${m.name.name}' in its own ${w}() Hook.`,P=h?`To fix this, ${O}`:`Move it inside the ${y} callback. Alternatively, ${O}`,q=S==="conditional"||S==="logical expression"?"could make":"makes",J=`The '${m.name.name}' ${S} ${q} the dependencies of ${y} Hook (at line ${D.loc.start.line}) change on every render. ${P}`,Ge;h&&m.type==="Variable"&&S==="function"&&(Ge=[{desc:`Wrap the ${E} of '${m.name.name}' in its own ${w}() Hook.`,fix(Ze){let[Zt,Qt]=w==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Ze.insertTextBefore(m.node.init,Zt),Ze.insertTextAfter(m.node.init,Qt)]}}]),l({node:m.node,message:J,suggest:Ge})});return}!C&&Q.size>0&&(fe=ke({dependencies:z,declaredDependencies:[],stableDependencies:pe,externalDependencies:le,isEffect:C}).suggestedDependencies);function Gt(){if(ae.length===0)return!0;let p=ae.map(h=>h.key),m=p.slice().sort();return p.join(",")===m.join(",")}Gt()&&fe.sort();function be(p){let m=p.split("."),h="";for(let S=0;S<m.length;S++){if(S!==0){let w=m.slice(0,S+1).join("."),E=Te.get(w)===!0;h+=E?"?.":"."}h+=m[S]}return h}function xe(p,m,h,S){return p.size===0?null:(p.size>1?"":m+" ")+h+" "+(p.size>1?"dependencies":"dependency")+": "+vn(Array.from(p).sort().map(w=>"'"+be(w)+"'"))+`. Either ${S} ${p.size>1?"them":"it"} or remove the dependency array.`}let B="";if(ue.size>0){let p=null;if(Array.from(ue.keys()).forEach(m=>{p===null&&m.endsWith(".current")&&(p=m)}),p!==null)B=` Mutable values like '${p}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(le.size>0){let m=Array.from(le)[0];R.set.has(m)||(B=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!B&&Q.has("props")){let p=z.get("props");if(p==null)return;let m=p.references;if(!Array.isArray(m))return;let h=!0;for(let S=0;S<m.length;S++){let w=m[S],E=Oe($.block,w.identifier);if(!E){h=!1;break}let O=E.parent;if(O==null){h=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){h=!1;break}}h&&(B=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${y} call and refer to those specific props inside ${n(v)}.`)}if(!B&&Q.size>0){let p=null;Q.forEach(m=>{if(p)return;let h=$.set.get(m),S=z.get(m);if(S.references[0].resolved!==h)return;let w=h.defs[0];if(w==null||w.name==null||w.type!=="Parameter")return;let E=!1,O;for(let P=0;P<S.references.length;P++)if(O=S.references[P].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){E=!0;break}E&&(p=m)}),p!==null&&(B=` If '${p}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!B&&Q.size>0){let p=null;if(Q.forEach(m=>{if(p!==null)return;let S=z.get(m).references,w,E;for(let O=0;O<S.length;O++){for(w=S[O].identifier,E=w.parent;E!=null&&E!==$.block;){if(E.type==="CallExpression"){let P=o.get(E.callee);if(P!=null){if(P.name===m)p={missingDep:m,setter:E.callee.name,form:"updater"};else if(i.has(w))p={missingDep:m,setter:E.callee.name,form:"reducer"};else{let q=S[O].resolved;if(q!=null){let J=q.defs[0];J!=null&&J.type==="Parameter"&&(p={missingDep:m,setter:E.callee.name,form:"inlineReducer"})}}break}}E=E.parent}if(p!==null)break}}),p!==null)switch(p.form){case"reducer":B=` You can also replace multiple useState variables with useReducer if '${p.setter}' needs the current value of '${p.missingDep}'.`;break;case"inlineReducer":B=` If '${p.setter}' needs the current value of '${p.missingDep}', you can also switch to useReducer instead of useState and read '${p.missingDep}' in the reducer.`;break;case"updater":B=` You can also do a functional update '${p.setter}(${p.missingDep.slice(0,1)} => ...)' if you only need '${p.missingDep}' in the '${p.setter}' call.`;break;default:throw new Error("Unknown case.")}}l({node:D,message:`React Hook ${n(v)} has `+(xe(Q,"a","missing","include")||xe(ue,"an","unnecessary","exclude")||xe(Je,"a","duplicate","omit"))+B,suggest:[{desc:`Update the dependencies array to be: [${fe.map(be).join(", ")}]`,fix(p){return p.replaceText(D,`[${fe.map(be).join(", ")}]`)}}]})}function x(g){let D=Rn(g.callee,c);if(D===-1)return;let v=g.arguments[D],y=g.callee,C=ft(y).name,R=g.arguments[D+1],k=/Effect($|[^a-z])/g.test(C);if(!v){l({node:y,message:`React Hook ${C} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!R&&!k){(C==="useMemo"||C==="useCallback")&&l({node:y,message:`React Hook ${C} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(v.type){case"FunctionExpression":case"ArrowFunctionExpression":d(v,R,y,C,k);return;case"Identifier":if(!R||R.elements&&R.elements.some(H=>H&&H.type==="Identifier"&&H.name===v.name))return;let $=r(g).set.get(v.name);if($==null||$.defs==null)return;let A=$.defs[0];if(!A||!A.node||A.type!=="Variable"&&A.type!=="FunctionName")break;switch(A.node.type){case"FunctionDeclaration":d(A.node,R,y,C,k);return;case"VariableDeclarator":let H=A.node.init;if(!H)break;switch(H.type){case"ArrowFunctionExpression":case"FunctionExpression":d(H,R,y,C,k);return}break}break;default:l({node:y,message:`React Hook ${C} received a function whose dependencies are unknown. Pass an inline function instead.`});return}l({node:y,message:`React Hook ${C} has a missing dependency: '${v.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${v.name}]`,fix($){return $.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(wn.test(g.value))return t=!0,{CallExpression:D=>x(D,!0)}}return{CallExpression:g=>x(g)}}};function ke({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:a}){let u=c();function c(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,x)=>{let g=l(u,x);g.isUsed=!0,s(u,x,D=>{D.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let x=l(u,d);x.isSatisfiedRecursively=!0}),n.forEach(d=>{let x=l(u,d);x.isSatisfiedRecursively=!0});function l(d,x){let g=x.split("."),D=d;for(let v of g){let y=D.children.get(v);y||(y=c(),D.children.set(v,y)),D=y}return D}function s(d,x,g){let D=x.split("."),v=d;for(let y of D){let C=v.children.get(y);if(!C)return;g(C),v=C}}let o=new Set,i=new Set;f(u,o,i,d=>d);function f(d,x,g,D){d.children.forEach((v,y)=>{let C=D(y);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&g.add(C);return}if(v.isUsed){x.add(C);return}f(v,x,g,R=>C+"."+R)})}let T=[],I=new Set,b=new Set;return t.forEach(({key:d})=>{i.has(d)?T.indexOf(d)===-1?T.push(d):b.add(d):I.add(d)}),o.forEach(d=>{T.push(d)}),{suggestedDependencies:T,unnecessaryDependencies:I,duplicateDependencies:b,missingDependencies:o}}function te(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 te(e.consequent)!=null||te(e.alternate)!=null?"conditional":null;case"LogicalExpression":return te(e.left)!=null||te(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return te(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return te(e.expression);case"TSAsExpression":return te(e.expression)}return null}function Cn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let a=e.map(({key:c})=>{let l=n.variables.find(o=>o.name===c);if(l==null)return null;let s=l.defs[0];if(s==null)return null;if(s.type==="Variable"&&s.node.type==="VariableDeclarator"&&s.node.id.type==="Identifier"&&s.node.init!=null){let o=te(s.node.init);if(o!=null)return[l,o]}return s.type==="FunctionName"&&s.node.type==="FunctionDeclaration"?[l,"function"]:s.type==="ClassName"&&s.node.type==="ClassDeclaration"?[l,"class"]:null}).filter(Boolean);function u(c){let l=!1;for(let s=0;s<c.references.length;s++){let o=c.references[s];if(o.writeExpr){if(l)return!0;l=!0;continue}let i=o.from;for(;i!==r&&i!=null;)i=i.upper;if(i!==r&&!mt(t,o.identifier))return!0}return!1}return a.map(([c,l])=>({construction:c.defs[0],depType:l,isUsedOutsideOfHook:u(c)}))}function ut(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?ut(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ae(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),r=G(e.property,null),a=`${n}.${r}`;return Ae(e,t,a),a}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=G(e.object,t),r=G(e.property,null),a=`${n}.${r}`;return Ae(e,t,a),a}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=G(n.object,t),a=G(n.property,null),u=`${r}.${a}`;return Ae(n,t,u),u}else throw new Error(`Unsupported node type: ${e.type}`)}function ft(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Rn(e,t){let n=ft(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=G(n,null)}catch(a){if(/Unsupported node type/.test(a.message))return 0;throw a}return t.additionalHooks.test(r)?0:-1}else return-1}}function Oe(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),kn(r,t))return r;if(mt(r,t))for(let[a,u]of Object.entries(r))a!=="parent"&&(ct(u)?(u.parent=r,n.push(u)):Array.isArray(u)&&u.forEach(c=>{ct(c)&&(c.parent=r,n.push(c))}))}return null}function vn(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 ct(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function kn(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 mt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function An(e){return!1}var de=require("@typescript-eslint/utils");var On=de.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dt="no-call-with-explicit-generics",Pn=W({functions:Y(M())}),Dn=On({name:dt,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(r){let{callee:a}=r;a.type===de.AST_NODE_TYPES.Identifier&&n.has(a.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:a.name}})}}}}),Pe={name:dt,rule:Dn};var ne=require("@typescript-eslint/utils"),_n=ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yt="no-call-with-inferred-generics",$n=_n({name:yt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:a}=r;if(a.type!==ne.AST_NODE_TYPES.Identifier)return;let u=n.get(a.name);if(!u)return;let{minGenerics:c=1,allowAny:l,disallowTypes:s=t.disallowTypes}=u;(r.typeArguments?.params.length||0)<(c||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:a.name,minGenerics:c||0}}),!(l&&!s)&&r.typeArguments?.params?.some(i=>!l&&i.type===ne.AST_NODE_TYPES.TSAnyKeyword||s&&i.type===ne.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===ne.AST_NODE_TYPES.Identifier&&s.includes(i.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:a.name}})}}}}),De={name:yt,rule:$n};var ce=require("@typescript-eslint/utils"),Nn=ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gt="no-commented-out-code",Ln=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Mn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],jn=Nn({name:gt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let r=n.trimStart();if(n.startsWith("*")||r.startsWith("INFO:")||r.startsWith("TODO:")||r.startsWith("DOCS:")||r.startsWith("FIX:")||r.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let a of Ln)if(r.startsWith(a))return{wrongPattern:a};for(let a of Mn)if(typeof a=="string"){if(n.includes(a))return{wrongPattern:a}}else if(a.test(n))return{wrongPattern:`regex(${a.toString()})`};return!1}return{Program(){let r=e.sourceCode.getAllComments();for(let a of r)if(a.type===ce.TSESTree.AST_TOKEN_TYPES.Line||a.type===ce.TSESTree.AST_TOKEN_TYPES.Block){let u=t(a.value);u&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:u.wrongPattern}})}}}}}),_e={name:gt,rule:jn};var ye=require("@typescript-eslint/utils"),Fn=ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ht="no-default-export",Wn=Fn({name:ht,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===ye.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),$e={name:ht,rule:Wn};var St=require("@typescript-eslint/utils"),Hn=St.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tt="no-leaked-text-in-jsx",Un=[",",";","[","]","(",")"],Yn=Hn({name:Tt,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;let r="";Un.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),Ne={name:Tt,rule:Yn};var Z=require("@typescript-eslint/utils"),Vn=Z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bt="no-non-camel-case-functions",zn=/^[a-z][a-zA-Z0-9]*$/;function Et(e){return e.typeName.type===Z.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===Z.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===Z.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var qn=Vn({name:bt,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&&!zn.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===Z.AST_NODE_TYPES.TSTypeReference?Et(n):n.type===Z.AST_NODE_TYPES.TSUnionType&&n.types.some(a=>a.type===Z.AST_NODE_TYPES.TSTypeReference&&Et(a))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Le={name:bt,rule:qn};var j=require("@typescript-eslint/utils");function se(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:se(e.parent,t,n===1/0?n:n-1)}function*Me(e){yield e,e.parent&&(yield*Me(e.parent))}var Bn=j.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xt="no-optional-root-props",Kn=Bn({name:xt,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(a){return a?a.parent?.type===j.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||a.parent?.type===j.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function n(a){let c=e.sourceCode.getDeclaredVariables(a)[0];if(!c||c.references.length!==1)return!1;let l=c.references[0];if(!l)return!1;for(let s of Me(l.identifier)){if("returnType"in s||s.type===j.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let o=s.parent;if(!o)return!1;if(o.type===j.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&o.parent.type===j.TSESTree.AST_NODE_TYPES.TSTypeReference&&o.parent.typeName.type===j.TSESTree.AST_NODE_TYPES.Identifier&&o.parent.typeName.name==="FC"){let f=se(o.parent.parent,j.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(f)return!(t(f)||e.sourceCode.getScope(f).references.some(I=>t(I.identifier.parent.parent)))}if(s.type===j.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(o.type===j.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let i=se(o,j.TSESTree.AST_NODE_TYPES.VariableDeclaration);return i&&t(i)||i&&e.sourceCode.getScope(i).references.some(T=>T.identifier.parent.parent?.parent?.type===j.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)?!1:o.params.some(f=>f===s)}if(o.type===j.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return t(o)||e.sourceCode.getScope(o).upper?.references.some(f=>t(f.identifier.parent.parent))?!1:o.params.some(f=>f===s)}return!1}function r(a){a.key.type!==j.TSESTree.AST_NODE_TYPES.Identifier||!a.optional||e.report({node:a.key,messageId:"optionalNotAllowed",data:{propertyName:a.key.name},suggest:[{messageId:"suggestion",fix:u=>{let c=se(a,j.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!c)return null;let l=e.sourceCode.getText(c);return u.replaceText(c,l.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(a){if(a.typeAnnotation.type===j.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(t(a)||!n(a)))for(let u of a.typeAnnotation.members)u.type===j.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(u)},TSInterfaceDeclaration(a){if(!(t(a)||!n(a)))for(let u of a.body.body)u.type===j.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(u)},TSTypeReference(a){if(a.typeName.type!==j.TSESTree.AST_NODE_TYPES.Identifier||a.typeName.name!=="FC"||!a.typeArguments?.params[0])return;let u=a.typeArguments.params[0];if(u.type!==j.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let c=se(a.parent,j.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!c||t(c)||e.sourceCode.getScope(c).references.some(i=>i.identifier.parent.parent?.parent?.type===j.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration))return;let s=c.declarations[0].id.type===j.TSESTree.AST_NODE_TYPES.Identifier?c.declarations[0].id:null,o=e.sourceCode.getScope(c).variables.find(i=>i.name===s?.name)?.references.filter(i=>i.identifier!==s);if(!(o&&o.length>1))for(let i of u.members)i.type===j.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(i)}}}}),je={name:xt,rule:Kn};var It=require("@typescript-eslint/utils"),ge=an(require("path"));var Xn=It.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wt="no-relative-imports",Jn=W({find:M(),replacement:M()}),Gn=W({aliases:Y(Jn),rootDir:L(M()),allowNotFoundAliases:L(re()),_dev_simulateFileName:L(M())}),Zn=Xn({name:wt,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[Gn]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(c){return c.startsWith(".")||c.startsWith("..")}function a(c,l){let s=ge.default.dirname(l);return ge.default.resolve(s,c)}function u(c){let l=t.rootDir??process.cwd(),s=ge.default.relative(l,c);if(s.startsWith("."))return null;s.startsWith("/")||(s=`/${s}`);for(let{find:o,replacement:i}of t.aliases)if(s.startsWith(i)){let f=s.replace(i,o);return{alias:o,newPath:f}}return null}return{ImportDeclaration(c){let l=c.source.value;if(!r(l))return;let s=a(l,n),o=u(s);!o&&t.allowNotFoundAliases||e.report({node:c,messageId:o?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:o?.alias},fix:o?i=>i.replaceText(c.source,`'${o.newPath}'`):void 0})}}}}),Fe={name:wt,rule:Zn};var N=require("@typescript-eslint/utils");var Qn=N.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Ct(e){let t=[];for(let n of e.members)n.type===N.AST_NODE_TYPES.TSPropertySignature&&n.key.type===N.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function Rt(e,...t){for(let n of t)e.set(...n);return e}var er=W({forceCheckOnFCPropTypesWithName:L(Y(M()))}),vt="no-unused-type-props-in-args",We=null,tr=Qn({name:vt,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:[er],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!We&&(We=n.map(l=>new RegExp(l)));function r(l,s,o,i,f=!0){let T=o.name,I=e.sourceCode.getScope(s).references.find(x=>x.identifier.name===T)?.resolved,b=l&&We?.some(x=>x.test(T));if(!I||!b&&I.references.filter(x=>x.isTypeReference).length>1)return;let d=I?.defs[0]?.node;if(!(f&&d?.parent?.type===N.AST_NODE_TYPES.ExportNamedDeclaration)){if(d?.type===N.AST_NODE_TYPES.TSTypeAliasDeclaration){a(l,s,i,d.typeAnnotation,!0);return}if(d?.type===N.AST_NODE_TYPES.TSInterfaceDeclaration){a(l,s,i,d.body,!0);return}}}function a(l,s,o,i,f){if(i.type===N.AST_NODE_TYPES.TSInterfaceBody){for(let T of i.body)T.type===N.AST_NODE_TYPES.TSPropertySignature&&T.key.type===N.AST_NODE_TYPES.Identifier&&o.set(T.key.name,T);return}if(i.type===N.AST_NODE_TYPES.TSTypeLiteral){Rt(o,...Ct(i));return}if(i.type===N.AST_NODE_TYPES.TSIntersectionType){for(let T of i.types)a(l,s,o,T,!0);return}f||i.type===N.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===N.AST_NODE_TYPES.Identifier&&r(l,s,i.typeName,o)}function u(l,s,o){for(let i of o)if(i.type==="ObjectPattern"&&i.typeAnnotation){let f=new Map;if(a(l,s,f,i.typeAnnotation.typeAnnotation,!1),f.size===0)continue;c(i,f)}else i.type===N.AST_NODE_TYPES.AssignmentPattern&&i.left.type===N.AST_NODE_TYPES.ObjectPattern&&u(l,s,[i.left])}function c(l,s){let o=[];if(l.properties.at(-1)?.type===N.AST_NODE_TYPES.RestElement)return;for(let I of l.properties)I.type===N.AST_NODE_TYPES.Property&&I.key.type===N.AST_NODE_TYPES.Identifier&&o.push(I.key.name);let f=[],T=[];for(let[I,b]of s)o.includes(I)||(T.push(I),f.push({node:b,messageId:"unusedObjectTypeProperty",data:{propertyName:I}}));for(let[I,b]of f.entries())e.report({...b,fix:I===f.length-1?d=>{let x=l.properties.at(-1),g=T.join(", ");return x?x?.type===N.AST_NODE_TYPES.RestElement?null:d.insertTextAfter(x,`, ${g}`):d.insertTextBeforeRange([l.range[0]+1,l.range[1]],`${g}`)}:void 0})}return{VariableDeclaration(l){let s=l.declarations[0];if(!s)return;let o=new Map,i=s.id.type===N.AST_NODE_TYPES.Identifier&&s.id.typeAnnotation?.typeAnnotation.type===N.AST_NODE_TYPES.TSTypeReference&&s.id.typeAnnotation.typeAnnotation.typeName.type===N.AST_NODE_TYPES.Identifier&&s.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&s.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===N.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===N.AST_NODE_TYPES.Identifier)r(!0,l,i.typeName,o,!1);else if(i.type===N.AST_NODE_TYPES.TSTypeLiteral)Rt(o,...Ct(i));else if(i.type===N.AST_NODE_TYPES.TSIntersectionType)for(let f of i.types)f.type===N.AST_NODE_TYPES.TSTypeReference&&f.typeName.type===N.AST_NODE_TYPES.Identifier?r(!0,l,f.typeName,o,!1):a(!0,l,o,f,!0);if(o.size!==0&&s.init?.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let f=s.init.params[0];if(!f){e.report({node:s.init,messageId:"missingComponentParam"});return}f.type===N.AST_NODE_TYPES.ObjectPattern&&c(f,o)}}},FunctionDeclaration:function(l){u(!1,l,l.params)},ArrowFunctionExpression(l){u(!1,l,l.params)}}}}),He={name:vt,rule:tr};var oe=require("@typescript-eslint/utils"),nr=oe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="prefer-named-functions",kt=new Map,rr=nr({name:At,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=kt.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),kt.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===oe.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===oe.AST_NODE_TYPES.Identifier){let a=r.id.name;if(r.id.typeAnnotation||n&&n.test(a)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==oe.AST_NODE_TYPES.BlockStatement)return;let u=r.parent,c=r.init.params,l=r.init.body,s=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:a,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:o=>o.replaceText(u,`${s.async?"async ":""}function ${a}(${c.map(i=>e.sourceCode.getText(i)).join(", ")||""}) ${e.sourceCode.getText(l)}`)}]})}}}}}),Ue={name:At,rule:rr};var F=require("@typescript-eslint/utils");var ir=F.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="prefer-single-line-if",sr=W({maxLineLength:L(X()),maxNonSimpleConditionLength:L(X())}),or=ir({name:Pt,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[sr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==F.AST_NODE_TYPES.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let u=r.consequent.body[0];if(u.type===F.AST_NODE_TYPES.ReturnStatement){if(!_t(u))return}else if(!(u.type===F.AST_NODE_TYPES.ContinueStatement||u.type===F.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===F.AST_NODE_TYPES.LogicalExpression||r.test.type===F.AST_NODE_TYPES.ConditionalExpression)return;let c;if(t.maxNonSimpleConditionLength){let f=Ot(r.test);if(!f&&r.test.type===F.AST_NODE_TYPES.UnaryExpression&&r.test.operator==="!"){let T=r.test.argument;Ot(T)&&(f=!0)}if(f&&(c=n.getText(r.test),c.length>t.maxNonSimpleConditionLength))return}c||(c=n.getText(r.test));let l=n.getText(u);if(c.includes(`
14
- `))return;let s=n.getTokenAfter(r);if(s&&s.type===F.AST_TOKEN_TYPES.Punctuator&&s.value==="}"){let f=n.getTokenAfter(s);if(f&&f.type===F.AST_TOKEN_TYPES.Keyword&&(f.value==="else"||f.value==="catch"))return}let o=ar(n,r),i=`if (${c}) ${l}`;t.maxLineLength&&i.length+o.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:f=>f.replaceText(r,i)})}}}});function Ot(e){return e.type===F.AST_NODE_TYPES.CallExpression||e.type===F.AST_NODE_TYPES.BinaryExpression||e.type===F.AST_NODE_TYPES.MemberExpression&&Dt(e)}function Dt(e){return e.object.type===F.AST_NODE_TYPES.MemberExpression?Dt(e.object):e.object.type!==F.AST_NODE_TYPES.Identifier}function ar(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function _t(e){if(!e.argument)return!0;let t=e.argument;return t.type===F.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===F.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===F.AST_NODE_TYPES.Literal||t.type===F.AST_NODE_TYPES.Identifier||t.type===F.AST_NODE_TYPES.TemplateLiteral||t.type===F.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===F.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===F.AST_NODE_TYPES.UnaryExpression?_t(t):!1}var Ye={name:Pt,rule:or};var V=require("@typescript-eslint/utils");var lr=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="react-compiler-migration",cr=W({disallowHooks:L(Y(W({name:M(),replacement:M()}))),disallowMethods:L(Y(W({name:M(),replacement:L(M()),requireTrueProp:L(M())})))}),pr=/eslint +react-compiler\/react-compiler: +\["error/;function ur(e){return e.type===V.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===V.AST_NODE_TYPES.MemberExpression&&e.property.type===V.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var fr=lr({name:$t,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[cr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(pr.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let a=null,u=null;if(r.callee.type===V.AST_NODE_TYPES.Identifier?(a=r.callee.name,u=r.callee):r.callee.type===V.AST_NODE_TYPES.MemberExpression&&r.callee.property.type===V.AST_NODE_TYPES.Identifier&&(a=r.callee.property.name,u=r.callee.property),a){let c=t.disallowHooks.find(l=>l.name===a);c&&u&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:c.name,replacement:c.replacement},suggest:[{messageId:"replace",data:{replacement:c.replacement},fix:l=>l.replaceText(u,c.replacement)}]})}}if(t.disallowMethods?.length&&ur(r.callee)){for(let a of r.arguments)if(a.type===V.AST_NODE_TYPES.ObjectExpression){for(let u of a.properties)if(u.type===V.AST_NODE_TYPES.Property&&u.key.type===V.AST_NODE_TYPES.Identifier){let c=u.key.name,l=t.disallowMethods.find(s=>s.name===c);if(l){if(l.requireTrueProp){let s=l.requireTrueProp,o=!1;for(let i of a.properties)if(i.type===V.AST_NODE_TYPES.Property&&i.key.type===V.AST_NODE_TYPES.Identifier&&i.key.name===s&&i.value.type===V.AST_NODE_TYPES.Literal&&i.value.value===!0){o=!0;break}if(!o){e.report({node:u,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:l.name,requireTrueProp:s}});continue}}l.replacement&&e.report({node:u,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:l.name,replacement:l.replacement},suggest:[{messageId:"replace",data:{replacement:l.replacement},fix:s=>s.replaceText(u.key,l.replacement)}]})}}}}}}:{}}}),Ve={name:$t,rule:fr};var he=require("@typescript-eslint/utils"),mr=he.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="require-description",dr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,yr=/^eslint-disable-(next-)?line$/u,gr=mr({name:Nt,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let a of n.getAllComments()){let u=hr(a);u!=null&&(r.has(u.kind)||u.description||e.report({loc:Tr(a.loc),messageId:"missingDescription"}))}}}}}),Lt={name:Nt,rule:gr};function hr(e){let{text:t,description:n}=Sr(e.value);if(!t)return null;let r=dr.exec(t);if(!r)return null;let a=r[1];if(!a)return null;let u=yr.test(a);if(e.type===he.TSESTree.AST_TOKEN_TYPES.Line&&!u||u&&e.loc.start.line!==e.loc.end.line)return null;let c=t.slice(r.index+a.length);return{kind:a,value:c.trim(),description:n}}function Sr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Tr(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Ft(e){return/^use[A-Z0-9]/.test(e)}function Se(e){return e.type==="Identifier"?Ft(e.name):e.type==="MemberExpression"&&!e.computed&&Se(e.property)?e.object.type==="Identifier":!1}function Wt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Ht(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Ut(e){return!!(e.parent&&e.parent.callee&&Ht(e.parent.callee,"forwardRef"))}function Yt(e){return!!(e.parent&&e.parent.callee&&Ht(e.parent.callee,"memo"))}function ze(e){for(;e;){let t=zt(e);if(t&&(Wt(t)||Se(t))||Ut(e)||Yt(e))return!0;e=e.parent}return!1}function Mt(e){return!1}function qe(e){return!1}var Er=/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 s of e.sourceCode.getAllComments())if(Er.test(s.value))return{CallExpression(o){let i=null;o.callee.name==="useMemo"?i="useMemo":o.callee.name==="useCallback"&&(i="useCallback"),i&&e.report({node:o,message:`"${i}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?s=>t(s):s=>e.sourceCode.getText(s),n=typeof e.getScope=="function"?()=>n():s=>e.sourceCode.getScope(s),r=null,a=[],u=[],c=new WeakSet;function l(s){for(let o of s.references){let i=o.identifier.parent;if(i.type==="VariableDeclarator"&&i.init&&i.init.type==="CallExpression"&&i.init.callee&&Mt(i.init.callee))for(let f of o.resolved.references)f!==o&&c.add(f.identifier)}}return{onCodePathSegmentStart:s=>u.push(s),onCodePathSegmentEnd:()=>u.pop(),onCodePathStart:()=>a.push(new Map),onCodePathEnd(s,o){let i=a.pop();if(i.size===0)return;let f=new Set;function T(y,C){let{cache:R}=T,k=R.get(y.id),$=new Set(C);if($.has(y.id)){let A=[...$],H=A.slice(A.indexOf(y.id)+1);for(let K of H)f.add(K);return BigInt("0")}if($.add(y.id),k!==void 0)return k;if(s.thrownSegments.includes(y))k=BigInt("0");else if(y.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of y.prevSegments)k+=T(A,$)}return y.reachable&&k===BigInt("0")?R.delete(y.id):R.set(y.id,k),k}function I(y,C){let{cache:R}=I,k=R.get(y.id),$=new Set(C);if($.has(y.id)){let A=Array.from($),H=A.slice(A.indexOf(y.id)+1);for(let K of H)f.add(K);return BigInt("0")}if($.add(y.id),k!==void 0)return k;if(s.thrownSegments.includes(y))k=BigInt("0");else if(y.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of y.nextSegments)k+=I(A,$)}return R.set(y.id,k),k}function b(y){let{cache:C}=b,R=C.get(y.id);if(R===null)return 1/0;if(R!==void 0)return R;if(C.set(y.id,null),y.prevSegments.length===0)R=1;else{R=1/0;for(let k of y.prevSegments){let $=b(k);$<R&&(R=$)}R+=1}return C.set(y.id,R),R}T.cache=new Map,I.cache=new Map,b.cache=new Map;let d=I(s.initialSegment),x=zt(o),g=ze(o),D=x?Wt(x)||Se(x):Ut(o)||Yt(o),v=1/0;for(let y of s.finalSegments){if(!y.reachable)continue;let C=b(y);C<v&&(v=C)}for(let[y,C]of i){if(!y.reachable)continue;let R=y.nextSegments.length===0?v<=b(y):v<b(y),k=T(y)*I(y),$=f.has(y.id);for(let A of C)if($&&!qe(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.`}),D){if(o.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!$&&k!==d&&!qe(A)){let K=`React Hook "${t(A)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:A,message:K})}}else if(o.parent&&(o.parent.type==="MethodDefinition"||o.parent.type==="ClassProperty")&&o.parent.value===o){let H=`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:H})}else if(x){let H=`React Hook "${t(A)}" is called in function "${t(x)}" 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:H})}else if(o.type==="Program"){let H=`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:H})}else if(g&&!qe(A)){if(o.parent.type==="CallExpression"&&o.parent.callee.type==="Identifier"&&o.parent.callee.name==="useCallback"){let K=o.parent;if(K.parent.type==="VariableDeclarator"&&Ft(K.parent.id.name))return}let H=`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:H})}}},CallExpression(s){if(Se(s.callee)){let o=jt(a),i=jt(u),f=o.get(i);f||(f=[],o.set(i,f)),f.push(s.callee)}s.callee.type==="Identifier"&&(s.callee.name==="useEffect"||Mt(s.callee))&&s.arguments.length>0&&(r=s)},Identifier(s){r==null&&c.has(s)&&s.parent.type!=="CallExpression"&&e.report({node:s,message:`\`${t(s)}\` 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"(s){s===r&&(r=null)},FunctionDeclaration(s){ze(s)&&l(n(s))},ArrowFunctionExpression(s){ze(s)&&l(n(s))}}}};function zt(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 jt(e){return e[e.length-1]}var qt={[He.name]:He.rule,[_e.name]:_e.rule,[De.name]:De.rule,"rules-of-hooks":Vt,"exhaustive-deps":pt,"require-description":Lt.rule,[$e.name]:$e.rule,[Le.name]:Le.rule,[Ue.name]:Ue.rule,[Re.name]:Re.rule,[Pe.name]:Pe.rule,[Fe.name]:Fe.rule,[Ye.name]:Ye.rule,[je.name]:je.rule,[Ne.name]:Ne.rule,[ve.name]:ve.rule,[Ve.name]:Ve.rule,[Ce.name]:Ce.rule};var br={rules:qt};0&&(module.exports={extendedLintPlugin});
13
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=a.acquire(T),k=new Set,_=null;{let u=R.upper;for(;u&&(k.add(u),u.type!=="function");)u=u.upper;if(!u)return;_=u}let A=Array.isArray;function W(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let S=m.node.init;if(S==null)return!1;for(;S.type==="TSAsExpression";)S=S.expression;let E=m.node.parent;if(E==null&&(_e(_.block,m.node.id),E=m.node.parent,E==null))return!1;if(E.kind==="const"&&S.type==="Literal"&&(typeof S.value=="string"||typeof S.value=="number"||S.value===null))return!0;if(S.type!=="CallExpression")return!1;let w=S.callee;if(w.type==="MemberExpression"&&w.object.name==="React"&&w.property!=null&&!w.computed&&(w=w.property),w.type!=="Identifier")return!1;let b=m.node.id,{name:O}=w;if(O==="useRef"&&b.type==="Identifier")return!0;if($n(w)&&b.type==="Identifier"){for(let P of u.references)P!==b&&h.add(P.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(b.type==="ArrayPattern"&&b.elements.length===2&&A(u.identifiers)){if(b.elements[1]===u.identifiers[0]){if(O==="useState"){let P=u.references,q=0;for(let G=0;G<P.length;G++){if(P[G].isWrite()&&q++,q>1)return!1;s.set(P[G].identifier,b.elements[0])}}return!0}else if(b.elements[0]===u.identifiers[0]){if(O==="useState"){let P=u.references;for(let q=0;q<P.length;q++)i.add(P[q].identifier)}return!1}}}else if(O==="useTransition"&&b.type==="ArrayPattern"&&b.elements.length===2&&Array.isArray(u.identifiers)&&b.elements[1]===u.identifiers[0])return!0;return!1}function X(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let S=m.node,E=_.childScopes,w=null,b;for(b=0;b<E.length;b++){let O=E[b],P=O.block;if(S.type==="FunctionDeclaration"&&P===S||S.type==="VariableDeclarator"&&P.parent===S){w=O;break}}if(w==null)return!1;for(b=0;b<w.through.length;b++){let O=w.through[b];if(O.resolved!=null&&k.has(O.resolved.scope)&&!Ze(O.resolved))return!1}return!0}let Ze=x(W,p),en=x(X,g),Qe=new Map;function tn(u){let m=u.from,S=!1;for(;m.block!==T;)m.type==="function"&&(S=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return S}let B=new Map,Ie=new Map;et(R);function et(u){for(let m of u.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let S=_e(T,m.identifier),E=ht(S),w=Q(E,Ie);if(C&&E.type==="Identifier"&&(E.parent.type==="MemberExpression"||E.parent.type==="OptionalMemberExpression")&&!E.parent.computed&&E.parent.property.type==="Identifier"&&E.parent.property.name==="current"&&tn(m)&&Qe.set(w,{reference:m,dependencyNode:E}),E.parent.type==="TSTypeQuery"||E.parent.type==="TSTypeReference")continue;let b=m.resolved.defs[0];if(b!=null&&!(b.node!=null&&b.node.init===T.parent)&&b.type!=="TypeParameter")if(B.has(w))B.get(w).references.push(m);else{let O=m.resolved,P=Ze(O)||en(O);B.set(w,{isStable:P,references:[m]})}}for(let m of u.childScopes)et(m)}Qe.forEach(({reference:u,dependencyNode:m},S)=>{let E=u.resolved.references,w=!1;for(let b=0;b<E.length;b++){let{identifier:O}=E[b],{parent:P}=O;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){w=!0;break}}w||r({node:m.parent.property,message:`The ref value '${S}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${S}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let we=new Set;function nn(u,m){we.has(m)||(we.add(m),r({node:u,message:`Assignments to the '${m}' variable from inside React Hook ${n(v)} 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(v)}.`}))}let me=new Set;if(B.forEach(({isStable:u,references:m},S)=>{u&&me.add(S),m.forEach(E=>{E.writeExpr&&nn(E.writeExpr,S)})}),we.size>0)return;if(!N){let u=null;if(B.forEach(({isStable:m,references:S},E)=>{u||S.forEach(w=>{if(u)return;let b=w.identifier;if(!s.has(b))return;let P=w.from;for(;P.type!=="function";)P=P.upper;P.block===T&&(u=E)})}),u){let{suggestedDependencies:m}=Ne({dependencies:B,declaredDependencies:[],stableDependencies:me,externalDependencies:new Set,isEffect:!0});r({node:v,message:`React Hook ${y} contains a call to '${u}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${y} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(S){return S.insertTextAfter(T,`, [${m.join(", ")}]`)}}]})}return}let pe=[],ue=new Set;N.type!=="ArrayExpression"?r({node:N,message:`React Hook ${n(v)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):N.elements.forEach(u=>{if(u===null)return;if(u.type==="SpreadElement"){r({node:u,message:`React Hook ${n(v)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}h.has(u)&&r({node:u,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(u)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(u)}\``,fix(w){return w.removeRange(u.range)}}]});let m;try{m=Q(u,Ie)}catch(w){if(/Unsupported node type/.test(w.message)){u.type==="Literal"?B.has(u.value)?r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. Did you mean to include ${u.value} in the array instead?`}):r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):r({node:u,message:`React Hook ${n(v)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw w}let S=u;for(;S.type==="MemberExpression"||S.type==="OptionalMemberExpression"||S.type==="ChainExpression";)S=S.object||S.expression.object;let E=!_.through.some(w=>w.identifier===S);pe.push({key:m,node:u}),E||ue.add(m)});let{suggestedDependencies:rn,unnecessaryDependencies:de,missingDependencies:te,duplicateDependencies:tt}=Ne({dependencies:B,declaredDependencies:pe,stableDependencies:me,externalDependencies:ue,isEffect:C}),ye=rn;if(tt.size+te.size+de.size===0){if(t)return;Pn({declaredDependencies:pe,declaredDependenciesNode:N,componentScope:_,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:S,depType:E})=>{let w=E==="function"?"useCallback":"useMemo",b=E==="function"?"definition":"initialization",O=`wrap the ${b} of '${m.name.name}' in its own ${w}() Hook.`,P=S?`To fix this, ${O}`:`Move it inside the ${y} callback. Alternatively, ${O}`,q=E==="conditional"||E==="logical expression"?"could make":"makes",G=`The '${m.name.name}' ${E} ${q} the dependencies of ${y} Hook (at line ${N.loc.start.line}) change on every render. ${P}`,nt;S&&m.type==="Variable"&&E==="function"&&(nt=[{desc:`Wrap the ${b} of '${m.name.name}' in its own ${w}() Hook.`,fix(rt){let[on,an]=w==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[rt.insertTextBefore(m.node.init,on),rt.insertTextAfter(m.node.init,an)]}}]),r({node:m.node,message:G,suggest:nt})});return}!C&&te.size>0&&(ye=Ne({dependencies:B,declaredDependencies:[],stableDependencies:me,externalDependencies:ue,isEffect:C}).suggestedDependencies);function sn(){if(pe.length===0)return!0;let u=pe.map(S=>S.key),m=u.slice().sort();return u.join(",")===m.join(",")}sn()&&ye.sort();function Ce(u){let m=u.split("."),S="";for(let E=0;E<m.length;E++){if(E!==0){let w=m.slice(0,E+1).join("."),b=Ie.get(w)===!0;S+=b?"?.":"."}S+=m[E]}return S}function Re(u,m,S,E){return u.size===0?null:(u.size>1?"":m+" ")+S+" "+(u.size>1?"dependencies":"dependency")+": "+Dn(Array.from(u).sort().map(w=>"'"+Ce(w)+"'"))+`. Either ${E} ${u.size>1?"them":"it"} or remove the dependency array.`}let K="";if(de.size>0){let u=null;if(Array.from(de.keys()).forEach(m=>{u===null&&m.endsWith(".current")&&(u=m)}),u!==null)K=` Mutable values like '${u}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ue.size>0){let m=Array.from(ue)[0];R.set.has(m)||(K=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!K&&te.has("props")){let u=B.get("props");if(u==null)return;let m=u.references;if(!Array.isArray(m))return;let S=!0;for(let E=0;E<m.length;E++){let w=m[E],b=_e(_.block,w.identifier);if(!b){S=!1;break}let O=b.parent;if(O==null){S=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){S=!1;break}}S&&(K=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${y} call and refer to those specific props inside ${n(v)}.`)}if(!K&&te.size>0){let u=null;te.forEach(m=>{if(u)return;let S=_.set.get(m),E=B.get(m);if(E.references[0].resolved!==S)return;let w=S.defs[0];if(w==null||w.name==null||w.type!=="Parameter")return;let b=!1,O;for(let P=0;P<E.references.length;P++)if(O=E.references[P].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){b=!0;break}b&&(u=m)}),u!==null&&(K=` If '${u}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!K&&te.size>0){let u=null;if(te.forEach(m=>{if(u!==null)return;let E=B.get(m).references,w,b;for(let O=0;O<E.length;O++){for(w=E[O].identifier,b=w.parent;b!=null&&b!==_.block;){if(b.type==="CallExpression"){let P=s.get(b.callee);if(P!=null){if(P.name===m)u={missingDep:m,setter:b.callee.name,form:"updater"};else if(i.has(w))u={missingDep:m,setter:b.callee.name,form:"reducer"};else{let q=E[O].resolved;if(q!=null){let G=q.defs[0];G!=null&&G.type==="Parameter"&&(u={missingDep:m,setter:b.callee.name,form:"inlineReducer"})}}break}}b=b.parent}if(u!==null)break}}),u!==null)switch(u.form){case"reducer":K=` You can also replace multiple useState variables with useReducer if '${u.setter}' needs the current value of '${u.missingDep}'.`;break;case"inlineReducer":K=` If '${u.setter}' needs the current value of '${u.missingDep}', you can also switch to useReducer instead of useState and read '${u.missingDep}' in the reducer.`;break;case"updater":K=` You can also do a functional update '${u.setter}(${u.missingDep.slice(0,1)} => ...)' if you only need '${u.missingDep}' in the '${u.setter}' call.`;break;default:throw new Error("Unknown case.")}}r({node:N,message:`React Hook ${n(v)} has `+(Re(te,"a","missing","include")||Re(de,"an","unnecessary","exclude")||Re(tt,"a","duplicate","omit"))+K,suggest:[{desc:`Update the dependencies array to be: [${ye.map(Ce).join(", ")}]`,fix(u){return u.replaceText(N,`[${ye.map(Ce).join(", ")}]`)}}]})}function I(T){let N=Nn(T.callee,c);if(N===-1)return;let v=T.arguments[N],y=T.callee,C=Tt(y).name,R=T.arguments[N+1],k=/Effect($|[^a-z])/g.test(C);if(!v){r({node:y,message:`React Hook ${C} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!R&&!k){(C==="useMemo"||C==="useCallback")&&r({node:y,message:`React Hook ${C} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(v.type){case"FunctionExpression":case"ArrowFunctionExpression":d(v,R,y,C,k);return;case"Identifier":if(!R||R.elements&&R.elements.some(W=>W&&W.type==="Identifier"&&W.name===v.name))return;let _=o(T).set.get(v.name);if(_==null||_.defs==null)return;let A=_.defs[0];if(!A||!A.node||A.type!=="Variable"&&A.type!=="FunctionName")break;switch(A.node.type){case"FunctionDeclaration":d(A.node,R,y,C,k);return;case"VariableDeclarator":let W=A.node.init;if(!W)break;switch(W.type){case"ArrowFunctionExpression":case"FunctionExpression":d(W,R,y,C,k);return}break}break;default:r({node:y,message:`React Hook ${C} received a function whose dependencies are unknown. Pass an inline function instead.`});return}r({node:y,message:`React Hook ${C} has a missing dependency: '${v.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${v.name}]`,fix(_){return _.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let T of e.sourceCode.getAllComments())if(On.test(T.value))return t=!0,{CallExpression:N=>I(N,!0)}}return{CallExpression:T=>I(T)}}};function Ne({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:o,isEffect:l}){let f=c();function c(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,I)=>{let T=r(f,I);T.isUsed=!0,a(f,I,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let I=r(f,d);I.isSatisfiedRecursively=!0}),n.forEach(d=>{let I=r(f,d);I.isSatisfiedRecursively=!0});function r(d,I){let T=I.split("."),N=d;for(let v of T){let y=N.children.get(v);y||(y=c(),N.children.set(v,y)),N=y}return N}function a(d,I,T){let N=I.split("."),v=d;for(let y of N){let C=v.children.get(y);if(!C)return;T(C),v=C}}let s=new Set,i=new Set;p(f,s,i,d=>d);function p(d,I,T,N){d.children.forEach((v,y)=>{let C=N(y);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&T.add(C);return}if(v.isUsed){I.add(C);return}p(v,I,T,R=>C+"."+R)})}let g=[],h=new Set,x=new Set;return t.forEach(({key:d})=>{i.has(d)?g.indexOf(d)===-1?g.push(d):x.add(d):h.add(d)}),s.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:h,duplicateDependencies:x,missingDependencies:s}}function ne(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return ne(e.consequent)!=null||ne(e.alternate)!=null?"conditional":null;case"LogicalExpression":return ne(e.left)!=null||ne(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return ne(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return ne(e.expression);case"TSAsExpression":return ne(e.expression)}return null}function Pn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:o}){let l=e.map(({key:c})=>{let r=n.variables.find(s=>s.name===c);if(r==null)return null;let a=r.defs[0];if(a==null)return null;if(a.type==="Variable"&&a.node.type==="VariableDeclarator"&&a.node.id.type==="Identifier"&&a.node.init!=null){let s=ne(a.node.init);if(s!=null)return[r,s]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[r,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[r,"class"]:null}).filter(Boolean);function f(c){let r=!1;for(let a=0;a<c.references.length;a++){let s=c.references[a];if(s.writeExpr){if(r)return!0;r=!0;continue}let i=s.from;for(;i!==o&&i!=null;)i=i.upper;if(i!==o&&!St(t,s.identifier))return!0}return!1}return l.map(([c,r])=>({construction:c.defs[0],depType:r,isUsedOutsideOfHook:f(c)}))}function ht(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)?ht(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function De(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function Q(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=Q(e.object,t),o=Q(e.property,null),l=`${n}.${o}`;return De(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=Q(e.object,t),o=Q(e.property,null),l=`${n}.${o}`;return De(e,t,l),l}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let o=Q(n.object,t),l=Q(n.property,null),f=`${o}.${l}`;return De(n,t,f),f}else throw new Error(`Unsupported node type: ${e.type}`)}function Tt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Nn(e,t){let n=Tt(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let o;try{o=Q(n,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(o)?0:-1}else return-1}}function _e(e,t){let n=[e],o=null;for(;n.length;){if(o=n.shift(),_n(o,t))return o;if(St(o,t))for(let[l,f]of Object.entries(o))l!=="parent"&&(yt(f)?(f.parent=o,n.push(f)):Array.isArray(f)&&f.forEach(c=>{yt(c)&&(c.parent=o,n.push(c))}))}return null}function Dn(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 yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function _n(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 $n(e){return!1}var re=require("@typescript-eslint/utils");var Y=st(require("typescript")),Ln=re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Et="improved-no-unnecessary-condition",jn=F({}),Fn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Mn=new Set(Fn),$e={name:Et,rule:Ln({name:Et,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[jn]},defaultOptions:[{}],create(e){let t=re.ESLintUtils.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function o(r){return r.type===re.AST_NODE_TYPES.UnaryExpression&&r.operator==="typeof"}function l(r){return r.flags&Y.default.TypeFlags.Any||r.flags&Y.default.TypeFlags.Unknown?null:r.flags&Y.default.TypeFlags.StringLike?["string"]:r.flags&Y.default.TypeFlags.NumberLike?["number"]:r.flags&Y.default.TypeFlags.BigIntLike?["bigint"]:r.flags&Y.default.TypeFlags.BooleanLike?["boolean"]:r.flags&Y.default.TypeFlags.ESSymbolLike?["symbol"]:r.flags&Y.default.TypeFlags.Undefined||r.flags&Y.default.TypeFlags.Void?["undefined"]:r.flags&Y.default.TypeFlags.Null?["object"]:r.getCallSignatures().length>0?["function"]:r.flags&Y.default.TypeFlags.Object?r.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:r.flags&Y.default.TypeFlags.NonPrimitive?["object"]:r.flags&Y.default.TypeFlags.Never?["never"]:null}function f(r){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(r),s=n.getTypeAtLocation(a.expression);if(s.flags&Y.default.TypeFlags.Any||s.flags&Y.default.TypeFlags.Unknown)return null;let i=[];if(s.isUnion()){for(let g of s.types){let h=l(g);if(h)i.push(...h);else return null}return i}let p=l(s);return p?(i.push(...p),i):null}function c(r){if(!(r.operator==="==="||r.operator==="!=="))return;let s=null,i=null;if(o(r.left)?(s=r.left,i=r.right.type===re.AST_NODE_TYPES.Literal&&typeof r.right.value=="string"?r.right.value:null):o(r.right)&&(s=r.right,i=r.left.type===re.AST_NODE_TYPES.Literal&&typeof r.left.value=="string"?r.left.value:null),!s||!i||!Un(i,Mn))return;let p=f(s);if(!p)return;let g=r.operator==="!==",h=p.includes(i);p.length===1?h&&!g?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:ae(s,e),type:i}}):!h&&g?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:ae(s,e),type:Array.from(p)[0]}}):!h&&!g?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:ae(s,e),actualType:he(p),conditionType:i}}):h&&g&&e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:ae(s,e),actualType:he(p),conditionType:i}}):!h&&!g?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:ae(s,e),actualType:he(p),conditionType:i}}):!h&&g&&e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:ae(s,e),type:he(p)}})}return{BinaryExpression:c}}})};function he(e){return Array.from(new Set(e)).join(" | ")||"never"}function ae(e,t){let n=e.argument;return n.type===re.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function Un(e,t){return t.has(e)}var Te=require("@typescript-eslint/utils");var Wn=Te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bt="no-call-with-explicit-generics",Hn=F({functions:V(j())}),Vn=Wn({name:bt,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:[Hn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(o){let{callee:l}=o;l.type===Te.AST_NODE_TYPES.Identifier&&n.has(l.name)&&o.typeArguments&&e.report({node:o,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),Le={name:bt,rule:Vn};var ie=require("@typescript-eslint/utils"),Yn=ie.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xt="no-call-with-inferred-generics",zn=Yn({name:xt,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(o=>[o.name,o]));return{CallExpression(o){let{callee:l}=o;if(l.type!==ie.AST_NODE_TYPES.Identifier)return;let f=n.get(l.name);if(!f)return;let{minGenerics:c=1,allowAny:r,disallowTypes:a=t.disallowTypes}=f;(o.typeArguments?.params.length||0)<(c||0)&&e.report({node:o,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:c||0}}),!(r&&!a)&&o.typeArguments?.params?.some(i=>!r&&i.type===ie.AST_NODE_TYPES.TSAnyKeyword||a&&i.type===ie.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===ie.AST_NODE_TYPES.Identifier&&a.includes(i.typeName.name))&&e.report({node:o,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),je={name:xt,rule:zn};var fe=require("@typescript-eslint/utils"),Bn=fe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="no-commented-out-code",qn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Kn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],Xn=Bn({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 o=n.trimStart();if(n.startsWith("*")||o.startsWith("INFO:")||o.startsWith("TODO:")||o.startsWith("DOCS:")||o.startsWith("FIX:")||o.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let l of qn)if(o.startsWith(l))return{wrongPattern:l};for(let l of Kn)if(typeof l=="string"){if(n.includes(l))return{wrongPattern:l}}else if(l.test(n))return{wrongPattern:`regex(${l.toString()})`};return!1}return{Program(){let o=e.sourceCode.getAllComments();for(let l of o)if(l.type===fe.TSESTree.AST_TOKEN_TYPES.Line||l.type===fe.TSESTree.AST_TOKEN_TYPES.Block){let f=t(l.value);f&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:f.wrongPattern}})}}}}}),Fe={name:It,rule:Xn};var Se=require("@typescript-eslint/utils"),Jn=Se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wt="no-default-export",Gn=Jn({name:wt,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===Se.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Me={name:wt,rule:Gn};var Ct=require("@typescript-eslint/utils"),Zn=Ct.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="no-leaked-text-in-jsx",Qn=[",",";","[","]","(",")"],er=Zn({name:Rt,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let o="";Qn.includes(n)?o=n:n.includes("&&")?o="&&":n.includes("||")?o="||":n.endsWith("? (")&&(o="? ("),o&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:o}})}}}}),Ue={name:Rt,rule:er};var ee=require("@typescript-eslint/utils"),tr=ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kt="no-non-camel-case-functions",nr=/^[a-z][a-zA-Z0-9]*$/;function vt(e){return e.typeName.type===ee.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===ee.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ee.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var rr=tr({name:kt,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!nr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ee.AST_NODE_TYPES.TSTypeReference?vt(n):n.type===ee.AST_NODE_TYPES.TSUnionType&&n.types.some(l=>l.type===ee.AST_NODE_TYPES.TSTypeReference&&vt(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),We={name:kt,rule:rr};var M=require("@typescript-eslint/utils");function le(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:le(e.parent,t,n===1/0?n:n-1)}function*He(e){yield e,e.parent&&(yield*He(e.parent))}var ir=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-optional-root-props",sr=ir({name:At,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(l){return l?l.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||l.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function n(l){let c=e.sourceCode.getDeclaredVariables(l)[0];if(!c||c.references.length!==1)return!1;let r=c.references[0];if(!r)return!1;for(let a of He(r.identifier)){if("returnType"in a||a.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let s=a.parent;if(!s)return!1;if(s.type===M.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&s.parent.type===M.TSESTree.AST_NODE_TYPES.TSTypeReference&&s.parent.typeName.type===M.TSESTree.AST_NODE_TYPES.Identifier&&s.parent.typeName.name==="FC"){let p=le(s.parent.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(p)return!(t(p)||e.sourceCode.getScope(p).references.some(h=>t(h.identifier.parent.parent)))}if(a.type===M.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(s.type===M.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let i=le(s,M.TSESTree.AST_NODE_TYPES.VariableDeclaration);return i&&t(i)||i&&e.sourceCode.getScope(i).references.some(g=>g.identifier.parent.parent?.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)?!1:s.params.some(p=>p===a)}if(s.type===M.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return t(s)||e.sourceCode.getScope(s).upper?.references.some(p=>t(p.identifier.parent.parent))?!1:s.params.some(p=>p===a)}return!1}function o(l){l.key.type!==M.TSESTree.AST_NODE_TYPES.Identifier||!l.optional||e.report({node:l.key,messageId:"optionalNotAllowed",data:{propertyName:l.key.name},suggest:[{messageId:"suggestion",fix:f=>{let c=le(l,M.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!c)return null;let r=e.sourceCode.getText(c);return f.replaceText(c,r.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(l){if(l.typeAnnotation.type===M.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(t(l)||!n(l)))for(let f of l.typeAnnotation.members)f.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSInterfaceDeclaration(l){if(!(t(l)||!n(l)))for(let f of l.body.body)f.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSTypeReference(l){if(l.typeName.type!==M.TSESTree.AST_NODE_TYPES.Identifier||l.typeName.name!=="FC"||!l.typeArguments?.params[0])return;let f=l.typeArguments.params[0];if(f.type!==M.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let c=le(l.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!c||t(c)||e.sourceCode.getScope(c).references.some(i=>i.identifier.parent.parent?.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration))return;let a=c.declarations[0].id.type===M.TSESTree.AST_NODE_TYPES.Identifier?c.declarations[0].id:null,s=e.sourceCode.getScope(c).variables.find(i=>i.name===a?.name)?.references.filter(i=>i.identifier!==a);if(!(s&&s.length>1))for(let i of f.members)i.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&o(i)}}}}),Ve={name:At,rule:sr};var Ot=require("@typescript-eslint/utils"),Ee=st(require("path"));var or=Ot.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="no-relative-imports",ar=F({find:j(),replacement:j()}),lr=F({aliases:V(ar),rootDir:L(j()),allowNotFoundAliases:L(se()),_dev_simulateFileName:L(j())}),cr=or({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:[lr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function o(c){return c.startsWith(".")||c.startsWith("..")}function l(c,r){let a=Ee.default.dirname(r);return Ee.default.resolve(a,c)}function f(c){let r=t.rootDir??process.cwd(),a=Ee.default.relative(r,c);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:s,replacement:i}of t.aliases)if(a.startsWith(i)){let p=a.replace(i,s);return{alias:s,newPath:p}}return null}return{ImportDeclaration(c){let r=c.source.value;if(!o(r))return;let a=l(r,n),s=f(a);!s&&t.allowNotFoundAliases||e.report({node:c,messageId:s?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:s?.alias},fix:s?i=>i.replaceText(c.source,`'${s.newPath}'`):void 0})}}}}),Ye={name:Pt,rule:cr};var $=require("@typescript-eslint/utils");var pr=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Nt(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 Dt(e,...t){for(let n of t)e.set(...n);return e}var ur=F({forceCheckOnFCPropTypesWithName:L(V(j()))}),_t="no-unused-type-props-in-args",ze=null,fr=pr({name:_t,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:[ur],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!ze&&(ze=n.map(r=>new RegExp(r)));function o(r,a,s,i,p=!0){let g=s.name,h=e.sourceCode.getScope(a).references.find(I=>I.identifier.name===g)?.resolved,x=r&&ze?.some(I=>I.test(g));if(!h||!x&&h.references.filter(I=>I.isTypeReference).length>1)return;let d=h?.defs[0]?.node;if(!(p&&d?.parent?.type===$.AST_NODE_TYPES.ExportNamedDeclaration)){if(d?.type===$.AST_NODE_TYPES.TSTypeAliasDeclaration){l(r,a,i,d.typeAnnotation,!0);return}if(d?.type===$.AST_NODE_TYPES.TSInterfaceDeclaration){l(r,a,i,d.body,!0);return}}}function l(r,a,s,i,p){if(i.type===$.AST_NODE_TYPES.TSInterfaceBody){for(let g of i.body)g.type===$.AST_NODE_TYPES.TSPropertySignature&&g.key.type===$.AST_NODE_TYPES.Identifier&&s.set(g.key.name,g);return}if(i.type===$.AST_NODE_TYPES.TSTypeLiteral){Dt(s,...Nt(i));return}if(i.type===$.AST_NODE_TYPES.TSIntersectionType){for(let g of i.types)l(r,a,s,g,!0);return}p||i.type===$.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===$.AST_NODE_TYPES.Identifier&&o(r,a,i.typeName,s)}function f(r,a,s){for(let i of s)if(i.type==="ObjectPattern"&&i.typeAnnotation){let p=new Map;if(l(r,a,p,i.typeAnnotation.typeAnnotation,!1),p.size===0)continue;c(i,p)}else i.type===$.AST_NODE_TYPES.AssignmentPattern&&i.left.type===$.AST_NODE_TYPES.ObjectPattern&&f(r,a,[i.left])}function c(r,a){let s=[];if(r.properties.at(-1)?.type===$.AST_NODE_TYPES.RestElement)return;for(let h of r.properties)h.type===$.AST_NODE_TYPES.Property&&h.key.type===$.AST_NODE_TYPES.Identifier&&s.push(h.key.name);let p=[],g=[];for(let[h,x]of a)s.includes(h)||(g.push(h),p.push({node:x,messageId:"unusedObjectTypeProperty",data:{propertyName:h}}));for(let[h,x]of p.entries())e.report({...x,fix:h===p.length-1?d=>{let I=r.properties.at(-1),T=g.join(", ");return I?I?.type===$.AST_NODE_TYPES.RestElement?null:d.insertTextAfter(I,`, ${T}`):d.insertTextBeforeRange([r.range[0]+1,r.range[1]],`${T}`)}:void 0})}return{VariableDeclaration(r){let a=r.declarations[0];if(!a)return;let s=new Map,i=a.id.type===$.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===$.AST_NODE_TYPES.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===$.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===$.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===$.AST_NODE_TYPES.Identifier)o(!0,r,i.typeName,s,!1);else if(i.type===$.AST_NODE_TYPES.TSTypeLiteral)Dt(s,...Nt(i));else if(i.type===$.AST_NODE_TYPES.TSIntersectionType)for(let p of i.types)p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier?o(!0,r,p.typeName,s,!1):l(!0,r,s,p,!0);if(s.size!==0&&a.init?.type===$.AST_NODE_TYPES.ArrowFunctionExpression){let p=a.init.params[0];if(!p){e.report({node:a.init,messageId:"missingComponentParam"});return}p.type===$.AST_NODE_TYPES.ObjectPattern&&c(p,s)}}},FunctionDeclaration:function(r){f(!1,r,r.params)},ArrowFunctionExpression(r){f(!1,r,r.params)}}}}),Be={name:_t,rule:fr};var ce=require("@typescript-eslint/utils"),mr=ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="prefer-named-functions",$t=new Map,dr=mr({name:Lt,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 o=$t.get(t.ignoreRegex);o?n=o:(n=new RegExp(t.ignoreRegex),$t.set(t.ignoreRegex,n))}return{VariableDeclarator(o){if(o.init&&o.init.type===ce.AST_NODE_TYPES.ArrowFunctionExpression&&o.id.type===ce.AST_NODE_TYPES.Identifier){let l=o.id.name;if(o.id.typeAnnotation||n&&n.test(l)||!t.disallowArrowFnWithImplicitReturns&&o.init.body.type!==ce.AST_NODE_TYPES.BlockStatement)return;let f=o.parent,c=o.init.params,r=o.init.body,a=o.init;e.report({node:o.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:s=>s.replaceText(f,`${a.async?"async ":""}function ${l}(${c.map(i=>e.sourceCode.getText(i)).join(", ")||""}) ${e.sourceCode.getText(r)}`)}]})}}}}}),qe={name:Lt,rule:dr};var U=require("@typescript-eslint/utils");var yr=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="prefer-single-line-if",gr=F({maxLineLength:L(J()),maxNonSimpleConditionLength:L(J())}),hr=yr({name:Ft,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:[gr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(o){if(o.consequent.type!==U.AST_NODE_TYPES.BlockStatement||o.loc.start.line===o.loc.end.line||n.getCommentsInside(o.consequent).length>0||o.alternate||o.consequent.body.length!==1)return;let f=o.consequent.body[0];if(f.type===U.AST_NODE_TYPES.ReturnStatement){if(!Ut(f))return}else if(!(f.type===U.AST_NODE_TYPES.ContinueStatement||f.type===U.AST_NODE_TYPES.BreakStatement))return;if(o.test.type===U.AST_NODE_TYPES.LogicalExpression||o.test.type===U.AST_NODE_TYPES.ConditionalExpression)return;let c;if(t.maxNonSimpleConditionLength){let p=jt(o.test);if(!p&&o.test.type===U.AST_NODE_TYPES.UnaryExpression&&o.test.operator==="!"){let g=o.test.argument;jt(g)&&(p=!0)}if(p&&(c=n.getText(o.test),c.length>t.maxNonSimpleConditionLength))return}c||(c=n.getText(o.test));let r=n.getText(f);if(c.includes(`
14
+ `))return;let a=n.getTokenAfter(o);if(a&&a.type===U.AST_TOKEN_TYPES.Punctuator&&a.value==="}"){let p=n.getTokenAfter(a);if(p&&p.type===U.AST_TOKEN_TYPES.Keyword&&(p.value==="else"||p.value==="catch"))return}let s=Tr(n,o),i=`if (${c}) ${r}`;t.maxLineLength&&i.length+s.length>t.maxLineLength||e.report({node:o,messageId:"noSingleLineCurly",fix:p=>p.replaceText(o,i)})}}}});function jt(e){return e.type===U.AST_NODE_TYPES.CallExpression||e.type===U.AST_NODE_TYPES.BinaryExpression||e.type===U.AST_NODE_TYPES.MemberExpression&&Mt(e)}function Mt(e){return e.object.type===U.AST_NODE_TYPES.MemberExpression?Mt(e.object):e.object.type!==U.AST_NODE_TYPES.Identifier}function Tr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Ut(e){if(!e.argument)return!0;let t=e.argument;return t.type===U.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===U.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===U.AST_NODE_TYPES.Literal||t.type===U.AST_NODE_TYPES.Identifier||t.type===U.AST_NODE_TYPES.TemplateLiteral||t.type===U.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===U.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===U.AST_NODE_TYPES.UnaryExpression?Ut(t):!1}var Ke={name:Ft,rule:hr};var z=require("@typescript-eslint/utils");var Sr=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="react-compiler-migration",Er=F({disallowHooks:L(V(F({name:j(),replacement:j()}))),disallowMethods:L(V(F({name:j(),replacement:L(j()),requireTrueProp:L(j())})))}),br=/eslint +react-compiler\/react-compiler: +\["error/;function xr(e){return e.type===z.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===z.AST_NODE_TYPES.MemberExpression&&e.property.type===z.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Ir=Sr({name:Wt,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[Er]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let o of e.sourceCode.getAllComments())if(br.test(o.value)){n=!0;break}return n?{CallExpression(o){if(t.disallowHooks?.length){let l=null,f=null;if(o.callee.type===z.AST_NODE_TYPES.Identifier?(l=o.callee.name,f=o.callee):o.callee.type===z.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===z.AST_NODE_TYPES.Identifier&&(l=o.callee.property.name,f=o.callee.property),l){let c=t.disallowHooks.find(r=>r.name===l);c&&f&&e.report({node:o,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:c.name,replacement:c.replacement},suggest:[{messageId:"replace",data:{replacement:c.replacement},fix:r=>r.replaceText(f,c.replacement)}]})}}if(t.disallowMethods?.length&&xr(o.callee)){for(let l of o.arguments)if(l.type===z.AST_NODE_TYPES.ObjectExpression){for(let f of l.properties)if(f.type===z.AST_NODE_TYPES.Property&&f.key.type===z.AST_NODE_TYPES.Identifier){let c=f.key.name,r=t.disallowMethods.find(a=>a.name===c);if(r){if(r.requireTrueProp){let a=r.requireTrueProp,s=!1;for(let i of l.properties)if(i.type===z.AST_NODE_TYPES.Property&&i.key.type===z.AST_NODE_TYPES.Identifier&&i.key.name===a&&i.value.type===z.AST_NODE_TYPES.Literal&&i.value.value===!0){s=!0;break}if(!s){e.report({node:f,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:r.name,requireTrueProp:a}});continue}}r.replacement&&e.report({node:f,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:r.name,replacement:r.replacement},suggest:[{messageId:"replace",data:{replacement:r.replacement},fix:a=>a.replaceText(f.key,r.replacement)}]})}}}}}}:{}}}),Xe={name:Wt,rule:Ir};var be=require("@typescript-eslint/utils"),wr=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="require-description",Cr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Rr=/^eslint-disable-(next-)?line$/u,vr=wr({name:Ht,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,o=new Set(t.ignore||[]);return{Program(){for(let l of n.getAllComments()){let f=kr(l);f!=null&&(o.has(f.kind)||f.description||e.report({loc:Or(l.loc),messageId:"missingDescription"}))}}}}}),Vt={name:Ht,rule:vr};function kr(e){let{text:t,description:n}=Ar(e.value);if(!t)return null;let o=Cr.exec(t);if(!o)return null;let l=o[1];if(!l)return null;let f=Rr.test(l);if(e.type===be.TSESTree.AST_TOKEN_TYPES.Line&&!f||f&&e.loc.start.line!==e.loc.end.line)return null;let c=t.slice(o.index+l.length);return{kind:l,value:c.trim(),description:n}}function Ar(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Or(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Bt(e){return/^use[A-Z0-9]/.test(e)}function xe(e){return e.type==="Identifier"?Bt(e.name):e.type==="MemberExpression"&&!e.computed&&xe(e.property)?e.object.type==="Identifier":!1}function qt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Kt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Xt(e){return!!(e.parent&&e.parent.callee&&Kt(e.parent.callee,"forwardRef"))}function Jt(e){return!!(e.parent&&e.parent.callee&&Kt(e.parent.callee,"memo"))}function Je(e){for(;e;){let t=Zt(e);if(t&&(qt(t)||xe(t))||Xt(e)||Jt(e))return!0;e=e.parent}return!1}function Yt(e){return!1}function Ge(e){return!1}var Pr=/eslint +react-compiler\/react-compiler: +\["error/,Gt={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let a of e.sourceCode.getAllComments())if(Pr.test(a.value))return{CallExpression(s){let i=null;s.callee.name==="useMemo"?i="useMemo":s.callee.name==="useCallback"&&(i="useCallback"),i&&e.report({node:s,message:`"${i}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),o=null,l=[],f=[],c=new WeakSet;function r(a){for(let s of a.references){let i=s.identifier.parent;if(i.type==="VariableDeclarator"&&i.init&&i.init.type==="CallExpression"&&i.init.callee&&Yt(i.init.callee))for(let p of s.resolved.references)p!==s&&c.add(p.identifier)}}return{onCodePathSegmentStart:a=>f.push(a),onCodePathSegmentEnd:()=>f.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(a,s){let i=l.pop();if(i.size===0)return;let p=new Set;function g(y,C){let{cache:R}=g,k=R.get(y.id),_=new Set(C);if(_.has(y.id)){let A=[..._],W=A.slice(A.indexOf(y.id)+1);for(let X of W)p.add(X);return BigInt("0")}if(_.add(y.id),k!==void 0)return k;if(a.thrownSegments.includes(y))k=BigInt("0");else if(y.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of y.prevSegments)k+=g(A,_)}return y.reachable&&k===BigInt("0")?R.delete(y.id):R.set(y.id,k),k}function h(y,C){let{cache:R}=h,k=R.get(y.id),_=new Set(C);if(_.has(y.id)){let A=Array.from(_),W=A.slice(A.indexOf(y.id)+1);for(let X of W)p.add(X);return BigInt("0")}if(_.add(y.id),k!==void 0)return k;if(a.thrownSegments.includes(y))k=BigInt("0");else if(y.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of y.nextSegments)k+=h(A,_)}return R.set(y.id,k),k}function x(y){let{cache:C}=x,R=C.get(y.id);if(R===null)return 1/0;if(R!==void 0)return R;if(C.set(y.id,null),y.prevSegments.length===0)R=1;else{R=1/0;for(let k of y.prevSegments){let _=x(k);_<R&&(R=_)}R+=1}return C.set(y.id,R),R}g.cache=new Map,h.cache=new Map,x.cache=new Map;let d=h(a.initialSegment),I=Zt(s),T=Je(s),N=I?qt(I)||xe(I):Xt(s)||Jt(s),v=1/0;for(let y of a.finalSegments){if(!y.reachable)continue;let C=x(y);C<v&&(v=C)}for(let[y,C]of i){if(!y.reachable)continue;let R=y.nextSegments.length===0?v<=x(y):v<x(y),k=g(y)*h(y),_=p.has(y.id);for(let A of C)if(_&&!Ge(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.`}),N){if(s.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!_&&k!==d&&!Ge(A)){let X=`React Hook "${t(A)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:A,message:X})}}else if(s.parent&&(s.parent.type==="MethodDefinition"||s.parent.type==="ClassProperty")&&s.parent.value===s){let W=`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:W})}else if(I){let W=`React Hook "${t(A)}" is called in function "${t(I)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:A,message:W})}else if(s.type==="Program"){let W=`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:W})}else if(T&&!Ge(A)){if(s.parent.type==="CallExpression"&&s.parent.callee.type==="Identifier"&&s.parent.callee.name==="useCallback"){let X=s.parent;if(X.parent.type==="VariableDeclarator"&&Bt(X.parent.id.name))return}let W=`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:W})}}},CallExpression(a){if(xe(a.callee)){let s=zt(l),i=zt(f),p=s.get(i);p||(p=[],s.set(i,p)),p.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Yt(a.callee))&&a.arguments.length>0&&(o=a)},Identifier(a){o==null&&c.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===o&&(o=null)},FunctionDeclaration(a){Je(a)&&r(n(a))},ArrowFunctionExpression(a){Je(a)&&r(n(a))}}}};function Zt(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 zt(e){return e[e.length-1]}var Qt={[Be.name]:Be.rule,[Fe.name]:Fe.rule,[je.name]:je.rule,"rules-of-hooks":Gt,"exhaustive-deps":gt,"require-description":Vt.rule,[Me.name]:Me.rule,[We.name]:We.rule,[qe.name]:qe.rule,[Oe.name]:Oe.rule,[Le.name]:Le.rule,[Ye.name]:Ye.rule,[Ke.name]:Ke.rule,[Ve.name]:Ve.rule,[Ue.name]:Ue.rule,[Pe.name]:Pe.rule,[Xe.name]:Xe.rule,[Ae.name]:Ae.rule,[$e.name]:$e.rule};var Nr={rules:Qt};0&&(module.exports={extendedLintPlugin});
@@ -1,5 +1,5 @@
1
- import{AST_NODE_TYPES as U,ESLintUtils as Xt}from"@typescript-eslint/utils";var ye=Symbol.for("optional");function $(e){return{...e,[ye]:!0}}function Xe(e,t){return{enum:e,...t}}function te(e){return{...e,type:"boolean"}}function L(e){return{...e,type:"string"}}function X(e){return{...e,type:"number"}}function Je(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 r,l=[];for(r in e)e[r][ye]?e[r][ye]=void 0:l.push(r);l.length>0&&(n.required=l)}return n}function ge(...e){return{anyOf:e}}var Jt=Xt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ze="react-compiler-extra",Gt=j({runOnlyWithEnableCompilerDirective:$(te())}),Zt=/eslint +react-compiler\/react-compiler: +\["error/;function Qt(e){return e.type===U.Identifier?e.name.startsWith("use"):e.type===U.MemberExpression&&e.property.type===U.Identifier?e.property.name.startsWith("use"):!1}var en=/\bthis[.[]/;function Ge(e){return en.test(e)}var tn=Jt({name:Ze,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[Gt]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let u of e.sourceCode.getAllComments())if(Zt.test(u.value)){n=!0;break}if(!n)return{}}function r(u){for(let c of u.properties)if(c.type===U.Property&&c.method&&c.value.type===U.FunctionExpression){let a=e.sourceCode,s=a.getText(c.key),o=c.value,i=a.getText(o.body);if(Ge(i))e.report({node:c,messageId:"thisKeywordInMethod"});else{let f=o.params.map(I=>a.getText(I)).join(", "),T="";o.generator?T=`${s}: function* (${f}) ${i}`:T=`${s}: (${f}) => ${i}`,e.report({node:c,messageId:"objectMethodIsNotSupported",fix:I=>I.replaceText(c,T)})}}}function l(u){for(let c of u.properties)if(c.type===U.Property&&c.value.type===U.ObjectExpression){for(let a of c.value.properties)if(a.type===U.Property&&a.method&&a.value.type===U.FunctionExpression){let o=e.sourceCode.getText(a.value.body);Ge(o)&&e.report({node:a,messageId:"thisKeywordInMethod"})}}}return{CallExpression(u){if(Qt(u.callee))for(let c of u.arguments){if(c.type===U.ObjectExpression&&(r(c),l(c)),c.type===U.ArrowFunctionExpression&&(c.body.type===U.ObjectExpression&&(r(c.body),l(c.body)),c.body.type===U.BlockStatement))for(let a of c.body.body)a.type===U.ReturnStatement&&a.argument?.type===U.ObjectExpression&&(r(a.argument),l(a.argument));if(c.type===U.FunctionExpression)for(let a of c.body.body)a.type===U.ReturnStatement&&a.argument?.type===U.ObjectExpression&&(r(a.argument),l(a.argument))}}}}}),he={name:Ze,rule:tn};import{AST_NODE_TYPES as Se,ESLintUtils as nn}from"@typescript-eslint/utils";var rn=nn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn=j({disallow:$(Y(j({selector:L(),message:L(),replace:$(ge(L(),j({regex:L(),with:L()}))),replaceType:$(Xe(["suggestion","autofix"]))}))),__dev_simulateFileName:$(L()),mustMatchSyntax:$(Y(j({includeRegex:L(),mustCallFn:Y(j({anyCall:Y(j({fn:L(),withArgs:Y(j({atIndex:Je(),literal:ge(L(),X(),te())}))})),message:$(L())}))})))}),tt="advanced-no-restricted-syntax",on=rn({name:tt,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[sn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:l,disallow:u}=t,c=l??e.filename,a=[],s=new Set;for(let{includeRegex:i,mustCallFn:f}of r??[]){let T=an(c,new RegExp(i));if(!T)continue;let I=b=>{let d=b;for(let{name:x,value:g}of T)d=d.replaceAll(x,g);return d};for(let{anyCall:b,message:d}of f){let x=`Expected file to call the function: ${b.map(({fn:g})=>g).join(" or ")}`;s.add(x),a.push(g=>{let{callee:D}=g;if(D.type===Se.Identifier){for(let{fn:v,withArgs:y}of b)if(D.name===v){s.delete(x);for(let C of y){let R=g.arguments[C.atIndex],k=typeof C.literal=="string"?I(C.literal):C.literal;if(!R){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${C.atIndex}${d?`: ${I(d)}`:""}`}});continue}if(R.type!==Se.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${C.atIndex} should the literal "${k}"${d?`: ${I(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${I(d)}`:""}`},fix:_=>_.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:i,message:f,replace:T,replaceType:I="suggestion"}of u??[]){if(i==="CallExpression"){a.push(b=>{o(T,b,f,I)});continue}n[i]=b=>{o(T,b,f,I)}}return a.length>0&&(n.CallExpression=i=>{if(i.type===Se.CallExpression)for(let f of a)f(i)}),n["Program:exit"]=i=>{for(let f of s)e.report({node:i,messageId:"default",data:{message:`${f}`}})},n;function o(i,f,T,I){let b=d=>{if(!i)return null;if(typeof i=="string")return d.replaceText(f,i);{let x=new RegExp(i.regex),g=e.sourceCode.getText(f);return d.replaceText(f,g.replace(x,i.with))}};e.report({node:f,messageId:"default",data:{message:T},fix:i&&I==="autofix"?b:void 0,suggest:i&&I==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:b}]:void 0})}}});function an(e,t){let n=[],r=t.exec(e);if(!r)return null;let[l,...u]=r;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:Qe(l)}),n.push({name:"$0_uncapitalize",value:et(l)}),n.push({name:"$0",value:l});for(let c=0;c<u.length;c++){let a=`$${c+1}`,s=u[c];n.push({name:`${a}_lowercase`,value:s.toLowerCase()}),n.push({name:`${a}_capitalize`,value:Qe(s)}),n.push({name:`${a}_uncapitalize`,value:et(s)}),n.push({name:a,value:s})}return n}function Qe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function et(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Te={name:tt,rule:on};import{AST_NODE_TYPES as M,AST_TOKEN_TYPES as Ee,ESLintUtils as ln}from"@typescript-eslint/utils";var cn=ln.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rt="collapse-simple-objs-in-one-line",pn=j({maxLineLength:$(X()),maxProperties:$(X()),nestedObjMaxLineLength:$(X()),nestedObjMaxProperties:$(X()),ignoreTypesWithSuffix:$(Y(L()))}),un=cn({name:rt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[pn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,u=t.nestedObjMaxLineLength??t.maxLineLength,c=t.nestedObjMaxProperties??3;function a(o){if(o.type===M.ObjectExpression){let i=o.parent.type===M.Property,f=i?c:l,T=o.properties.length;if(T>f)return!1;if(T===1){let b=o.properties[0];return b.type===M.Property&&(b.value.type===M.ObjectExpression||b.value.type===M.ArrayExpression)?!1:{text:n.getText(b),isNested:i,propsSize:T}}let I=[];for(let b of o.properties){if(b.type===M.Property){let d=b.value.type;if(!(d===M.Literal||d===M.Identifier||d===M.TemplateLiteral||d===M.TaggedTemplateExpression))return!1}I.push(n.getText(b))}return{text:I.join(", "),isNested:i,propsSize:T}}else{let i=o.parent.parent?.type===M.TSPropertySignature,f=i?c:l,T=o.members.length;if(T>f)return!1;if(r.length>0&&o.parent.type===M.TSTypeAliasDeclaration){let b=o.parent.id.name;if(r.some(d=>b.endsWith(d)))return!1}if(T===1){let b=o.members[0];return b.type===M.TSPropertySignature&&b.typeAnnotation?.typeAnnotation.type===M.TSTypeLiteral?!1:{text:n.getText(b),isNested:i,propsSize:1}}if(o.parent.type===M.TSIntersectionType||o.parent.type===M.TSUnionType)return!1;let I=[];for(let b of o.members){if(b.type!==M.TSPropertySignature)return!1;let d=b.typeAnnotation?.typeAnnotation;if(!d||d.type===M.TSTypeLiteral||!nt(d.type))return!1;if(d.type===M.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let g=d.typeArguments.params[0];if(!nt(g.type))return!1}let x=n.getText(b).trim();(x.endsWith(";")||x.endsWith(","))&&(x=x.slice(0,-1)),I.push(x)}return{text:I.join("; "),isNested:i,propsSize:T}}}function s(o){if(o.loc.start.line===o.loc.end.line||o.parent.type!==M.JSXExpressionContainer&&n.getTokenAfter(o,{filter:x=>{let g=x.type===Ee.Punctuator&&x.value===",",D=x.type===Ee.Punctuator&&x.value===";";return!g&&!D}})?.loc.start.line===o.loc.end.line)return;let i=a(o);if(!i)return;let f=i.text;if(f.includes(`
2
- `)||n.getCommentsInside(o).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let T=`{ ${f} }`,I=mn(n,o),b=i.isNested&&i.propsSize>2?u:t.maxLineLength;b&&T.length+I.length+(fn(o,n)?1:0)>b||e.report({node:o,messageId:"singleLineProp",fix:d=>d.replaceText(o,T)})}return{TSTypeLiteral:s,ObjectExpression:s}}});function nt(e){return e===M.TSLiteralType||e===M.TSTypeReference||e===M.TSNumberKeyword||e===M.TSStringKeyword||e===M.TSBooleanKeyword||e===M.TSNullKeyword||e===M.TSUndefinedKeyword}function fn(e,t){let n=t.getTokenAfter(e);return n?.type===Ee.Punctuator&&(n.value===","||n.value===";"||n.value==="}")&&n.loc.start.line===e.loc.end.line}function mn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var be={name:rt,rule:un};var dn=/eslint +react-compiler\/react-compiler: +\["error/,st={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?g=>n(g):g=>e.sourceCode.getText(g),r=typeof e.getScope=="function"?()=>r():g=>e.sourceCode.getScope(g),l=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,c={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:u};function a(g){u&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let s=e.getSourceCode().scopeManager,o=new WeakMap,i=new WeakSet,f=new WeakMap,T=new WeakMap,I=new WeakSet;function b(g,D){return function(v){if(D.has(v))return D.get(v);let y=g(v);return D.set(v,y),y}}function d(g,D,v,y,C){C&&g.async&&a({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ import{AST_NODE_TYPES as H,ESLintUtils as nn}from"@typescript-eslint/utils";var Se=Symbol.for("optional");function _(e){return{...e,[Se]:!0}}function et(e,t){return{enum:e,...t}}function ne(e){return{...e,type:"boolean"}}function L(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function tt(e){return{...e,type:"integer"}}function V(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 o,l=[];for(o in e)e[o][Se]?e[o][Se]=void 0:l.push(o);l.length>0&&(n.required=l)}return n}function Ee(...e){return{anyOf:e}}var rn=nn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rt="react-compiler-extra",sn=j({runOnlyWithEnableCompilerDirective:_(ne())}),on=/eslint +react-compiler\/react-compiler: +\["error/;function an(e){return e.type===H.Identifier?e.name.startsWith("use"):e.type===H.MemberExpression&&e.property.type===H.Identifier?e.property.name.startsWith("use"):!1}var ln=/\bthis[.[]/;function nt(e){return ln.test(e)}var cn=rn({name:rt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[sn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(on.test(f.value)){n=!0;break}if(!n)return{}}function o(f){for(let c of f.properties)if(c.type===H.Property&&c.method&&c.value.type===H.FunctionExpression){let r=e.sourceCode,a=r.getText(c.key),s=c.value,i=r.getText(s.body);if(nt(i))e.report({node:c,messageId:"thisKeywordInMethod"});else{let p=s.params.map(h=>r.getText(h)).join(", "),g="";s.generator?g=`${a}: function* (${p}) ${i}`:g=`${a}: (${p}) => ${i}`,e.report({node:c,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(c,g)})}}}function l(f){for(let c of f.properties)if(c.type===H.Property&&c.value.type===H.ObjectExpression){for(let r of c.value.properties)if(r.type===H.Property&&r.method&&r.value.type===H.FunctionExpression){let s=e.sourceCode.getText(r.value.body);nt(s)&&e.report({node:r,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(an(f.callee))for(let c of f.arguments){if(c.type===H.ObjectExpression&&(o(c),l(c)),c.type===H.ArrowFunctionExpression&&(c.body.type===H.ObjectExpression&&(o(c.body),l(c.body)),c.body.type===H.BlockStatement))for(let r of c.body.body)r.type===H.ReturnStatement&&r.argument?.type===H.ObjectExpression&&(o(r.argument),l(r.argument));if(c.type===H.FunctionExpression)for(let r of c.body.body)r.type===H.ReturnStatement&&r.argument?.type===H.ObjectExpression&&(o(r.argument),l(r.argument))}}}}}),be={name:rt,rule:cn};import{AST_NODE_TYPES as xe,ESLintUtils as pn}from"@typescript-eslint/utils";var un=pn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn=j({disallow:_(V(j({selector:L(),message:L(),replace:_(Ee(L(),j({regex:L(),with:L()}))),replaceType:_(et(["suggestion","autofix"]))}))),__dev_simulateFileName:_(L()),mustMatchSyntax:_(V(j({includeRegex:L(),mustCallFn:V(j({anyCall:V(j({fn:L(),withArgs:V(j({atIndex:tt(),literal:Ee(L(),J(),ne())}))})),message:_(L())}))})))}),ot="advanced-no-restricted-syntax",mn=un({name:ot,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[fn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:o,__dev_simulateFileName:l,disallow:f}=t,c=l??e.filename,r=[],a=new Set;for(let{includeRegex:i,mustCallFn:p}of o??[]){let g=dn(c,new RegExp(i));if(!g)continue;let h=x=>{let d=x;for(let{name:I,value:T}of g)d=d.replaceAll(I,T);return d};for(let{anyCall:x,message:d}of p){let I=`Expected file to call the function: ${x.map(({fn:T})=>T).join(" or ")}`;a.add(I),r.push(T=>{let{callee:N}=T;if(N.type===xe.Identifier){for(let{fn:v,withArgs:y}of x)if(N.name===v){a.delete(I);for(let C of y){let R=T.arguments[C.atIndex],k=typeof C.literal=="string"?h(C.literal):C.literal;if(!R){e.report({node:T,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${C.atIndex}${d?`: ${h(d)}`:""}`}});continue}if(R.type!==xe.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${C.atIndex} should the literal "${k}"${d?`: ${h(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${h(d)}`:""}`},fix:D=>D.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:i,message:p,replace:g,replaceType:h="suggestion"}of f??[]){if(i==="CallExpression"){r.push(x=>{s(g,x,p,h)});continue}n[i]=x=>{s(g,x,p,h)}}return r.length>0&&(n.CallExpression=i=>{if(i.type===xe.CallExpression)for(let p of r)p(i)}),n["Program:exit"]=i=>{for(let p of a)e.report({node:i,messageId:"default",data:{message:`${p}`}})},n;function s(i,p,g,h){let x=d=>{if(!i)return null;if(typeof i=="string")return d.replaceText(p,i);{let I=new RegExp(i.regex),T=e.sourceCode.getText(p);return d.replaceText(p,T.replace(I,i.with))}};e.report({node:p,messageId:"default",data:{message:g},fix:i&&h==="autofix"?x:void 0,suggest:i&&h==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:x}]:void 0})}}});function dn(e,t){let n=[],o=t.exec(e);if(!o)return null;let[l,...f]=o;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:it(l)}),n.push({name:"$0_uncapitalize",value:st(l)}),n.push({name:"$0",value:l});for(let c=0;c<f.length;c++){let r=`$${c+1}`,a=f[c];n.push({name:`${r}_lowercase`,value:a.toLowerCase()}),n.push({name:`${r}_capitalize`,value:it(a)}),n.push({name:`${r}_uncapitalize`,value:st(a)}),n.push({name:r,value:a})}return n}function it(e){return e.charAt(0).toUpperCase()+e.slice(1)}function st(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Ie={name:ot,rule:mn};import{AST_NODE_TYPES as F,AST_TOKEN_TYPES as we,ESLintUtils as yn}from"@typescript-eslint/utils";var gn=yn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lt="collapse-simple-objs-in-one-line",hn=j({maxLineLength:_(J()),maxProperties:_(J()),nestedObjMaxLineLength:_(J()),nestedObjMaxProperties:_(J()),ignoreTypesWithSuffix:_(V(L()))}),Tn=gn({name:lt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[hn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,o=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,c=t.nestedObjMaxProperties??3;function r(s){if(s.type===F.ObjectExpression){let i=s.parent.type===F.Property,p=i?c:l,g=s.properties.length;if(g>p)return!1;if(g===1){let x=s.properties[0];return x.type===F.Property&&(x.value.type===F.ObjectExpression||x.value.type===F.ArrayExpression)?!1:{text:n.getText(x),isNested:i,propsSize:g}}let h=[];for(let x of s.properties){if(x.type===F.Property){let d=x.value.type;if(!(d===F.Literal||d===F.Identifier||d===F.TemplateLiteral||d===F.TaggedTemplateExpression))return!1}h.push(n.getText(x))}return{text:h.join(", "),isNested:i,propsSize:g}}else{let i=s.parent.parent?.type===F.TSPropertySignature,p=i?c:l,g=s.members.length;if(g>p)return!1;if(o.length>0&&s.parent.type===F.TSTypeAliasDeclaration){let x=s.parent.id.name;if(o.some(d=>x.endsWith(d)))return!1}if(g===1){let x=s.members[0];return x.type===F.TSPropertySignature&&x.typeAnnotation?.typeAnnotation.type===F.TSTypeLiteral?!1:{text:n.getText(x),isNested:i,propsSize:1}}if(s.parent.type===F.TSIntersectionType||s.parent.type===F.TSUnionType)return!1;let h=[];for(let x of s.members){if(x.type!==F.TSPropertySignature)return!1;let d=x.typeAnnotation?.typeAnnotation;if(!d||d.type===F.TSTypeLiteral||!at(d.type))return!1;if(d.type===F.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let T=d.typeArguments.params[0];if(!at(T.type))return!1}let I=n.getText(x).trim();(I.endsWith(";")||I.endsWith(","))&&(I=I.slice(0,-1)),h.push(I)}return{text:h.join("; "),isNested:i,propsSize:g}}}function a(s){if(s.loc.start.line===s.loc.end.line||s.parent.type!==F.JSXExpressionContainer&&n.getTokenAfter(s,{filter:I=>{let T=I.type===we.Punctuator&&I.value===",",N=I.type===we.Punctuator&&I.value===";";return!T&&!N}})?.loc.start.line===s.loc.end.line)return;let i=r(s);if(!i)return;let p=i.text;if(p.includes(`
2
+ `)||n.getCommentsInside(s).length>0)return;p.endsWith(";")&&(p=p.slice(0,-1));let g=`{ ${p} }`,h=En(n,s),x=i.isNested&&i.propsSize>2?f:t.maxLineLength;x&&g.length+h.length+(Sn(s,n)?1:0)>x||e.report({node:s,messageId:"singleLineProp",fix:d=>d.replaceText(s,g)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function at(e){return e===F.TSLiteralType||e===F.TSTypeReference||e===F.TSNumberKeyword||e===F.TSStringKeyword||e===F.TSBooleanKeyword||e===F.TSNullKeyword||e===F.TSUndefinedKeyword}function Sn(e,t){let n=t.getTokenAfter(e);return n?.type===we.Punctuator&&(n.value===","||n.value===";"||n.value==="}")&&n.loc.start.line===e.loc.end.line}function En(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ce={name:lt,rule:Tn};var bn=/eslint +react-compiler\/react-compiler: +\["error/,pt={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"?T=>n(T):T=>e.sourceCode.getText(T),o=typeof e.getScope=="function"?()=>o():T=>e.sourceCode.getScope(T),l=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,f=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,c={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:f};function r(T){f&&Array.isArray(T.suggest)&&T.suggest.length>0&&(T.fix=T.suggest[0].fix),e.report(T)}let a=e.getSourceCode().scopeManager,s=new WeakMap,i=new WeakSet,p=new WeakMap,g=new WeakMap,h=new WeakSet;function x(T,N){return function(v){if(N.has(v))return N.get(v);let y=T(v);return N.set(v,y),y}}function d(T,N,v,y,C){C&&T.async&&r({node:T,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
3
3
 
4
4
  useEffect(() => {
5
5
  async function fetchData() {
@@ -10,5 +10,5 @@ useEffect(() => {
10
10
  fetchData();
11
11
  }, [someId]); // Or [] if effect doesn't need props or state
12
12
 
13
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=s.acquire(g),k=new Set,_=null;{let p=R.upper;for(;p&&(k.add(p),p.type!=="function");)p=p.upper;if(!p)return;_=p}let A=Array.isArray;function W(p){if(!A(p.defs))return!1;let m=p.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let h=m.node.init;if(h==null)return!1;for(;h.type==="TSAsExpression";)h=h.expression;let S=m.node.parent;if(S==null&&(we(_.block,m.node.id),S=m.node.parent,S==null))return!1;if(S.kind==="const"&&h.type==="Literal"&&(typeof h.value=="string"||typeof h.value=="number"||h.value===null))return!0;if(h.type!=="CallExpression")return!1;let w=h.callee;if(w.type==="MemberExpression"&&w.object.name==="React"&&w.property!=null&&!w.computed&&(w=w.property),w.type!=="Identifier")return!1;let E=m.node.id,{name:O}=w;if(O==="useRef"&&E.type==="Identifier")return!0;if(Tn(w)&&E.type==="Identifier"){for(let P of p.references)P!==E&&I.add(P.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(E.type==="ArrayPattern"&&E.elements.length===2&&A(p.identifiers)){if(E.elements[1]===p.identifiers[0]){if(O==="useState"){let P=p.references,z=0;for(let J=0;J<P.length;J++){if(P[J].isWrite()&&z++,z>1)return!1;o.set(P[J].identifier,E.elements[0])}}return!0}else if(E.elements[0]===p.identifiers[0]){if(O==="useState"){let P=p.references;for(let z=0;z<P.length;z++)i.add(P[z].identifier)}return!1}}}else if(O==="useTransition"&&E.type==="ArrayPattern"&&E.elements.length===2&&Array.isArray(p.identifiers)&&E.elements[1]===p.identifiers[0])return!0;return!1}function K(p){if(!A(p.defs))return!1;let m=p.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let h=m.node,S=_.childScopes,w=null,E;for(E=0;E<S.length;E++){let O=S[E],P=O.block;if(h.type==="FunctionDeclaration"&&P===h||h.type==="VariableDeclarator"&&P.parent===h){w=O;break}}if(w==null)return!1;for(E=0;E<w.through.length;E++){let O=w.through[E];if(O.resolved!=null&&k.has(O.resolved.scope)&&!Ye(O.resolved))return!1}return!0}let Ye=b(W,f),Ut=b(K,T),Ve=new Map;function Yt(p){let m=p.from,h=!1;for(;m.block!==g;)m.type==="function"&&(h=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return h}let V=new Map,ue=new Map;ze(R);function ze(p){for(let m of p.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let h=we(g,m.identifier),S=ot(h),w=G(S,ue);if(C&&S.type==="Identifier"&&(S.parent.type==="MemberExpression"||S.parent.type==="OptionalMemberExpression")&&!S.parent.computed&&S.parent.property.type==="Identifier"&&S.parent.property.name==="current"&&Yt(m)&&Ve.set(w,{reference:m,dependencyNode:S}),S.parent.type==="TSTypeQuery"||S.parent.type==="TSTypeReference")continue;let E=m.resolved.defs[0];if(E!=null&&!(E.node!=null&&E.node.init===g.parent)&&E.type!=="TypeParameter")if(V.has(w))V.get(w).references.push(m);else{let O=m.resolved,P=Ye(O)||Ut(O);V.set(w,{isStable:P,references:[m]})}}for(let m of p.childScopes)ze(m)}Ve.forEach(({reference:p,dependencyNode:m},h)=>{let S=p.resolved.references,w=!1;for(let E=0;E<S.length;E++){let{identifier:O}=S[E],{parent:P}=O;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){w=!0;break}}w||a({node:m.parent.property,message:`The ref value '${h}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${h}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let fe=new Set;function Vt(p,m){fe.has(m)||(fe.add(m),a({node:p,message:`Assignments to the '${m}' variable from inside React Hook ${n(v)} 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(v)}.`}))}let oe=new Set;if(V.forEach(({isStable:p,references:m},h)=>{p&&oe.add(h),m.forEach(S=>{S.writeExpr&&Vt(S.writeExpr,h)})}),fe.size>0)return;if(!D){let p=null;if(V.forEach(({isStable:m,references:h},S)=>{p||h.forEach(w=>{if(p)return;let E=w.identifier;if(!o.has(E))return;let P=w.from;for(;P.type!=="function";)P=P.upper;P.block===g&&(p=S)})}),p){let{suggestedDependencies:m}=xe({dependencies:V,declaredDependencies:[],stableDependencies:oe,externalDependencies:new Set,isEffect:!0});a({node:v,message:`React Hook ${y} contains a call to '${p}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${y} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(h){return h.insertTextAfter(g,`, [${m.join(", ")}]`)}}]})}return}let ie=[],se=new Set;D.type!=="ArrayExpression"?a({node:D,message:`React Hook ${n(v)} 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.`}):D.elements.forEach(p=>{if(p===null)return;if(p.type==="SpreadElement"){a({node:p,message:`React Hook ${n(v)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}I.has(p)&&a({node:p,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(p)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(p)}\``,fix(w){return w.removeRange(p.range)}}]});let m;try{m=G(p,ue)}catch(w){if(/Unsupported node type/.test(w.message)){p.type==="Literal"?V.has(p.value)?a({node:p,message:`The ${p.raw} literal is not a valid dependency because it never changes. Did you mean to include ${p.value} in the array instead?`}):a({node:p,message:`The ${p.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):a({node:p,message:`React Hook ${n(v)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw w}let h=p;for(;h.type==="MemberExpression"||h.type==="OptionalMemberExpression"||h.type==="ChainExpression";)h=h.object||h.expression.object;let S=!_.through.some(w=>w.identifier===h);ie.push({key:m,node:p}),S||se.add(m)});let{suggestedDependencies:zt,unnecessaryDependencies:ae,missingDependencies:Z,duplicateDependencies:qe}=xe({dependencies:V,declaredDependencies:ie,stableDependencies:oe,externalDependencies:se,isEffect:C}),le=zt;if(qe.size+Z.size+ae.size===0){if(t)return;yn({declaredDependencies:ie,declaredDependenciesNode:D,componentScope:_,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:h,depType:S})=>{let w=S==="function"?"useCallback":"useMemo",E=S==="function"?"definition":"initialization",O=`wrap the ${E} of '${m.name.name}' in its own ${w}() Hook.`,P=h?`To fix this, ${O}`:`Move it inside the ${y} callback. Alternatively, ${O}`,z=S==="conditional"||S==="logical expression"?"could make":"makes",J=`The '${m.name.name}' ${S} ${z} the dependencies of ${y} Hook (at line ${D.loc.start.line}) change on every render. ${P}`,Be;h&&m.type==="Variable"&&S==="function"&&(Be=[{desc:`Wrap the ${E} of '${m.name.name}' in its own ${w}() Hook.`,fix(Ke){let[Bt,Kt]=w==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Ke.insertTextBefore(m.node.init,Bt),Ke.insertTextAfter(m.node.init,Kt)]}}]),a({node:m.node,message:J,suggest:Be})});return}!C&&Z.size>0&&(le=xe({dependencies:V,declaredDependencies:[],stableDependencies:oe,externalDependencies:se,isEffect:C}).suggestedDependencies);function qt(){if(ie.length===0)return!0;let p=ie.map(h=>h.key),m=p.slice().sort();return p.join(",")===m.join(",")}qt()&&le.sort();function me(p){let m=p.split("."),h="";for(let S=0;S<m.length;S++){if(S!==0){let w=m.slice(0,S+1).join("."),E=ue.get(w)===!0;h+=E?"?.":"."}h+=m[S]}return h}function de(p,m,h,S){return p.size===0?null:(p.size>1?"":m+" ")+h+" "+(p.size>1?"dependencies":"dependency")+": "+hn(Array.from(p).sort().map(w=>"'"+me(w)+"'"))+`. Either ${S} ${p.size>1?"them":"it"} or remove the dependency array.`}let B="";if(ae.size>0){let p=null;if(Array.from(ae.keys()).forEach(m=>{p===null&&m.endsWith(".current")&&(p=m)}),p!==null)B=` Mutable values like '${p}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(se.size>0){let m=Array.from(se)[0];R.set.has(m)||(B=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!B&&Z.has("props")){let p=V.get("props");if(p==null)return;let m=p.references;if(!Array.isArray(m))return;let h=!0;for(let S=0;S<m.length;S++){let w=m[S],E=we(_.block,w.identifier);if(!E){h=!1;break}let O=E.parent;if(O==null){h=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){h=!1;break}}h&&(B=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${y} call and refer to those specific props inside ${n(v)}.`)}if(!B&&Z.size>0){let p=null;Z.forEach(m=>{if(p)return;let h=_.set.get(m),S=V.get(m);if(S.references[0].resolved!==h)return;let w=h.defs[0];if(w==null||w.name==null||w.type!=="Parameter")return;let E=!1,O;for(let P=0;P<S.references.length;P++)if(O=S.references[P].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){E=!0;break}E&&(p=m)}),p!==null&&(B=` If '${p}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!B&&Z.size>0){let p=null;if(Z.forEach(m=>{if(p!==null)return;let S=V.get(m).references,w,E;for(let O=0;O<S.length;O++){for(w=S[O].identifier,E=w.parent;E!=null&&E!==_.block;){if(E.type==="CallExpression"){let P=o.get(E.callee);if(P!=null){if(P.name===m)p={missingDep:m,setter:E.callee.name,form:"updater"};else if(i.has(w))p={missingDep:m,setter:E.callee.name,form:"reducer"};else{let z=S[O].resolved;if(z!=null){let J=z.defs[0];J!=null&&J.type==="Parameter"&&(p={missingDep:m,setter:E.callee.name,form:"inlineReducer"})}}break}}E=E.parent}if(p!==null)break}}),p!==null)switch(p.form){case"reducer":B=` You can also replace multiple useState variables with useReducer if '${p.setter}' needs the current value of '${p.missingDep}'.`;break;case"inlineReducer":B=` If '${p.setter}' needs the current value of '${p.missingDep}', you can also switch to useReducer instead of useState and read '${p.missingDep}' in the reducer.`;break;case"updater":B=` You can also do a functional update '${p.setter}(${p.missingDep.slice(0,1)} => ...)' if you only need '${p.missingDep}' in the '${p.setter}' call.`;break;default:throw new Error("Unknown case.")}}a({node:D,message:`React Hook ${n(v)} has `+(de(Z,"a","missing","include")||de(ae,"an","unnecessary","exclude")||de(qe,"a","duplicate","omit"))+B,suggest:[{desc:`Update the dependencies array to be: [${le.map(me).join(", ")}]`,fix(p){return p.replaceText(D,`[${le.map(me).join(", ")}]`)}}]})}function x(g){let D=gn(g.callee,c);if(D===-1)return;let v=g.arguments[D],y=g.callee,C=at(y).name,R=g.arguments[D+1],k=/Effect($|[^a-z])/g.test(C);if(!v){a({node:y,message:`React Hook ${C} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!R&&!k){(C==="useMemo"||C==="useCallback")&&a({node:y,message:`React Hook ${C} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(v.type){case"FunctionExpression":case"ArrowFunctionExpression":d(v,R,y,C,k);return;case"Identifier":if(!R||R.elements&&R.elements.some(W=>W&&W.type==="Identifier"&&W.name===v.name))return;let _=r(g).set.get(v.name);if(_==null||_.defs==null)return;let A=_.defs[0];if(!A||!A.node||A.type!=="Variable"&&A.type!=="FunctionName")break;switch(A.node.type){case"FunctionDeclaration":d(A.node,R,y,C,k);return;case"VariableDeclarator":let W=A.node.init;if(!W)break;switch(W.type){case"ArrowFunctionExpression":case"FunctionExpression":d(W,R,y,C,k);return}break}break;default:a({node:y,message:`React Hook ${C} received a function whose dependencies are unknown. Pass an inline function instead.`});return}a({node:y,message:`React Hook ${C} has a missing dependency: '${v.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${v.name}]`,fix(_){return _.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(dn.test(g.value))return t=!0,{CallExpression:D=>x(D,!0)}}return{CallExpression:g=>x(g)}}};function xe({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:l}){let u=c();function c(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,x)=>{let g=a(u,x);g.isUsed=!0,s(u,x,D=>{D.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let x=a(u,d);x.isSatisfiedRecursively=!0}),n.forEach(d=>{let x=a(u,d);x.isSatisfiedRecursively=!0});function a(d,x){let g=x.split("."),D=d;for(let v of g){let y=D.children.get(v);y||(y=c(),D.children.set(v,y)),D=y}return D}function s(d,x,g){let D=x.split("."),v=d;for(let y of D){let C=v.children.get(y);if(!C)return;g(C),v=C}}let o=new Set,i=new Set;f(u,o,i,d=>d);function f(d,x,g,D){d.children.forEach((v,y)=>{let C=D(y);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&g.add(C);return}if(v.isUsed){x.add(C);return}f(v,x,g,R=>C+"."+R)})}let T=[],I=new Set,b=new Set;return t.forEach(({key:d})=>{i.has(d)?T.indexOf(d)===-1?T.push(d):b.add(d):I.add(d)}),o.forEach(d=>{T.push(d)}),{suggestedDependencies:T,unnecessaryDependencies:I,duplicateDependencies:b,missingDependencies:o}}function ee(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 ee(e.consequent)!=null||ee(e.alternate)!=null?"conditional":null;case"LogicalExpression":return ee(e.left)!=null||ee(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return ee(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return ee(e.expression);case"TSAsExpression":return ee(e.expression)}return null}function yn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let l=e.map(({key:c})=>{let a=n.variables.find(o=>o.name===c);if(a==null)return null;let s=a.defs[0];if(s==null)return null;if(s.type==="Variable"&&s.node.type==="VariableDeclarator"&&s.node.id.type==="Identifier"&&s.node.init!=null){let o=ee(s.node.init);if(o!=null)return[a,o]}return s.type==="FunctionName"&&s.node.type==="FunctionDeclaration"?[a,"function"]:s.type==="ClassName"&&s.node.type==="ClassDeclaration"?[a,"class"]:null}).filter(Boolean);function u(c){let a=!1;for(let s=0;s<c.references.length;s++){let o=c.references[s];if(o.writeExpr){if(a)return!0;a=!0;continue}let i=o.from;for(;i!==r&&i!=null;)i=i.upper;if(i!==r&&!lt(t,o.identifier))return!0}return!1}return l.map(([c,a])=>({construction:c.defs[0],depType:a,isUsedOutsideOfHook:u(c)}))}function ot(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)?ot(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ie(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),r=G(e.property,null),l=`${n}.${r}`;return Ie(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=G(e.object,t),r=G(e.property,null),l=`${n}.${r}`;return Ie(e,t,l),l}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=G(n.object,t),l=G(n.property,null),u=`${r}.${l}`;return Ie(n,t,u),u}else throw new Error(`Unsupported node type: ${e.type}`)}function at(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function gn(e,t){let n=at(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=G(n,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(r)?0:-1}else return-1}}function we(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),Sn(r,t))return r;if(lt(r,t))for(let[l,u]of Object.entries(r))l!=="parent"&&(it(u)?(u.parent=r,n.push(u)):Array.isArray(u)&&u.forEach(c=>{it(c)&&(c.parent=r,n.push(c))}))}return null}function hn(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 it(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Sn(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 lt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Tn(e){return!1}import{AST_NODE_TYPES as En,ESLintUtils as bn}from"@typescript-eslint/utils";var xn=bn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ct="no-call-with-explicit-generics",In=j({functions:Y(L())}),wn=xn({name:ct,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:[In]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:l}=r;l.type===En.Identifier&&n.has(l.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),Ce={name:ct,rule:wn};import{AST_NODE_TYPES as ce,ESLintUtils as Cn}from"@typescript-eslint/utils";var Rn=Cn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pt="no-call-with-inferred-generics",vn=Rn({name:pt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:l}=r;if(l.type!==ce.Identifier)return;let u=n.get(l.name);if(!u)return;let{minGenerics:c=1,allowAny:a,disallowTypes:s=t.disallowTypes}=u;(r.typeArguments?.params.length||0)<(c||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:c||0}}),!(a&&!s)&&r.typeArguments?.params?.some(i=>!a&&i.type===ce.TSAnyKeyword||s&&i.type===ce.TSTypeReference&&i.typeName.type===ce.Identifier&&s.includes(i.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),Re={name:pt,rule:vn};import{ESLintUtils as kn,TSESTree as ut}from"@typescript-eslint/utils";var An=kn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ft="no-commented-out-code",On=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Pn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],Dn=An({name:ft,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let r=n.trimStart();if(n.startsWith("*")||r.startsWith("INFO:")||r.startsWith("TODO:")||r.startsWith("DOCS:")||r.startsWith("FIX:")||r.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let l of On)if(r.startsWith(l))return{wrongPattern:l};for(let l of Pn)if(typeof l=="string"){if(n.includes(l))return{wrongPattern:l}}else if(l.test(n))return{wrongPattern:`regex(${l.toString()})`};return!1}return{Program(){let r=e.sourceCode.getAllComments();for(let l of r)if(l.type===ut.AST_TOKEN_TYPES.Line||l.type===ut.AST_TOKEN_TYPES.Block){let u=t(l.value);u&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:u.wrongPattern}})}}}}}),ve={name:ft,rule:Dn};import{ESLintUtils as _n,TSESTree as $n}from"@typescript-eslint/utils";var Nn=_n.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mt="no-default-export",Ln=Nn({name:mt,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===$n.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ke={name:mt,rule:Ln};import{ESLintUtils as Mn}from"@typescript-eslint/utils";var jn=Mn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dt="no-leaked-text-in-jsx",Fn=[",",";","[","]","(",")"],Wn=jn({name:dt,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;let r="";Fn.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),Ae={name:dt,rule:Wn};import{AST_NODE_TYPES as ne,ESLintUtils as Hn}from"@typescript-eslint/utils";var Un=Hn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gt="no-non-camel-case-functions",Yn=/^[a-z][a-zA-Z0-9]*$/;function yt(e){return e.typeName.type===ne.TSQualifiedName&&e.typeName.left.type===ne.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ne.Identifier&&e.typeName.right.name==="Element"}var Vn=Un({name:gt,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&&!Yn.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ne.TSTypeReference?yt(n):n.type===ne.TSUnionType&&n.types.some(l=>l.type===ne.TSTypeReference&&yt(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Oe={name:gt,rule:Vn};import{ESLintUtils as zn,TSESTree as F}from"@typescript-eslint/utils";function re(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:re(e.parent,t,n===1/0?n:n-1)}function*Pe(e){yield e,e.parent&&(yield*Pe(e.parent))}var qn=zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ht="no-optional-root-props",Bn=qn({name:ht,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(l){return l?l.parent?.type===F.AST_NODE_TYPES.ExportNamedDeclaration||l.parent?.type===F.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function n(l){let c=e.sourceCode.getDeclaredVariables(l)[0];if(!c||c.references.length!==1)return!1;let a=c.references[0];if(!a)return!1;for(let s of Pe(a.identifier)){if("returnType"in s||s.type===F.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let o=s.parent;if(!o)return!1;if(o.type===F.AST_NODE_TYPES.TSTypeParameterInstantiation&&o.parent.type===F.AST_NODE_TYPES.TSTypeReference&&o.parent.typeName.type===F.AST_NODE_TYPES.Identifier&&o.parent.typeName.name==="FC"){let f=re(o.parent.parent,F.AST_NODE_TYPES.VariableDeclaration,4);if(f)return!(t(f)||e.sourceCode.getScope(f).references.some(I=>t(I.identifier.parent.parent)))}if(s.type===F.AST_NODE_TYPES.AssignmentPattern)return!1;if(o.type===F.AST_NODE_TYPES.ArrowFunctionExpression){let i=re(o,F.AST_NODE_TYPES.VariableDeclaration);return i&&t(i)||i&&e.sourceCode.getScope(i).references.some(T=>T.identifier.parent.parent?.parent?.type===F.AST_NODE_TYPES.ExportNamedDeclaration)?!1:o.params.some(f=>f===s)}if(o.type===F.AST_NODE_TYPES.FunctionDeclaration)return t(o)||e.sourceCode.getScope(o).upper?.references.some(f=>t(f.identifier.parent.parent))?!1:o.params.some(f=>f===s)}return!1}function r(l){l.key.type!==F.AST_NODE_TYPES.Identifier||!l.optional||e.report({node:l.key,messageId:"optionalNotAllowed",data:{propertyName:l.key.name},suggest:[{messageId:"suggestion",fix:u=>{let c=re(l,F.AST_NODE_TYPES.TSPropertySignature);if(!c)return null;let a=e.sourceCode.getText(c);return u.replaceText(c,a.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(l){if(l.typeAnnotation.type===F.AST_NODE_TYPES.TSTypeLiteral&&!(t(l)||!n(l)))for(let u of l.typeAnnotation.members)u.type===F.AST_NODE_TYPES.TSPropertySignature&&r(u)},TSInterfaceDeclaration(l){if(!(t(l)||!n(l)))for(let u of l.body.body)u.type===F.AST_NODE_TYPES.TSPropertySignature&&r(u)},TSTypeReference(l){if(l.typeName.type!==F.AST_NODE_TYPES.Identifier||l.typeName.name!=="FC"||!l.typeArguments?.params[0])return;let u=l.typeArguments.params[0];if(u.type!==F.AST_NODE_TYPES.TSTypeLiteral)return;let c=re(l.parent,F.AST_NODE_TYPES.VariableDeclaration,4);if(!c||t(c)||e.sourceCode.getScope(c).references.some(i=>i.identifier.parent.parent?.parent?.type===F.AST_NODE_TYPES.ExportNamedDeclaration))return;let s=c.declarations[0].id.type===F.AST_NODE_TYPES.Identifier?c.declarations[0].id:null,o=e.sourceCode.getScope(c).variables.find(i=>i.name===s?.name)?.references.filter(i=>i.identifier!==s);if(!(o&&o.length>1))for(let i of u.members)i.type===F.AST_NODE_TYPES.TSPropertySignature&&r(i)}}}}),De={name:ht,rule:Bn};import{ESLintUtils as Kn}from"@typescript-eslint/utils";import _e from"node:path";var Xn=Kn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),St="no-relative-imports",Jn=j({find:L(),replacement:L()}),Gn=j({aliases:Y(Jn),rootDir:$(L()),allowNotFoundAliases:$(te()),_dev_simulateFileName:$(L())}),Zn=Xn({name:St,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[Gn]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(c){return c.startsWith(".")||c.startsWith("..")}function l(c,a){let s=_e.dirname(a);return _e.resolve(s,c)}function u(c){let a=t.rootDir??process.cwd(),s=_e.relative(a,c);if(s.startsWith("."))return null;s.startsWith("/")||(s=`/${s}`);for(let{find:o,replacement:i}of t.aliases)if(s.startsWith(i)){let f=s.replace(i,o);return{alias:o,newPath:f}}return null}return{ImportDeclaration(c){let a=c.source.value;if(!r(a))return;let s=l(a,n),o=u(s);!o&&t.allowNotFoundAliases||e.report({node:c,messageId:o?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:o?.alias},fix:o?i=>i.replaceText(c.source,`'${o.newPath}'`):void 0})}}}}),$e={name:St,rule:Zn};import{AST_NODE_TYPES as N,ESLintUtils as Qn}from"@typescript-eslint/utils";var er=Qn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Tt(e){let t=[];for(let n of e.members)n.type===N.TSPropertySignature&&n.key.type===N.Identifier&&t.push([n.key.name,n]);return t}function Et(e,...t){for(let n of t)e.set(...n);return e}var tr=j({forceCheckOnFCPropTypesWithName:$(Y(L()))}),bt="no-unused-type-props-in-args",Ne=null,nr=er({name:bt,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:[tr],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Ne&&(Ne=n.map(a=>new RegExp(a)));function r(a,s,o,i,f=!0){let T=o.name,I=e.sourceCode.getScope(s).references.find(x=>x.identifier.name===T)?.resolved,b=a&&Ne?.some(x=>x.test(T));if(!I||!b&&I.references.filter(x=>x.isTypeReference).length>1)return;let d=I?.defs[0]?.node;if(!(f&&d?.parent?.type===N.ExportNamedDeclaration)){if(d?.type===N.TSTypeAliasDeclaration){l(a,s,i,d.typeAnnotation,!0);return}if(d?.type===N.TSInterfaceDeclaration){l(a,s,i,d.body,!0);return}}}function l(a,s,o,i,f){if(i.type===N.TSInterfaceBody){for(let T of i.body)T.type===N.TSPropertySignature&&T.key.type===N.Identifier&&o.set(T.key.name,T);return}if(i.type===N.TSTypeLiteral){Et(o,...Tt(i));return}if(i.type===N.TSIntersectionType){for(let T of i.types)l(a,s,o,T,!0);return}f||i.type===N.TSTypeReference&&i.typeName.type===N.Identifier&&r(a,s,i.typeName,o)}function u(a,s,o){for(let i of o)if(i.type==="ObjectPattern"&&i.typeAnnotation){let f=new Map;if(l(a,s,f,i.typeAnnotation.typeAnnotation,!1),f.size===0)continue;c(i,f)}else i.type===N.AssignmentPattern&&i.left.type===N.ObjectPattern&&u(a,s,[i.left])}function c(a,s){let o=[];if(a.properties.at(-1)?.type===N.RestElement)return;for(let I of a.properties)I.type===N.Property&&I.key.type===N.Identifier&&o.push(I.key.name);let f=[],T=[];for(let[I,b]of s)o.includes(I)||(T.push(I),f.push({node:b,messageId:"unusedObjectTypeProperty",data:{propertyName:I}}));for(let[I,b]of f.entries())e.report({...b,fix:I===f.length-1?d=>{let x=a.properties.at(-1),g=T.join(", ");return x?x?.type===N.RestElement?null:d.insertTextAfter(x,`, ${g}`):d.insertTextBeforeRange([a.range[0]+1,a.range[1]],`${g}`)}:void 0})}return{VariableDeclaration(a){let s=a.declarations[0];if(!s)return;let o=new Map,i=s.id.type===N.Identifier&&s.id.typeAnnotation?.typeAnnotation.type===N.TSTypeReference&&s.id.typeAnnotation.typeAnnotation.typeName.type===N.Identifier&&s.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&s.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===N.TSTypeReference&&i.typeName.type===N.Identifier)r(!0,a,i.typeName,o,!1);else if(i.type===N.TSTypeLiteral)Et(o,...Tt(i));else if(i.type===N.TSIntersectionType)for(let f of i.types)f.type===N.TSTypeReference&&f.typeName.type===N.Identifier?r(!0,a,f.typeName,o,!1):l(!0,a,o,f,!0);if(o.size!==0&&s.init?.type===N.ArrowFunctionExpression){let f=s.init.params[0];if(!f){e.report({node:s.init,messageId:"missingComponentParam"});return}f.type===N.ObjectPattern&&c(f,o)}}},FunctionDeclaration:function(a){u(!1,a,a.params)},ArrowFunctionExpression(a){u(!1,a,a.params)}}}}),Le={name:bt,rule:nr};import{AST_NODE_TYPES as Me,ESLintUtils as rr}from"@typescript-eslint/utils";var ir=rr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="prefer-named-functions",xt=new Map,sr=ir({name:It,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=xt.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),xt.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===Me.ArrowFunctionExpression&&r.id.type===Me.Identifier){let l=r.id.name;if(r.id.typeAnnotation||n&&n.test(l)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==Me.BlockStatement)return;let u=r.parent,c=r.init.params,a=r.init.body,s=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:o=>o.replaceText(u,`${s.async?"async ":""}function ${l}(${c.map(i=>e.sourceCode.getText(i)).join(", ")||""}) ${e.sourceCode.getText(a)}`)}]})}}}}}),je={name:It,rule:sr};import{AST_NODE_TYPES as H,AST_TOKEN_TYPES as wt,ESLintUtils as or}from"@typescript-eslint/utils";var ar=or.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="prefer-single-line-if",lr=j({maxLineLength:$(X()),maxNonSimpleConditionLength:$(X())}),cr=ar({name:Rt,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:[lr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==H.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let u=r.consequent.body[0];if(u.type===H.ReturnStatement){if(!kt(u))return}else if(!(u.type===H.ContinueStatement||u.type===H.BreakStatement))return;if(r.test.type===H.LogicalExpression||r.test.type===H.ConditionalExpression)return;let c;if(t.maxNonSimpleConditionLength){let f=Ct(r.test);if(!f&&r.test.type===H.UnaryExpression&&r.test.operator==="!"){let T=r.test.argument;Ct(T)&&(f=!0)}if(f&&(c=n.getText(r.test),c.length>t.maxNonSimpleConditionLength))return}c||(c=n.getText(r.test));let a=n.getText(u);if(c.includes(`
14
- `))return;let s=n.getTokenAfter(r);if(s&&s.type===wt.Punctuator&&s.value==="}"){let f=n.getTokenAfter(s);if(f&&f.type===wt.Keyword&&(f.value==="else"||f.value==="catch"))return}let o=pr(n,r),i=`if (${c}) ${a}`;t.maxLineLength&&i.length+o.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:f=>f.replaceText(r,i)})}}}});function Ct(e){return e.type===H.CallExpression||e.type===H.BinaryExpression||e.type===H.MemberExpression&&vt(e)}function vt(e){return e.object.type===H.MemberExpression?vt(e.object):e.object.type!==H.Identifier}function pr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function kt(e){if(!e.argument)return!0;let t=e.argument;return t.type===H.ArrayExpression&&t.elements.length===0||t.type===H.ObjectExpression&&t.properties.length===0||t.type===H.Literal||t.type===H.Identifier||t.type===H.TemplateLiteral||t.type===H.TaggedTemplateExpression?!0:t.type===H.CallExpression?t.arguments.length===0:t.type===H.UnaryExpression?kt(t):!1}var Fe={name:Rt,rule:cr};import{AST_NODE_TYPES as q,ESLintUtils as ur}from"@typescript-eslint/utils";var fr=ur.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="react-compiler-migration",mr=j({disallowHooks:$(Y(j({name:L(),replacement:L()}))),disallowMethods:$(Y(j({name:L(),replacement:$(L()),requireTrueProp:$(L())})))}),dr=/eslint +react-compiler\/react-compiler: +\["error/;function yr(e){return e.type===q.Identifier?e.name.startsWith("use"):e.type===q.MemberExpression&&e.property.type===q.Identifier?e.property.name.startsWith("use"):!1}var gr=fr({name:At,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[mr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(dr.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let l=null,u=null;if(r.callee.type===q.Identifier?(l=r.callee.name,u=r.callee):r.callee.type===q.MemberExpression&&r.callee.property.type===q.Identifier&&(l=r.callee.property.name,u=r.callee.property),l){let c=t.disallowHooks.find(a=>a.name===l);c&&u&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:c.name,replacement:c.replacement},suggest:[{messageId:"replace",data:{replacement:c.replacement},fix:a=>a.replaceText(u,c.replacement)}]})}}if(t.disallowMethods?.length&&yr(r.callee)){for(let l of r.arguments)if(l.type===q.ObjectExpression){for(let u of l.properties)if(u.type===q.Property&&u.key.type===q.Identifier){let c=u.key.name,a=t.disallowMethods.find(s=>s.name===c);if(a){if(a.requireTrueProp){let s=a.requireTrueProp,o=!1;for(let i of l.properties)if(i.type===q.Property&&i.key.type===q.Identifier&&i.key.name===s&&i.value.type===q.Literal&&i.value.value===!0){o=!0;break}if(!o){e.report({node:u,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:a.name,requireTrueProp:s}});continue}}a.replacement&&e.report({node:u,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:a.name,replacement:a.replacement},suggest:[{messageId:"replace",data:{replacement:a.replacement},fix:s=>s.replaceText(u.key,a.replacement)}]})}}}}}}:{}}}),We={name:At,rule:gr};import{ESLintUtils as hr,TSESTree as Sr}from"@typescript-eslint/utils";var Tr=hr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ot="require-description",Er=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,br=/^eslint-disable-(next-)?line$/u,xr=Tr({name:Ot,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let l of n.getAllComments()){let u=Ir(l);u!=null&&(r.has(u.kind)||u.description||e.report({loc:Cr(l.loc),messageId:"missingDescription"}))}}}}}),Pt={name:Ot,rule:xr};function Ir(e){let{text:t,description:n}=wr(e.value);if(!t)return null;let r=Er.exec(t);if(!r)return null;let l=r[1];if(!l)return null;let u=br.test(l);if(e.type===Sr.AST_TOKEN_TYPES.Line&&!u||u&&e.loc.start.line!==e.loc.end.line)return null;let c=t.slice(r.index+l.length);return{kind:l,value:c.trim(),description:n}}function wr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Cr(e){return{start:{line:e.start.line,column:-1},end:e.end}}function $t(e){return/^use[A-Z0-9]/.test(e)}function pe(e){return e.type==="Identifier"?$t(e.name):e.type==="MemberExpression"&&!e.computed&&pe(e.property)?e.object.type==="Identifier":!1}function Nt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Lt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Mt(e){return!!(e.parent&&e.parent.callee&&Lt(e.parent.callee,"forwardRef"))}function jt(e){return!!(e.parent&&e.parent.callee&&Lt(e.parent.callee,"memo"))}function He(e){for(;e;){let t=Wt(e);if(t&&(Nt(t)||pe(t))||Mt(e)||jt(e))return!0;e=e.parent}return!1}function Dt(e){return!1}function Ue(e){return!1}var Rr=/eslint +react-compiler\/react-compiler: +\["error/,Ft={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 s of e.sourceCode.getAllComments())if(Rr.test(s.value))return{CallExpression(o){let i=null;o.callee.name==="useMemo"?i="useMemo":o.callee.name==="useCallback"&&(i="useCallback"),i&&e.report({node:o,message:`"${i}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?s=>t(s):s=>e.sourceCode.getText(s),n=typeof e.getScope=="function"?()=>n():s=>e.sourceCode.getScope(s),r=null,l=[],u=[],c=new WeakSet;function a(s){for(let o of s.references){let i=o.identifier.parent;if(i.type==="VariableDeclarator"&&i.init&&i.init.type==="CallExpression"&&i.init.callee&&Dt(i.init.callee))for(let f of o.resolved.references)f!==o&&c.add(f.identifier)}}return{onCodePathSegmentStart:s=>u.push(s),onCodePathSegmentEnd:()=>u.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(s,o){let i=l.pop();if(i.size===0)return;let f=new Set;function T(y,C){let{cache:R}=T,k=R.get(y.id),_=new Set(C);if(_.has(y.id)){let A=[..._],W=A.slice(A.indexOf(y.id)+1);for(let K of W)f.add(K);return BigInt("0")}if(_.add(y.id),k!==void 0)return k;if(s.thrownSegments.includes(y))k=BigInt("0");else if(y.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of y.prevSegments)k+=T(A,_)}return y.reachable&&k===BigInt("0")?R.delete(y.id):R.set(y.id,k),k}function I(y,C){let{cache:R}=I,k=R.get(y.id),_=new Set(C);if(_.has(y.id)){let A=Array.from(_),W=A.slice(A.indexOf(y.id)+1);for(let K of W)f.add(K);return BigInt("0")}if(_.add(y.id),k!==void 0)return k;if(s.thrownSegments.includes(y))k=BigInt("0");else if(y.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of y.nextSegments)k+=I(A,_)}return R.set(y.id,k),k}function b(y){let{cache:C}=b,R=C.get(y.id);if(R===null)return 1/0;if(R!==void 0)return R;if(C.set(y.id,null),y.prevSegments.length===0)R=1;else{R=1/0;for(let k of y.prevSegments){let _=b(k);_<R&&(R=_)}R+=1}return C.set(y.id,R),R}T.cache=new Map,I.cache=new Map,b.cache=new Map;let d=I(s.initialSegment),x=Wt(o),g=He(o),D=x?Nt(x)||pe(x):Mt(o)||jt(o),v=1/0;for(let y of s.finalSegments){if(!y.reachable)continue;let C=b(y);C<v&&(v=C)}for(let[y,C]of i){if(!y.reachable)continue;let R=y.nextSegments.length===0?v<=b(y):v<b(y),k=T(y)*I(y),_=f.has(y.id);for(let A of C)if(_&&!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.`}),D){if(o.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!_&&k!==d&&!Ue(A)){let K=`React Hook "${t(A)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:A,message:K})}}else if(o.parent&&(o.parent.type==="MethodDefinition"||o.parent.type==="ClassProperty")&&o.parent.value===o){let W=`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:W})}else if(x){let W=`React Hook "${t(A)}" is called in function "${t(x)}" 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:W})}else if(o.type==="Program"){let W=`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:W})}else if(g&&!Ue(A)){if(o.parent.type==="CallExpression"&&o.parent.callee.type==="Identifier"&&o.parent.callee.name==="useCallback"){let K=o.parent;if(K.parent.type==="VariableDeclarator"&&$t(K.parent.id.name))return}let W=`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:W})}}},CallExpression(s){if(pe(s.callee)){let o=_t(l),i=_t(u),f=o.get(i);f||(f=[],o.set(i,f)),f.push(s.callee)}s.callee.type==="Identifier"&&(s.callee.name==="useEffect"||Dt(s.callee))&&s.arguments.length>0&&(r=s)},Identifier(s){r==null&&c.has(s)&&s.parent.type!=="CallExpression"&&e.report({node:s,message:`\`${t(s)}\` 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"(s){s===r&&(r=null)},FunctionDeclaration(s){He(s)&&a(n(s))},ArrowFunctionExpression(s){He(s)&&a(n(s))}}}};function Wt(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function _t(e){return e[e.length-1]}var Ht={[Le.name]:Le.rule,[ve.name]:ve.rule,[Re.name]:Re.rule,"rules-of-hooks":Ft,"exhaustive-deps":st,"require-description":Pt.rule,[ke.name]:ke.rule,[Oe.name]:Oe.rule,[je.name]:je.rule,[Te.name]:Te.rule,[Ce.name]:Ce.rule,[$e.name]:$e.rule,[Fe.name]:Fe.rule,[De.name]:De.rule,[Ae.name]:Ae.rule,[be.name]:be.rule,[We.name]:We.rule,[he.name]:he.rule};var Ui={rules:Ht};export{Ui as extendedLintPlugin};
13
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=a.acquire(T),k=new Set,D=null;{let u=R.upper;for(;u&&(k.add(u),u.type!=="function");)u=u.upper;if(!u)return;D=u}let A=Array.isArray;function U(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let S=m.node.init;if(S==null)return!1;for(;S.type==="TSAsExpression";)S=S.expression;let E=m.node.parent;if(E==null&&(ke(D.block,m.node.id),E=m.node.parent,E==null))return!1;if(E.kind==="const"&&S.type==="Literal"&&(typeof S.value=="string"||typeof S.value=="number"||S.value===null))return!0;if(S.type!=="CallExpression")return!1;let w=S.callee;if(w.type==="MemberExpression"&&w.object.name==="React"&&w.property!=null&&!w.computed&&(w=w.property),w.type!=="Identifier")return!1;let b=m.node.id,{name:O}=w;if(O==="useRef"&&b.type==="Identifier")return!0;if(Rn(w)&&b.type==="Identifier"){for(let P of u.references)P!==b&&h.add(P.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(b.type==="ArrayPattern"&&b.elements.length===2&&A(u.identifiers)){if(b.elements[1]===u.identifiers[0]){if(O==="useState"){let P=u.references,B=0;for(let G=0;G<P.length;G++){if(P[G].isWrite()&&B++,B>1)return!1;s.set(P[G].identifier,b.elements[0])}}return!0}else if(b.elements[0]===u.identifiers[0]){if(O==="useState"){let P=u.references;for(let B=0;B<P.length;B++)i.add(P[B].identifier)}return!1}}}else if(O==="useTransition"&&b.type==="ArrayPattern"&&b.elements.length===2&&Array.isArray(u.identifiers)&&b.elements[1]===u.identifiers[0])return!0;return!1}function X(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let S=m.node,E=D.childScopes,w=null,b;for(b=0;b<E.length;b++){let O=E[b],P=O.block;if(S.type==="FunctionDeclaration"&&P===S||S.type==="VariableDeclarator"&&P.parent===S){w=O;break}}if(w==null)return!1;for(b=0;b<w.through.length;b++){let O=w.through[b];if(O.resolved!=null&&k.has(O.resolved.scope)&&!Ke(O.resolved))return!1}return!0}let Ke=x(U,p),Xt=x(X,g),Xe=new Map;function Jt(u){let m=u.from,S=!1;for(;m.block!==T;)m.type==="function"&&(S=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return S}let z=new Map,ye=new Map;Je(R);function Je(u){for(let m of u.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let S=ke(T,m.identifier),E=ut(S),w=Q(E,ye);if(C&&E.type==="Identifier"&&(E.parent.type==="MemberExpression"||E.parent.type==="OptionalMemberExpression")&&!E.parent.computed&&E.parent.property.type==="Identifier"&&E.parent.property.name==="current"&&Jt(m)&&Xe.set(w,{reference:m,dependencyNode:E}),E.parent.type==="TSTypeQuery"||E.parent.type==="TSTypeReference")continue;let b=m.resolved.defs[0];if(b!=null&&!(b.node!=null&&b.node.init===T.parent)&&b.type!=="TypeParameter")if(z.has(w))z.get(w).references.push(m);else{let O=m.resolved,P=Ke(O)||Xt(O);z.set(w,{isStable:P,references:[m]})}}for(let m of u.childScopes)Je(m)}Xe.forEach(({reference:u,dependencyNode:m},S)=>{let E=u.resolved.references,w=!1;for(let b=0;b<E.length;b++){let{identifier:O}=E[b],{parent:P}=O;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){w=!0;break}}w||r({node:m.parent.property,message:`The ref value '${S}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${S}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ge=new Set;function Gt(u,m){ge.has(m)||(ge.add(m),r({node:u,message:`Assignments to the '${m}' variable from inside React Hook ${n(v)} 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(v)}.`}))}let le=new Set;if(z.forEach(({isStable:u,references:m},S)=>{u&&le.add(S),m.forEach(E=>{E.writeExpr&&Gt(E.writeExpr,S)})}),ge.size>0)return;if(!N){let u=null;if(z.forEach(({isStable:m,references:S},E)=>{u||S.forEach(w=>{if(u)return;let b=w.identifier;if(!s.has(b))return;let P=w.from;for(;P.type!=="function";)P=P.upper;P.block===T&&(u=E)})}),u){let{suggestedDependencies:m}=Re({dependencies:z,declaredDependencies:[],stableDependencies:le,externalDependencies:new Set,isEffect:!0});r({node:v,message:`React Hook ${y} contains a call to '${u}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${y} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(S){return S.insertTextAfter(T,`, [${m.join(", ")}]`)}}]})}return}let oe=[],ae=new Set;N.type!=="ArrayExpression"?r({node:N,message:`React Hook ${n(v)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):N.elements.forEach(u=>{if(u===null)return;if(u.type==="SpreadElement"){r({node:u,message:`React Hook ${n(v)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}h.has(u)&&r({node:u,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(u)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(u)}\``,fix(w){return w.removeRange(u.range)}}]});let m;try{m=Q(u,ye)}catch(w){if(/Unsupported node type/.test(w.message)){u.type==="Literal"?z.has(u.value)?r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. Did you mean to include ${u.value} in the array instead?`}):r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):r({node:u,message:`React Hook ${n(v)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw w}let S=u;for(;S.type==="MemberExpression"||S.type==="OptionalMemberExpression"||S.type==="ChainExpression";)S=S.object||S.expression.object;let E=!D.through.some(w=>w.identifier===S);oe.push({key:m,node:u}),E||ae.add(m)});let{suggestedDependencies:Zt,unnecessaryDependencies:ce,missingDependencies:ee,duplicateDependencies:Ge}=Re({dependencies:z,declaredDependencies:oe,stableDependencies:le,externalDependencies:ae,isEffect:C}),pe=Zt;if(Ge.size+ee.size+ce.size===0){if(t)return;xn({declaredDependencies:oe,declaredDependenciesNode:N,componentScope:D,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:S,depType:E})=>{let w=E==="function"?"useCallback":"useMemo",b=E==="function"?"definition":"initialization",O=`wrap the ${b} of '${m.name.name}' in its own ${w}() Hook.`,P=S?`To fix this, ${O}`:`Move it inside the ${y} callback. Alternatively, ${O}`,B=E==="conditional"||E==="logical expression"?"could make":"makes",G=`The '${m.name.name}' ${E} ${B} the dependencies of ${y} Hook (at line ${N.loc.start.line}) change on every render. ${P}`,Ze;S&&m.type==="Variable"&&E==="function"&&(Ze=[{desc:`Wrap the ${b} of '${m.name.name}' in its own ${w}() Hook.`,fix(Qe){let[en,tn]=w==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Qe.insertTextBefore(m.node.init,en),Qe.insertTextAfter(m.node.init,tn)]}}]),r({node:m.node,message:G,suggest:Ze})});return}!C&&ee.size>0&&(pe=Re({dependencies:z,declaredDependencies:[],stableDependencies:le,externalDependencies:ae,isEffect:C}).suggestedDependencies);function Qt(){if(oe.length===0)return!0;let u=oe.map(S=>S.key),m=u.slice().sort();return u.join(",")===m.join(",")}Qt()&&pe.sort();function he(u){let m=u.split("."),S="";for(let E=0;E<m.length;E++){if(E!==0){let w=m.slice(0,E+1).join("."),b=ye.get(w)===!0;S+=b?"?.":"."}S+=m[E]}return S}function Te(u,m,S,E){return u.size===0?null:(u.size>1?"":m+" ")+S+" "+(u.size>1?"dependencies":"dependency")+": "+wn(Array.from(u).sort().map(w=>"'"+he(w)+"'"))+`. Either ${E} ${u.size>1?"them":"it"} or remove the dependency array.`}let K="";if(ce.size>0){let u=null;if(Array.from(ce.keys()).forEach(m=>{u===null&&m.endsWith(".current")&&(u=m)}),u!==null)K=` Mutable values like '${u}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ae.size>0){let m=Array.from(ae)[0];R.set.has(m)||(K=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!K&&ee.has("props")){let u=z.get("props");if(u==null)return;let m=u.references;if(!Array.isArray(m))return;let S=!0;for(let E=0;E<m.length;E++){let w=m[E],b=ke(D.block,w.identifier);if(!b){S=!1;break}let O=b.parent;if(O==null){S=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){S=!1;break}}S&&(K=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${y} call and refer to those specific props inside ${n(v)}.`)}if(!K&&ee.size>0){let u=null;ee.forEach(m=>{if(u)return;let S=D.set.get(m),E=z.get(m);if(E.references[0].resolved!==S)return;let w=S.defs[0];if(w==null||w.name==null||w.type!=="Parameter")return;let b=!1,O;for(let P=0;P<E.references.length;P++)if(O=E.references[P].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){b=!0;break}b&&(u=m)}),u!==null&&(K=` If '${u}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!K&&ee.size>0){let u=null;if(ee.forEach(m=>{if(u!==null)return;let E=z.get(m).references,w,b;for(let O=0;O<E.length;O++){for(w=E[O].identifier,b=w.parent;b!=null&&b!==D.block;){if(b.type==="CallExpression"){let P=s.get(b.callee);if(P!=null){if(P.name===m)u={missingDep:m,setter:b.callee.name,form:"updater"};else if(i.has(w))u={missingDep:m,setter:b.callee.name,form:"reducer"};else{let B=E[O].resolved;if(B!=null){let G=B.defs[0];G!=null&&G.type==="Parameter"&&(u={missingDep:m,setter:b.callee.name,form:"inlineReducer"})}}break}}b=b.parent}if(u!==null)break}}),u!==null)switch(u.form){case"reducer":K=` You can also replace multiple useState variables with useReducer if '${u.setter}' needs the current value of '${u.missingDep}'.`;break;case"inlineReducer":K=` If '${u.setter}' needs the current value of '${u.missingDep}', you can also switch to useReducer instead of useState and read '${u.missingDep}' in the reducer.`;break;case"updater":K=` You can also do a functional update '${u.setter}(${u.missingDep.slice(0,1)} => ...)' if you only need '${u.missingDep}' in the '${u.setter}' call.`;break;default:throw new Error("Unknown case.")}}r({node:N,message:`React Hook ${n(v)} has `+(Te(ee,"a","missing","include")||Te(ce,"an","unnecessary","exclude")||Te(Ge,"a","duplicate","omit"))+K,suggest:[{desc:`Update the dependencies array to be: [${pe.map(he).join(", ")}]`,fix(u){return u.replaceText(N,`[${pe.map(he).join(", ")}]`)}}]})}function I(T){let N=In(T.callee,c);if(N===-1)return;let v=T.arguments[N],y=T.callee,C=ft(y).name,R=T.arguments[N+1],k=/Effect($|[^a-z])/g.test(C);if(!v){r({node:y,message:`React Hook ${C} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!R&&!k){(C==="useMemo"||C==="useCallback")&&r({node:y,message:`React Hook ${C} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(v.type){case"FunctionExpression":case"ArrowFunctionExpression":d(v,R,y,C,k);return;case"Identifier":if(!R||R.elements&&R.elements.some(U=>U&&U.type==="Identifier"&&U.name===v.name))return;let D=o(T).set.get(v.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":d(A.node,R,y,C,k);return;case"VariableDeclarator":let U=A.node.init;if(!U)break;switch(U.type){case"ArrowFunctionExpression":case"FunctionExpression":d(U,R,y,C,k);return}break}break;default:r({node:y,message:`React Hook ${C} received a function whose dependencies are unknown. Pass an inline function instead.`});return}r({node:y,message:`React Hook ${C} has a missing dependency: '${v.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${v.name}]`,fix(D){return D.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let T of e.sourceCode.getAllComments())if(bn.test(T.value))return t=!0,{CallExpression:N=>I(N,!0)}}return{CallExpression:T=>I(T)}}};function Re({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:o,isEffect:l}){let f=c();function c(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,I)=>{let T=r(f,I);T.isUsed=!0,a(f,I,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let I=r(f,d);I.isSatisfiedRecursively=!0}),n.forEach(d=>{let I=r(f,d);I.isSatisfiedRecursively=!0});function r(d,I){let T=I.split("."),N=d;for(let v of T){let y=N.children.get(v);y||(y=c(),N.children.set(v,y)),N=y}return N}function a(d,I,T){let N=I.split("."),v=d;for(let y of N){let C=v.children.get(y);if(!C)return;T(C),v=C}}let s=new Set,i=new Set;p(f,s,i,d=>d);function p(d,I,T,N){d.children.forEach((v,y)=>{let C=N(y);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&T.add(C);return}if(v.isUsed){I.add(C);return}p(v,I,T,R=>C+"."+R)})}let g=[],h=new Set,x=new Set;return t.forEach(({key:d})=>{i.has(d)?g.indexOf(d)===-1?g.push(d):x.add(d):h.add(d)}),s.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:h,duplicateDependencies:x,missingDependencies:s}}function te(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 te(e.consequent)!=null||te(e.alternate)!=null?"conditional":null;case"LogicalExpression":return te(e.left)!=null||te(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return te(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return te(e.expression);case"TSAsExpression":return te(e.expression)}return null}function xn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:o}){let l=e.map(({key:c})=>{let r=n.variables.find(s=>s.name===c);if(r==null)return null;let a=r.defs[0];if(a==null)return null;if(a.type==="Variable"&&a.node.type==="VariableDeclarator"&&a.node.id.type==="Identifier"&&a.node.init!=null){let s=te(a.node.init);if(s!=null)return[r,s]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[r,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[r,"class"]:null}).filter(Boolean);function f(c){let r=!1;for(let a=0;a<c.references.length;a++){let s=c.references[a];if(s.writeExpr){if(r)return!0;r=!0;continue}let i=s.from;for(;i!==o&&i!=null;)i=i.upper;if(i!==o&&!mt(t,s.identifier))return!0}return!1}return l.map(([c,r])=>({construction:c.defs[0],depType:r,isUsedOutsideOfHook:f(c)}))}function ut(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?ut(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function ve(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function Q(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=Q(e.object,t),o=Q(e.property,null),l=`${n}.${o}`;return ve(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=Q(e.object,t),o=Q(e.property,null),l=`${n}.${o}`;return ve(e,t,l),l}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let o=Q(n.object,t),l=Q(n.property,null),f=`${o}.${l}`;return ve(n,t,f),f}else throw new Error(`Unsupported node type: ${e.type}`)}function ft(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function In(e,t){let n=ft(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 o;try{o=Q(n,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(o)?0:-1}else return-1}}function ke(e,t){let n=[e],o=null;for(;n.length;){if(o=n.shift(),Cn(o,t))return o;if(mt(o,t))for(let[l,f]of Object.entries(o))l!=="parent"&&(ct(f)?(f.parent=o,n.push(f)):Array.isArray(f)&&f.forEach(c=>{ct(c)&&(c.parent=o,n.push(c))}))}return null}function wn(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 ct(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Cn(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 mt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Rn(e){return!1}import{AST_NODE_TYPES as fe,ESLintUtils as yt}from"@typescript-eslint/utils";import Y from"typescript";var vn=yt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dt="improved-no-unnecessary-condition",kn=j({}),An=["string","number","bigint","boolean","symbol","undefined","object","function","never"],On=new Set(An),Ae={name:dt,rule:vn({name:dt,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[kn]},defaultOptions:[{}],create(e){let t=yt.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function o(r){return r.type===fe.UnaryExpression&&r.operator==="typeof"}function l(r){return r.flags&Y.TypeFlags.Any||r.flags&Y.TypeFlags.Unknown?null:r.flags&Y.TypeFlags.StringLike?["string"]:r.flags&Y.TypeFlags.NumberLike?["number"]:r.flags&Y.TypeFlags.BigIntLike?["bigint"]:r.flags&Y.TypeFlags.BooleanLike?["boolean"]:r.flags&Y.TypeFlags.ESSymbolLike?["symbol"]:r.flags&Y.TypeFlags.Undefined||r.flags&Y.TypeFlags.Void?["undefined"]:r.flags&Y.TypeFlags.Null?["object"]:r.getCallSignatures().length>0?["function"]:r.flags&Y.TypeFlags.Object?r.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:r.flags&Y.TypeFlags.NonPrimitive?["object"]:r.flags&Y.TypeFlags.Never?["never"]:null}function f(r){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(r),s=n.getTypeAtLocation(a.expression);if(s.flags&Y.TypeFlags.Any||s.flags&Y.TypeFlags.Unknown)return null;let i=[];if(s.isUnion()){for(let g of s.types){let h=l(g);if(h)i.push(...h);else return null}return i}let p=l(s);return p?(i.push(...p),i):null}function c(r){if(!(r.operator==="==="||r.operator==="!=="))return;let s=null,i=null;if(o(r.left)?(s=r.left,i=r.right.type===fe.Literal&&typeof r.right.value=="string"?r.right.value:null):o(r.right)&&(s=r.right,i=r.left.type===fe.Literal&&typeof r.left.value=="string"?r.left.value:null),!s||!i||!Pn(i,On))return;let p=f(s);if(!p)return;let g=r.operator==="!==",h=p.includes(i);p.length===1?h&&!g?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:re(s,e),type:i}}):!h&&g?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:re(s,e),type:Array.from(p)[0]}}):!h&&!g?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:re(s,e),actualType:ue(p),conditionType:i}}):h&&g&&e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:re(s,e),actualType:ue(p),conditionType:i}}):!h&&!g?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:re(s,e),actualType:ue(p),conditionType:i}}):!h&&g&&e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:re(s,e),type:ue(p)}})}return{BinaryExpression:c}}})};function ue(e){return Array.from(new Set(e)).join(" | ")||"never"}function re(e,t){let n=e.argument;return n.type===fe.Identifier?n.name:t.sourceCode.getText(n)}function Pn(e,t){return t.has(e)}import{AST_NODE_TYPES as Nn,ESLintUtils as Dn}from"@typescript-eslint/utils";var _n=Dn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gt="no-call-with-explicit-generics",$n=j({functions:V(L())}),Ln=_n({name:gt,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:[$n]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(o){let{callee:l}=o;l.type===Nn.Identifier&&n.has(l.name)&&o.typeArguments&&e.report({node:o,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),Oe={name:gt,rule:Ln};import{AST_NODE_TYPES as me,ESLintUtils as jn}from"@typescript-eslint/utils";var Fn=jn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ht="no-call-with-inferred-generics",Mn=Fn({name:ht,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(o=>[o.name,o]));return{CallExpression(o){let{callee:l}=o;if(l.type!==me.Identifier)return;let f=n.get(l.name);if(!f)return;let{minGenerics:c=1,allowAny:r,disallowTypes:a=t.disallowTypes}=f;(o.typeArguments?.params.length||0)<(c||0)&&e.report({node:o,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:c||0}}),!(r&&!a)&&o.typeArguments?.params?.some(i=>!r&&i.type===me.TSAnyKeyword||a&&i.type===me.TSTypeReference&&i.typeName.type===me.Identifier&&a.includes(i.typeName.name))&&e.report({node:o,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),Pe={name:ht,rule:Mn};import{ESLintUtils as Un,TSESTree as Tt}from"@typescript-eslint/utils";var Wn=Un.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),St="no-commented-out-code",Hn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Vn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],Yn=Wn({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 o=n.trimStart();if(n.startsWith("*")||o.startsWith("INFO:")||o.startsWith("TODO:")||o.startsWith("DOCS:")||o.startsWith("FIX:")||o.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let l of Hn)if(o.startsWith(l))return{wrongPattern:l};for(let l of Vn)if(typeof l=="string"){if(n.includes(l))return{wrongPattern:l}}else if(l.test(n))return{wrongPattern:`regex(${l.toString()})`};return!1}return{Program(){let o=e.sourceCode.getAllComments();for(let l of o)if(l.type===Tt.AST_TOKEN_TYPES.Line||l.type===Tt.AST_TOKEN_TYPES.Block){let f=t(l.value);f&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:f.wrongPattern}})}}}}}),Ne={name:St,rule:Yn};import{ESLintUtils as zn,TSESTree as Bn}from"@typescript-eslint/utils";var qn=zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Et="no-default-export",Kn=qn({name:Et,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===Bn.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),De={name:Et,rule:Kn};import{ESLintUtils as Xn}from"@typescript-eslint/utils";var Jn=Xn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bt="no-leaked-text-in-jsx",Gn=[",",";","[","]","(",")"],Zn=Jn({name:bt,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;let o="";Gn.includes(n)?o=n:n.includes("&&")?o="&&":n.includes("||")?o="||":n.endsWith("? (")&&(o="? ("),o&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:o}})}}}}),_e={name:bt,rule:Zn};import{AST_NODE_TYPES as ie,ESLintUtils as Qn}from"@typescript-eslint/utils";var er=Qn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="no-non-camel-case-functions",tr=/^[a-z][a-zA-Z0-9]*$/;function xt(e){return e.typeName.type===ie.TSQualifiedName&&e.typeName.left.type===ie.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ie.Identifier&&e.typeName.right.name==="Element"}var nr=er({name:It,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!tr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ie.TSTypeReference?xt(n):n.type===ie.TSUnionType&&n.types.some(l=>l.type===ie.TSTypeReference&&xt(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),$e={name:It,rule:nr};import{ESLintUtils as rr,TSESTree as M}from"@typescript-eslint/utils";function se(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:se(e.parent,t,n===1/0?n:n-1)}function*Le(e){yield e,e.parent&&(yield*Le(e.parent))}var ir=rr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wt="no-optional-root-props",sr=ir({name:wt,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(l){return l?l.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration||l.parent?.type===M.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function n(l){let c=e.sourceCode.getDeclaredVariables(l)[0];if(!c||c.references.length!==1)return!1;let r=c.references[0];if(!r)return!1;for(let a of Le(r.identifier)){if("returnType"in a||a.type===M.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let s=a.parent;if(!s)return!1;if(s.type===M.AST_NODE_TYPES.TSTypeParameterInstantiation&&s.parent.type===M.AST_NODE_TYPES.TSTypeReference&&s.parent.typeName.type===M.AST_NODE_TYPES.Identifier&&s.parent.typeName.name==="FC"){let p=se(s.parent.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(p)return!(t(p)||e.sourceCode.getScope(p).references.some(h=>t(h.identifier.parent.parent)))}if(a.type===M.AST_NODE_TYPES.AssignmentPattern)return!1;if(s.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let i=se(s,M.AST_NODE_TYPES.VariableDeclaration);return i&&t(i)||i&&e.sourceCode.getScope(i).references.some(g=>g.identifier.parent.parent?.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration)?!1:s.params.some(p=>p===a)}if(s.type===M.AST_NODE_TYPES.FunctionDeclaration)return t(s)||e.sourceCode.getScope(s).upper?.references.some(p=>t(p.identifier.parent.parent))?!1:s.params.some(p=>p===a)}return!1}function o(l){l.key.type!==M.AST_NODE_TYPES.Identifier||!l.optional||e.report({node:l.key,messageId:"optionalNotAllowed",data:{propertyName:l.key.name},suggest:[{messageId:"suggestion",fix:f=>{let c=se(l,M.AST_NODE_TYPES.TSPropertySignature);if(!c)return null;let r=e.sourceCode.getText(c);return f.replaceText(c,r.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(l){if(l.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeLiteral&&!(t(l)||!n(l)))for(let f of l.typeAnnotation.members)f.type===M.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSInterfaceDeclaration(l){if(!(t(l)||!n(l)))for(let f of l.body.body)f.type===M.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSTypeReference(l){if(l.typeName.type!==M.AST_NODE_TYPES.Identifier||l.typeName.name!=="FC"||!l.typeArguments?.params[0])return;let f=l.typeArguments.params[0];if(f.type!==M.AST_NODE_TYPES.TSTypeLiteral)return;let c=se(l.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(!c||t(c)||e.sourceCode.getScope(c).references.some(i=>i.identifier.parent.parent?.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration))return;let a=c.declarations[0].id.type===M.AST_NODE_TYPES.Identifier?c.declarations[0].id:null,s=e.sourceCode.getScope(c).variables.find(i=>i.name===a?.name)?.references.filter(i=>i.identifier!==a);if(!(s&&s.length>1))for(let i of f.members)i.type===M.AST_NODE_TYPES.TSPropertySignature&&o(i)}}}}),je={name:wt,rule:sr};import{ESLintUtils as or}from"@typescript-eslint/utils";import Fe from"node:path";var ar=or.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ct="no-relative-imports",lr=j({find:L(),replacement:L()}),cr=j({aliases:V(lr),rootDir:_(L()),allowNotFoundAliases:_(ne()),_dev_simulateFileName:_(L())}),pr=ar({name:Ct,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:[cr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function o(c){return c.startsWith(".")||c.startsWith("..")}function l(c,r){let a=Fe.dirname(r);return Fe.resolve(a,c)}function f(c){let r=t.rootDir??process.cwd(),a=Fe.relative(r,c);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:s,replacement:i}of t.aliases)if(a.startsWith(i)){let p=a.replace(i,s);return{alias:s,newPath:p}}return null}return{ImportDeclaration(c){let r=c.source.value;if(!o(r))return;let a=l(r,n),s=f(a);!s&&t.allowNotFoundAliases||e.report({node:c,messageId:s?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:s?.alias},fix:s?i=>i.replaceText(c.source,`'${s.newPath}'`):void 0})}}}}),Me={name:Ct,rule:pr};import{AST_NODE_TYPES as $,ESLintUtils as ur}from"@typescript-eslint/utils";var fr=ur.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Rt(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 vt(e,...t){for(let n of t)e.set(...n);return e}var mr=j({forceCheckOnFCPropTypesWithName:_(V(L()))}),kt="no-unused-type-props-in-args",Ue=null,dr=fr({name:kt,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:[mr],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Ue&&(Ue=n.map(r=>new RegExp(r)));function o(r,a,s,i,p=!0){let g=s.name,h=e.sourceCode.getScope(a).references.find(I=>I.identifier.name===g)?.resolved,x=r&&Ue?.some(I=>I.test(g));if(!h||!x&&h.references.filter(I=>I.isTypeReference).length>1)return;let d=h?.defs[0]?.node;if(!(p&&d?.parent?.type===$.ExportNamedDeclaration)){if(d?.type===$.TSTypeAliasDeclaration){l(r,a,i,d.typeAnnotation,!0);return}if(d?.type===$.TSInterfaceDeclaration){l(r,a,i,d.body,!0);return}}}function l(r,a,s,i,p){if(i.type===$.TSInterfaceBody){for(let g of i.body)g.type===$.TSPropertySignature&&g.key.type===$.Identifier&&s.set(g.key.name,g);return}if(i.type===$.TSTypeLiteral){vt(s,...Rt(i));return}if(i.type===$.TSIntersectionType){for(let g of i.types)l(r,a,s,g,!0);return}p||i.type===$.TSTypeReference&&i.typeName.type===$.Identifier&&o(r,a,i.typeName,s)}function f(r,a,s){for(let i of s)if(i.type==="ObjectPattern"&&i.typeAnnotation){let p=new Map;if(l(r,a,p,i.typeAnnotation.typeAnnotation,!1),p.size===0)continue;c(i,p)}else i.type===$.AssignmentPattern&&i.left.type===$.ObjectPattern&&f(r,a,[i.left])}function c(r,a){let s=[];if(r.properties.at(-1)?.type===$.RestElement)return;for(let h of r.properties)h.type===$.Property&&h.key.type===$.Identifier&&s.push(h.key.name);let p=[],g=[];for(let[h,x]of a)s.includes(h)||(g.push(h),p.push({node:x,messageId:"unusedObjectTypeProperty",data:{propertyName:h}}));for(let[h,x]of p.entries())e.report({...x,fix:h===p.length-1?d=>{let I=r.properties.at(-1),T=g.join(", ");return I?I?.type===$.RestElement?null:d.insertTextAfter(I,`, ${T}`):d.insertTextBeforeRange([r.range[0]+1,r.range[1]],`${T}`)}:void 0})}return{VariableDeclaration(r){let a=r.declarations[0];if(!a)return;let s=new Map,i=a.id.type===$.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===$.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===$.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===$.TSTypeReference&&i.typeName.type===$.Identifier)o(!0,r,i.typeName,s,!1);else if(i.type===$.TSTypeLiteral)vt(s,...Rt(i));else if(i.type===$.TSIntersectionType)for(let p of i.types)p.type===$.TSTypeReference&&p.typeName.type===$.Identifier?o(!0,r,p.typeName,s,!1):l(!0,r,s,p,!0);if(s.size!==0&&a.init?.type===$.ArrowFunctionExpression){let p=a.init.params[0];if(!p){e.report({node:a.init,messageId:"missingComponentParam"});return}p.type===$.ObjectPattern&&c(p,s)}}},FunctionDeclaration:function(r){f(!1,r,r.params)},ArrowFunctionExpression(r){f(!1,r,r.params)}}}}),We={name:kt,rule:dr};import{AST_NODE_TYPES as He,ESLintUtils as yr}from"@typescript-eslint/utils";var gr=yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ot="prefer-named-functions",At=new Map,hr=gr({name:Ot,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 o=At.get(t.ignoreRegex);o?n=o:(n=new RegExp(t.ignoreRegex),At.set(t.ignoreRegex,n))}return{VariableDeclarator(o){if(o.init&&o.init.type===He.ArrowFunctionExpression&&o.id.type===He.Identifier){let l=o.id.name;if(o.id.typeAnnotation||n&&n.test(l)||!t.disallowArrowFnWithImplicitReturns&&o.init.body.type!==He.BlockStatement)return;let f=o.parent,c=o.init.params,r=o.init.body,a=o.init;e.report({node:o.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:s=>s.replaceText(f,`${a.async?"async ":""}function ${l}(${c.map(i=>e.sourceCode.getText(i)).join(", ")||""}) ${e.sourceCode.getText(r)}`)}]})}}}}}),Ve={name:Ot,rule:hr};import{AST_NODE_TYPES as W,AST_TOKEN_TYPES as Pt,ESLintUtils as Tr}from"@typescript-eslint/utils";var Sr=Tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dt="prefer-single-line-if",Er=j({maxLineLength:_(J()),maxNonSimpleConditionLength:_(J())}),br=Sr({name:Dt,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:[Er]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(o){if(o.consequent.type!==W.BlockStatement||o.loc.start.line===o.loc.end.line||n.getCommentsInside(o.consequent).length>0||o.alternate||o.consequent.body.length!==1)return;let f=o.consequent.body[0];if(f.type===W.ReturnStatement){if(!$t(f))return}else if(!(f.type===W.ContinueStatement||f.type===W.BreakStatement))return;if(o.test.type===W.LogicalExpression||o.test.type===W.ConditionalExpression)return;let c;if(t.maxNonSimpleConditionLength){let p=Nt(o.test);if(!p&&o.test.type===W.UnaryExpression&&o.test.operator==="!"){let g=o.test.argument;Nt(g)&&(p=!0)}if(p&&(c=n.getText(o.test),c.length>t.maxNonSimpleConditionLength))return}c||(c=n.getText(o.test));let r=n.getText(f);if(c.includes(`
14
+ `))return;let a=n.getTokenAfter(o);if(a&&a.type===Pt.Punctuator&&a.value==="}"){let p=n.getTokenAfter(a);if(p&&p.type===Pt.Keyword&&(p.value==="else"||p.value==="catch"))return}let s=xr(n,o),i=`if (${c}) ${r}`;t.maxLineLength&&i.length+s.length>t.maxLineLength||e.report({node:o,messageId:"noSingleLineCurly",fix:p=>p.replaceText(o,i)})}}}});function Nt(e){return e.type===W.CallExpression||e.type===W.BinaryExpression||e.type===W.MemberExpression&&_t(e)}function _t(e){return e.object.type===W.MemberExpression?_t(e.object):e.object.type!==W.Identifier}function xr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function $t(e){if(!e.argument)return!0;let t=e.argument;return t.type===W.ArrayExpression&&t.elements.length===0||t.type===W.ObjectExpression&&t.properties.length===0||t.type===W.Literal||t.type===W.Identifier||t.type===W.TemplateLiteral||t.type===W.TaggedTemplateExpression?!0:t.type===W.CallExpression?t.arguments.length===0:t.type===W.UnaryExpression?$t(t):!1}var Ye={name:Dt,rule:br};import{AST_NODE_TYPES as q,ESLintUtils as Ir}from"@typescript-eslint/utils";var wr=Ir.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="react-compiler-migration",Cr=j({disallowHooks:_(V(j({name:L(),replacement:L()}))),disallowMethods:_(V(j({name:L(),replacement:_(L()),requireTrueProp:_(L())})))}),Rr=/eslint +react-compiler\/react-compiler: +\["error/;function vr(e){return e.type===q.Identifier?e.name.startsWith("use"):e.type===q.MemberExpression&&e.property.type===q.Identifier?e.property.name.startsWith("use"):!1}var kr=wr({name:Lt,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[Cr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let o of e.sourceCode.getAllComments())if(Rr.test(o.value)){n=!0;break}return n?{CallExpression(o){if(t.disallowHooks?.length){let l=null,f=null;if(o.callee.type===q.Identifier?(l=o.callee.name,f=o.callee):o.callee.type===q.MemberExpression&&o.callee.property.type===q.Identifier&&(l=o.callee.property.name,f=o.callee.property),l){let c=t.disallowHooks.find(r=>r.name===l);c&&f&&e.report({node:o,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:c.name,replacement:c.replacement},suggest:[{messageId:"replace",data:{replacement:c.replacement},fix:r=>r.replaceText(f,c.replacement)}]})}}if(t.disallowMethods?.length&&vr(o.callee)){for(let l of o.arguments)if(l.type===q.ObjectExpression){for(let f of l.properties)if(f.type===q.Property&&f.key.type===q.Identifier){let c=f.key.name,r=t.disallowMethods.find(a=>a.name===c);if(r){if(r.requireTrueProp){let a=r.requireTrueProp,s=!1;for(let i of l.properties)if(i.type===q.Property&&i.key.type===q.Identifier&&i.key.name===a&&i.value.type===q.Literal&&i.value.value===!0){s=!0;break}if(!s){e.report({node:f,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:r.name,requireTrueProp:a}});continue}}r.replacement&&e.report({node:f,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:r.name,replacement:r.replacement},suggest:[{messageId:"replace",data:{replacement:r.replacement},fix:a=>a.replaceText(f.key,r.replacement)}]})}}}}}}:{}}}),ze={name:Lt,rule:kr};import{ESLintUtils as Ar,TSESTree as Or}from"@typescript-eslint/utils";var Pr=Ar.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jt="require-description",Nr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Dr=/^eslint-disable-(next-)?line$/u,_r=Pr({name:jt,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,o=new Set(t.ignore||[]);return{Program(){for(let l of n.getAllComments()){let f=$r(l);f!=null&&(o.has(f.kind)||f.description||e.report({loc:jr(l.loc),messageId:"missingDescription"}))}}}}}),Ft={name:jt,rule:_r};function $r(e){let{text:t,description:n}=Lr(e.value);if(!t)return null;let o=Nr.exec(t);if(!o)return null;let l=o[1];if(!l)return null;let f=Dr.test(l);if(e.type===Or.AST_TOKEN_TYPES.Line&&!f||f&&e.loc.start.line!==e.loc.end.line)return null;let c=t.slice(o.index+l.length);return{kind:l,value:c.trim(),description:n}}function Lr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function jr(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Wt(e){return/^use[A-Z0-9]/.test(e)}function de(e){return e.type==="Identifier"?Wt(e.name):e.type==="MemberExpression"&&!e.computed&&de(e.property)?e.object.type==="Identifier":!1}function Ht(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Vt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Yt(e){return!!(e.parent&&e.parent.callee&&Vt(e.parent.callee,"forwardRef"))}function zt(e){return!!(e.parent&&e.parent.callee&&Vt(e.parent.callee,"memo"))}function Be(e){for(;e;){let t=qt(e);if(t&&(Ht(t)||de(t))||Yt(e)||zt(e))return!0;e=e.parent}return!1}function Mt(e){return!1}function qe(e){return!1}var Fr=/eslint +react-compiler\/react-compiler: +\["error/,Bt={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let a of e.sourceCode.getAllComments())if(Fr.test(a.value))return{CallExpression(s){let i=null;s.callee.name==="useMemo"?i="useMemo":s.callee.name==="useCallback"&&(i="useCallback"),i&&e.report({node:s,message:`"${i}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),o=null,l=[],f=[],c=new WeakSet;function r(a){for(let s of a.references){let i=s.identifier.parent;if(i.type==="VariableDeclarator"&&i.init&&i.init.type==="CallExpression"&&i.init.callee&&Mt(i.init.callee))for(let p of s.resolved.references)p!==s&&c.add(p.identifier)}}return{onCodePathSegmentStart:a=>f.push(a),onCodePathSegmentEnd:()=>f.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(a,s){let i=l.pop();if(i.size===0)return;let p=new Set;function g(y,C){let{cache:R}=g,k=R.get(y.id),D=new Set(C);if(D.has(y.id)){let A=[...D],U=A.slice(A.indexOf(y.id)+1);for(let X of U)p.add(X);return BigInt("0")}if(D.add(y.id),k!==void 0)return k;if(a.thrownSegments.includes(y))k=BigInt("0");else if(y.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of y.prevSegments)k+=g(A,D)}return y.reachable&&k===BigInt("0")?R.delete(y.id):R.set(y.id,k),k}function h(y,C){let{cache:R}=h,k=R.get(y.id),D=new Set(C);if(D.has(y.id)){let A=Array.from(D),U=A.slice(A.indexOf(y.id)+1);for(let X of U)p.add(X);return BigInt("0")}if(D.add(y.id),k!==void 0)return k;if(a.thrownSegments.includes(y))k=BigInt("0");else if(y.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of y.nextSegments)k+=h(A,D)}return R.set(y.id,k),k}function x(y){let{cache:C}=x,R=C.get(y.id);if(R===null)return 1/0;if(R!==void 0)return R;if(C.set(y.id,null),y.prevSegments.length===0)R=1;else{R=1/0;for(let k of y.prevSegments){let D=x(k);D<R&&(R=D)}R+=1}return C.set(y.id,R),R}g.cache=new Map,h.cache=new Map,x.cache=new Map;let d=h(a.initialSegment),I=qt(s),T=Be(s),N=I?Ht(I)||de(I):Yt(s)||zt(s),v=1/0;for(let y of a.finalSegments){if(!y.reachable)continue;let C=x(y);C<v&&(v=C)}for(let[y,C]of i){if(!y.reachable)continue;let R=y.nextSegments.length===0?v<=x(y):v<x(y),k=g(y)*h(y),D=p.has(y.id);for(let A of C)if(D&&!qe(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.`}),N){if(s.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!D&&k!==d&&!qe(A)){let X=`React Hook "${t(A)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:A,message:X})}}else if(s.parent&&(s.parent.type==="MethodDefinition"||s.parent.type==="ClassProperty")&&s.parent.value===s){let U=`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:U})}else if(I){let U=`React Hook "${t(A)}" is called in function "${t(I)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:A,message:U})}else if(s.type==="Program"){let U=`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:U})}else if(T&&!qe(A)){if(s.parent.type==="CallExpression"&&s.parent.callee.type==="Identifier"&&s.parent.callee.name==="useCallback"){let X=s.parent;if(X.parent.type==="VariableDeclarator"&&Wt(X.parent.id.name))return}let U=`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:U})}}},CallExpression(a){if(de(a.callee)){let s=Ut(l),i=Ut(f),p=s.get(i);p||(p=[],s.set(i,p)),p.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Mt(a.callee))&&a.arguments.length>0&&(o=a)},Identifier(a){o==null&&c.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===o&&(o=null)},FunctionDeclaration(a){Be(a)&&r(n(a))},ArrowFunctionExpression(a){Be(a)&&r(n(a))}}}};function qt(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function Ut(e){return e[e.length-1]}var Kt={[We.name]:We.rule,[Ne.name]:Ne.rule,[Pe.name]:Pe.rule,"rules-of-hooks":Bt,"exhaustive-deps":pt,"require-description":Ft.rule,[De.name]:De.rule,[$e.name]:$e.rule,[Ve.name]:Ve.rule,[Ie.name]:Ie.rule,[Oe.name]:Oe.rule,[Me.name]:Me.rule,[Ye.name]:Ye.rule,[je.name]:je.rule,[_e.name]:_e.rule,[Ce.name]:Ce.rule,[ze.name]:ze.rule,[be.name]:be.rule,[Ae.name]:Ae.rule};var os={rules:Kt};export{os as extendedLintPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ls-stack/extended-lint",
3
- "version": "0.33.1",
3
+ "version": "0.34.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -30,9 +30,9 @@
30
30
  "tschema": "^3.2.0",
31
31
  "tsm": "^2.3.0",
32
32
  "tsup": "^8.3.6",
33
- "typescript": "^5.7.3",
34
33
  "vite": "^6.0.11",
35
- "vitest": "^3.0.4"
34
+ "vitest": "^3.0.4",
35
+ "typescript": "^5.7.3"
36
36
  },
37
37
  "dependencies": {
38
38
  "@typescript-eslint/utils": "^8.22.0",
@@ -41,6 +41,7 @@
41
41
  "esutils": "^2.0.3"
42
42
  },
43
43
  "peerDependencies": {
44
+ "typescript": "^5.7.3",
44
45
  "eslint": "^9.9.1"
45
46
  },
46
47
  "scripts": {
@@ -50,7 +51,8 @@
50
51
  "test:ui": "vitest --ui",
51
52
  "build": "pnpm test && pnpm lint && pnpm run build:no-test",
52
53
  "build:no-test": "tsup --minify --dts",
53
- "run-in-test-project": "pnpm build:no-test && node --experimental-strip-types ./debug/runInTestProject.ts",
54
+ "build:no-minify": "tsup --dts",
55
+ "run-in-test-project": "pnpm build:no-minify && node --experimental-strip-types ./debug/runInTestProject.ts",
54
56
  "pre-publish": "./scripts/check-if-is-sync.sh && pnpm build",
55
57
  "npm-publish": "pnpm publish --access=public"
56
58
  }