@ls-stack/extended-lint 0.40.1 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- "use strict";var Rn=Object.create;var he=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var On=Object.getOwnPropertyNames;var kn=Object.getPrototypeOf,An=Object.prototype.hasOwnProperty;var Pn=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},Tt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of On(t))!An.call(e,s)&&s!==n&&he(e,s,{get:()=>t[s],enumerable:!(r=vn(t,s))||r.enumerable});return e};var Ne=(e,t,n)=>(n=e!=null?Rn(kn(e)):{},Tt(t||!e||!e.__esModule?he(n,"default",{value:e,enumerable:!0}):n,e)),Fn=e=>Tt(he({},"__esModule",{value:!0}),e);var li={};Pn(li,{extendedLintPlugin:()=>ai});module.exports=Fn(li);var z=require("@typescript-eslint/utils");var Le=Symbol.for("optional");function F(e){return{...e,[Le]:!0}}function Ee(e,t){return{enum:e,...t}}function le(e){return{...e,type:"boolean"}}function L(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function ht(e){return{...e,type:"integer"}}function Y(e,t){return{...t,type:"array",items:e}}function D(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,s=[];for(r in e)e[r][Le]?e[r][Le]=void 0:s.push(r);s.length>0&&(n.required=s)}return n}function _e(...e){return{anyOf:e}}var Nn=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bt="react-compiler-extra",Ln=D({runOnlyWithEnableCompilerDirective:F(le())}),_n=/eslint +react-compiler\/react-compiler: +\["error/;function Dn(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 jn=/\bthis[.[]/;function Et(e){return jn.test(e)}var $n=Nn({name:bt,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:[Ln]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let l of e.sourceCode.getAllComments())if(_n.test(l.value)){n=!0;break}if(!n)return{}}function r(l){for(let u of l.properties)if(u.type===z.AST_NODE_TYPES.Property&&u.method&&u.value.type===z.AST_NODE_TYPES.FunctionExpression){let i=e.sourceCode,a=i.getText(u.key),c=u.value,o=i.getText(c.body);if(Et(o))e.report({node:u,messageId:"thisKeywordInMethod"});else{let p=c.params.map(y=>i.getText(y)).join(", "),g="";c.generator?g=`${a}: function* (${p}) ${o}`:g=`${a}: (${p}) => ${o}`,e.report({node:u,messageId:"objectMethodIsNotSupported",fix:y=>y.replaceText(u,g)})}}}function s(l){for(let u of l.properties)if(u.type===z.AST_NODE_TYPES.Property&&u.value.type===z.AST_NODE_TYPES.ObjectExpression){for(let i of u.value.properties)if(i.type===z.AST_NODE_TYPES.Property&&i.method&&i.value.type===z.AST_NODE_TYPES.FunctionExpression){let c=e.sourceCode.getText(i.value.body);Et(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(l){if(Dn(l.callee))for(let u of l.arguments){if(u.type===z.AST_NODE_TYPES.ObjectExpression&&(r(u),s(u)),u.type===z.AST_NODE_TYPES.ArrowFunctionExpression&&(u.body.type===z.AST_NODE_TYPES.ObjectExpression&&(r(u.body),s(u.body)),u.body.type===z.AST_NODE_TYPES.BlockStatement))for(let i of u.body.body)i.type===z.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===z.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),s(i.argument));if(u.type===z.AST_NODE_TYPES.FunctionExpression)for(let i of u.body.body)i.type===z.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===z.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),s(i.argument))}}}}}),De={name:bt,rule:$n};var ce=require("@typescript-eslint/utils");var Mn=ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Un=D({disallow:F(Y(D({selector:L(),message:L(),replace:F(_e(L(),D({regex:L(),with:L()}))),replaceType:F(Ee(["suggestion","autofix"]))}))),__dev_simulateFileName:F(L()),mustMatchSyntax:F(Y(D({includeRegex:L(),mustCallFn:Y(D({anyCall:Y(D({fn:L(),withArgs:Y(D({atIndex:ht(),literal:_e(L(),J(),le())}))})),message:F(L())}))})))}),It="advanced-no-restricted-syntax",Vn=Mn({name:It,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Un],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:s,disallow:l}=t,u=s??e.filename,i=[],a=new Set;for(let{includeRegex:o,mustCallFn:p}of r??[]){let g=Wn(u,new RegExp(o));if(!g)continue;let y=S=>{let d=S;for(let{name:b,value:T}of g)d=d.replaceAll(b,T);return d};for(let{anyCall:S,message:d}of p){let b=`Expected file to call the function: ${S.map(({fn:T})=>T).join(" or ")}`;a.add(b),i.push(T=>{let{callee:N}=T;if(N.type===ce.AST_NODE_TYPES.Identifier){for(let{fn:v,withArgs:h}of S)if(N.name===v){a.delete(b);for(let w of h){let R=T.arguments[w.atIndex],O=typeof w.literal=="string"?y(w.literal):w.literal;if(!R){e.report({node:T,messageId:"default",data:{message:`Missing argument with value "${O}" at index ${w.atIndex}${d?`: ${y(d)}`:""}`}});continue}if(R.type!==ce.AST_NODE_TYPES.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${O}"${d?`: ${y(d)}`:""}`}});continue}R.value!==O&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${O}"${d?`: ${y(d)}`:""}`},fix:j=>j.replaceText(R,typeof O=="string"?`'${O}'`:String(O))})}break}}})}}for(let{selector:o,message:p,replace:g,replaceType:y="suggestion"}of l??[]){if(o==="CallExpression"){i.push(S=>{c(g,S,p,y)});continue}n[o]=S=>{c(g,S,p,y)}}return i.length>0&&(n.CallExpression=o=>{if(o.type===ce.AST_NODE_TYPES.CallExpression)for(let p of i)p(o)}),n["Program:exit"]=o=>{for(let p of a)e.report({node:o,messageId:"default",data:{message:`${p}`}})},n;function c(o,p,g,y){let S=d=>{if(!o)return null;if(typeof o=="string")return d.replaceText(p,o);{let b=new RegExp(o.regex),T=e.sourceCode.getText(p);return d.replaceText(p,T.replace(b,o.with))}};e.report({node:p,messageId:"default",data:{message:g},fix:o&&y==="autofix"?S:void 0,suggest:o&&y==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof o=="string"?o:o.with}"`},fix:S}]:void 0})}}});function Wn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[s,...l]=r;n.push({name:"$0_lowercase",value:s.toLowerCase()}),n.push({name:"$0_capitalize",value:xt(s)}),n.push({name:"$0_uncapitalize",value:Ct(s)}),n.push({name:"$0",value:s});for(let u=0;u<l.length;u++){let i=`$${u+1}`,a=l[u];n.push({name:`${i}_lowercase`,value:a.toLowerCase()}),n.push({name:`${i}_capitalize`,value:xt(a)}),n.push({name:`${i}_uncapitalize`,value:Ct(a)}),n.push({name:i,value:a})}return n}function xt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ct(e){return e.charAt(0).toLowerCase()+e.slice(1)}var je={name:It,rule:Vn};var _=require("@typescript-eslint/utils");var Hn=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="collapse-simple-objs-in-one-line",Yn=D({maxLineLength:F(J()),maxProperties:F(J()),nestedObjMaxLineLength:F(J()),nestedObjMaxProperties:F(J()),ignoreTypesWithSuffix:F(Y(L()))}),zn=Hn({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:[Yn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,l=t.nestedObjMaxLineLength??t.maxLineLength,u=t.nestedObjMaxProperties??3;function i(c){if(c.type===_.AST_NODE_TYPES.ObjectExpression){let o=c.parent.type===_.AST_NODE_TYPES.Property,p=o?u:s,g=c.properties.length;if(g>p)return!1;if(g===1){let S=c.properties[0];return S.type===_.AST_NODE_TYPES.Property&&S.value.type===_.AST_NODE_TYPES.ObjectExpression||S.type===_.AST_NODE_TYPES.Property&&S.value.type===_.AST_NODE_TYPES.ArrayExpression&&!S.value.elements.every(b=>b&&$e(b))?!1:{text:n.getText(S),isNested:o,propsSize:g}}let y=[];for(let S of c.properties){if(S.type===_.AST_NODE_TYPES.Property&&!$e(S.value))return!1;y.push(n.getText(S))}return{text:y.join(", "),isNested:o,propsSize:g}}else{let o=c.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,p=o?u:s,g=c.members.length;if(g>p)return!1;if(r.length>0&&c.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let S=c.parent.id.name;if(r.some(d=>S.endsWith(d)))return!1}if(g===1){let S=c.members[0];return S.type===_.AST_NODE_TYPES.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(S),isNested:o,propsSize:1}}if(c.parent.type===_.AST_NODE_TYPES.TSIntersectionType||c.parent.type===_.AST_NODE_TYPES.TSUnionType)return!1;let y=[];for(let S of c.members){if(S.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===_.AST_NODE_TYPES.TSTypeLiteral||!wt(d))return!1;if(d.type===_.AST_NODE_TYPES.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let T=d.typeArguments.params[0];if(!wt(T))return!1}let b=n.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),y.push(b)}return{text:y.join("; "),isNested:o,propsSize:g}}}function a(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer){let d=0,b=n.getTokenAfter(c,{filter:T=>T.type!==_.AST_TOKEN_TYPES.Punctuator?!0:T.value===","||T.value===";"||T.value===")"||T.value==="}"?(d++,!1):!0});if(d>4||b?.loc.start.line===c.loc.end.line)return}let o=i(c);if(!o)return;let p=o.text;if(p.includes(`
2
- `)||n.getCommentsInside(c).length>0)return;p.endsWith(";")&&(p=p.slice(0,-1));let g=`{ ${p} }`,y=qn(n,c),S=o.isNested&&o.propsSize>2?l:t.maxLineLength;S&&g.length+y.length+Bn(c,n)>S||e.report({node:c,messageId:"singleLineProp",fix:d=>d.replaceText(c,g)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function wt(e){return e.type===_.AST_NODE_TYPES.TSLiteralType||e.type===_.AST_NODE_TYPES.TSTypeReference||e.type===_.AST_NODE_TYPES.TSNumberKeyword||e.type===_.AST_NODE_TYPES.TSStringKeyword||e.type===_.AST_NODE_TYPES.TSBooleanKeyword||e.type===_.AST_NODE_TYPES.TSNullKeyword||e.type===_.AST_NODE_TYPES.TSUndefinedKeyword}function $e(e,t){return!!(e.type===_.AST_NODE_TYPES.Literal||e.type===_.AST_NODE_TYPES.Identifier||e.type===_.AST_NODE_TYPES.TemplateLiteral||e.type===_.AST_NODE_TYPES.TaggedTemplateExpression||!t&&e.type===_.AST_NODE_TYPES.ArrayExpression&&e.elements.every(n=>n&&$e(n,!0)))}function Bn(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
3
- `,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function qn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Me={name:Rt,rule:zn};var Kn=/eslint +react-compiler\/react-compiler: +\["error/,Ot={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),r=typeof e.getScope=="function"?()=>r():T=>e.sourceCode.getScope(T),s=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,l=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,u={additionalHooks:s,enableDangerousAutofixThisMayCauseInfiniteLoops:l};function i(T){l&&Array.isArray(T.suggest)&&T.suggest.length>0&&(T.fix=T.suggest[0].fix),e.report(T)}let a=e.getSourceCode().scopeManager,c=new WeakMap,o=new WeakSet,p=new WeakMap,g=new WeakMap,y=new WeakSet;function S(T,N){return function(v){if(N.has(v))return N.get(v);let h=T(v);return N.set(v,h),h}}function d(T,N,v,h,w){w&&T.async&&i({node:T,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ "use strict";var wn=Object.create;var he=Object.defineProperty;var Rn=Object.getOwnPropertyDescriptor;var vn=Object.getOwnPropertyNames;var On=Object.getPrototypeOf,kn=Object.prototype.hasOwnProperty;var An=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},ht=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of vn(t))!kn.call(e,s)&&s!==n&&he(e,s,{get:()=>t[s],enumerable:!(r=Rn(t,s))||r.enumerable});return e};var _e=(e,t,n)=>(n=e!=null?wn(On(e)):{},ht(t||!e||!e.__esModule?he(n,"default",{value:e,enumerable:!0}):n,e)),Pn=e=>ht(he({},"__esModule",{value:!0}),e);var si={};An(si,{extendedLintPlugin:()=>ii});module.exports=Pn(si);var z=require("@typescript-eslint/utils");var De=Symbol.for("optional");function F(e){return{...e,[De]:!0}}function Ee(e,t){return{enum:e,...t}}function le(e){return{...e,type:"boolean"}}function N(e){return{...e,type:"string"}}function G(e){return{...e,type:"number"}}function Et(e){return{...e,type:"integer"}}function Y(e,t){return{...t,type:"array",items:e}}function _(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,s=[];for(r in e)e[r][De]?e[r][De]=void 0:s.push(r);s.length>0&&(n.required=s)}return n}function je(...e){return{anyOf:e}}var Fn=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xt="react-compiler-extra",Nn=_({runOnlyWithEnableCompilerDirective:F(le())}),Ln=/eslint +react-compiler\/react-compiler: +\["error/;function _n(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 Dn=/\bthis[.[]/;function bt(e){return Dn.test(e)}var jn=Fn({name:xt,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:[Nn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(Ln.test(a.value)){n=!0;break}if(!n)return{}}function r(a){for(let u of a.properties)if(u.type===z.AST_NODE_TYPES.Property&&u.method&&u.value.type===z.AST_NODE_TYPES.FunctionExpression){let i=e.sourceCode,o=i.getText(u.key),l=u.value,c=i.getText(l.body);if(bt(c))e.report({node:u,messageId:"thisKeywordInMethod"});else{let f=l.params.map(m=>i.getText(m)).join(", "),h="";l.generator?h=`${o}: function* (${f}) ${c}`:h=`${o}: (${f}) => ${c}`,e.report({node:u,messageId:"objectMethodIsNotSupported",fix:m=>m.replaceText(u,h)})}}}function s(a){for(let u of a.properties)if(u.type===z.AST_NODE_TYPES.Property&&u.value.type===z.AST_NODE_TYPES.ObjectExpression){for(let i of u.value.properties)if(i.type===z.AST_NODE_TYPES.Property&&i.method&&i.value.type===z.AST_NODE_TYPES.FunctionExpression){let l=e.sourceCode.getText(i.value.body);bt(l)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(_n(a.callee))for(let u of a.arguments){if(u.type===z.AST_NODE_TYPES.ObjectExpression&&(r(u),s(u)),u.type===z.AST_NODE_TYPES.ArrowFunctionExpression&&(u.body.type===z.AST_NODE_TYPES.ObjectExpression&&(r(u.body),s(u.body)),u.body.type===z.AST_NODE_TYPES.BlockStatement))for(let i of u.body.body)i.type===z.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===z.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),s(i.argument));if(u.type===z.AST_NODE_TYPES.FunctionExpression)for(let i of u.body.body)i.type===z.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===z.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),s(i.argument))}}}}}),Me={name:xt,rule:jn};var xe=require("@typescript-eslint/utils");var Ct=require("@typescript-eslint/utils");function be(e){let n=Ct.ESLintUtils.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}var Mn=_({disallow:F(Y(_({selector:N(),message:N(),replace:F(je(N(),_({regex:N(),with:N()}))),replaceType:F(Ee(["suggestion","autofix"]))}))),__dev_simulateFileName:F(N()),mustMatchSyntax:F(Y(_({includeRegex:N(),mustCallFn:F(Y(_({anyCall:Y(_({fn:N(),withArgs:Y(_({atIndex:Et(),literal:je(N(),G(),le())}))})),message:F(N())}))),mustMatchSelector:F(Y(_({selector:N(),message:N()})))})))}),$e=be({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Mn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:s,disallow:a}=t,u=s??e.filename,i=[],o=new Map,l=new Set,c=new Map;for(let{includeRegex:m,mustCallFn:y,mustMatchSelector:T}of r??[]){let E=$n(u,new RegExp(m));if(!E)continue;let g=O=>{let C=O;for(let{name:S,value:v}of E)C=C.replaceAll(S,v);return C};for(let{anyCall:O,message:C}of y??[]){let S=`Expected file to call the function: ${O.map(({fn:v})=>v).join(" or ")}`;l.add(S),i.push(v=>{let{callee:A}=v;if(A.type===xe.AST_NODE_TYPES.Identifier){for(let{fn:L,withArgs:j}of O)if(A.name===L){l.delete(S);for(let R of j){let U=v.arguments[R.atIndex],B=typeof R.literal=="string"?g(R.literal):R.literal;if(!U){e.report({node:v,messageId:"default",data:{message:`Missing argument with value "${B}" at index ${R.atIndex}${C?`: ${g(C)}`:""}`}});continue}if(U.type!==xe.AST_NODE_TYPES.Literal){e.report({node:U,messageId:"default",data:{message:`Argument at position ${R.atIndex} should the literal "${B}"${C?`: ${g(C)}`:""}`}});continue}U.value!==B&&e.report({node:U,messageId:"default",data:{message:`Argument should have the value "${B}"${C?`: ${g(C)}`:""}`},fix:ye=>ye.replaceText(U,typeof B=="string"?`'${B}'`:String(B))})}break}}})}for(let{selector:O,message:C}of T??[])c.set(O,g(C)),o.set(g(O),()=>{c.delete(O)})}function f(m,y){let T=n[m];T?n[m]=E=>{T(E),y(E)}:n[m]=y}for(let{selector:m,message:y,replace:T,replaceType:E="suggestion"}of a??[]){if(m==="CallExpression"){i.push(g=>{h(T,g,y,E)});continue}n[m]=g=>{h(T,g,y,E)}}if(o.size>0)for(let[m,y]of o)f(m,y);return i.length>0&&(n.CallExpression=m=>{if(m.type===xe.AST_NODE_TYPES.CallExpression)for(let y of i)y(m)}),n["Program:exit"]=m=>{for(let y of l)e.report({node:m,messageId:"default",data:{message:y}});for(let[,y]of c)e.report({node:m,messageId:"default",data:{message:y}})},n;function h(m,y,T,E){let g=O=>{if(!m)return null;if(typeof m=="string")return O.replaceText(y,m);{let C=new RegExp(m.regex),S=e.sourceCode.getText(y);return O.replaceText(y,S.replace(C,m.with))}};e.report({node:y,messageId:"default",data:{message:T},fix:m&&E==="autofix"?g:void 0,suggest:m&&E==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:g}]:void 0})}}});function $n(e,t){let n=[],r=t.exec(e);if(!r)return null;let[s,...a]=r;n.push({name:"$0_lowercase",value:s.toLowerCase()}),n.push({name:"$0_capitalize",value:It(s)}),n.push({name:"$0_uncapitalize",value:wt(s)}),n.push({name:"$0",value:s});for(let u=0;u<a.length;u++){let i=`$${u+1}`,o=a[u];n.push({name:`${i}_lowercase`,value:o.toLowerCase()}),n.push({name:`${i}_capitalize`,value:It(o)}),n.push({name:`${i}_uncapitalize`,value:wt(o)}),n.push({name:i,value:o})}return n}function It(e){return e.charAt(0).toUpperCase()+e.slice(1)}function wt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var D=require("@typescript-eslint/utils");var Un=D.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="collapse-simple-objs-in-one-line",Vn=_({maxLineLength:F(G()),maxProperties:F(G()),nestedObjMaxLineLength:F(G()),nestedObjMaxProperties:F(G()),ignoreTypesWithSuffix:F(Y(N()))}),Wn=Un({name:vt,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:[Vn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,u=t.nestedObjMaxProperties??3;function i(l){if(l.type===D.AST_NODE_TYPES.ObjectExpression){let c=l.parent.type===D.AST_NODE_TYPES.Property,f=c?u:s,h=l.properties.length;if(h>f)return!1;if(h===1){let y=l.properties[0];return y.type===D.AST_NODE_TYPES.Property&&y.value.type===D.AST_NODE_TYPES.ObjectExpression||y.type===D.AST_NODE_TYPES.Property&&y.value.type===D.AST_NODE_TYPES.ArrayExpression&&!y.value.elements.every(E=>E&&Ue(E))?!1:{text:n.getText(y),isNested:c,propsSize:h}}let m=[];for(let y of l.properties){if(y.type===D.AST_NODE_TYPES.Property&&!Ue(y.value))return!1;m.push(n.getText(y))}return{text:m.join(", "),isNested:c,propsSize:h}}else{let c=l.parent.parent?.type===D.AST_NODE_TYPES.TSPropertySignature,f=c?u:s,h=l.members.length;if(h>f)return!1;if(r.length>0&&l.parent.type===D.AST_NODE_TYPES.TSTypeAliasDeclaration){let y=l.parent.id.name;if(r.some(T=>y.endsWith(T)))return!1}if(h===1){let y=l.members[0];return y.type===D.AST_NODE_TYPES.TSPropertySignature&&y.typeAnnotation?.typeAnnotation.type===D.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(y),isNested:c,propsSize:1}}if(l.parent.type===D.AST_NODE_TYPES.TSIntersectionType||l.parent.type===D.AST_NODE_TYPES.TSUnionType)return!1;let m=[];for(let y of l.members){if(y.type!==D.AST_NODE_TYPES.TSPropertySignature)return!1;let T=y.typeAnnotation?.typeAnnotation;if(!T||T.type===D.AST_NODE_TYPES.TSTypeLiteral||!Rt(T))return!1;if(T.type===D.AST_NODE_TYPES.TSTypeReference&&T.typeArguments){if(T.typeArguments.params.length>1)return!1;let g=T.typeArguments.params[0];if(!Rt(g))return!1}let E=n.getText(y).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),m.push(E)}return{text:m.join("; "),isNested:c,propsSize:h}}}function o(l){if(l.loc.start.line===l.loc.end.line)return;if(l.parent.type!==D.AST_NODE_TYPES.JSXExpressionContainer){let T=0,E=n.getTokenAfter(l,{filter:g=>g.type!==D.AST_TOKEN_TYPES.Punctuator?!0:g.value===","||g.value===";"||g.value===")"||g.value==="}"?(T++,!1):!0});if(T>4||E?.loc.start.line===l.loc.end.line)return}let c=i(l);if(!c)return;let f=c.text;if(f.includes(`
2
+ `)||n.getCommentsInside(l).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let h=`{ ${f} }`,m=Yn(n,l),y=c.isNested&&c.propsSize>2?a:t.maxLineLength;y&&h.length+m.length+Hn(l,n)>y||e.report({node:l,messageId:"singleLineProp",fix:T=>T.replaceText(l,h)})}return{TSTypeLiteral:o,ObjectExpression:o}}});function Rt(e){return e.type===D.AST_NODE_TYPES.TSLiteralType||e.type===D.AST_NODE_TYPES.TSTypeReference||e.type===D.AST_NODE_TYPES.TSNumberKeyword||e.type===D.AST_NODE_TYPES.TSStringKeyword||e.type===D.AST_NODE_TYPES.TSBooleanKeyword||e.type===D.AST_NODE_TYPES.TSNullKeyword||e.type===D.AST_NODE_TYPES.TSUndefinedKeyword}function Ue(e,t){return!!(e.type===D.AST_NODE_TYPES.Literal||e.type===D.AST_NODE_TYPES.Identifier||e.type===D.AST_NODE_TYPES.TemplateLiteral||e.type===D.AST_NODE_TYPES.TaggedTemplateExpression||!t&&e.type===D.AST_NODE_TYPES.ArrayExpression&&e.elements.every(n=>n&&Ue(n,!0)))}function Hn(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
3
+ `,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function Yn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ve={name:vt,rule:Wn};var zn=/eslint +react-compiler\/react-compiler: +\["error/,kt={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),s=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,a=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,u={additionalHooks:s,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function i(g){a&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let o=e.getSourceCode().scopeManager,l=new WeakMap,c=new WeakSet,f=new WeakMap,h=new WeakMap,m=new WeakSet;function y(g,O){return function(C){if(O.has(C))return O.get(C);let S=g(C);return O.set(C,S),S}}function T(g,O,C,S,v){v&&g.async&&i({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
4
4
 
5
5
  useEffect(() => {
6
6
  async function fetchData() {
@@ -11,5 +11,5 @@ useEffect(() => {
11
11
  fetchData();
12
12
  }, [someId]); // Or [] if effect doesn't need props or state
13
13
 
14
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=a.acquire(T),O=new Set,j=null;{let f=R.upper;for(;f&&(O.add(f),f.type!=="function");)f=f.upper;if(!f)return;j=f}let k=Array.isArray;function H(f){if(!k(f.defs))return!1;let m=f.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let E=m.node.init;if(E==null)return!1;for(;E.type==="TSAsExpression";)E=E.expression;let x=m.node.parent;if(x==null&&(We(j.block,m.node.id),x=m.node.parent,x==null))return!1;if(x.kind==="const"&&E.type==="Literal"&&(typeof E.value=="string"||typeof E.value=="number"||E.value===null))return!0;if(E.type!=="CallExpression")return!1;let I=E.callee;if(I.type==="MemberExpression"&&I.object.name==="React"&&I.property!=null&&!I.computed&&(I=I.property),I.type!=="Identifier")return!1;let C=m.node.id,{name:A}=I;if(A==="useRef"&&C.type==="Identifier")return!0;if(Qn(I)&&C.type==="Identifier"){for(let P of f.references)P!==C&&y.add(P.identifier);return!0}else if(A==="useState"||A==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&k(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(A==="useState"){let P=f.references,X=0;for(let ee=0;ee<P.length;ee++){if(P[ee].isWrite()&&X++,X>1)return!1;c.set(P[ee].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(A==="useState"){let P=f.references;for(let X=0;X<P.length;X++)o.add(P[X].identifier)}return!1}}}else if(A==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function Q(f){if(!k(f.defs))return!1;let m=f.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let E=m.node,x=j.childScopes,I=null,C;for(C=0;C<x.length;C++){let A=x[C],P=A.block;if(E.type==="FunctionDeclaration"&&P===E||E.type==="VariableDeclarator"&&P.parent===E){I=A;break}}if(I==null)return!1;for(C=0;C<I.through.length;C++){let A=I.through[C];if(A.resolved!=null&&O.has(A.resolved.scope)&&!ft(A.resolved))return!1}return!0}let ft=S(H,p),hn=S(Q,g),mt=new Map;function En(f){let m=f.from,E=!1;for(;m.block!==T;)m.type==="function"&&(E=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return E}let K=new Map,ke=new Map;dt(R);function dt(f){for(let m of f.references){if(!m.resolved||!O.has(m.resolved.scope))continue;let E=We(T,m.identifier),x=kt(E),I=te(x,ke);if(w&&x.type==="Identifier"&&(x.parent.type==="MemberExpression"||x.parent.type==="OptionalMemberExpression")&&!x.parent.computed&&x.parent.property.type==="Identifier"&&x.parent.property.name==="current"&&En(m)&&mt.set(I,{reference:m,dependencyNode:x}),x.parent.type==="TSTypeQuery"||x.parent.type==="TSTypeReference")continue;let C=m.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===T.parent)&&C.type!=="TypeParameter")if(K.has(I))K.get(I).references.push(m);else{let A=m.resolved,P=ft(A)||hn(A);K.set(I,{isStable:P,references:[m]})}}for(let m of f.childScopes)dt(m)}mt.forEach(({reference:f,dependencyNode:m},E)=>{let x=f.resolved.references,I=!1;for(let C=0;C<x.length;C++){let{identifier:A}=x[C],{parent:P}=A;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){I=!0;break}}I||i({node:m.parent.property,message:`The ref value '${E}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${E}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Ae=new Set;function bn(f,m){Ae.has(m)||(Ae.add(m),i({node:f,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 ge=new Set;if(K.forEach(({isStable:f,references:m},E)=>{f&&ge.add(E),m.forEach(x=>{x.writeExpr&&bn(x.writeExpr,E)})}),Ae.size>0)return;if(!N){let f=null;if(K.forEach(({isStable:m,references:E},x)=>{f||E.forEach(I=>{if(f)return;let C=I.identifier;if(!c.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===T&&(f=x)})}),f){let{suggestedDependencies:m}=Ue({dependencies:K,declaredDependencies:[],stableDependencies:ge,externalDependencies:new Set,isEffect:!0});i({node:v,message:`React Hook ${h} contains a call to '${f}'. 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 ${h} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(E){return E.insertTextAfter(T,`, [${m.join(", ")}]`)}}]})}return}let me=[],de=new Set;N.type!=="ArrayExpression"?i({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(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,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}y.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(f)}\``,fix(I){return I.removeRange(f.range)}}]});let m;try{m=te(f,ke)}catch(I){if(/Unsupported node type/.test(I.message)){f.type==="Literal"?K.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${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 I}let E=f;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let x=!j.through.some(I=>I.identifier===E);me.push({key:m,node:f}),x||de.add(m)});let{suggestedDependencies:xn,unnecessaryDependencies:Se,missingDependencies:ie,duplicateDependencies:yt}=Ue({dependencies:K,declaredDependencies:me,stableDependencies:ge,externalDependencies:de,isEffect:w}),Te=xn;if(yt.size+ie.size+Se.size===0){if(t)return;Xn({declaredDependencies:me,declaredDependenciesNode:N,componentScope:j,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:E,depType:x})=>{let I=x==="function"?"useCallback":"useMemo",C=x==="function"?"definition":"initialization",A=`wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,P=E?`To fix this, ${A}`:`Move it inside the ${h} callback. Alternatively, ${A}`,X=x==="conditional"||x==="logical expression"?"could make":"makes",ee=`The '${m.name.name}' ${x} ${X} the dependencies of ${h} Hook (at line ${N.loc.start.line}) change on every render. ${P}`,gt;E&&m.type==="Variable"&&x==="function"&&(gt=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(St){let[In,wn]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[St.insertTextBefore(m.node.init,In),St.insertTextAfter(m.node.init,wn)]}}]),i({node:m.node,message:ee,suggest:gt})});return}!w&&ie.size>0&&(Te=Ue({dependencies:K,declaredDependencies:[],stableDependencies:ge,externalDependencies:de,isEffect:w}).suggestedDependencies);function Cn(){if(me.length===0)return!0;let f=me.map(E=>E.key),m=f.slice().sort();return f.join(",")===m.join(",")}Cn()&&Te.sort();function Pe(f){let m=f.split("."),E="";for(let x=0;x<m.length;x++){if(x!==0){let I=m.slice(0,x+1).join("."),C=ke.get(I)===!0;E+=C?"?.":"."}E+=m[x]}return E}function Fe(f,m,E,x){return f.size===0?null:(f.size>1?"":m+" ")+E+" "+(f.size>1?"dependencies":"dependency")+": "+Gn(Array.from(f).sort().map(I=>"'"+Pe(I)+"'"))+`. Either ${x} ${f.size>1?"them":"it"} or remove the dependency array.`}let G="";if(Se.size>0){let f=null;if(Array.from(Se.keys()).forEach(m=>{f===null&&m.endsWith(".current")&&(f=m)}),f!==null)G=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(de.size>0){let m=Array.from(de)[0];R.set.has(m)||(G=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!G&&ie.has("props")){let f=K.get("props");if(f==null)return;let m=f.references;if(!Array.isArray(m))return;let E=!0;for(let x=0;x<m.length;x++){let I=m[x],C=We(j.block,I.identifier);if(!C){E=!1;break}let A=C.parent;if(A==null){E=!1;break}if(A.type!=="MemberExpression"&&A.type!=="OptionalMemberExpression"){E=!1;break}}E&&(G=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${h} call and refer to those specific props inside ${n(v)}.`)}if(!G&&ie.size>0){let f=null;ie.forEach(m=>{if(f)return;let E=j.set.get(m),x=K.get(m);if(x.references[0].resolved!==E)return;let I=E.defs[0];if(I==null||I.name==null||I.type!=="Parameter")return;let C=!1,A;for(let P=0;P<x.references.length;P++)if(A=x.references[P].identifier,A!=null&&A.parent!=null&&(A.parent.type==="CallExpression"||A.parent.type==="OptionalCallExpression")&&A.parent.callee===A){C=!0;break}C&&(f=m)}),f!==null&&(G=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!G&&ie.size>0){let f=null;if(ie.forEach(m=>{if(f!==null)return;let x=K.get(m).references,I,C;for(let A=0;A<x.length;A++){for(I=x[A].identifier,C=I.parent;C!=null&&C!==j.block;){if(C.type==="CallExpression"){let P=c.get(C.callee);if(P!=null){if(P.name===m)f={missingDep:m,setter:C.callee.name,form:"updater"};else if(o.has(I))f={missingDep:m,setter:C.callee.name,form:"reducer"};else{let X=x[A].resolved;if(X!=null){let ee=X.defs[0];ee!=null&&ee.type==="Parameter"&&(f={missingDep:m,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":G=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":G=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":G=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:N,message:`React Hook ${n(v)} has `+(Fe(ie,"a","missing","include")||Fe(Se,"an","unnecessary","exclude")||Fe(yt,"a","duplicate","omit"))+G,suggest:[{desc:`Update the dependencies array to be: [${Te.map(Pe).join(", ")}]`,fix(f){return f.replaceText(N,`[${Te.map(Pe).join(", ")}]`)}}]})}function b(T){let N=Jn(T.callee,u);if(N===-1)return;let v=T.arguments[N],h=T.callee,w=At(h).name,R=T.arguments[N+1],O=/Effect($|[^a-z])/g.test(w);if(!v){i({node:h,message:`React Hook ${w} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!O)){if(!R&&!O){(w==="useMemo"||w==="useCallback")&&i({node:h,message:`React Hook ${w} 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,h,w,O);return;case"Identifier":if(!R||R.elements&&R.elements.some(H=>H&&H.type==="Identifier"&&H.name===v.name))return;let j=r(T).set.get(v.name);if(j==null||j.defs==null)return;let k=j.defs[0];if(!k||!k.node||k.type!=="Variable"&&k.type!=="FunctionName")break;switch(k.node.type){case"FunctionDeclaration":d(k.node,R,h,w,O);return;case"VariableDeclarator":let H=k.node.init;if(!H)break;switch(H.type){case"ArrowFunctionExpression":case"FunctionExpression":d(H,R,h,w,O);return}break}break;default:i({node:h,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:h,message:`React Hook ${w} 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(j){return j.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let T of e.sourceCode.getAllComments())if(Kn.test(T.value))return t=!0,{CallExpression:N=>b(N,!0)}}return{CallExpression:T=>b(T)}}};function Ue({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:s}){let l=u();function u(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,b)=>{let T=i(l,b);T.isUsed=!0,a(l,b,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let b=i(l,d);b.isSatisfiedRecursively=!0}),n.forEach(d=>{let b=i(l,d);b.isSatisfiedRecursively=!0});function i(d,b){let T=b.split("."),N=d;for(let v of T){let h=N.children.get(v);h||(h=u(),N.children.set(v,h)),N=h}return N}function a(d,b,T){let N=b.split("."),v=d;for(let h of N){let w=v.children.get(h);if(!w)return;T(w),v=w}}let c=new Set,o=new Set;p(l,c,o,d=>d);function p(d,b,T,N){d.children.forEach((v,h)=>{let w=N(h);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&T.add(w);return}if(v.isUsed){b.add(w);return}p(v,b,T,R=>w+"."+R)})}let g=[],y=new Set,S=new Set;return t.forEach(({key:d})=>{o.has(d)?g.indexOf(d)===-1?g.push(d):S.add(d):y.add(d)}),c.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:y,duplicateDependencies:S,missingDependencies:c}}function se(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 se(e.consequent)!=null||se(e.alternate)!=null?"conditional":null;case"LogicalExpression":return se(e.left)!=null||se(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return se(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return se(e.expression);case"TSAsExpression":return se(e.expression)}return null}function Xn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let s=e.map(({key:u})=>{let i=n.variables.find(c=>c.name===u);if(i==null)return null;let a=i.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 c=se(a.node.init);if(c!=null)return[i,c]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[i,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function l(u){let i=!1;for(let a=0;a<u.references.length;a++){let c=u.references[a];if(c.writeExpr){if(i)return!0;i=!0;continue}let o=c.from;for(;o!==r&&o!=null;)o=o.upper;if(o!==r&&!Pt(t,c.identifier))return!0}return!1}return s.map(([u,i])=>({construction:u.defs[0],depType:i,isUsedOutsideOfHook:l(u)}))}function kt(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)?kt(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 te(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=te(e.object,t),r=te(e.property,null),s=`${n}.${r}`;return Ve(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=te(e.object,t),r=te(e.property,null),s=`${n}.${r}`;return Ve(e,t,s),s}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=te(n.object,t),s=te(n.property,null),l=`${r}.${s}`;return Ve(n,t,l),l}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 Jn(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=te(n,null)}catch(s){if(/Unsupported node type/.test(s.message))return 0;throw s}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(),Zn(r,t))return r;if(Pt(r,t))for(let[s,l]of Object.entries(r))s!=="parent"&&(vt(l)?(l.parent=r,n.push(l)):Array.isArray(l)&&l.forEach(u=>{vt(u)&&(u.parent=r,n.push(u))}))}return null}function Gn(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 vt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Zn(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 Pt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Qn(e){return!1}var oe=require("@typescript-eslint/utils");var B=Ne(require("typescript")),er=oe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="improved-no-unnecessary-condition",tr=D({}),nr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],rr=new Set(nr),He={name:Ft,rule:er({name:Ft,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:[tr]},defaultOptions:[{}],create(e){let t=oe.ESLintUtils.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===oe.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function s(i){return i.flags&B.default.TypeFlags.Any||i.flags&B.default.TypeFlags.Unknown?null:i.flags&B.default.TypeFlags.StringLike?["string"]:i.flags&B.default.TypeFlags.NumberLike?["number"]:i.flags&B.default.TypeFlags.BigIntLike?["bigint"]:i.flags&B.default.TypeFlags.BooleanLike?["boolean"]:i.flags&B.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&B.default.TypeFlags.Undefined||i.flags&B.default.TypeFlags.Void?["undefined"]:i.flags&B.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&B.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&B.default.TypeFlags.NonPrimitive?["object"]:i.flags&B.default.TypeFlags.Never?["never"]:null}function l(i){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(i),c=n.getTypeAtLocation(a.expression);if(c.flags&B.default.TypeFlags.Any||c.flags&B.default.TypeFlags.Unknown)return null;let o=[];if(c.isUnion()){for(let g of c.types){let y=s(g);if(y)o.push(...y);else return null}return o}let p=s(c);return p?(o.push(...p),o):null}function u(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,o=null;if(r(i.left)?(c=i.left,o=i.right.type===oe.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(c=i.right,o=i.left.type===oe.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!o||!ir(o,rr))return;let p=l(c);if(!p)return;let g=i.operator==="!==",y=p.includes(o);p.length===1?y&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ue(c,e),type:o}}):!y&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ue(c,e),type:Array.from(p)[0]}}):!y&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ue(c,e),actualType:be(p),conditionType:o}}):y&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ue(c,e),actualType:be(p),conditionType:o}}):!y&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ue(c,e),actualType:be(p),conditionType:o}}):!y&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ue(c,e),type:be(p)}})}return{BinaryExpression:u}}})};function be(e){return Array.from(new Set(e)).join(" | ")||"never"}function ue(e,t){let n=e.argument;return n.type===oe.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function ir(e,t){return t.has(e)}var xe=require("@typescript-eslint/utils");var sr=xe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="no-call-with-explicit-generics",or=D({functions:Y(L())}),ar=sr({name:Nt,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[or]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:s}=r;s.type===xe.AST_NODE_TYPES.Identifier&&n.has(s.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),Ye={name:Nt,rule:ar};var ae=require("@typescript-eslint/utils"),lr=ae.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="no-call-with-inferred-generics",cr=lr({name:Lt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:s}=r;if(s.type!==ae.AST_NODE_TYPES.Identifier)return;let l=n.get(s.name);if(!l)return;let{minGenerics:u=1,allowAny:i,disallowTypes:a=t.disallowTypes}=l;(r.typeArguments?.params.length||0)<(u||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:u||0}}),!(i&&!a)&&r.typeArguments?.params?.some(o=>!i&&o.type===ae.AST_NODE_TYPES.TSAnyKeyword||a&&o.type===ae.AST_NODE_TYPES.TSTypeReference&&o.typeName.type===ae.AST_NODE_TYPES.Identifier&&a.includes(o.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),ze={name:Lt,rule:cr};var ye=require("@typescript-eslint/utils"),ur=ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="no-commented-out-code",pr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],fr=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],mr=ur({name:_t,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 s of pr)if(r.startsWith(s))return{wrongPattern:s};for(let s of fr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}return{Program(){let r=e.sourceCode.getAllComments();for(let s of r)if(s.type===ye.TSESTree.AST_TOKEN_TYPES.Line||s.type===ye.TSESTree.AST_TOKEN_TYPES.Block){let l=t(s.value);l&&e.report({node:s,messageId:"commentedOutCode",data:{wrongPattern:l.wrongPattern}})}}}}}),Be={name:_t,rule:mr};var Ce=require("@typescript-eslint/utils"),dr=Ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dt="no-default-export",yr=dr({name:Dt,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===Ce.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),qe={name:Dt,rule:yr};var jt=require("@typescript-eslint/utils"),gr=jt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="no-leaked-text-in-jsx",Sr=[",",";","[","]","(",")"],Tr=gr({name:$t,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="";Sr.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),Ke={name:$t,rule:Tr};var ne=require("@typescript-eslint/utils"),hr=ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="no-non-camel-case-functions",Er=/^[a-z][a-zA-Z0-9]*$/;function Mt(e){return e.typeName.type===ne.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===ne.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ne.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var br=hr({name:Ut,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&&!Er.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ne.AST_NODE_TYPES.TSTypeReference?Mt(n):n.type===ne.AST_NODE_TYPES.TSUnionType&&n.types.some(s=>s.type===ne.AST_NODE_TYPES.TSTypeReference&&Mt(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Xe={name:Ut,rule:br};var M=require("@typescript-eslint/utils");var Je=require("@typescript-eslint/utils");function pe(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:pe(e.parent,t,n===1/0?n:n-1)}function*Ge(e){yield e,e.parent&&(yield*Ge(e.parent))}function Ze(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function Vt(e,t,n){let s=n.getDeclaredVariables(e).find(l=>l.name===t||l.identifiers[0]?.parent.type===Je.AST_NODE_TYPES.Property&&l.identifiers[0]?.parent.key.type===Je.AST_NODE_TYPES.Identifier&&l.identifiers[0]?.parent.key.name===t);return s?s.references.filter(l=>!l.init):[]}var xr=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="no-optional-root-props",Cr=xr({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(r){let l=e.sourceCode.getDeclaredVariables(r)[0];if(!l||l.references.length!==1)return!1;let u=l.references[0];if(!u)return!1;for(let i of Ge(u.identifier)){if("returnType"in i||i.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let a=i.parent;if(!a)return!1;if(a.type===M.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&a.parent.type===M.TSESTree.AST_NODE_TYPES.TSTypeReference&&a.parent.typeName.type===M.TSESTree.AST_NODE_TYPES.Identifier&&a.parent.typeName.name==="FC"){let o=pe(a.parent.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!o)return!1;let p=Ie(o,e.sourceCode);return p?!(p.parent.type===M.TSESTree.AST_NODE_TYPES.CallExpression&&p.parent.callee.type===M.TSESTree.AST_NODE_TYPES.Identifier&&p.parent.callee.name==="memo"):!1}if(i.type===M.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(a.type===M.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let c=pe(a,M.TSESTree.AST_NODE_TYPES.VariableDeclaration);return c?!!Ie(c,e.sourceCode):!1}if(a.type===M.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Ie(a,e.sourceCode)}return!1}function n(r){r.key.type!==M.TSESTree.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:s=>{let l=pe(r,M.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!l)return null;let u=e.sourceCode.getText(l);return s.replaceText(l,u.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===M.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(we(r)||!t(r)))for(let s of r.typeAnnotation.members)s.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(s)},TSInterfaceDeclaration(r){if(!(we(r)||!t(r)))for(let s of r.body.body)s.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(s)},TSTypeReference(r){if(r.typeName.type!==M.TSESTree.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let s=r.typeArguments.params[0];if(s.type!==M.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let l=pe(r.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!l)return;let u=Ie(l,e.sourceCode);if(!(!u||u.parent.type===M.TSESTree.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===M.TSESTree.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"))for(let a of s.members)a.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(a)}}}});function we(e){return e?e.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ie(e,t){if(we(e))return;let n;if(e.type===M.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===M.TSESTree.AST_NODE_TYPES.Identifier&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===M.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let s=r.variables.find(u=>u.identifiers.includes(n));if(!s)return;let l=s.references.filter(u=>u.identifier!==n);if(!(l.length!==1||!l[0])&&!we(l[0].identifier.parent.parent))return l[0].identifier}var Qe={name:Wt,rule:Cr};var Ht=require("@typescript-eslint/utils"),Re=Ne(require("path"));var Ir=Ht.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="no-relative-imports",wr=D({find:L(),replacement:L()}),Rr=D({aliases:Y(wr),rootDir:F(L()),allowNotFoundAliases:F(le()),_dev_simulateFileName:F(L())}),vr=Ir({name:Yt,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:[Rr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(u){return u.startsWith(".")||u.startsWith("..")}function s(u,i){let a=Re.default.dirname(i);return Re.default.resolve(a,u)}function l(u){let i=t.rootDir??process.cwd(),a=Re.default.relative(i,u);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:c,replacement:o}of t.aliases)if(a.startsWith(o)){let p=a.replace(o,c);return{alias:c,newPath:p}}return null}return{ImportDeclaration(u){let i=u.source.value;if(!r(i))return;let a=s(i,n),c=l(a);!c&&t.allowNotFoundAliases||e.report({node:u,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?o=>o.replaceText(u.source,`'${c.newPath}'`):void 0})}}}}),et={name:Yt,rule:vr};var re=require("@typescript-eslint/utils");var tt=Ne(require("typescript")),Or=re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="no-unnecessary-casting",kr=D({additionalCastFunctions:F(Y(D({name:L(),expectedType:Ee(["string","number"])})))}),nt={name:zt,rule:Or({name:zt,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[kr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],s=re.ESLintUtils.getParserServices(e,!0),l=s.program?.getTypeChecker();if(!l||!s.program)throw new Error("TypeScript services or program not available");function u(o,p){switch(o.type){case re.AST_NODE_TYPES.Literal:return p==="number"?typeof o.value=="number":typeof o.value=="string";case re.AST_NODE_TYPES.TemplateLiteral:return p==="string";case re.AST_NODE_TYPES.UnaryExpression:return p==="number"?o.operator==="+"||o.operator==="-"||o.operator==="~":!1;default:return!1}}function i(o,p){return p==="number"?!!(o.flags&tt.TypeFlags.NumberLike):!!(o.flags&tt.TypeFlags.StringLike)}function a(o,p){return g=>g.replaceText(o,e.sourceCode.getText(p))}function c(o){if(!l||o.arguments.length!==1)return;let p=o.arguments[0];if(!p||p.type===re.AST_NODE_TYPES.SpreadElement)return;let{callee:g}=o;if(g.type!==re.AST_NODE_TYPES.Identifier)return;let y=g.name,S=r.find(b=>b.name===y);if(!S)return;if(u(p,S.expectedType)||i(l.getTypeAtLocation(s.esTreeNodeToTSNodeMap.get(p)),S.expectedType)){let b,T;y==="Number"?b="unnecessaryNumberCasting":y==="String"?b="unnecessaryStringCasting":(b="unnecessaryCustomCasting",T={name:S.name,type:S.expectedType}),e.report({node:o,messageId:b,...T?{data:T}:{},fix:a(o,p)})}}return{CallExpression:c}}})};var U=require("@typescript-eslint/utils");var Ar=D({selectors:Y(D({name:L(),selectorProp:F(L()),selectorArgPos:F(J()),returnProp:F(L())}))}),Pr=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt="no-unused-selected-values",rt={name:Bt,rule:Pr({name:Bt,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Ar]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.map(s=>[s.name,s]));return{VariableDeclarator(s){let l=null;if(s.init?.type===U.AST_NODE_TYPES.CallExpression&&(l=s.init),!l)return;let u=Nr(l);if(!u)return;let i=r.get(u);if(!i)return;let a=Fr(l,i.selectorArgPos??0,i.selectorProp);if(!a)return;let c=Lr(a);if(!c)return;let o=qt(c.properties,void 0);if(!o)return;if(s.id.type===U.AST_NODE_TYPES.ObjectPattern){let y=qt(s.id.properties,i.returnProp);if(!y)return;for(let[S,d]of o)y.has(S)||e.report({node:d,messageId:"unusedSelectedValue",data:{name:S}});return}if(s.id.type!==U.AST_NODE_TYPES.Identifier||i.returnProp)return;let p=_r(s,e.sourceCode);if(p.length===0)return;let g=new Set;for(let y of p){if(y.identifier.parent.type!==U.AST_NODE_TYPES.MemberExpression)return;let S=y.identifier.parent.property;if(S.type!==U.AST_NODE_TYPES.Identifier)return;g.add(S.name)}for(let[y,S]of o)g.has(y)||e.report({node:S,messageId:"unusedSelectedValue",data:{name:y}})}}}})};function Fr(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===U.AST_NODE_TYPES.ArrowFunctionExpression||r.type===U.AST_NODE_TYPES.FunctionExpression)return r;if(n&&r.type===U.AST_NODE_TYPES.ObjectExpression){let s=r.properties.find(u=>u.type===U.AST_NODE_TYPES.Property&&u.key.type===U.AST_NODE_TYPES.Identifier&&u.key.name===n);if(s?.type!==U.AST_NODE_TYPES.Property)return null;let l=s.value;if(l.type===U.AST_NODE_TYPES.ArrowFunctionExpression||l.type===U.AST_NODE_TYPES.FunctionExpression)return l}return null}function Nr(e){return e.callee.type===U.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===U.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===U.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Lr(e){if(e.body.type===U.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===U.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===U.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==U.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function qt(e,t){let n=e;if(t){let s=e.find(l=>l.type===U.AST_NODE_TYPES.Property&&l.key.type===U.AST_NODE_TYPES.Identifier&&l.key.name===t);if(s?.type!==U.AST_NODE_TYPES.Property||s.value.type!==U.AST_NODE_TYPES.ObjectPattern)return null;n=s.value.properties}let r=new Map;for(let s of n){if(s.type!==U.AST_NODE_TYPES.Property||s.key.type!==U.AST_NODE_TYPES.Identifier)return null;r.set(s.key.name,s)}return r.size>0?r:null}function _r(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(s=>s.identifier!==e.id):[]}var V=require("@typescript-eslint/utils");var Kt=require("@typescript-eslint/utils");function Xt(e){let n=Kt.ESLintUtils.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}var it=Xt({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(l=>l.type===V.AST_NODE_TYPES.ImportDeclaration&&l.source.value==="t-state-form"))return{};let r=null,s=!1;return{CallExpression(l){if(s)return;if(!r){let i=Dr(l);i&&(r=i);return}let u=jr(l,e.sourceCode);if(u){s=!0;for(let i of u)r.delete(i);if(r.size!==0)for(let[i,a]of r)e.report({node:a,messageId:"unusedField",data:{name:i}})}}}}});function Dr(e){if(!(e.callee.type===V.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==V.AST_NODE_TYPES.ObjectExpression)return null;let r=Ze(n.properties,l=>l.type!==V.AST_NODE_TYPES.Property||l.key.type!==V.AST_NODE_TYPES.Identifier||l.key.name!=="initialConfig"?null:l.value.type===V.AST_NODE_TYPES.ObjectExpression?l.value:l.value.type===V.AST_NODE_TYPES.ArrowFunctionExpression||l.value.type===V.AST_NODE_TYPES.FunctionExpression?$r(l.value):null);if(!r)return null;let s=new Map;for(let l of r.properties)l.type===V.AST_NODE_TYPES.Property&&l.key.type===V.AST_NODE_TYPES.Identifier&&s.set(l.key.name,l);return s}function jr(e,t){if(!(e.callee.type===V.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==V.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==V.AST_NODE_TYPES.ObjectPattern||!Ze(e.parent.id.properties,u=>u.type===V.AST_NODE_TYPES.Property&&u.key.type===V.AST_NODE_TYPES.Identifier&&u.key.name==="formFields"&&u))return null;let s=Vt(e.parent,"formFields",t),l=new Set;for(let{identifier:u}of s){if(u.type!==V.AST_NODE_TYPES.Identifier||u.parent.type===V.AST_NODE_TYPES.Property&&u.parent.parent.type===V.AST_NODE_TYPES.ObjectExpression&&u.parent.parent.parent.type===V.AST_NODE_TYPES.ReturnStatement||u.parent.type===V.AST_NODE_TYPES.ReturnStatement)return null;if(u.parent.type===V.AST_NODE_TYPES.MemberExpression){if(u.parent.object.type!==V.AST_NODE_TYPES.Identifier||u.parent.property.type!==V.AST_NODE_TYPES.Identifier)return null;l.add(u.parent.property.name)}}return l}function $r(e){if(e.body.type===V.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===V.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===V.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==V.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var $=require("@typescript-eslint/utils");var Mr=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Jt(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 Gt(e,...t){for(let n of t)e.set(...n);return e}var Ur=D({forceCheckOnFCPropTypesWithName:F(Y(L()))}),Zt="no-unused-type-props-in-args",st=null,Vr=Mr({name:Zt,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&&!st&&(st=n.map(i=>new RegExp(i)));function r(i,a,c,o,p=!0){let g=c.name,y=e.sourceCode.getScope(a).references.find(b=>b.identifier.name===g)?.resolved,S=i&&st?.some(b=>b.test(g));if(!y||!S&&y.references.filter(b=>b.isTypeReference).length>1)return;let d=y?.defs[0]?.node;if(!(p&&d?.parent?.type===$.AST_NODE_TYPES.ExportNamedDeclaration)){if(d?.type===$.AST_NODE_TYPES.TSTypeAliasDeclaration){s(i,a,o,d.typeAnnotation,!0);return}if(d?.type===$.AST_NODE_TYPES.TSInterfaceDeclaration){s(i,a,o,d.body,!0);return}}}function s(i,a,c,o,p){if(o.type===$.AST_NODE_TYPES.TSInterfaceBody){for(let g of o.body)g.type===$.AST_NODE_TYPES.TSPropertySignature&&g.key.type===$.AST_NODE_TYPES.Identifier&&c.set(g.key.name,g);return}if(o.type===$.AST_NODE_TYPES.TSTypeLiteral){Gt(c,...Jt(o));return}if(o.type===$.AST_NODE_TYPES.TSIntersectionType){for(let g of o.types)s(i,a,c,g,!0);return}p||o.type===$.AST_NODE_TYPES.TSTypeReference&&o.typeName.type===$.AST_NODE_TYPES.Identifier&&r(i,a,o.typeName,c)}function l(i,a,c){for(let o of c)if(o.type==="ObjectPattern"&&o.typeAnnotation){let p=new Map;if(s(i,a,p,o.typeAnnotation.typeAnnotation,!1),p.size===0)continue;u(o,p)}else o.type===$.AST_NODE_TYPES.AssignmentPattern&&o.left.type===$.AST_NODE_TYPES.ObjectPattern&&l(i,a,[o.left])}function u(i,a){let c=[];if(i.properties.at(-1)?.type===$.AST_NODE_TYPES.RestElement)return;for(let y of i.properties)y.type===$.AST_NODE_TYPES.Property&&y.key.type===$.AST_NODE_TYPES.Identifier&&c.push(y.key.name);let p=[],g=[];for(let[y,S]of a)c.includes(y)||(g.push(y),p.push({node:S,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,S]of p.entries())e.report({...S,fix:y===p.length-1?d=>{let b=i.properties.at(-1),T=g.join(", ");return b?b?.type===$.AST_NODE_TYPES.RestElement?null:d.insertTextAfter(b,`, ${T}`):d.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${T}`)}:void 0})}return{VariableDeclaration(i){let a=i.declarations[0];if(!a)return;let c=new Map,o=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(o){if(o.type===$.AST_NODE_TYPES.TSTypeReference&&o.typeName.type===$.AST_NODE_TYPES.Identifier)r(!0,i,o.typeName,c,!1);else if(o.type===$.AST_NODE_TYPES.TSTypeLiteral)Gt(c,...Jt(o));else if(o.type===$.AST_NODE_TYPES.TSIntersectionType)for(let p of o.types)p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier?r(!0,i,p.typeName,c,!1):s(!0,i,c,p,!0);if(c.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&&u(p,c)}}},FunctionDeclaration:function(i){l(!1,i,i.params)},ArrowFunctionExpression(i){l(!1,i,i.params)}}}}),ot={name:Zt,rule:Vr};var fe=require("@typescript-eslint/utils"),Wr=fe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),en="prefer-named-functions",Qt=new Map,Hr=Wr({name:en,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=Qt.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),Qt.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===fe.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===fe.AST_NODE_TYPES.Identifier){let s=r.id.name;if(r.id.typeAnnotation||n&&n.test(s)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==fe.AST_NODE_TYPES.BlockStatement)return;let l=r.parent,u=r.init.params,i=r.init.body,a=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(l,`${a.async?"async ":""}function ${s}(${u.map(o=>e.sourceCode.getText(o)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),at={name:en,rule:Hr};var W=require("@typescript-eslint/utils");var Yr=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nn="prefer-single-line-if",zr=D({maxLineLength:F(J()),maxNonSimpleConditionLength:F(J())}),Br=Yr({name:nn,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:[zr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==W.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 l=r.consequent.body[0];if(l.type===W.AST_NODE_TYPES.ReturnStatement){if(!sn(l))return}else if(!(l.type===W.AST_NODE_TYPES.ContinueStatement||l.type===W.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===W.AST_NODE_TYPES.LogicalExpression||r.test.type===W.AST_NODE_TYPES.ConditionalExpression)return;let u;if(t.maxNonSimpleConditionLength){let p=tn(r.test);if(!p&&r.test.type===W.AST_NODE_TYPES.UnaryExpression&&r.test.operator==="!"){let g=r.test.argument;tn(g)&&(p=!0)}if(p&&(u=n.getText(r.test),u.length>t.maxNonSimpleConditionLength))return}u||(u=n.getText(r.test));let i=n.getText(l);if(u.includes(`
15
- `))return;let a=n.getTokenAfter(r);if(a&&a.type===W.AST_TOKEN_TYPES.Punctuator&&a.value==="}"){let p=n.getTokenAfter(a);if(p&&p.type===W.AST_TOKEN_TYPES.Keyword&&(p.value==="else"||p.value==="catch"))return}let c=qr(n,r),o=`if (${u}) ${i}`;t.maxLineLength&&o.length+c.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:p=>p.replaceText(r,o)})}}}});function tn(e){return e.type===W.AST_NODE_TYPES.CallExpression||e.type===W.AST_NODE_TYPES.BinaryExpression||e.type===W.AST_NODE_TYPES.MemberExpression&&rn(e)}function rn(e){return e.object.type===W.AST_NODE_TYPES.MemberExpression?rn(e.object):e.object.type!==W.AST_NODE_TYPES.Identifier}function qr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function sn(e){if(!e.argument)return!0;let t=e.argument;return t.type===W.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===W.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===W.AST_NODE_TYPES.Literal||t.type===W.AST_NODE_TYPES.Identifier||t.type===W.AST_NODE_TYPES.TemplateLiteral||t.type===W.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===W.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===W.AST_NODE_TYPES.UnaryExpression?sn(t):!1}var lt={name:nn,rule:Br};var q=require("@typescript-eslint/utils");var Kr=q.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="react-compiler-migration",Xr=D({disallowHooks:F(Y(D({name:L(),replacement:L()}))),disallowMethods:F(Y(D({name:L(),replacement:F(L()),requireTrueProp:F(L())})))}),Jr=/eslint +react-compiler\/react-compiler: +\["error/;function Gr(e){return e.type===q.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===q.AST_NODE_TYPES.MemberExpression&&e.property.type===q.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Zr=Kr({name:on,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:[Xr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(Jr.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let s=null,l=null;if(r.callee.type===q.AST_NODE_TYPES.Identifier?(s=r.callee.name,l=r.callee):r.callee.type===q.AST_NODE_TYPES.MemberExpression&&r.callee.property.type===q.AST_NODE_TYPES.Identifier&&(s=r.callee.property.name,l=r.callee.property),s){let u=t.disallowHooks.find(i=>i.name===s);u&&l&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:u.name,replacement:u.replacement},suggest:[{messageId:"replace",data:{replacement:u.replacement},fix:i=>i.replaceText(l,u.replacement)}]})}}if(t.disallowMethods?.length&&Gr(r.callee)){for(let s of r.arguments)if(s.type===q.AST_NODE_TYPES.ObjectExpression){for(let l of s.properties)if(l.type===q.AST_NODE_TYPES.Property&&l.key.type===q.AST_NODE_TYPES.Identifier){let u=l.key.name,i=t.disallowMethods.find(a=>a.name===u);if(i){if(i.requireTrueProp){let a=i.requireTrueProp,c=!1;for(let o of s.properties)if(o.type===q.AST_NODE_TYPES.Property&&o.key.type===q.AST_NODE_TYPES.Identifier&&o.key.name===a&&o.value.type===q.AST_NODE_TYPES.Literal&&o.value.value===!0){c=!0;break}if(!c){e.report({node:l,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:a}});continue}}i.replacement&&e.report({node:l,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:a=>a.replaceText(l.key,i.replacement)}]})}}}}}}:{}}}),ct={name:on,rule:Zr};var ve=require("@typescript-eslint/utils"),Qr=ve.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="require-description",ei=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ti=/^eslint-disable-(next-)?line$/u,ni=Qr({name:an,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 s of n.getAllComments()){let l=ri(s);l!=null&&(r.has(l.kind)||l.description||e.report({loc:si(s.loc),messageId:"missingDescription"}))}}}}}),ln={name:an,rule:ni};function ri(e){let{text:t,description:n}=ii(e.value);if(!t)return null;let r=ei.exec(t);if(!r)return null;let s=r[1];if(!s)return null;let l=ti.test(s);if(e.type===ve.TSESTree.AST_TOKEN_TYPES.Line&&!l||l&&e.loc.start.line!==e.loc.end.line)return null;let u=t.slice(r.index+s.length);return{kind:s,value:u.trim(),description:n}}function ii(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function si(e){return{start:{line:e.start.line,column:-1},end:e.end}}function pn(e){return/^use[A-Z0-9]/.test(e)}function Oe(e){return e.type==="Identifier"?pn(e.name):e.type==="MemberExpression"&&!e.computed&&Oe(e.property)?e.object.type==="Identifier":!1}function fn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function mn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function dn(e){return!!(e.parent&&e.parent.callee&&mn(e.parent.callee,"forwardRef"))}function yn(e){return!!(e.parent&&e.parent.callee&&mn(e.parent.callee,"memo"))}function ut(e){for(;e;){let t=Sn(e);if(t&&(fn(t)||Oe(t))||dn(e)||yn(e))return!0;e=e.parent}return!1}function cn(e){return!1}function pt(e){return!1}var oi=/eslint +react-compiler\/react-compiler: +\["error/,gn={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(oi.test(a.value))return{CallExpression(c){let o=null;c.callee.name==="useMemo"?o="useMemo":c.callee.name==="useCallback"&&(o="useCallback"),o&&e.report({node:c,message:`"${o}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),r=null,s=[],l=[],u=new WeakSet;function i(a){for(let c of a.references){let o=c.identifier.parent;if(o.type==="VariableDeclarator"&&o.init&&o.init.type==="CallExpression"&&o.init.callee&&cn(o.init.callee))for(let p of c.resolved.references)p!==c&&u.add(p.identifier)}}return{onCodePathSegmentStart:a=>l.push(a),onCodePathSegmentEnd:()=>l.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(a,c){let o=s.pop();if(o.size===0)return;let p=new Set;function g(h,w){let{cache:R}=g,O=R.get(h.id),j=new Set(w);if(j.has(h.id)){let k=[...j],H=k.slice(k.indexOf(h.id)+1);for(let Q of H)p.add(Q);return BigInt("0")}if(j.add(h.id),O!==void 0)return O;if(a.thrownSegments.includes(h))O=BigInt("0");else if(h.prevSegments.length===0)O=BigInt("1");else{O=BigInt("0");for(let k of h.prevSegments)O+=g(k,j)}return h.reachable&&O===BigInt("0")?R.delete(h.id):R.set(h.id,O),O}function y(h,w){let{cache:R}=y,O=R.get(h.id),j=new Set(w);if(j.has(h.id)){let k=Array.from(j),H=k.slice(k.indexOf(h.id)+1);for(let Q of H)p.add(Q);return BigInt("0")}if(j.add(h.id),O!==void 0)return O;if(a.thrownSegments.includes(h))O=BigInt("0");else if(h.nextSegments.length===0)O=BigInt("1");else{O=BigInt("0");for(let k of h.nextSegments)O+=y(k,j)}return R.set(h.id,O),O}function S(h){let{cache:w}=S,R=w.get(h.id);if(R===null)return 1/0;if(R!==void 0)return R;if(w.set(h.id,null),h.prevSegments.length===0)R=1;else{R=1/0;for(let O of h.prevSegments){let j=S(O);j<R&&(R=j)}R+=1}return w.set(h.id,R),R}g.cache=new Map,y.cache=new Map,S.cache=new Map;let d=y(a.initialSegment),b=Sn(c),T=ut(c),N=b?fn(b)||Oe(b):dn(c)||yn(c),v=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let w=S(h);w<v&&(v=w)}for(let[h,w]of o){if(!h.reachable)continue;let R=h.nextSegments.length===0?v<=S(h):v<S(h),O=g(h)*y(h),j=p.has(h.id);for(let k of w)if(j&&!pt(k)&&e.report({node:k,message:`React Hook "${t(k)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),N){if(c.async&&e.report({node:k,message:`React Hook "${t(k)}" cannot be called in an async function.`}),!j&&O!==d&&!pt(k)){let Q=`React Hook "${t(k)}" 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:k,message:Q})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let H=`React Hook "${t(k)}" 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:k,message:H})}else if(b){let H=`React Hook "${t(k)}" is called in function "${t(b)}" 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:k,message:H})}else if(c.type==="Program"){let H=`React Hook "${t(k)}" 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:k,message:H})}else if(T&&!pt(k)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let Q=c.parent;if(Q.parent.type==="VariableDeclarator"&&pn(Q.parent.id.name))return}let H=`React Hook "${t(k)}" 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:k,message:H})}}},CallExpression(a){if(Oe(a.callee)){let c=un(s),o=un(l),p=c.get(o);p||(p=[],c.set(o,p)),p.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||cn(a.callee))&&a.arguments.length>0&&(r=a)},Identifier(a){r==null&&u.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===r&&(r=null)},FunctionDeclaration(a){ut(a)&&i(n(a))},ArrowFunctionExpression(a){ut(a)&&i(n(a))}}}};function Sn(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 un(e){return e[e.length-1]}var Tn={[ot.name]:ot.rule,[Be.name]:Be.rule,[ze.name]:ze.rule,"rules-of-hooks":gn,"exhaustive-deps":Ot,"require-description":ln.rule,[qe.name]:qe.rule,[Xe.name]:Xe.rule,[at.name]:at.rule,[je.name]:je.rule,[Ye.name]:Ye.rule,[et.name]:et.rule,[lt.name]:lt.rule,[Qe.name]:Qe.rule,[Ke.name]:Ke.rule,[Me.name]:Me.rule,[ct.name]:ct.rule,[De.name]:De.rule,[He.name]:He.rule,[nt.name]:nt.rule,[rt.name]:rt.rule,[it.name]:it.rule};var ai={rules:Tn};0&&(module.exports={extendedLintPlugin});
14
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let A=o.acquire(g),L=new Set,j=null;{let p=A.upper;for(;p&&(L.add(p),p.type!=="function");)p=p.upper;if(!p)return;j=p}let R=Array.isArray;function U(p){if(!R(p.defs))return!1;let d=p.defs[0];if(d==null||d.node.type!=="VariableDeclarator")return!1;let b=d.node.init;if(b==null)return!1;for(;b.type==="TSAsExpression";)b=b.expression;let x=d.node.parent;if(x==null&&(Ye(j.block,d.node.id),x=d.node.parent,x==null))return!1;if(x.kind==="const"&&b.type==="Literal"&&(typeof b.value=="string"||typeof b.value=="number"||b.value===null))return!0;if(b.type!=="CallExpression")return!1;let w=b.callee;if(w.type==="MemberExpression"&&w.object.name==="React"&&w.property!=null&&!w.computed&&(w=w.property),w.type!=="Identifier")return!1;let I=d.node.id,{name:k}=w;if(k==="useRef"&&I.type==="Identifier")return!0;if(Jn(w)&&I.type==="Identifier"){for(let P of p.references)P!==I&&m.add(P.identifier);return!0}else if(k==="useState"||k==="useReducer"){if(I.type==="ArrayPattern"&&I.elements.length===2&&R(p.identifiers)){if(I.elements[1]===p.identifiers[0]){if(k==="useState"){let P=p.references,J=0;for(let ee=0;ee<P.length;ee++){if(P[ee].isWrite()&&J++,J>1)return!1;l.set(P[ee].identifier,I.elements[0])}}return!0}else if(I.elements[0]===p.identifiers[0]){if(k==="useState"){let P=p.references;for(let J=0;J<P.length;J++)c.add(P[J].identifier)}return!1}}}else if(k==="useTransition"&&I.type==="ArrayPattern"&&I.elements.length===2&&Array.isArray(p.identifiers)&&I.elements[1]===p.identifiers[0])return!0;return!1}function B(p){if(!R(p.defs))return!1;let d=p.defs[0];if(d==null||d.node==null||d.node.id==null)return!1;let b=d.node,x=j.childScopes,w=null,I;for(I=0;I<x.length;I++){let k=x[I],P=k.block;if(b.type==="FunctionDeclaration"&&P===b||b.type==="VariableDeclarator"&&P.parent===b){w=k;break}}if(w==null)return!1;for(I=0;I<w.through.length;I++){let k=w.through[I];if(k.resolved!=null&&L.has(k.resolved.scope)&&!ye(k.resolved))return!1}return!0}let ye=y(U,f),Tn=y(B,h),dt=new Map;function hn(p){let d=p.from,b=!1;for(;d.block!==g;)d.type==="function"&&(b=d.block.parent!=null&&d.block.parent.type==="ReturnStatement"),d=d.upper;return b}let X=new Map,Pe=new Map;yt(A);function yt(p){for(let d of p.references){if(!d.resolved||!L.has(d.resolved.scope))continue;let b=Ye(g,d.identifier),x=At(b),w=te(x,Pe);if(v&&x.type==="Identifier"&&(x.parent.type==="MemberExpression"||x.parent.type==="OptionalMemberExpression")&&!x.parent.computed&&x.parent.property.type==="Identifier"&&x.parent.property.name==="current"&&hn(d)&&dt.set(w,{reference:d,dependencyNode:x}),x.parent.type==="TSTypeQuery"||x.parent.type==="TSTypeReference")continue;let I=d.resolved.defs[0];if(I!=null&&!(I.node!=null&&I.node.init===g.parent)&&I.type!=="TypeParameter")if(X.has(w))X.get(w).references.push(d);else{let k=d.resolved,P=ye(k)||Tn(k);X.set(w,{isStable:P,references:[d]})}}for(let d of p.childScopes)yt(d)}dt.forEach(({reference:p,dependencyNode:d},b)=>{let x=p.resolved.references,w=!1;for(let I=0;I<x.length;I++){let{identifier:k}=x[I],{parent:P}=k;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){w=!0;break}}w||i({node:d.parent.property,message:`The ref value '${b}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${b}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Fe=new Set;function En(p,d){Fe.has(d)||(Fe.add(d),i({node:p,message:`Assignments to the '${d}' variable from inside React Hook ${n(C)} 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(C)}.`}))}let ge=new Set;if(X.forEach(({isStable:p,references:d},b)=>{p&&ge.add(b),d.forEach(x=>{x.writeExpr&&En(x.writeExpr,b)})}),Fe.size>0)return;if(!O){let p=null;if(X.forEach(({isStable:d,references:b},x)=>{p||b.forEach(w=>{if(p)return;let I=w.identifier;if(!l.has(I))return;let P=w.from;for(;P.type!=="function";)P=P.upper;P.block===g&&(p=x)})}),p){let{suggestedDependencies:d}=We({dependencies:X,declaredDependencies:[],stableDependencies:ge,externalDependencies:new Set,isEffect:!0});i({node:C,message:`React Hook ${S} contains a call to '${p}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+d.join(", ")+`] as a second argument to the ${S} Hook.`,suggest:[{desc:`Add dependencies array: [${d.join(", ")}]`,fix(b){return b.insertTextAfter(g,`, [${d.join(", ")}]`)}}]})}return}let fe=[],me=new Set;O.type!=="ArrayExpression"?i({node:O,message:`React Hook ${n(C)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):O.elements.forEach(p=>{if(p===null)return;if(p.type==="SpreadElement"){i({node:p,message:`React Hook ${n(C)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}m.has(p)&&i({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 d;try{d=te(p,Pe)}catch(w){if(/Unsupported node type/.test(w.message)){p.type==="Literal"?X.has(p.value)?i({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?`}):i({node:p,message:`The ${p.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:p,message:`React Hook ${n(C)} 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 b=p;for(;b.type==="MemberExpression"||b.type==="OptionalMemberExpression"||b.type==="ChainExpression";)b=b.object||b.expression.object;let x=!j.through.some(w=>w.identifier===b);fe.push({key:d,node:p}),x||me.add(d)});let{suggestedDependencies:bn,unnecessaryDependencies:Se,missingDependencies:ie,duplicateDependencies:gt}=We({dependencies:X,declaredDependencies:fe,stableDependencies:ge,externalDependencies:me,isEffect:v}),Te=bn;if(gt.size+ie.size+Se.size===0){if(t)return;Bn({declaredDependencies:fe,declaredDependenciesNode:O,componentScope:j,scope:A}).forEach(({construction:d,isUsedOutsideOfHook:b,depType:x})=>{let w=x==="function"?"useCallback":"useMemo",I=x==="function"?"definition":"initialization",k=`wrap the ${I} of '${d.name.name}' in its own ${w}() Hook.`,P=b?`To fix this, ${k}`:`Move it inside the ${S} callback. Alternatively, ${k}`,J=x==="conditional"||x==="logical expression"?"could make":"makes",ee=`The '${d.name.name}' ${x} ${J} the dependencies of ${S} Hook (at line ${O.loc.start.line}) change on every render. ${P}`,St;b&&d.type==="Variable"&&x==="function"&&(St=[{desc:`Wrap the ${I} of '${d.name.name}' in its own ${w}() Hook.`,fix(Tt){let[Cn,In]=w==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Tt.insertTextBefore(d.node.init,Cn),Tt.insertTextAfter(d.node.init,In)]}}]),i({node:d.node,message:ee,suggest:St})});return}!v&&ie.size>0&&(Te=We({dependencies:X,declaredDependencies:[],stableDependencies:ge,externalDependencies:me,isEffect:v}).suggestedDependencies);function xn(){if(fe.length===0)return!0;let p=fe.map(b=>b.key),d=p.slice().sort();return p.join(",")===d.join(",")}xn()&&Te.sort();function Ne(p){let d=p.split("."),b="";for(let x=0;x<d.length;x++){if(x!==0){let w=d.slice(0,x+1).join("."),I=Pe.get(w)===!0;b+=I?"?.":"."}b+=d[x]}return b}function Le(p,d,b,x){return p.size===0?null:(p.size>1?"":d+" ")+b+" "+(p.size>1?"dependencies":"dependency")+": "+Kn(Array.from(p).sort().map(w=>"'"+Ne(w)+"'"))+`. Either ${x} ${p.size>1?"them":"it"} or remove the dependency array.`}let Z="";if(Se.size>0){let p=null;if(Array.from(Se.keys()).forEach(d=>{p===null&&d.endsWith(".current")&&(p=d)}),p!==null)Z=` Mutable values like '${p}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(me.size>0){let d=Array.from(me)[0];A.set.has(d)||(Z=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!Z&&ie.has("props")){let p=X.get("props");if(p==null)return;let d=p.references;if(!Array.isArray(d))return;let b=!0;for(let x=0;x<d.length;x++){let w=d[x],I=Ye(j.block,w.identifier);if(!I){b=!1;break}let k=I.parent;if(k==null){b=!1;break}if(k.type!=="MemberExpression"&&k.type!=="OptionalMemberExpression"){b=!1;break}}b&&(Z=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${S} call and refer to those specific props inside ${n(C)}.`)}if(!Z&&ie.size>0){let p=null;ie.forEach(d=>{if(p)return;let b=j.set.get(d),x=X.get(d);if(x.references[0].resolved!==b)return;let w=b.defs[0];if(w==null||w.name==null||w.type!=="Parameter")return;let I=!1,k;for(let P=0;P<x.references.length;P++)if(k=x.references[P].identifier,k!=null&&k.parent!=null&&(k.parent.type==="CallExpression"||k.parent.type==="OptionalCallExpression")&&k.parent.callee===k){I=!0;break}I&&(p=d)}),p!==null&&(Z=` If '${p}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!Z&&ie.size>0){let p=null;if(ie.forEach(d=>{if(p!==null)return;let x=X.get(d).references,w,I;for(let k=0;k<x.length;k++){for(w=x[k].identifier,I=w.parent;I!=null&&I!==j.block;){if(I.type==="CallExpression"){let P=l.get(I.callee);if(P!=null){if(P.name===d)p={missingDep:d,setter:I.callee.name,form:"updater"};else if(c.has(w))p={missingDep:d,setter:I.callee.name,form:"reducer"};else{let J=x[k].resolved;if(J!=null){let ee=J.defs[0];ee!=null&&ee.type==="Parameter"&&(p={missingDep:d,setter:I.callee.name,form:"inlineReducer"})}}break}}I=I.parent}if(p!==null)break}}),p!==null)switch(p.form){case"reducer":Z=` You can also replace multiple useState variables with useReducer if '${p.setter}' needs the current value of '${p.missingDep}'.`;break;case"inlineReducer":Z=` 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":Z=` 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.")}}i({node:O,message:`React Hook ${n(C)} has `+(Le(ie,"a","missing","include")||Le(Se,"an","unnecessary","exclude")||Le(gt,"a","duplicate","omit"))+Z,suggest:[{desc:`Update the dependencies array to be: [${Te.map(Ne).join(", ")}]`,fix(p){return p.replaceText(O,`[${Te.map(Ne).join(", ")}]`)}}]})}function E(g){let O=qn(g.callee,u);if(O===-1)return;let C=g.arguments[O],S=g.callee,v=Pt(S).name,A=g.arguments[O+1],L=/Effect($|[^a-z])/g.test(v);if(!C){i({node:S,message:`React Hook ${v} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!L)){if(!A&&!L){(v==="useMemo"||v==="useCallback")&&i({node:S,message:`React Hook ${v} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(C.type){case"FunctionExpression":case"ArrowFunctionExpression":T(C,A,S,v,L);return;case"Identifier":if(!A||A.elements&&A.elements.some(U=>U&&U.type==="Identifier"&&U.name===C.name))return;let j=r(g).set.get(C.name);if(j==null||j.defs==null)return;let R=j.defs[0];if(!R||!R.node||R.type!=="Variable"&&R.type!=="FunctionName")break;switch(R.node.type){case"FunctionDeclaration":T(R.node,A,S,v,L);return;case"VariableDeclarator":let U=R.node.init;if(!U)break;switch(U.type){case"ArrowFunctionExpression":case"FunctionExpression":T(U,A,S,v,L);return}break}break;default:i({node:S,message:`React Hook ${v} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:S,message:`React Hook ${v} has a missing dependency: '${C.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${C.name}]`,fix(j){return j.replaceText(A,`[${C.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(zn.test(g.value))return t=!0,{CallExpression:O=>E(O,!0)}}return{CallExpression:g=>E(g)}}};function We({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:s}){let a=u();function u(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,E)=>{let g=i(a,E);g.isUsed=!0,o(a,E,O=>{O.isSubtreeUsed=!0})}),t.forEach(({key:T})=>{let E=i(a,T);E.isSatisfiedRecursively=!0}),n.forEach(T=>{let E=i(a,T);E.isSatisfiedRecursively=!0});function i(T,E){let g=E.split("."),O=T;for(let C of g){let S=O.children.get(C);S||(S=u(),O.children.set(C,S)),O=S}return O}function o(T,E,g){let O=E.split("."),C=T;for(let S of O){let v=C.children.get(S);if(!v)return;g(v),C=v}}let l=new Set,c=new Set;f(a,l,c,T=>T);function f(T,E,g,O){T.children.forEach((C,S)=>{let v=O(S);if(C.isSatisfiedRecursively){C.isSubtreeUsed&&g.add(v);return}if(C.isUsed){E.add(v);return}f(C,E,g,A=>v+"."+A)})}let h=[],m=new Set,y=new Set;return t.forEach(({key:T})=>{c.has(T)?h.indexOf(T)===-1?h.push(T):y.add(T):m.add(T)}),l.forEach(T=>{h.push(T)}),{suggestedDependencies:h,unnecessaryDependencies:m,duplicateDependencies:y,missingDependencies:l}}function se(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 se(e.consequent)!=null||se(e.alternate)!=null?"conditional":null;case"LogicalExpression":return se(e.left)!=null||se(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return se(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return se(e.expression);case"TSAsExpression":return se(e.expression)}return null}function Bn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let s=e.map(({key:u})=>{let i=n.variables.find(l=>l.name===u);if(i==null)return null;let o=i.defs[0];if(o==null)return null;if(o.type==="Variable"&&o.node.type==="VariableDeclarator"&&o.node.id.type==="Identifier"&&o.node.init!=null){let l=se(o.node.init);if(l!=null)return[i,l]}return o.type==="FunctionName"&&o.node.type==="FunctionDeclaration"?[i,"function"]:o.type==="ClassName"&&o.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(u){let i=!1;for(let o=0;o<u.references.length;o++){let l=u.references[o];if(l.writeExpr){if(i)return!0;i=!0;continue}let c=l.from;for(;c!==r&&c!=null;)c=c.upper;if(c!==r&&!Ft(t,l.identifier))return!0}return!1}return s.map(([u,i])=>({construction:u.defs[0],depType:i,isUsedOutsideOfHook:a(u)}))}function At(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)?At(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function He(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function te(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=te(e.object,t),r=te(e.property,null),s=`${n}.${r}`;return He(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=te(e.object,t),r=te(e.property,null),s=`${n}.${r}`;return He(e,t,s),s}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=te(n.object,t),s=te(n.property,null),a=`${r}.${s}`;return He(n,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Pt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function qn(e,t){let n=Pt(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=te(n,null)}catch(s){if(/Unsupported node type/.test(s.message))return 0;throw s}return t.additionalHooks.test(r)?0:-1}else return-1}}function Ye(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),Xn(r,t))return r;if(Ft(r,t))for(let[s,a]of Object.entries(r))s!=="parent"&&(Ot(a)?(a.parent=r,n.push(a)):Array.isArray(a)&&a.forEach(u=>{Ot(u)&&(u.parent=r,n.push(u))}))}return null}function Kn(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 Ot(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Xn(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 Ft(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Jn(e){return!1}var oe=require("@typescript-eslint/utils");var q=_e(require("typescript")),Gn=oe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="improved-no-unnecessary-condition",Zn=_({}),Qn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],er=new Set(Qn),ze={name:Nt,rule:Gn({name:Nt,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:[Zn]},defaultOptions:[{}],create(e){let t=oe.ESLintUtils.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===oe.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function s(i){return i.flags&q.default.TypeFlags.Any||i.flags&q.default.TypeFlags.Unknown?null:i.flags&q.default.TypeFlags.StringLike?["string"]:i.flags&q.default.TypeFlags.NumberLike?["number"]:i.flags&q.default.TypeFlags.BigIntLike?["bigint"]:i.flags&q.default.TypeFlags.BooleanLike?["boolean"]:i.flags&q.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&q.default.TypeFlags.Undefined||i.flags&q.default.TypeFlags.Void?["undefined"]:i.flags&q.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&q.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&q.default.TypeFlags.NonPrimitive?["object"]:i.flags&q.default.TypeFlags.Never?["never"]:null}function a(i){if(!n)return null;let o=t.esTreeNodeToTSNodeMap.get(i),l=n.getTypeAtLocation(o.expression);if(l.flags&q.default.TypeFlags.Any||l.flags&q.default.TypeFlags.Unknown)return null;let c=[];if(l.isUnion()){for(let h of l.types){let m=s(h);if(m)c.push(...m);else return null}return c}let f=s(l);return f?(c.push(...f),c):null}function u(i){if(!(i.operator==="==="||i.operator==="!=="))return;let l=null,c=null;if(r(i.left)?(l=i.left,c=i.right.type===oe.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(l=i.right,c=i.left.type===oe.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!l||!c||!tr(c,er))return;let f=a(l);if(!f)return;let h=i.operator==="!==",m=f.includes(c);f.length===1?m&&!h?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ce(l,e),type:c}}):!m&&h?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ce(l,e),type:Array.from(f)[0]}}):!m&&!h?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ce(l,e),actualType:Ce(f),conditionType:c}}):m&&h&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ce(l,e),actualType:Ce(f),conditionType:c}}):!m&&!h?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ce(l,e),actualType:Ce(f),conditionType:c}}):!m&&h&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ce(l,e),type:Ce(f)}})}return{BinaryExpression:u}}})};function Ce(e){return Array.from(new Set(e)).join(" | ")||"never"}function ce(e,t){let n=e.argument;return n.type===oe.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function tr(e,t){return t.has(e)}var Ie=require("@typescript-eslint/utils");var nr=Ie.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="no-call-with-explicit-generics",rr=_({functions:Y(N())}),ir=nr({name:Lt,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:[rr]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:s}=r;s.type===Ie.AST_NODE_TYPES.Identifier&&n.has(s.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),Be={name:Lt,rule:ir};var ae=require("@typescript-eslint/utils"),sr=ae.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="no-call-with-inferred-generics",or=sr({name:_t,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:s}=r;if(s.type!==ae.AST_NODE_TYPES.Identifier)return;let a=n.get(s.name);if(!a)return;let{minGenerics:u=1,allowAny:i,disallowTypes:o=t.disallowTypes}=a;(r.typeArguments?.params.length||0)<(u||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:u||0}}),!(i&&!o)&&r.typeArguments?.params?.some(c=>!i&&c.type===ae.AST_NODE_TYPES.TSAnyKeyword||o&&c.type===ae.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===ae.AST_NODE_TYPES.Identifier&&o.includes(c.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),qe={name:_t,rule:or};var de=require("@typescript-eslint/utils"),ar=de.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dt="no-commented-out-code",lr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],cr=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],ur=ar({name:Dt,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 s of lr)if(r.startsWith(s))return{wrongPattern:s};for(let s of cr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}return{Program(){let r=e.sourceCode.getAllComments();for(let s of r)if(s.type===de.TSESTree.AST_TOKEN_TYPES.Line||s.type===de.TSESTree.AST_TOKEN_TYPES.Block){let a=t(s.value);a&&e.report({node:s,messageId:"commentedOutCode",data:{wrongPattern:a.wrongPattern}})}}}}}),Ke={name:Dt,rule:ur};var we=require("@typescript-eslint/utils"),pr=we.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jt="no-default-export",fr=pr({name:jt,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===we.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Xe={name:jt,rule:fr};var Mt=require("@typescript-eslint/utils"),mr=Mt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="no-leaked-text-in-jsx",dr=[",",";","[","]","(",")"],yr=mr({name:$t,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="";dr.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),Je={name:$t,rule:yr};var ne=require("@typescript-eslint/utils"),gr=ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vt="no-non-camel-case-functions",Sr=/^[a-z][a-zA-Z0-9]*$/;function Ut(e){return e.typeName.type===ne.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===ne.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ne.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var Tr=gr({name:Vt,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&&!Sr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ne.AST_NODE_TYPES.TSTypeReference?Ut(n):n.type===ne.AST_NODE_TYPES.TSUnionType&&n.types.some(s=>s.type===ne.AST_NODE_TYPES.TSTypeReference&&Ut(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Ge={name:Vt,rule:Tr};var $=require("@typescript-eslint/utils");var Ze=require("@typescript-eslint/utils");function ue(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:ue(e.parent,t,n===1/0?n:n-1)}function*Qe(e){yield e,e.parent&&(yield*Qe(e.parent))}function et(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function Wt(e,t,n){let s=n.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Ze.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===Ze.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return s?s.references.filter(a=>!a.init):[]}var hr=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="no-optional-root-props",Er=hr({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(r){let a=e.sourceCode.getDeclaredVariables(r)[0];if(!a||a.references.length!==1)return!1;let u=a.references[0];if(!u)return!1;for(let i of Qe(u.identifier)){if("returnType"in i||i.type===$.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let o=i.parent;if(!o)return!1;if(o.type===$.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&o.parent.type===$.TSESTree.AST_NODE_TYPES.TSTypeReference&&o.parent.typeName.type===$.TSESTree.AST_NODE_TYPES.Identifier&&o.parent.typeName.name==="FC"){let c=ue(o.parent.parent,$.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let f=Re(c,e.sourceCode);return f?!(f.parent.type===$.TSESTree.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===$.TSESTree.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(i.type===$.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(o.type===$.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let l=ue(o,$.TSESTree.AST_NODE_TYPES.VariableDeclaration);return l?!!Re(l,e.sourceCode):!1}if(o.type===$.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Re(o,e.sourceCode)}return!1}function n(r){r.key.type!==$.TSESTree.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:s=>{let a=ue(r,$.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let u=e.sourceCode.getText(a);return s.replaceText(a,u.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===$.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(ve(r)||!t(r)))for(let s of r.typeAnnotation.members)s.type===$.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(s)},TSInterfaceDeclaration(r){if(!(ve(r)||!t(r)))for(let s of r.body.body)s.type===$.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(s)},TSTypeReference(r){if(r.typeName.type!==$.TSESTree.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let s=r.typeArguments.params[0];if(s.type!==$.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=ue(r.parent,$.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let u=Re(a,e.sourceCode);if(!(!u||u.parent.type===$.TSESTree.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===$.TSESTree.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"))for(let o of s.members)o.type===$.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)}}}});function ve(e){return e?e.parent?.type===$.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===$.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Re(e,t){if(ve(e))return;let n;if(e.type===$.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===$.TSESTree.AST_NODE_TYPES.Identifier&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===$.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let s=r.variables.find(u=>u.identifiers.includes(n));if(!s)return;let a=s.references.filter(u=>u.identifier!==n);if(!(a.length!==1||!a[0])&&!ve(a[0].identifier.parent.parent))return a[0].identifier}var tt={name:Ht,rule:Er};var Yt=require("@typescript-eslint/utils"),Oe=_e(require("path"));var br=Yt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="no-relative-imports",xr=_({find:N(),replacement:N()}),Cr=_({aliases:Y(xr),rootDir:F(N()),allowNotFoundAliases:F(le()),_dev_simulateFileName:F(N())}),Ir=br({name:zt,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 r(u){return u.startsWith(".")||u.startsWith("..")}function s(u,i){let o=Oe.default.dirname(i);return Oe.default.resolve(o,u)}function a(u){let i=t.rootDir??process.cwd(),o=Oe.default.relative(i,u);if(o.startsWith("."))return null;o.startsWith("/")||(o=`/${o}`);for(let{find:l,replacement:c}of t.aliases)if(o.startsWith(c)){let f=o.replace(c,l);return{alias:l,newPath:f}}return null}return{ImportDeclaration(u){let i=u.source.value;if(!r(i))return;let o=s(i,n),l=a(o);!l&&t.allowNotFoundAliases||e.report({node:u,messageId:l?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:l?.alias},fix:l?c=>c.replaceText(u.source,`'${l.newPath}'`):void 0})}}}}),nt={name:zt,rule:Ir};var re=require("@typescript-eslint/utils");var rt=_e(require("typescript")),wr=re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt="no-unnecessary-casting",Rr=_({additionalCastFunctions:F(Y(_({name:N(),expectedType:Ee(["string","number"])})))}),it={name:Bt,rule:wr({name:Bt,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[Rr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],s=re.ESLintUtils.getParserServices(e,!0),a=s.program?.getTypeChecker();if(!a||!s.program)throw new Error("TypeScript services or program not available");function u(c,f){switch(c.type){case re.AST_NODE_TYPES.Literal:return f==="number"?typeof c.value=="number":typeof c.value=="string";case re.AST_NODE_TYPES.TemplateLiteral:return f==="string";case re.AST_NODE_TYPES.UnaryExpression:return f==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function i(c,f){return f==="number"?!!(c.flags&rt.TypeFlags.NumberLike):!!(c.flags&rt.TypeFlags.StringLike)}function o(c,f){return h=>h.replaceText(c,e.sourceCode.getText(f))}function l(c){if(!a||c.arguments.length!==1)return;let f=c.arguments[0];if(!f||f.type===re.AST_NODE_TYPES.SpreadElement)return;let{callee:h}=c;if(h.type!==re.AST_NODE_TYPES.Identifier)return;let m=h.name,y=r.find(E=>E.name===m);if(!y)return;if(u(f,y.expectedType)||i(a.getTypeAtLocation(s.esTreeNodeToTSNodeMap.get(f)),y.expectedType)){let E,g;m==="Number"?E="unnecessaryNumberCasting":m==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",g={name:y.name,type:y.expectedType}),e.report({node:c,messageId:E,...g?{data:g}:{},fix:o(c,f)})}}return{CallExpression:l}}})};var V=require("@typescript-eslint/utils");var vr=_({selectors:Y(_({name:N(),selectorProp:F(N()),selectorArgPos:F(G()),returnProp:F(N())}))}),Or=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="no-unused-selected-values",st={name:qt,rule:Or({name:qt,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[vr]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.map(s=>[s.name,s]));return{VariableDeclarator(s){let a=null;if(s.init?.type===V.AST_NODE_TYPES.CallExpression&&(a=s.init),!a)return;let u=Ar(a);if(!u)return;let i=r.get(u);if(!i)return;let o=kr(a,i.selectorArgPos??0,i.selectorProp);if(!o)return;let l=Pr(o);if(!l)return;let c=Kt(l.properties,void 0);if(!c)return;if(s.id.type===V.AST_NODE_TYPES.ObjectPattern){let m=Kt(s.id.properties,i.returnProp);if(!m)return;for(let[y,T]of c)m.has(y)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:y}});return}if(s.id.type!==V.AST_NODE_TYPES.Identifier||i.returnProp)return;let f=Fr(s,e.sourceCode);if(f.length===0)return;let h=new Set;for(let m of f){if(m.identifier.parent.type!==V.AST_NODE_TYPES.MemberExpression)return;let y=m.identifier.parent.property;if(y.type!==V.AST_NODE_TYPES.Identifier)return;h.add(y.name)}for(let[m,y]of c)h.has(m)||e.report({node:y,messageId:"unusedSelectedValue",data:{name:m}})}}}})};function kr(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===V.AST_NODE_TYPES.ArrowFunctionExpression||r.type===V.AST_NODE_TYPES.FunctionExpression)return r;if(n&&r.type===V.AST_NODE_TYPES.ObjectExpression){let s=r.properties.find(u=>u.type===V.AST_NODE_TYPES.Property&&u.key.type===V.AST_NODE_TYPES.Identifier&&u.key.name===n);if(s?.type!==V.AST_NODE_TYPES.Property)return null;let a=s.value;if(a.type===V.AST_NODE_TYPES.ArrowFunctionExpression||a.type===V.AST_NODE_TYPES.FunctionExpression)return a}return null}function Ar(e){return e.callee.type===V.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===V.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===V.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Pr(e){if(e.body.type===V.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===V.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===V.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==V.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function Kt(e,t){let n=e;if(t){let s=e.find(a=>a.type===V.AST_NODE_TYPES.Property&&a.key.type===V.AST_NODE_TYPES.Identifier&&a.key.name===t);if(s?.type!==V.AST_NODE_TYPES.Property||s.value.type!==V.AST_NODE_TYPES.ObjectPattern)return null;n=s.value.properties}let r=new Map;for(let s of n){if(s.type!==V.AST_NODE_TYPES.Property||s.key.type!==V.AST_NODE_TYPES.Identifier)return null;r.set(s.key.name,s)}return r.size>0?r:null}function Fr(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(s=>s.identifier!==e.id):[]}var W=require("@typescript-eslint/utils");var ot=be({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===W.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let r=null,s=!1;return{CallExpression(a){if(s)return;if(!r){let i=Nr(a);i&&(r=i);return}let u=Lr(a,e.sourceCode);if(u){s=!0;for(let i of u)r.delete(i);if(r.size!==0)for(let[i,o]of r)e.report({node:o,messageId:"unusedField",data:{name:i}})}}}}});function Nr(e){if(!(e.callee.type===W.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==W.AST_NODE_TYPES.ObjectExpression)return null;let r=et(n.properties,a=>a.type!==W.AST_NODE_TYPES.Property||a.key.type!==W.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===W.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===W.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===W.AST_NODE_TYPES.FunctionExpression?_r(a.value):null);if(!r)return null;let s=new Map;for(let a of r.properties)a.type===W.AST_NODE_TYPES.Property&&a.key.type===W.AST_NODE_TYPES.Identifier&&s.set(a.key.name,a);return s}function Lr(e,t){if(!(e.callee.type===W.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==W.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==W.AST_NODE_TYPES.ObjectPattern||!et(e.parent.id.properties,u=>u.type===W.AST_NODE_TYPES.Property&&u.key.type===W.AST_NODE_TYPES.Identifier&&u.key.name==="formFields"&&u))return null;let s=Wt(e.parent,"formFields",t),a=new Set;for(let{identifier:u}of s){if(u.type!==W.AST_NODE_TYPES.Identifier||u.parent.type===W.AST_NODE_TYPES.Property&&u.parent.parent.type===W.AST_NODE_TYPES.ObjectExpression&&u.parent.parent.parent.type===W.AST_NODE_TYPES.ReturnStatement||u.parent.type===W.AST_NODE_TYPES.ReturnStatement)return null;if(u.parent.type===W.AST_NODE_TYPES.MemberExpression){if(u.parent.object.type!==W.AST_NODE_TYPES.Identifier||u.parent.property.type!==W.AST_NODE_TYPES.Identifier)return null;a.add(u.parent.property.name)}}return a}function _r(e){if(e.body.type===W.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===W.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===W.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==W.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var M=require("@typescript-eslint/utils");var Dr=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Xt(e){let t=[];for(let n of e.members)n.type===M.AST_NODE_TYPES.TSPropertySignature&&n.key.type===M.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function Jt(e,...t){for(let n of t)e.set(...n);return e}var jr=_({forceCheckOnFCPropTypesWithName:F(Y(N()))}),Gt="no-unused-type-props-in-args",at=null,Mr=Dr({name:Gt,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:[jr],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!at&&(at=n.map(i=>new RegExp(i)));function r(i,o,l,c,f=!0){let h=l.name,m=e.sourceCode.getScope(o).references.find(E=>E.identifier.name===h)?.resolved,y=i&&at?.some(E=>E.test(h));if(!m||!y&&m.references.filter(E=>E.isTypeReference).length>1)return;let T=m?.defs[0]?.node;if(!(f&&T?.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration)){if(T?.type===M.AST_NODE_TYPES.TSTypeAliasDeclaration){s(i,o,c,T.typeAnnotation,!0);return}if(T?.type===M.AST_NODE_TYPES.TSInterfaceDeclaration){s(i,o,c,T.body,!0);return}}}function s(i,o,l,c,f){if(c.type===M.AST_NODE_TYPES.TSInterfaceBody){for(let h of c.body)h.type===M.AST_NODE_TYPES.TSPropertySignature&&h.key.type===M.AST_NODE_TYPES.Identifier&&l.set(h.key.name,h);return}if(c.type===M.AST_NODE_TYPES.TSTypeLiteral){Jt(l,...Xt(c));return}if(c.type===M.AST_NODE_TYPES.TSIntersectionType){for(let h of c.types)s(i,o,l,h,!0);return}f||c.type===M.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===M.AST_NODE_TYPES.Identifier&&r(i,o,c.typeName,l)}function a(i,o,l){for(let c of l)if(c.type==="ObjectPattern"&&c.typeAnnotation){let f=new Map;if(s(i,o,f,c.typeAnnotation.typeAnnotation,!1),f.size===0)continue;u(c,f)}else c.type===M.AST_NODE_TYPES.AssignmentPattern&&c.left.type===M.AST_NODE_TYPES.ObjectPattern&&a(i,o,[c.left])}function u(i,o){let l=[];if(i.properties.at(-1)?.type===M.AST_NODE_TYPES.RestElement)return;for(let m of i.properties)m.type===M.AST_NODE_TYPES.Property&&m.key.type===M.AST_NODE_TYPES.Identifier&&l.push(m.key.name);let f=[],h=[];for(let[m,y]of o)l.includes(m)||(h.push(m),f.push({node:y,messageId:"unusedObjectTypeProperty",data:{propertyName:m}}));for(let[m,y]of f.entries())e.report({...y,fix:m===f.length-1?T=>{let E=i.properties.at(-1),g=h.join(", ");return E?E?.type===M.AST_NODE_TYPES.RestElement?null:T.insertTextAfter(E,`, ${g}`):T.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${g}`)}:void 0})}return{VariableDeclaration(i){let o=i.declarations[0];if(!o)return;let l=new Map,c=o.id.type===M.AST_NODE_TYPES.Identifier&&o.id.typeAnnotation?.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeReference&&o.id.typeAnnotation.typeAnnotation.typeName.type===M.AST_NODE_TYPES.Identifier&&o.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&o.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===M.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===M.AST_NODE_TYPES.Identifier)r(!0,i,c.typeName,l,!1);else if(c.type===M.AST_NODE_TYPES.TSTypeLiteral)Jt(l,...Xt(c));else if(c.type===M.AST_NODE_TYPES.TSIntersectionType)for(let f of c.types)f.type===M.AST_NODE_TYPES.TSTypeReference&&f.typeName.type===M.AST_NODE_TYPES.Identifier?r(!0,i,f.typeName,l,!1):s(!0,i,l,f,!0);if(l.size!==0&&o.init?.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let f=o.init.params[0];if(!f){e.report({node:o.init,messageId:"missingComponentParam"});return}f.type===M.AST_NODE_TYPES.ObjectPattern&&u(f,l)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),lt={name:Gt,rule:Mr};var pe=require("@typescript-eslint/utils"),$r=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="prefer-named-functions",Zt=new Map,Ur=$r({name:Qt,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=Zt.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),Zt.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===pe.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===pe.AST_NODE_TYPES.Identifier){let s=r.id.name;if(r.id.typeAnnotation||n&&n.test(s)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==pe.AST_NODE_TYPES.BlockStatement)return;let a=r.parent,u=r.init.params,i=r.init.body,o=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:l=>l.replaceText(a,`${o.async?"async ":""}function ${s}(${u.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),ct={name:Qt,rule:Ur};var H=require("@typescript-eslint/utils");var Vr=H.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="prefer-single-line-if",Wr=_({maxLineLength:F(G()),maxNonSimpleConditionLength:F(G())}),Hr=Vr({name:tn,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:[Wr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==H.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 a=r.consequent.body[0];if(a.type===H.AST_NODE_TYPES.ReturnStatement){if(!rn(a))return}else if(!(a.type===H.AST_NODE_TYPES.ContinueStatement||a.type===H.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===H.AST_NODE_TYPES.LogicalExpression||r.test.type===H.AST_NODE_TYPES.ConditionalExpression)return;let u;if(t.maxNonSimpleConditionLength){let f=en(r.test);if(!f&&r.test.type===H.AST_NODE_TYPES.UnaryExpression&&r.test.operator==="!"){let h=r.test.argument;en(h)&&(f=!0)}if(f&&(u=n.getText(r.test),u.length>t.maxNonSimpleConditionLength))return}u||(u=n.getText(r.test));let i=n.getText(a);if(u.includes(`
15
+ `))return;let o=n.getTokenAfter(r);if(o&&o.type===H.AST_TOKEN_TYPES.Punctuator&&o.value==="}"){let f=n.getTokenAfter(o);if(f&&f.type===H.AST_TOKEN_TYPES.Keyword&&(f.value==="else"||f.value==="catch"))return}let l=Yr(n,r),c=`if (${u}) ${i}`;t.maxLineLength&&c.length+l.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:f=>f.replaceText(r,c)})}}}});function en(e){return e.type===H.AST_NODE_TYPES.CallExpression||e.type===H.AST_NODE_TYPES.BinaryExpression||e.type===H.AST_NODE_TYPES.MemberExpression&&nn(e)}function nn(e){return e.object.type===H.AST_NODE_TYPES.MemberExpression?nn(e.object):e.object.type!==H.AST_NODE_TYPES.Identifier}function Yr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function rn(e){if(!e.argument)return!0;let t=e.argument;return t.type===H.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===H.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===H.AST_NODE_TYPES.Literal||t.type===H.AST_NODE_TYPES.Identifier||t.type===H.AST_NODE_TYPES.TemplateLiteral||t.type===H.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===H.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===H.AST_NODE_TYPES.UnaryExpression?rn(t):!1}var ut={name:tn,rule:Hr};var K=require("@typescript-eslint/utils");var zr=K.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="react-compiler-migration",Br=_({disallowHooks:F(Y(_({name:N(),replacement:N()}))),disallowMethods:F(Y(_({name:N(),replacement:F(N()),requireTrueProp:F(N())})))}),qr=/eslint +react-compiler\/react-compiler: +\["error/;function Kr(e){return e.type===K.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===K.AST_NODE_TYPES.MemberExpression&&e.property.type===K.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Xr=zr({name:sn,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:[Br]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(qr.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let s=null,a=null;if(r.callee.type===K.AST_NODE_TYPES.Identifier?(s=r.callee.name,a=r.callee):r.callee.type===K.AST_NODE_TYPES.MemberExpression&&r.callee.property.type===K.AST_NODE_TYPES.Identifier&&(s=r.callee.property.name,a=r.callee.property),s){let u=t.disallowHooks.find(i=>i.name===s);u&&a&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:u.name,replacement:u.replacement},suggest:[{messageId:"replace",data:{replacement:u.replacement},fix:i=>i.replaceText(a,u.replacement)}]})}}if(t.disallowMethods?.length&&Kr(r.callee)){for(let s of r.arguments)if(s.type===K.AST_NODE_TYPES.ObjectExpression){for(let a of s.properties)if(a.type===K.AST_NODE_TYPES.Property&&a.key.type===K.AST_NODE_TYPES.Identifier){let u=a.key.name,i=t.disallowMethods.find(o=>o.name===u);if(i){if(i.requireTrueProp){let o=i.requireTrueProp,l=!1;for(let c of s.properties)if(c.type===K.AST_NODE_TYPES.Property&&c.key.type===K.AST_NODE_TYPES.Identifier&&c.key.name===o&&c.value.type===K.AST_NODE_TYPES.Literal&&c.value.value===!0){l=!0;break}if(!l){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:o}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:o=>o.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),pt={name:sn,rule:Xr};var ke=require("@typescript-eslint/utils"),Jr=ke.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="require-description",Gr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Zr=/^eslint-disable-(next-)?line$/u,Qr=Jr({name:on,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 s of n.getAllComments()){let a=ei(s);a!=null&&(r.has(a.kind)||a.description||e.report({loc:ni(s.loc),messageId:"missingDescription"}))}}}}}),an={name:on,rule:Qr};function ei(e){let{text:t,description:n}=ti(e.value);if(!t)return null;let r=Gr.exec(t);if(!r)return null;let s=r[1];if(!s)return null;let a=Zr.test(s);if(e.type===ke.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let u=t.slice(r.index+s.length);return{kind:s,value:u.trim(),description:n}}function ti(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ni(e){return{start:{line:e.start.line,column:-1},end:e.end}}function un(e){return/^use[A-Z0-9]/.test(e)}function Ae(e){return e.type==="Identifier"?un(e.name):e.type==="MemberExpression"&&!e.computed&&Ae(e.property)?e.object.type==="Identifier":!1}function pn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function fn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function mn(e){return!!(e.parent&&e.parent.callee&&fn(e.parent.callee,"forwardRef"))}function dn(e){return!!(e.parent&&e.parent.callee&&fn(e.parent.callee,"memo"))}function ft(e){for(;e;){let t=gn(e);if(t&&(pn(t)||Ae(t))||mn(e)||dn(e))return!0;e=e.parent}return!1}function ln(e){return!1}function mt(e){return!1}var ri=/eslint +react-compiler\/react-compiler: +\["error/,yn={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 o of e.sourceCode.getAllComments())if(ri.test(o.value))return{CallExpression(l){let c=null;l.callee.name==="useMemo"?c="useMemo":l.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:l,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?o=>t(o):o=>e.sourceCode.getText(o),n=typeof e.getScope=="function"?()=>n():o=>e.sourceCode.getScope(o),r=null,s=[],a=[],u=new WeakSet;function i(o){for(let l of o.references){let c=l.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&ln(c.init.callee))for(let f of l.resolved.references)f!==l&&u.add(f.identifier)}}return{onCodePathSegmentStart:o=>a.push(o),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(o,l){let c=s.pop();if(c.size===0)return;let f=new Set;function h(S,v){let{cache:A}=h,L=A.get(S.id),j=new Set(v);if(j.has(S.id)){let R=[...j],U=R.slice(R.indexOf(S.id)+1);for(let B of U)f.add(B);return BigInt("0")}if(j.add(S.id),L!==void 0)return L;if(o.thrownSegments.includes(S))L=BigInt("0");else if(S.prevSegments.length===0)L=BigInt("1");else{L=BigInt("0");for(let R of S.prevSegments)L+=h(R,j)}return S.reachable&&L===BigInt("0")?A.delete(S.id):A.set(S.id,L),L}function m(S,v){let{cache:A}=m,L=A.get(S.id),j=new Set(v);if(j.has(S.id)){let R=Array.from(j),U=R.slice(R.indexOf(S.id)+1);for(let B of U)f.add(B);return BigInt("0")}if(j.add(S.id),L!==void 0)return L;if(o.thrownSegments.includes(S))L=BigInt("0");else if(S.nextSegments.length===0)L=BigInt("1");else{L=BigInt("0");for(let R of S.nextSegments)L+=m(R,j)}return A.set(S.id,L),L}function y(S){let{cache:v}=y,A=v.get(S.id);if(A===null)return 1/0;if(A!==void 0)return A;if(v.set(S.id,null),S.prevSegments.length===0)A=1;else{A=1/0;for(let L of S.prevSegments){let j=y(L);j<A&&(A=j)}A+=1}return v.set(S.id,A),A}h.cache=new Map,m.cache=new Map,y.cache=new Map;let T=m(o.initialSegment),E=gn(l),g=ft(l),O=E?pn(E)||Ae(E):mn(l)||dn(l),C=1/0;for(let S of o.finalSegments){if(!S.reachable)continue;let v=y(S);v<C&&(C=v)}for(let[S,v]of c){if(!S.reachable)continue;let A=S.nextSegments.length===0?C<=y(S):C<y(S),L=h(S)*m(S),j=f.has(S.id);for(let R of v)if(j&&!mt(R)&&e.report({node:R,message:`React Hook "${t(R)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),O){if(l.async&&e.report({node:R,message:`React Hook "${t(R)}" cannot be called in an async function.`}),!j&&L!==T&&!mt(R)){let B=`React Hook "${t(R)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(A?" Did you accidentally call a React Hook after an early return?":"");e.report({node:R,message:B})}}else if(l.parent&&(l.parent.type==="MethodDefinition"||l.parent.type==="ClassProperty")&&l.parent.value===l){let U=`React Hook "${t(R)}" 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:R,message:U})}else if(E){let U=`React Hook "${t(R)}" is called in function "${t(E)}" 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:R,message:U})}else if(l.type==="Program"){let U=`React Hook "${t(R)}" 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:R,message:U})}else if(g&&!mt(R)){if(l.parent.type==="CallExpression"&&l.parent.callee.type==="Identifier"&&l.parent.callee.name==="useCallback"){let B=l.parent;if(B.parent.type==="VariableDeclarator"&&un(B.parent.id.name))return}let U=`React Hook "${t(R)}" 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:R,message:U})}}},CallExpression(o){if(Ae(o.callee)){let l=cn(s),c=cn(a),f=l.get(c);f||(f=[],l.set(c,f)),f.push(o.callee)}o.callee.type==="Identifier"&&(o.callee.name==="useEffect"||ln(o.callee))&&o.arguments.length>0&&(r=o)},Identifier(o){r==null&&u.has(o)&&o.parent.type!=="CallExpression"&&e.report({node:o,message:`\`${t(o)}\` 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"(o){o===r&&(r=null)},FunctionDeclaration(o){ft(o)&&i(n(o))},ArrowFunctionExpression(o){ft(o)&&i(n(o))}}}};function gn(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 cn(e){return e[e.length-1]}var Sn={[lt.name]:lt.rule,[Ke.name]:Ke.rule,[qe.name]:qe.rule,"rules-of-hooks":yn,"exhaustive-deps":kt,"require-description":an.rule,[Xe.name]:Xe.rule,[Ge.name]:Ge.rule,[ct.name]:ct.rule,[$e.name]:$e.rule,[Be.name]:Be.rule,[nt.name]:nt.rule,[ut.name]:ut.rule,[tt.name]:tt.rule,[Je.name]:Je.rule,[Ve.name]:Ve.rule,[pt.name]:pt.rule,[Me.name]:Me.rule,[ze.name]:ze.rule,[it.name]:it.rule,[st.name]:st.rule,[ot.name]:ot.rule};var ii={rules:Sn};0&&(module.exports={extendedLintPlugin});
@@ -1,6 +1,6 @@
1
- import{AST_NODE_TYPES as z,ESLintUtils as En}from"@typescript-eslint/utils";var we=Symbol.for("optional");function F(e){return{...e,[we]:!0}}function de(e,t){return{enum:e,...t}}function ie(e){return{...e,type:"boolean"}}function L(e){return{...e,type:"string"}}function X(e){return{...e,type:"number"}}function pt(e){return{...e,type:"integer"}}function H(e,t){return{...t,type:"array",items:e}}function _(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,o=[];for(r in e)e[r][we]?e[r][we]=void 0:o.push(r);o.length>0&&(n.required=o)}return n}function Re(...e){return{anyOf:e}}var bn=En.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mt="react-compiler-extra",xn=_({runOnlyWithEnableCompilerDirective:F(ie())}),Cn=/eslint +react-compiler\/react-compiler: +\["error/;function In(e){return e.type===z.Identifier?e.name.startsWith("use"):e.type===z.MemberExpression&&e.property.type===z.Identifier?e.property.name.startsWith("use"):!1}var wn=/\bthis[.[]/;function ft(e){return wn.test(e)}var Rn=bn({name:mt,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:[xn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let l of e.sourceCode.getAllComments())if(Cn.test(l.value)){n=!0;break}if(!n)return{}}function r(l){for(let u of l.properties)if(u.type===z.Property&&u.method&&u.value.type===z.FunctionExpression){let i=e.sourceCode,a=i.getText(u.key),c=u.value,s=i.getText(c.body);if(ft(s))e.report({node:u,messageId:"thisKeywordInMethod"});else{let p=c.params.map(y=>i.getText(y)).join(", "),g="";c.generator?g=`${a}: function* (${p}) ${s}`:g=`${a}: (${p}) => ${s}`,e.report({node:u,messageId:"objectMethodIsNotSupported",fix:y=>y.replaceText(u,g)})}}}function o(l){for(let u of l.properties)if(u.type===z.Property&&u.value.type===z.ObjectExpression){for(let i of u.value.properties)if(i.type===z.Property&&i.method&&i.value.type===z.FunctionExpression){let c=e.sourceCode.getText(i.value.body);ft(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(l){if(In(l.callee))for(let u of l.arguments){if(u.type===z.ObjectExpression&&(r(u),o(u)),u.type===z.ArrowFunctionExpression&&(u.body.type===z.ObjectExpression&&(r(u.body),o(u.body)),u.body.type===z.BlockStatement))for(let i of u.body.body)i.type===z.ReturnStatement&&i.argument?.type===z.ObjectExpression&&(r(i.argument),o(i.argument));if(u.type===z.FunctionExpression)for(let i of u.body.body)i.type===z.ReturnStatement&&i.argument?.type===z.ObjectExpression&&(r(i.argument),o(i.argument))}}}}}),ve={name:mt,rule:Rn};import{AST_NODE_TYPES as Oe,ESLintUtils as vn}from"@typescript-eslint/utils";var On=vn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kn=_({disallow:F(H(_({selector:L(),message:L(),replace:F(Re(L(),_({regex:L(),with:L()}))),replaceType:F(de(["suggestion","autofix"]))}))),__dev_simulateFileName:F(L()),mustMatchSyntax:F(H(_({includeRegex:L(),mustCallFn:H(_({anyCall:H(_({fn:L(),withArgs:H(_({atIndex:pt(),literal:Re(L(),X(),ie())}))})),message:F(L())}))})))}),gt="advanced-no-restricted-syntax",An=On({name:gt,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[kn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:o,disallow:l}=t,u=o??e.filename,i=[],a=new Set;for(let{includeRegex:s,mustCallFn:p}of r??[]){let g=Pn(u,new RegExp(s));if(!g)continue;let y=S=>{let d=S;for(let{name:b,value:T}of g)d=d.replaceAll(b,T);return d};for(let{anyCall:S,message:d}of p){let b=`Expected file to call the function: ${S.map(({fn:T})=>T).join(" or ")}`;a.add(b),i.push(T=>{let{callee:N}=T;if(N.type===Oe.Identifier){for(let{fn:v,withArgs:h}of S)if(N.name===v){a.delete(b);for(let w of h){let R=T.arguments[w.atIndex],O=typeof w.literal=="string"?y(w.literal):w.literal;if(!R){e.report({node:T,messageId:"default",data:{message:`Missing argument with value "${O}" at index ${w.atIndex}${d?`: ${y(d)}`:""}`}});continue}if(R.type!==Oe.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${O}"${d?`: ${y(d)}`:""}`}});continue}R.value!==O&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${O}"${d?`: ${y(d)}`:""}`},fix:D=>D.replaceText(R,typeof O=="string"?`'${O}'`:String(O))})}break}}})}}for(let{selector:s,message:p,replace:g,replaceType:y="suggestion"}of l??[]){if(s==="CallExpression"){i.push(S=>{c(g,S,p,y)});continue}n[s]=S=>{c(g,S,p,y)}}return i.length>0&&(n.CallExpression=s=>{if(s.type===Oe.CallExpression)for(let p of i)p(s)}),n["Program:exit"]=s=>{for(let p of a)e.report({node:s,messageId:"default",data:{message:`${p}`}})},n;function c(s,p,g,y){let S=d=>{if(!s)return null;if(typeof s=="string")return d.replaceText(p,s);{let b=new RegExp(s.regex),T=e.sourceCode.getText(p);return d.replaceText(p,T.replace(b,s.with))}};e.report({node:p,messageId:"default",data:{message:g},fix:s&&y==="autofix"?S:void 0,suggest:s&&y==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof s=="string"?s:s.with}"`},fix:S}]:void 0})}}});function Pn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[o,...l]=r;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:dt(o)}),n.push({name:"$0_uncapitalize",value:yt(o)}),n.push({name:"$0",value:o});for(let u=0;u<l.length;u++){let i=`$${u+1}`,a=l[u];n.push({name:`${i}_lowercase`,value:a.toLowerCase()}),n.push({name:`${i}_capitalize`,value:dt(a)}),n.push({name:`${i}_uncapitalize`,value:yt(a)}),n.push({name:i,value:a})}return n}function dt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function yt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var ke={name:gt,rule:An};import{AST_NODE_TYPES as j,AST_TOKEN_TYPES as Fn,ESLintUtils as Nn}from"@typescript-eslint/utils";var Ln=Nn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tt="collapse-simple-objs-in-one-line",_n=_({maxLineLength:F(X()),maxProperties:F(X()),nestedObjMaxLineLength:F(X()),nestedObjMaxProperties:F(X()),ignoreTypesWithSuffix:F(H(L()))}),Dn=Ln({name:Tt,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:[_n]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,l=t.nestedObjMaxLineLength??t.maxLineLength,u=t.nestedObjMaxProperties??3;function i(c){if(c.type===j.ObjectExpression){let s=c.parent.type===j.Property,p=s?u:o,g=c.properties.length;if(g>p)return!1;if(g===1){let S=c.properties[0];return S.type===j.Property&&S.value.type===j.ObjectExpression||S.type===j.Property&&S.value.type===j.ArrayExpression&&!S.value.elements.every(b=>b&&Ae(b))?!1:{text:n.getText(S),isNested:s,propsSize:g}}let y=[];for(let S of c.properties){if(S.type===j.Property&&!Ae(S.value))return!1;y.push(n.getText(S))}return{text:y.join(", "),isNested:s,propsSize:g}}else{let s=c.parent.parent?.type===j.TSPropertySignature,p=s?u:o,g=c.members.length;if(g>p)return!1;if(r.length>0&&c.parent.type===j.TSTypeAliasDeclaration){let S=c.parent.id.name;if(r.some(d=>S.endsWith(d)))return!1}if(g===1){let S=c.members[0];return S.type===j.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===j.TSTypeLiteral?!1:{text:n.getText(S),isNested:s,propsSize:1}}if(c.parent.type===j.TSIntersectionType||c.parent.type===j.TSUnionType)return!1;let y=[];for(let S of c.members){if(S.type!==j.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===j.TSTypeLiteral||!St(d))return!1;if(d.type===j.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let T=d.typeArguments.params[0];if(!St(T))return!1}let b=n.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),y.push(b)}return{text:y.join("; "),isNested:s,propsSize:g}}}function a(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==j.JSXExpressionContainer){let d=0,b=n.getTokenAfter(c,{filter:T=>T.type!==Fn.Punctuator?!0:T.value===","||T.value===";"||T.value===")"||T.value==="}"?(d++,!1):!0});if(d>4||b?.loc.start.line===c.loc.end.line)return}let s=i(c);if(!s)return;let p=s.text;if(p.includes(`
2
- `)||n.getCommentsInside(c).length>0)return;p.endsWith(";")&&(p=p.slice(0,-1));let g=`{ ${p} }`,y=$n(n,c),S=s.isNested&&s.propsSize>2?l:t.maxLineLength;S&&g.length+y.length+jn(c,n)>S||e.report({node:c,messageId:"singleLineProp",fix:d=>d.replaceText(c,g)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function St(e){return e.type===j.TSLiteralType||e.type===j.TSTypeReference||e.type===j.TSNumberKeyword||e.type===j.TSStringKeyword||e.type===j.TSBooleanKeyword||e.type===j.TSNullKeyword||e.type===j.TSUndefinedKeyword}function Ae(e,t){return!!(e.type===j.Literal||e.type===j.Identifier||e.type===j.TemplateLiteral||e.type===j.TaggedTemplateExpression||!t&&e.type===j.ArrayExpression&&e.elements.every(n=>n&&Ae(n,!0)))}function jn(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
3
- `,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function $n(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Pe={name:Tt,rule:Dn};var Mn=/eslint +react-compiler\/react-compiler: +\["error/,Et={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?T=>n(T):T=>e.sourceCode.getText(T),r=typeof e.getScope=="function"?()=>r():T=>e.sourceCode.getScope(T),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,l=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,u={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:l};function i(T){l&&Array.isArray(T.suggest)&&T.suggest.length>0&&(T.fix=T.suggest[0].fix),e.report(T)}let a=e.getSourceCode().scopeManager,c=new WeakMap,s=new WeakSet,p=new WeakMap,g=new WeakMap,y=new WeakSet;function S(T,N){return function(v){if(N.has(v))return N.get(v);let h=T(v);return N.set(v,h),h}}function d(T,N,v,h,w){w&&T.async&&i({node:T,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ import{AST_NODE_TYPES as B,ESLintUtils as hn}from"@typescript-eslint/utils";var ve=Symbol.for("optional");function F(e){return{...e,[ve]:!0}}function ye(e,t){return{enum:e,...t}}function ie(e){return{...e,type:"boolean"}}function N(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function ft(e){return{...e,type:"integer"}}function H(e,t){return{...t,type:"array",items:e}}function _(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,s=[];for(r in e)e[r][ve]?e[r][ve]=void 0:s.push(r);s.length>0&&(n.required=s)}return n}function Oe(...e){return{anyOf:e}}var En=hn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dt="react-compiler-extra",bn=_({runOnlyWithEnableCompilerDirective:F(ie())}),xn=/eslint +react-compiler\/react-compiler: +\["error/;function Cn(e){return e.type===B.Identifier?e.name.startsWith("use"):e.type===B.MemberExpression&&e.property.type===B.Identifier?e.property.name.startsWith("use"):!1}var In=/\bthis[.[]/;function mt(e){return In.test(e)}var wn=En({name:dt,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:[bn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(xn.test(a.value)){n=!0;break}if(!n)return{}}function r(a){for(let u of a.properties)if(u.type===B.Property&&u.method&&u.value.type===B.FunctionExpression){let i=e.sourceCode,o=i.getText(u.key),l=u.value,c=i.getText(l.body);if(mt(c))e.report({node:u,messageId:"thisKeywordInMethod"});else{let f=l.params.map(m=>i.getText(m)).join(", "),h="";l.generator?h=`${o}: function* (${f}) ${c}`:h=`${o}: (${f}) => ${c}`,e.report({node:u,messageId:"objectMethodIsNotSupported",fix:m=>m.replaceText(u,h)})}}}function s(a){for(let u of a.properties)if(u.type===B.Property&&u.value.type===B.ObjectExpression){for(let i of u.value.properties)if(i.type===B.Property&&i.method&&i.value.type===B.FunctionExpression){let l=e.sourceCode.getText(i.value.body);mt(l)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Cn(a.callee))for(let u of a.arguments){if(u.type===B.ObjectExpression&&(r(u),s(u)),u.type===B.ArrowFunctionExpression&&(u.body.type===B.ObjectExpression&&(r(u.body),s(u.body)),u.body.type===B.BlockStatement))for(let i of u.body.body)i.type===B.ReturnStatement&&i.argument?.type===B.ObjectExpression&&(r(i.argument),s(i.argument));if(u.type===B.FunctionExpression)for(let i of u.body.body)i.type===B.ReturnStatement&&i.argument?.type===B.ObjectExpression&&(r(i.argument),s(i.argument))}}}}}),ke={name:dt,rule:wn};import{AST_NODE_TYPES as Ae}from"@typescript-eslint/utils";import{ESLintUtils as Rn}from"@typescript-eslint/utils";function ge(e){let n=Rn.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}var vn=_({disallow:F(H(_({selector:N(),message:N(),replace:F(Oe(N(),_({regex:N(),with:N()}))),replaceType:F(ye(["suggestion","autofix"]))}))),__dev_simulateFileName:F(N()),mustMatchSyntax:F(H(_({includeRegex:N(),mustCallFn:F(H(_({anyCall:H(_({fn:N(),withArgs:H(_({atIndex:ft(),literal:Oe(N(),J(),ie())}))})),message:F(N())}))),mustMatchSelector:F(H(_({selector:N(),message:N()})))})))}),Pe=ge({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[vn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:s,disallow:a}=t,u=s??e.filename,i=[],o=new Map,l=new Set,c=new Map;for(let{includeRegex:m,mustCallFn:y,mustMatchSelector:T}of r??[]){let E=On(u,new RegExp(m));if(!E)continue;let g=O=>{let C=O;for(let{name:S,value:v}of E)C=C.replaceAll(S,v);return C};for(let{anyCall:O,message:C}of y??[]){let S=`Expected file to call the function: ${O.map(({fn:v})=>v).join(" or ")}`;l.add(S),i.push(v=>{let{callee:A}=v;if(A.type===Ae.Identifier){for(let{fn:L,withArgs:D}of O)if(A.name===L){l.delete(S);for(let R of D){let j=v.arguments[R.atIndex],z=typeof R.literal=="string"?g(R.literal):R.literal;if(!j){e.report({node:v,messageId:"default",data:{message:`Missing argument with value "${z}" at index ${R.atIndex}${C?`: ${g(C)}`:""}`}});continue}if(j.type!==Ae.Literal){e.report({node:j,messageId:"default",data:{message:`Argument at position ${R.atIndex} should the literal "${z}"${C?`: ${g(C)}`:""}`}});continue}j.value!==z&&e.report({node:j,messageId:"default",data:{message:`Argument should have the value "${z}"${C?`: ${g(C)}`:""}`},fix:pe=>pe.replaceText(j,typeof z=="string"?`'${z}'`:String(z))})}break}}})}for(let{selector:O,message:C}of T??[])c.set(O,g(C)),o.set(g(O),()=>{c.delete(O)})}function f(m,y){let T=n[m];T?n[m]=E=>{T(E),y(E)}:n[m]=y}for(let{selector:m,message:y,replace:T,replaceType:E="suggestion"}of a??[]){if(m==="CallExpression"){i.push(g=>{h(T,g,y,E)});continue}n[m]=g=>{h(T,g,y,E)}}if(o.size>0)for(let[m,y]of o)f(m,y);return i.length>0&&(n.CallExpression=m=>{if(m.type===Ae.CallExpression)for(let y of i)y(m)}),n["Program:exit"]=m=>{for(let y of l)e.report({node:m,messageId:"default",data:{message:y}});for(let[,y]of c)e.report({node:m,messageId:"default",data:{message:y}})},n;function h(m,y,T,E){let g=O=>{if(!m)return null;if(typeof m=="string")return O.replaceText(y,m);{let C=new RegExp(m.regex),S=e.sourceCode.getText(y);return O.replaceText(y,S.replace(C,m.with))}};e.report({node:y,messageId:"default",data:{message:T},fix:m&&E==="autofix"?g:void 0,suggest:m&&E==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:g}]:void 0})}}});function On(e,t){let n=[],r=t.exec(e);if(!r)return null;let[s,...a]=r;n.push({name:"$0_lowercase",value:s.toLowerCase()}),n.push({name:"$0_capitalize",value:yt(s)}),n.push({name:"$0_uncapitalize",value:gt(s)}),n.push({name:"$0",value:s});for(let u=0;u<a.length;u++){let i=`$${u+1}`,o=a[u];n.push({name:`${i}_lowercase`,value:o.toLowerCase()}),n.push({name:`${i}_capitalize`,value:yt(o)}),n.push({name:`${i}_uncapitalize`,value:gt(o)}),n.push({name:i,value:o})}return n}function yt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function gt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as M,AST_TOKEN_TYPES as kn,ESLintUtils as An}from"@typescript-eslint/utils";var Pn=An.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tt="collapse-simple-objs-in-one-line",Fn=_({maxLineLength:F(J()),maxProperties:F(J()),nestedObjMaxLineLength:F(J()),nestedObjMaxProperties:F(J()),ignoreTypesWithSuffix:F(H(N()))}),Nn=Pn({name:Tt,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:[Fn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,u=t.nestedObjMaxProperties??3;function i(l){if(l.type===M.ObjectExpression){let c=l.parent.type===M.Property,f=c?u:s,h=l.properties.length;if(h>f)return!1;if(h===1){let y=l.properties[0];return y.type===M.Property&&y.value.type===M.ObjectExpression||y.type===M.Property&&y.value.type===M.ArrayExpression&&!y.value.elements.every(E=>E&&Fe(E))?!1:{text:n.getText(y),isNested:c,propsSize:h}}let m=[];for(let y of l.properties){if(y.type===M.Property&&!Fe(y.value))return!1;m.push(n.getText(y))}return{text:m.join(", "),isNested:c,propsSize:h}}else{let c=l.parent.parent?.type===M.TSPropertySignature,f=c?u:s,h=l.members.length;if(h>f)return!1;if(r.length>0&&l.parent.type===M.TSTypeAliasDeclaration){let y=l.parent.id.name;if(r.some(T=>y.endsWith(T)))return!1}if(h===1){let y=l.members[0];return y.type===M.TSPropertySignature&&y.typeAnnotation?.typeAnnotation.type===M.TSTypeLiteral?!1:{text:n.getText(y),isNested:c,propsSize:1}}if(l.parent.type===M.TSIntersectionType||l.parent.type===M.TSUnionType)return!1;let m=[];for(let y of l.members){if(y.type!==M.TSPropertySignature)return!1;let T=y.typeAnnotation?.typeAnnotation;if(!T||T.type===M.TSTypeLiteral||!St(T))return!1;if(T.type===M.TSTypeReference&&T.typeArguments){if(T.typeArguments.params.length>1)return!1;let g=T.typeArguments.params[0];if(!St(g))return!1}let E=n.getText(y).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),m.push(E)}return{text:m.join("; "),isNested:c,propsSize:h}}}function o(l){if(l.loc.start.line===l.loc.end.line)return;if(l.parent.type!==M.JSXExpressionContainer){let T=0,E=n.getTokenAfter(l,{filter:g=>g.type!==kn.Punctuator?!0:g.value===","||g.value===";"||g.value===")"||g.value==="}"?(T++,!1):!0});if(T>4||E?.loc.start.line===l.loc.end.line)return}let c=i(l);if(!c)return;let f=c.text;if(f.includes(`
2
+ `)||n.getCommentsInside(l).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let h=`{ ${f} }`,m=_n(n,l),y=c.isNested&&c.propsSize>2?a:t.maxLineLength;y&&h.length+m.length+Ln(l,n)>y||e.report({node:l,messageId:"singleLineProp",fix:T=>T.replaceText(l,h)})}return{TSTypeLiteral:o,ObjectExpression:o}}});function St(e){return e.type===M.TSLiteralType||e.type===M.TSTypeReference||e.type===M.TSNumberKeyword||e.type===M.TSStringKeyword||e.type===M.TSBooleanKeyword||e.type===M.TSNullKeyword||e.type===M.TSUndefinedKeyword}function Fe(e,t){return!!(e.type===M.Literal||e.type===M.Identifier||e.type===M.TemplateLiteral||e.type===M.TaggedTemplateExpression||!t&&e.type===M.ArrayExpression&&e.elements.every(n=>n&&Fe(n,!0)))}function Ln(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
3
+ `,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function _n(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ne={name:Tt,rule:Nn};var Dn=/eslint +react-compiler\/react-compiler: +\["error/,Et={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?g=>n(g):g=>e.sourceCode.getText(g),r=typeof e.getScope=="function"?()=>r():g=>e.sourceCode.getScope(g),s=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,a=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,u={additionalHooks:s,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function i(g){a&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let o=e.getSourceCode().scopeManager,l=new WeakMap,c=new WeakSet,f=new WeakMap,h=new WeakMap,m=new WeakSet;function y(g,O){return function(C){if(O.has(C))return O.get(C);let S=g(C);return O.set(C,S),S}}function T(g,O,C,S,v){v&&g.async&&i({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
4
4
 
5
5
  useEffect(() => {
6
6
  async function fetchData() {
@@ -11,5 +11,5 @@ useEffect(() => {
11
11
  fetchData();
12
12
  }, [someId]); // Or [] if effect doesn't need props or state
13
13
 
14
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=a.acquire(T),O=new Set,D=null;{let f=R.upper;for(;f&&(O.add(f),f.type!=="function");)f=f.upper;if(!f)return;D=f}let k=Array.isArray;function W(f){if(!k(f.defs))return!1;let m=f.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let E=m.node.init;if(E==null)return!1;for(;E.type==="TSAsExpression";)E=E.expression;let x=m.node.parent;if(x==null&&(Le(D.block,m.node.id),x=m.node.parent,x==null))return!1;if(x.kind==="const"&&E.type==="Literal"&&(typeof E.value=="string"||typeof E.value=="number"||E.value===null))return!0;if(E.type!=="CallExpression")return!1;let I=E.callee;if(I.type==="MemberExpression"&&I.object.name==="React"&&I.property!=null&&!I.computed&&(I=I.property),I.type!=="Identifier")return!1;let C=m.node.id,{name:A}=I;if(A==="useRef"&&C.type==="Identifier")return!0;if(Yn(I)&&C.type==="Identifier"){for(let P of f.references)P!==C&&y.add(P.identifier);return!0}else if(A==="useState"||A==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&k(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(A==="useState"){let P=f.references,K=0;for(let ee=0;ee<P.length;ee++){if(P[ee].isWrite()&&K++,K>1)return!1;c.set(P[ee].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(A==="useState"){let P=f.references;for(let K=0;K<P.length;K++)s.add(P[K].identifier)}return!1}}}else if(A==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function Q(f){if(!k(f.defs))return!1;let m=f.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let E=m.node,x=D.childScopes,I=null,C;for(C=0;C<x.length;C++){let A=x[C],P=A.block;if(E.type==="FunctionDeclaration"&&P===E||E.type==="VariableDeclarator"&&P.parent===E){I=A;break}}if(I==null)return!1;for(C=0;C<I.through.length;C++){let A=I.through[C];if(A.resolved!=null&&O.has(A.resolved.scope)&&!st(A.resolved))return!1}return!0}let st=S(W,p),mn=S(Q,g),ot=new Map;function dn(f){let m=f.from,E=!1;for(;m.block!==T;)m.type==="function"&&(E=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return E}let q=new Map,be=new Map;at(R);function at(f){for(let m of f.references){if(!m.resolved||!O.has(m.resolved.scope))continue;let E=Le(T,m.identifier),x=bt(E),I=te(x,be);if(w&&x.type==="Identifier"&&(x.parent.type==="MemberExpression"||x.parent.type==="OptionalMemberExpression")&&!x.parent.computed&&x.parent.property.type==="Identifier"&&x.parent.property.name==="current"&&dn(m)&&ot.set(I,{reference:m,dependencyNode:x}),x.parent.type==="TSTypeQuery"||x.parent.type==="TSTypeReference")continue;let C=m.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===T.parent)&&C.type!=="TypeParameter")if(q.has(I))q.get(I).references.push(m);else{let A=m.resolved,P=st(A)||mn(A);q.set(I,{isStable:P,references:[m]})}}for(let m of f.childScopes)at(m)}ot.forEach(({reference:f,dependencyNode:m},E)=>{let x=f.resolved.references,I=!1;for(let C=0;C<x.length;C++){let{identifier:A}=x[C],{parent:P}=A;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){I=!0;break}}I||i({node:m.parent.property,message:`The ref value '${E}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${E}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let xe=new Set;function yn(f,m){xe.has(m)||(xe.add(m),i({node:f,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(q.forEach(({isStable:f,references:m},E)=>{f&&pe.add(E),m.forEach(x=>{x.writeExpr&&yn(x.writeExpr,E)})}),xe.size>0)return;if(!N){let f=null;if(q.forEach(({isStable:m,references:E},x)=>{f||E.forEach(I=>{if(f)return;let C=I.identifier;if(!c.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===T&&(f=x)})}),f){let{suggestedDependencies:m}=Fe({dependencies:q,declaredDependencies:[],stableDependencies:pe,externalDependencies:new Set,isEffect:!0});i({node:v,message:`React Hook ${h} contains a call to '${f}'. 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 ${h} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(E){return E.insertTextAfter(T,`, [${m.join(", ")}]`)}}]})}return}let le=[],ce=new Set;N.type!=="ArrayExpression"?i({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(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,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}y.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(f)}\``,fix(I){return I.removeRange(f.range)}}]});let m;try{m=te(f,be)}catch(I){if(/Unsupported node type/.test(I.message)){f.type==="Literal"?q.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${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 I}let E=f;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let x=!D.through.some(I=>I.identifier===E);le.push({key:m,node:f}),x||ce.add(m)});let{suggestedDependencies:gn,unnecessaryDependencies:fe,missingDependencies:ne,duplicateDependencies:lt}=Fe({dependencies:q,declaredDependencies:le,stableDependencies:pe,externalDependencies:ce,isEffect:w}),me=gn;if(lt.size+ne.size+fe.size===0){if(t)return;Un({declaredDependencies:le,declaredDependenciesNode:N,componentScope:D,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:E,depType:x})=>{let I=x==="function"?"useCallback":"useMemo",C=x==="function"?"definition":"initialization",A=`wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,P=E?`To fix this, ${A}`:`Move it inside the ${h} callback. Alternatively, ${A}`,K=x==="conditional"||x==="logical expression"?"could make":"makes",ee=`The '${m.name.name}' ${x} ${K} the dependencies of ${h} Hook (at line ${N.loc.start.line}) change on every render. ${P}`,ct;E&&m.type==="Variable"&&x==="function"&&(ct=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(ut){let[Tn,hn]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[ut.insertTextBefore(m.node.init,Tn),ut.insertTextAfter(m.node.init,hn)]}}]),i({node:m.node,message:ee,suggest:ct})});return}!w&&ne.size>0&&(me=Fe({dependencies:q,declaredDependencies:[],stableDependencies:pe,externalDependencies:ce,isEffect:w}).suggestedDependencies);function Sn(){if(le.length===0)return!0;let f=le.map(E=>E.key),m=f.slice().sort();return f.join(",")===m.join(",")}Sn()&&me.sort();function Ce(f){let m=f.split("."),E="";for(let x=0;x<m.length;x++){if(x!==0){let I=m.slice(0,x+1).join("."),C=be.get(I)===!0;E+=C?"?.":"."}E+=m[x]}return E}function Ie(f,m,E,x){return f.size===0?null:(f.size>1?"":m+" ")+E+" "+(f.size>1?"dependencies":"dependency")+": "+Wn(Array.from(f).sort().map(I=>"'"+Ce(I)+"'"))+`. Either ${x} ${f.size>1?"them":"it"} or remove the dependency array.`}let G="";if(fe.size>0){let f=null;if(Array.from(fe.keys()).forEach(m=>{f===null&&m.endsWith(".current")&&(f=m)}),f!==null)G=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ce.size>0){let m=Array.from(ce)[0];R.set.has(m)||(G=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!G&&ne.has("props")){let f=q.get("props");if(f==null)return;let m=f.references;if(!Array.isArray(m))return;let E=!0;for(let x=0;x<m.length;x++){let I=m[x],C=Le(D.block,I.identifier);if(!C){E=!1;break}let A=C.parent;if(A==null){E=!1;break}if(A.type!=="MemberExpression"&&A.type!=="OptionalMemberExpression"){E=!1;break}}E&&(G=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${h} call and refer to those specific props inside ${n(v)}.`)}if(!G&&ne.size>0){let f=null;ne.forEach(m=>{if(f)return;let E=D.set.get(m),x=q.get(m);if(x.references[0].resolved!==E)return;let I=E.defs[0];if(I==null||I.name==null||I.type!=="Parameter")return;let C=!1,A;for(let P=0;P<x.references.length;P++)if(A=x.references[P].identifier,A!=null&&A.parent!=null&&(A.parent.type==="CallExpression"||A.parent.type==="OptionalCallExpression")&&A.parent.callee===A){C=!0;break}C&&(f=m)}),f!==null&&(G=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!G&&ne.size>0){let f=null;if(ne.forEach(m=>{if(f!==null)return;let x=q.get(m).references,I,C;for(let A=0;A<x.length;A++){for(I=x[A].identifier,C=I.parent;C!=null&&C!==D.block;){if(C.type==="CallExpression"){let P=c.get(C.callee);if(P!=null){if(P.name===m)f={missingDep:m,setter:C.callee.name,form:"updater"};else if(s.has(I))f={missingDep:m,setter:C.callee.name,form:"reducer"};else{let K=x[A].resolved;if(K!=null){let ee=K.defs[0];ee!=null&&ee.type==="Parameter"&&(f={missingDep:m,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":G=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":G=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":G=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:N,message:`React Hook ${n(v)} has `+(Ie(ne,"a","missing","include")||Ie(fe,"an","unnecessary","exclude")||Ie(lt,"a","duplicate","omit"))+G,suggest:[{desc:`Update the dependencies array to be: [${me.map(Ce).join(", ")}]`,fix(f){return f.replaceText(N,`[${me.map(Ce).join(", ")}]`)}}]})}function b(T){let N=Vn(T.callee,u);if(N===-1)return;let v=T.arguments[N],h=T.callee,w=xt(h).name,R=T.arguments[N+1],O=/Effect($|[^a-z])/g.test(w);if(!v){i({node:h,message:`React Hook ${w} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!O)){if(!R&&!O){(w==="useMemo"||w==="useCallback")&&i({node:h,message:`React Hook ${w} 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,h,w,O);return;case"Identifier":if(!R||R.elements&&R.elements.some(W=>W&&W.type==="Identifier"&&W.name===v.name))return;let D=r(T).set.get(v.name);if(D==null||D.defs==null)return;let k=D.defs[0];if(!k||!k.node||k.type!=="Variable"&&k.type!=="FunctionName")break;switch(k.node.type){case"FunctionDeclaration":d(k.node,R,h,w,O);return;case"VariableDeclarator":let W=k.node.init;if(!W)break;switch(W.type){case"ArrowFunctionExpression":case"FunctionExpression":d(W,R,h,w,O);return}break}break;default:i({node:h,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:h,message:`React Hook ${w} 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(Mn.test(T.value))return t=!0,{CallExpression:N=>b(N,!0)}}return{CallExpression:T=>b(T)}}};function Fe({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:o}){let l=u();function u(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,b)=>{let T=i(l,b);T.isUsed=!0,a(l,b,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let b=i(l,d);b.isSatisfiedRecursively=!0}),n.forEach(d=>{let b=i(l,d);b.isSatisfiedRecursively=!0});function i(d,b){let T=b.split("."),N=d;for(let v of T){let h=N.children.get(v);h||(h=u(),N.children.set(v,h)),N=h}return N}function a(d,b,T){let N=b.split("."),v=d;for(let h of N){let w=v.children.get(h);if(!w)return;T(w),v=w}}let c=new Set,s=new Set;p(l,c,s,d=>d);function p(d,b,T,N){d.children.forEach((v,h)=>{let w=N(h);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&T.add(w);return}if(v.isUsed){b.add(w);return}p(v,b,T,R=>w+"."+R)})}let g=[],y=new Set,S=new Set;return t.forEach(({key:d})=>{s.has(d)?g.indexOf(d)===-1?g.push(d):S.add(d):y.add(d)}),c.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:y,duplicateDependencies:S,missingDependencies:c}}function re(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 re(e.consequent)!=null||re(e.alternate)!=null?"conditional":null;case"LogicalExpression":return re(e.left)!=null||re(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return re(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return re(e.expression);case"TSAsExpression":return re(e.expression)}return null}function Un({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let o=e.map(({key:u})=>{let i=n.variables.find(c=>c.name===u);if(i==null)return null;let a=i.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 c=re(a.node.init);if(c!=null)return[i,c]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[i,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function l(u){let i=!1;for(let a=0;a<u.references.length;a++){let c=u.references[a];if(c.writeExpr){if(i)return!0;i=!0;continue}let s=c.from;for(;s!==r&&s!=null;)s=s.upper;if(s!==r&&!Ct(t,c.identifier))return!0}return!1}return o.map(([u,i])=>({construction:u.defs[0],depType:i,isUsedOutsideOfHook:l(u)}))}function bt(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)?bt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ne(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function te(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=te(e.object,t),r=te(e.property,null),o=`${n}.${r}`;return Ne(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=te(e.object,t),r=te(e.property,null),o=`${n}.${r}`;return Ne(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=te(n.object,t),o=te(n.property,null),l=`${r}.${o}`;return Ne(n,t,l),l}else throw new Error(`Unsupported node type: ${e.type}`)}function xt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Vn(e,t){let n=xt(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=te(n,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(r)?0:-1}else return-1}}function Le(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),Hn(r,t))return r;if(Ct(r,t))for(let[o,l]of Object.entries(r))o!=="parent"&&(ht(l)?(l.parent=r,n.push(l)):Array.isArray(l)&&l.forEach(u=>{ht(u)&&(u.parent=r,n.push(u))}))}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 ht(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Hn(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 Ct(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Yn(e){return!1}import{AST_NODE_TYPES as ge,ESLintUtils as wt}from"@typescript-eslint/utils";import B from"typescript";var zn=wt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="improved-no-unnecessary-condition",Bn=_({}),qn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Kn=new Set(qn),_e={name:It,rule:zn({name:It,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:[Bn]},defaultOptions:[{}],create(e){let t=wt.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===ge.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&B.TypeFlags.Any||i.flags&B.TypeFlags.Unknown?null:i.flags&B.TypeFlags.StringLike?["string"]:i.flags&B.TypeFlags.NumberLike?["number"]:i.flags&B.TypeFlags.BigIntLike?["bigint"]:i.flags&B.TypeFlags.BooleanLike?["boolean"]:i.flags&B.TypeFlags.ESSymbolLike?["symbol"]:i.flags&B.TypeFlags.Undefined||i.flags&B.TypeFlags.Void?["undefined"]:i.flags&B.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&B.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&B.TypeFlags.NonPrimitive?["object"]:i.flags&B.TypeFlags.Never?["never"]:null}function l(i){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(i),c=n.getTypeAtLocation(a.expression);if(c.flags&B.TypeFlags.Any||c.flags&B.TypeFlags.Unknown)return null;let s=[];if(c.isUnion()){for(let g of c.types){let y=o(g);if(y)s.push(...y);else return null}return s}let p=o(c);return p?(s.push(...p),s):null}function u(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,s=null;if(r(i.left)?(c=i.left,s=i.right.type===ge.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(c=i.right,s=i.left.type===ge.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!s||!Xn(s,Kn))return;let p=l(c);if(!p)return;let g=i.operator==="!==",y=p.includes(s);p.length===1?y&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:se(c,e),type:s}}):!y&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:se(c,e),type:Array.from(p)[0]}}):!y&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:se(c,e),actualType:ye(p),conditionType:s}}):y&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:se(c,e),actualType:ye(p),conditionType:s}}):!y&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:se(c,e),actualType:ye(p),conditionType:s}}):!y&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:se(c,e),type:ye(p)}})}return{BinaryExpression:u}}})};function ye(e){return Array.from(new Set(e)).join(" | ")||"never"}function se(e,t){let n=e.argument;return n.type===ge.Identifier?n.name:t.sourceCode.getText(n)}function Xn(e,t){return t.has(e)}import{AST_NODE_TYPES as Jn,ESLintUtils as Gn}from"@typescript-eslint/utils";var Zn=Gn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="no-call-with-explicit-generics",Qn=_({functions:H(L())}),er=Zn({name:Rt,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Qn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:o}=r;o.type===Jn.Identifier&&n.has(o.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),De={name:Rt,rule:er};import{AST_NODE_TYPES as Se,ESLintUtils as tr}from"@typescript-eslint/utils";var nr=tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="no-call-with-inferred-generics",rr=nr({name:vt,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:o}=r;if(o.type!==Se.Identifier)return;let l=n.get(o.name);if(!l)return;let{minGenerics:u=1,allowAny:i,disallowTypes:a=t.disallowTypes}=l;(r.typeArguments?.params.length||0)<(u||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:u||0}}),!(i&&!a)&&r.typeArguments?.params?.some(s=>!i&&s.type===Se.TSAnyKeyword||a&&s.type===Se.TSTypeReference&&s.typeName.type===Se.Identifier&&a.includes(s.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),je={name:vt,rule:rr};import{ESLintUtils as ir,TSESTree as Ot}from"@typescript-eslint/utils";var sr=ir.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kt="no-commented-out-code",or=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],ar=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],lr=sr({name:kt,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 o of or)if(r.startsWith(o))return{wrongPattern:o};for(let o of ar)if(typeof o=="string"){if(n.includes(o))return{wrongPattern:o}}else if(o.test(n))return{wrongPattern:`regex(${o.toString()})`};return!1}return{Program(){let r=e.sourceCode.getAllComments();for(let o of r)if(o.type===Ot.AST_TOKEN_TYPES.Line||o.type===Ot.AST_TOKEN_TYPES.Block){let l=t(o.value);l&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:l.wrongPattern}})}}}}}),$e={name:kt,rule:lr};import{ESLintUtils as cr,TSESTree as ur}from"@typescript-eslint/utils";var pr=cr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-default-export",fr=pr({name:At,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===ur.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Me={name:At,rule:fr};import{ESLintUtils as mr}from"@typescript-eslint/utils";var dr=mr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="no-leaked-text-in-jsx",yr=[",",";","[","]","(",")"],gr=dr({name:Pt,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let r="";yr.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),Ue={name:Pt,rule:gr};import{AST_NODE_TYPES as oe,ESLintUtils as Sr}from"@typescript-eslint/utils";var Tr=Sr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="no-non-camel-case-functions",hr=/^[a-z][a-zA-Z0-9]*$/;function Ft(e){return e.typeName.type===oe.TSQualifiedName&&e.typeName.left.type===oe.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===oe.Identifier&&e.typeName.right.name==="Element"}var Er=Tr({name:Nt,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&&!hr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===oe.TSTypeReference?Ft(n):n.type===oe.TSUnionType&&n.types.some(o=>o.type===oe.TSTypeReference&&Ft(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Ve={name:Nt,rule:Er};import{ESLintUtils as br,TSESTree as M}from"@typescript-eslint/utils";import{AST_NODE_TYPES as Lt}from"@typescript-eslint/utils";function ae(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:ae(e.parent,t,n===1/0?n:n-1)}function*We(e){yield e,e.parent&&(yield*We(e.parent))}function He(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function _t(e,t,n){let o=n.getDeclaredVariables(e).find(l=>l.name===t||l.identifiers[0]?.parent.type===Lt.Property&&l.identifiers[0]?.parent.key.type===Lt.Identifier&&l.identifiers[0]?.parent.key.name===t);return o?o.references.filter(l=>!l.init):[]}var xr=br.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dt="no-optional-root-props",Cr=xr({name:Dt,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let l=e.sourceCode.getDeclaredVariables(r)[0];if(!l||l.references.length!==1)return!1;let u=l.references[0];if(!u)return!1;for(let i of We(u.identifier)){if("returnType"in i||i.type===M.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let a=i.parent;if(!a)return!1;if(a.type===M.AST_NODE_TYPES.TSTypeParameterInstantiation&&a.parent.type===M.AST_NODE_TYPES.TSTypeReference&&a.parent.typeName.type===M.AST_NODE_TYPES.Identifier&&a.parent.typeName.name==="FC"){let s=ae(a.parent.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(!s)return!1;let p=Te(s,e.sourceCode);return p?!(p.parent.type===M.AST_NODE_TYPES.CallExpression&&p.parent.callee.type===M.AST_NODE_TYPES.Identifier&&p.parent.callee.name==="memo"):!1}if(i.type===M.AST_NODE_TYPES.AssignmentPattern)return!1;if(a.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let c=ae(a,M.AST_NODE_TYPES.VariableDeclaration);return c?!!Te(c,e.sourceCode):!1}if(a.type===M.AST_NODE_TYPES.FunctionDeclaration)return!!Te(a,e.sourceCode)}return!1}function n(r){r.key.type!==M.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:o=>{let l=ae(r,M.AST_NODE_TYPES.TSPropertySignature);if(!l)return null;let u=e.sourceCode.getText(l);return o.replaceText(l,u.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeLiteral&&!(he(r)||!t(r)))for(let o of r.typeAnnotation.members)o.type===M.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSInterfaceDeclaration(r){if(!(he(r)||!t(r)))for(let o of r.body.body)o.type===M.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSTypeReference(r){if(r.typeName.type!==M.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let o=r.typeArguments.params[0];if(o.type!==M.AST_NODE_TYPES.TSTypeLiteral)return;let l=ae(r.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(!l)return;let u=Te(l,e.sourceCode);if(!(!u||u.parent.type===M.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===M.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"))for(let a of o.members)a.type===M.AST_NODE_TYPES.TSPropertySignature&&n(a)}}}});function he(e){return e?e.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===M.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Te(e,t){if(he(e))return;let n;if(e.type===M.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===M.AST_NODE_TYPES.Identifier&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===M.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let o=r.variables.find(u=>u.identifiers.includes(n));if(!o)return;let l=o.references.filter(u=>u.identifier!==n);if(!(l.length!==1||!l[0])&&!he(l[0].identifier.parent.parent))return l[0].identifier}var Ye={name:Dt,rule:Cr};import{ESLintUtils as Ir}from"@typescript-eslint/utils";import ze from"node:path";var wr=Ir.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jt="no-relative-imports",Rr=_({find:L(),replacement:L()}),vr=_({aliases:H(Rr),rootDir:F(L()),allowNotFoundAliases:F(ie()),_dev_simulateFileName:F(L())}),Or=wr({name:jt,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[vr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(u){return u.startsWith(".")||u.startsWith("..")}function o(u,i){let a=ze.dirname(i);return ze.resolve(a,u)}function l(u){let i=t.rootDir??process.cwd(),a=ze.relative(i,u);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:c,replacement:s}of t.aliases)if(a.startsWith(s)){let p=a.replace(s,c);return{alias:c,newPath:p}}return null}return{ImportDeclaration(u){let i=u.source.value;if(!r(i))return;let a=o(i,n),c=l(a);!c&&t.allowNotFoundAliases||e.report({node:u,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?s=>s.replaceText(u.source,`'${c.newPath}'`):void 0})}}}}),Be={name:jt,rule:Or};import{AST_NODE_TYPES as ue,ESLintUtils as Mt}from"@typescript-eslint/utils";import*as qe from"typescript";var kr=Mt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="no-unnecessary-casting",Ar=_({additionalCastFunctions:F(H(_({name:L(),expectedType:de(["string","number"])})))}),Ke={name:$t,rule:kr({name:$t,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[Ar],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],o=Mt.getParserServices(e,!0),l=o.program?.getTypeChecker();if(!l||!o.program)throw new Error("TypeScript services or program not available");function u(s,p){switch(s.type){case ue.Literal:return p==="number"?typeof s.value=="number":typeof s.value=="string";case ue.TemplateLiteral:return p==="string";case ue.UnaryExpression:return p==="number"?s.operator==="+"||s.operator==="-"||s.operator==="~":!1;default:return!1}}function i(s,p){return p==="number"?!!(s.flags&qe.TypeFlags.NumberLike):!!(s.flags&qe.TypeFlags.StringLike)}function a(s,p){return g=>g.replaceText(s,e.sourceCode.getText(p))}function c(s){if(!l||s.arguments.length!==1)return;let p=s.arguments[0];if(!p||p.type===ue.SpreadElement)return;let{callee:g}=s;if(g.type!==ue.Identifier)return;let y=g.name,S=r.find(b=>b.name===y);if(!S)return;if(u(p,S.expectedType)||i(l.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(p)),S.expectedType)){let b,T;y==="Number"?b="unnecessaryNumberCasting":y==="String"?b="unnecessaryStringCasting":(b="unnecessaryCustomCasting",T={name:S.name,type:S.expectedType}),e.report({node:s,messageId:b,...T?{data:T}:{},fix:a(s,p)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as V,ESLintUtils as Pr}from"@typescript-eslint/utils";var Fr=_({selectors:H(_({name:L(),selectorProp:F(L()),selectorArgPos:F(X()),returnProp:F(L())}))}),Nr=Pr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="no-unused-selected-values",Xe={name:Ut,rule:Nr({name:Ut,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Fr]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.map(o=>[o.name,o]));return{VariableDeclarator(o){let l=null;if(o.init?.type===V.CallExpression&&(l=o.init),!l)return;let u=_r(l);if(!u)return;let i=r.get(u);if(!i)return;let a=Lr(l,i.selectorArgPos??0,i.selectorProp);if(!a)return;let c=Dr(a);if(!c)return;let s=Vt(c.properties,void 0);if(!s)return;if(o.id.type===V.ObjectPattern){let y=Vt(o.id.properties,i.returnProp);if(!y)return;for(let[S,d]of s)y.has(S)||e.report({node:d,messageId:"unusedSelectedValue",data:{name:S}});return}if(o.id.type!==V.Identifier||i.returnProp)return;let p=jr(o,e.sourceCode);if(p.length===0)return;let g=new Set;for(let y of p){if(y.identifier.parent.type!==V.MemberExpression)return;let S=y.identifier.parent.property;if(S.type!==V.Identifier)return;g.add(S.name)}for(let[y,S]of s)g.has(y)||e.report({node:S,messageId:"unusedSelectedValue",data:{name:y}})}}}})};function Lr(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===V.ArrowFunctionExpression||r.type===V.FunctionExpression)return r;if(n&&r.type===V.ObjectExpression){let o=r.properties.find(u=>u.type===V.Property&&u.key.type===V.Identifier&&u.key.name===n);if(o?.type!==V.Property)return null;let l=o.value;if(l.type===V.ArrowFunctionExpression||l.type===V.FunctionExpression)return l}return null}function _r(e){return e.callee.type===V.Identifier?e.callee.name:e.callee.type===V.MemberExpression&&e.callee.property.type===V.Identifier?e.callee.property.name:null}function Dr(e){if(e.body.type===V.ObjectExpression)return e.body;if(e.body.type===V.BlockStatement){let t=e.body.body.filter(n=>n.type===V.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==V.ObjectExpression?null:t[0].argument}return null}function Vt(e,t){let n=e;if(t){let o=e.find(l=>l.type===V.Property&&l.key.type===V.Identifier&&l.key.name===t);if(o?.type!==V.Property||o.value.type!==V.ObjectPattern)return null;n=o.value.properties}let r=new Map;for(let o of n){if(o.type!==V.Property||o.key.type!==V.Identifier)return null;r.set(o.key.name,o)}return r.size>0?r:null}function jr(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as U}from"@typescript-eslint/utils";import{ESLintUtils as $r}from"@typescript-eslint/utils";function Wt(e){let n=$r.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}var Je=Wt({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(l=>l.type===U.ImportDeclaration&&l.source.value==="t-state-form"))return{};let r=null,o=!1;return{CallExpression(l){if(o)return;if(!r){let i=Mr(l);i&&(r=i);return}let u=Ur(l,e.sourceCode);if(u){o=!0;for(let i of u)r.delete(i);if(r.size!==0)for(let[i,a]of r)e.report({node:a,messageId:"unusedField",data:{name:i}})}}}}});function Mr(e){if(!(e.callee.type===U.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==U.ObjectExpression)return null;let r=He(n.properties,l=>l.type!==U.Property||l.key.type!==U.Identifier||l.key.name!=="initialConfig"?null:l.value.type===U.ObjectExpression?l.value:l.value.type===U.ArrowFunctionExpression||l.value.type===U.FunctionExpression?Vr(l.value):null);if(!r)return null;let o=new Map;for(let l of r.properties)l.type===U.Property&&l.key.type===U.Identifier&&o.set(l.key.name,l);return o}function Ur(e,t){if(!(e.callee.type===U.Identifier&&e.callee.name==="useFormState")||e.parent.type!==U.VariableDeclarator||e.parent.id.type!==U.ObjectPattern||!He(e.parent.id.properties,u=>u.type===U.Property&&u.key.type===U.Identifier&&u.key.name==="formFields"&&u))return null;let o=_t(e.parent,"formFields",t),l=new Set;for(let{identifier:u}of o){if(u.type!==U.Identifier||u.parent.type===U.Property&&u.parent.parent.type===U.ObjectExpression&&u.parent.parent.parent.type===U.ReturnStatement||u.parent.type===U.ReturnStatement)return null;if(u.parent.type===U.MemberExpression){if(u.parent.object.type!==U.Identifier||u.parent.property.type!==U.Identifier)return null;l.add(u.parent.property.name)}}return l}function Vr(e){if(e.body.type===U.ObjectExpression)return e.body;if(e.body.type===U.BlockStatement){let t=e.body.body.filter(n=>n.type===U.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==U.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as $,ESLintUtils as Wr}from"@typescript-eslint/utils";var Hr=Wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Ht(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 Yt(e,...t){for(let n of t)e.set(...n);return e}var Yr=_({forceCheckOnFCPropTypesWithName:F(H(L()))}),zt="no-unused-type-props-in-args",Ge=null,zr=Hr({name:zt,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:[Yr],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Ge&&(Ge=n.map(i=>new RegExp(i)));function r(i,a,c,s,p=!0){let g=c.name,y=e.sourceCode.getScope(a).references.find(b=>b.identifier.name===g)?.resolved,S=i&&Ge?.some(b=>b.test(g));if(!y||!S&&y.references.filter(b=>b.isTypeReference).length>1)return;let d=y?.defs[0]?.node;if(!(p&&d?.parent?.type===$.ExportNamedDeclaration)){if(d?.type===$.TSTypeAliasDeclaration){o(i,a,s,d.typeAnnotation,!0);return}if(d?.type===$.TSInterfaceDeclaration){o(i,a,s,d.body,!0);return}}}function o(i,a,c,s,p){if(s.type===$.TSInterfaceBody){for(let g of s.body)g.type===$.TSPropertySignature&&g.key.type===$.Identifier&&c.set(g.key.name,g);return}if(s.type===$.TSTypeLiteral){Yt(c,...Ht(s));return}if(s.type===$.TSIntersectionType){for(let g of s.types)o(i,a,c,g,!0);return}p||s.type===$.TSTypeReference&&s.typeName.type===$.Identifier&&r(i,a,s.typeName,c)}function l(i,a,c){for(let s of c)if(s.type==="ObjectPattern"&&s.typeAnnotation){let p=new Map;if(o(i,a,p,s.typeAnnotation.typeAnnotation,!1),p.size===0)continue;u(s,p)}else s.type===$.AssignmentPattern&&s.left.type===$.ObjectPattern&&l(i,a,[s.left])}function u(i,a){let c=[];if(i.properties.at(-1)?.type===$.RestElement)return;for(let y of i.properties)y.type===$.Property&&y.key.type===$.Identifier&&c.push(y.key.name);let p=[],g=[];for(let[y,S]of a)c.includes(y)||(g.push(y),p.push({node:S,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,S]of p.entries())e.report({...S,fix:y===p.length-1?d=>{let b=i.properties.at(-1),T=g.join(", ");return b?b?.type===$.RestElement?null:d.insertTextAfter(b,`, ${T}`):d.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${T}`)}:void 0})}return{VariableDeclaration(i){let a=i.declarations[0];if(!a)return;let c=new Map,s=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(s){if(s.type===$.TSTypeReference&&s.typeName.type===$.Identifier)r(!0,i,s.typeName,c,!1);else if(s.type===$.TSTypeLiteral)Yt(c,...Ht(s));else if(s.type===$.TSIntersectionType)for(let p of s.types)p.type===$.TSTypeReference&&p.typeName.type===$.Identifier?r(!0,i,p.typeName,c,!1):o(!0,i,c,p,!0);if(c.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&&u(p,c)}}},FunctionDeclaration:function(i){l(!1,i,i.params)},ArrowFunctionExpression(i){l(!1,i,i.params)}}}}),Ze={name:zt,rule:zr};import{AST_NODE_TYPES as Qe,ESLintUtils as Br}from"@typescript-eslint/utils";var qr=Br.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="prefer-named-functions",Bt=new Map,Kr=qr({name:qt,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=Bt.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),Bt.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===Qe.ArrowFunctionExpression&&r.id.type===Qe.Identifier){let o=r.id.name;if(r.id.typeAnnotation||n&&n.test(o)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==Qe.BlockStatement)return;let l=r.parent,u=r.init.params,i=r.init.body,a=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(l,`${a.async?"async ":""}function ${o}(${u.map(s=>e.sourceCode.getText(s)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),et={name:qt,rule:Kr};import{AST_NODE_TYPES as Y,AST_TOKEN_TYPES as Kt,ESLintUtils as Xr}from"@typescript-eslint/utils";var Jr=Xr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="prefer-single-line-if",Gr=_({maxLineLength:F(X()),maxNonSimpleConditionLength:F(X())}),Zr=Jr({name:Jt,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(r){if(r.consequent.type!==Y.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let l=r.consequent.body[0];if(l.type===Y.ReturnStatement){if(!Zt(l))return}else if(!(l.type===Y.ContinueStatement||l.type===Y.BreakStatement))return;if(r.test.type===Y.LogicalExpression||r.test.type===Y.ConditionalExpression)return;let u;if(t.maxNonSimpleConditionLength){let p=Xt(r.test);if(!p&&r.test.type===Y.UnaryExpression&&r.test.operator==="!"){let g=r.test.argument;Xt(g)&&(p=!0)}if(p&&(u=n.getText(r.test),u.length>t.maxNonSimpleConditionLength))return}u||(u=n.getText(r.test));let i=n.getText(l);if(u.includes(`
15
- `))return;let a=n.getTokenAfter(r);if(a&&a.type===Kt.Punctuator&&a.value==="}"){let p=n.getTokenAfter(a);if(p&&p.type===Kt.Keyword&&(p.value==="else"||p.value==="catch"))return}let c=Qr(n,r),s=`if (${u}) ${i}`;t.maxLineLength&&s.length+c.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:p=>p.replaceText(r,s)})}}}});function Xt(e){return e.type===Y.CallExpression||e.type===Y.BinaryExpression||e.type===Y.MemberExpression&&Gt(e)}function Gt(e){return e.object.type===Y.MemberExpression?Gt(e.object):e.object.type!==Y.Identifier}function Qr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Zt(e){if(!e.argument)return!0;let t=e.argument;return t.type===Y.ArrayExpression&&t.elements.length===0||t.type===Y.ObjectExpression&&t.properties.length===0||t.type===Y.Literal||t.type===Y.Identifier||t.type===Y.TemplateLiteral||t.type===Y.TaggedTemplateExpression?!0:t.type===Y.CallExpression?t.arguments.length===0:t.type===Y.UnaryExpression?Zt(t):!1}var tt={name:Jt,rule:Zr};import{AST_NODE_TYPES as J,ESLintUtils as ei}from"@typescript-eslint/utils";var ti=ei.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="react-compiler-migration",ni=_({disallowHooks:F(H(_({name:L(),replacement:L()}))),disallowMethods:F(H(_({name:L(),replacement:F(L()),requireTrueProp:F(L())})))}),ri=/eslint +react-compiler\/react-compiler: +\["error/;function ii(e){return e.type===J.Identifier?e.name.startsWith("use"):e.type===J.MemberExpression&&e.property.type===J.Identifier?e.property.name.startsWith("use"):!1}var si=ti({name:Qt,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:[ni]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(ri.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let o=null,l=null;if(r.callee.type===J.Identifier?(o=r.callee.name,l=r.callee):r.callee.type===J.MemberExpression&&r.callee.property.type===J.Identifier&&(o=r.callee.property.name,l=r.callee.property),o){let u=t.disallowHooks.find(i=>i.name===o);u&&l&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:u.name,replacement:u.replacement},suggest:[{messageId:"replace",data:{replacement:u.replacement},fix:i=>i.replaceText(l,u.replacement)}]})}}if(t.disallowMethods?.length&&ii(r.callee)){for(let o of r.arguments)if(o.type===J.ObjectExpression){for(let l of o.properties)if(l.type===J.Property&&l.key.type===J.Identifier){let u=l.key.name,i=t.disallowMethods.find(a=>a.name===u);if(i){if(i.requireTrueProp){let a=i.requireTrueProp,c=!1;for(let s of o.properties)if(s.type===J.Property&&s.key.type===J.Identifier&&s.key.name===a&&s.value.type===J.Literal&&s.value.value===!0){c=!0;break}if(!c){e.report({node:l,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:a}});continue}}i.replacement&&e.report({node:l,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:a=>a.replaceText(l.key,i.replacement)}]})}}}}}}:{}}}),nt={name:Qt,rule:si};import{ESLintUtils as oi,TSESTree as ai}from"@typescript-eslint/utils";var li=oi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),en="require-description",ci=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ui=/^eslint-disable-(next-)?line$/u,pi=li({name:en,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 o of n.getAllComments()){let l=fi(o);l!=null&&(r.has(l.kind)||l.description||e.report({loc:di(o.loc),messageId:"missingDescription"}))}}}}}),tn={name:en,rule:pi};function fi(e){let{text:t,description:n}=mi(e.value);if(!t)return null;let r=ci.exec(t);if(!r)return null;let o=r[1];if(!o)return null;let l=ui.test(o);if(e.type===ai.AST_TOKEN_TYPES.Line&&!l||l&&e.loc.start.line!==e.loc.end.line)return null;let u=t.slice(r.index+o.length);return{kind:o,value:u.trim(),description:n}}function mi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function di(e){return{start:{line:e.start.line,column:-1},end:e.end}}function sn(e){return/^use[A-Z0-9]/.test(e)}function Ee(e){return e.type==="Identifier"?sn(e.name):e.type==="MemberExpression"&&!e.computed&&Ee(e.property)?e.object.type==="Identifier":!1}function on(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function an(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function ln(e){return!!(e.parent&&e.parent.callee&&an(e.parent.callee,"forwardRef"))}function cn(e){return!!(e.parent&&e.parent.callee&&an(e.parent.callee,"memo"))}function rt(e){for(;e;){let t=pn(e);if(t&&(on(t)||Ee(t))||ln(e)||cn(e))return!0;e=e.parent}return!1}function nn(e){return!1}function it(e){return!1}var yi=/eslint +react-compiler\/react-compiler: +\["error/,un={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(yi.test(a.value))return{CallExpression(c){let s=null;c.callee.name==="useMemo"?s="useMemo":c.callee.name==="useCallback"&&(s="useCallback"),s&&e.report({node:c,message:`"${s}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),r=null,o=[],l=[],u=new WeakSet;function i(a){for(let c of a.references){let s=c.identifier.parent;if(s.type==="VariableDeclarator"&&s.init&&s.init.type==="CallExpression"&&s.init.callee&&nn(s.init.callee))for(let p of c.resolved.references)p!==c&&u.add(p.identifier)}}return{onCodePathSegmentStart:a=>l.push(a),onCodePathSegmentEnd:()=>l.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(a,c){let s=o.pop();if(s.size===0)return;let p=new Set;function g(h,w){let{cache:R}=g,O=R.get(h.id),D=new Set(w);if(D.has(h.id)){let k=[...D],W=k.slice(k.indexOf(h.id)+1);for(let Q of W)p.add(Q);return BigInt("0")}if(D.add(h.id),O!==void 0)return O;if(a.thrownSegments.includes(h))O=BigInt("0");else if(h.prevSegments.length===0)O=BigInt("1");else{O=BigInt("0");for(let k of h.prevSegments)O+=g(k,D)}return h.reachable&&O===BigInt("0")?R.delete(h.id):R.set(h.id,O),O}function y(h,w){let{cache:R}=y,O=R.get(h.id),D=new Set(w);if(D.has(h.id)){let k=Array.from(D),W=k.slice(k.indexOf(h.id)+1);for(let Q of W)p.add(Q);return BigInt("0")}if(D.add(h.id),O!==void 0)return O;if(a.thrownSegments.includes(h))O=BigInt("0");else if(h.nextSegments.length===0)O=BigInt("1");else{O=BigInt("0");for(let k of h.nextSegments)O+=y(k,D)}return R.set(h.id,O),O}function S(h){let{cache:w}=S,R=w.get(h.id);if(R===null)return 1/0;if(R!==void 0)return R;if(w.set(h.id,null),h.prevSegments.length===0)R=1;else{R=1/0;for(let O of h.prevSegments){let D=S(O);D<R&&(R=D)}R+=1}return w.set(h.id,R),R}g.cache=new Map,y.cache=new Map,S.cache=new Map;let d=y(a.initialSegment),b=pn(c),T=rt(c),N=b?on(b)||Ee(b):ln(c)||cn(c),v=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let w=S(h);w<v&&(v=w)}for(let[h,w]of s){if(!h.reachable)continue;let R=h.nextSegments.length===0?v<=S(h):v<S(h),O=g(h)*y(h),D=p.has(h.id);for(let k of w)if(D&&!it(k)&&e.report({node:k,message:`React Hook "${t(k)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),N){if(c.async&&e.report({node:k,message:`React Hook "${t(k)}" cannot be called in an async function.`}),!D&&O!==d&&!it(k)){let Q=`React Hook "${t(k)}" 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:k,message:Q})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let W=`React Hook "${t(k)}" 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:k,message:W})}else if(b){let W=`React Hook "${t(k)}" is called in function "${t(b)}" 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:k,message:W})}else if(c.type==="Program"){let W=`React Hook "${t(k)}" 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:k,message:W})}else if(T&&!it(k)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let Q=c.parent;if(Q.parent.type==="VariableDeclarator"&&sn(Q.parent.id.name))return}let W=`React Hook "${t(k)}" 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:k,message:W})}}},CallExpression(a){if(Ee(a.callee)){let c=rn(o),s=rn(l),p=c.get(s);p||(p=[],c.set(s,p)),p.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||nn(a.callee))&&a.arguments.length>0&&(r=a)},Identifier(a){r==null&&u.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===r&&(r=null)},FunctionDeclaration(a){rt(a)&&i(n(a))},ArrowFunctionExpression(a){rt(a)&&i(n(a))}}}};function pn(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function rn(e){return e[e.length-1]}var fn={[Ze.name]:Ze.rule,[$e.name]:$e.rule,[je.name]:je.rule,"rules-of-hooks":un,"exhaustive-deps":Et,"require-description":tn.rule,[Me.name]:Me.rule,[Ve.name]:Ve.rule,[et.name]:et.rule,[ke.name]:ke.rule,[De.name]:De.rule,[Be.name]:Be.rule,[tt.name]:tt.rule,[Ye.name]:Ye.rule,[Ue.name]:Ue.rule,[Pe.name]:Pe.rule,[nt.name]:nt.rule,[ve.name]:ve.rule,[_e.name]:_e.rule,[Ke.name]:Ke.rule,[Xe.name]:Xe.rule,[Je.name]:Je.rule};var ao={rules:fn};export{ao as extendedLintPlugin};
14
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let A=o.acquire(g),L=new Set,D=null;{let p=A.upper;for(;p&&(L.add(p),p.type!=="function");)p=p.upper;if(!p)return;D=p}let R=Array.isArray;function j(p){if(!R(p.defs))return!1;let d=p.defs[0];if(d==null||d.node.type!=="VariableDeclarator")return!1;let b=d.node.init;if(b==null)return!1;for(;b.type==="TSAsExpression";)b=b.expression;let x=d.node.parent;if(x==null&&(De(D.block,d.node.id),x=d.node.parent,x==null))return!1;if(x.kind==="const"&&b.type==="Literal"&&(typeof b.value=="string"||typeof b.value=="number"||b.value===null))return!0;if(b.type!=="CallExpression")return!1;let w=b.callee;if(w.type==="MemberExpression"&&w.object.name==="React"&&w.property!=null&&!w.computed&&(w=w.property),w.type!=="Identifier")return!1;let I=d.node.id,{name:k}=w;if(k==="useRef"&&I.type==="Identifier")return!0;if(Vn(w)&&I.type==="Identifier"){for(let P of p.references)P!==I&&m.add(P.identifier);return!0}else if(k==="useState"||k==="useReducer"){if(I.type==="ArrayPattern"&&I.elements.length===2&&R(p.identifiers)){if(I.elements[1]===p.identifiers[0]){if(k==="useState"){let P=p.references,X=0;for(let ee=0;ee<P.length;ee++){if(P[ee].isWrite()&&X++,X>1)return!1;l.set(P[ee].identifier,I.elements[0])}}return!0}else if(I.elements[0]===p.identifiers[0]){if(k==="useState"){let P=p.references;for(let X=0;X<P.length;X++)c.add(P[X].identifier)}return!1}}}else if(k==="useTransition"&&I.type==="ArrayPattern"&&I.elements.length===2&&Array.isArray(p.identifiers)&&I.elements[1]===p.identifiers[0])return!0;return!1}function z(p){if(!R(p.defs))return!1;let d=p.defs[0];if(d==null||d.node==null||d.node.id==null)return!1;let b=d.node,x=D.childScopes,w=null,I;for(I=0;I<x.length;I++){let k=x[I],P=k.block;if(b.type==="FunctionDeclaration"&&P===b||b.type==="VariableDeclarator"&&P.parent===b){w=k;break}}if(w==null)return!1;for(I=0;I<w.through.length;I++){let k=w.through[I];if(k.resolved!=null&&L.has(k.resolved.scope)&&!pe(k.resolved))return!1}return!0}let pe=y(j,f),fn=y(z,h),at=new Map;function mn(p){let d=p.from,b=!1;for(;d.block!==g;)d.type==="function"&&(b=d.block.parent!=null&&d.block.parent.type==="ReturnStatement"),d=d.upper;return b}let K=new Map,Ce=new Map;lt(A);function lt(p){for(let d of p.references){if(!d.resolved||!L.has(d.resolved.scope))continue;let b=De(g,d.identifier),x=bt(b),w=te(x,Ce);if(v&&x.type==="Identifier"&&(x.parent.type==="MemberExpression"||x.parent.type==="OptionalMemberExpression")&&!x.parent.computed&&x.parent.property.type==="Identifier"&&x.parent.property.name==="current"&&mn(d)&&at.set(w,{reference:d,dependencyNode:x}),x.parent.type==="TSTypeQuery"||x.parent.type==="TSTypeReference")continue;let I=d.resolved.defs[0];if(I!=null&&!(I.node!=null&&I.node.init===g.parent)&&I.type!=="TypeParameter")if(K.has(w))K.get(w).references.push(d);else{let k=d.resolved,P=pe(k)||fn(k);K.set(w,{isStable:P,references:[d]})}}for(let d of p.childScopes)lt(d)}at.forEach(({reference:p,dependencyNode:d},b)=>{let x=p.resolved.references,w=!1;for(let I=0;I<x.length;I++){let{identifier:k}=x[I],{parent:P}=k;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){w=!0;break}}w||i({node:d.parent.property,message:`The ref value '${b}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${b}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Ie=new Set;function dn(p,d){Ie.has(d)||(Ie.add(d),i({node:p,message:`Assignments to the '${d}' variable from inside React Hook ${n(C)} 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(C)}.`}))}let fe=new Set;if(K.forEach(({isStable:p,references:d},b)=>{p&&fe.add(b),d.forEach(x=>{x.writeExpr&&dn(x.writeExpr,b)})}),Ie.size>0)return;if(!O){let p=null;if(K.forEach(({isStable:d,references:b},x)=>{p||b.forEach(w=>{if(p)return;let I=w.identifier;if(!l.has(I))return;let P=w.from;for(;P.type!=="function";)P=P.upper;P.block===g&&(p=x)})}),p){let{suggestedDependencies:d}=Le({dependencies:K,declaredDependencies:[],stableDependencies:fe,externalDependencies:new Set,isEffect:!0});i({node:C,message:`React Hook ${S} contains a call to '${p}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+d.join(", ")+`] as a second argument to the ${S} Hook.`,suggest:[{desc:`Add dependencies array: [${d.join(", ")}]`,fix(b){return b.insertTextAfter(g,`, [${d.join(", ")}]`)}}]})}return}let le=[],ce=new Set;O.type!=="ArrayExpression"?i({node:O,message:`React Hook ${n(C)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):O.elements.forEach(p=>{if(p===null)return;if(p.type==="SpreadElement"){i({node:p,message:`React Hook ${n(C)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}m.has(p)&&i({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 d;try{d=te(p,Ce)}catch(w){if(/Unsupported node type/.test(w.message)){p.type==="Literal"?K.has(p.value)?i({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?`}):i({node:p,message:`The ${p.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:p,message:`React Hook ${n(C)} 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 b=p;for(;b.type==="MemberExpression"||b.type==="OptionalMemberExpression"||b.type==="ChainExpression";)b=b.object||b.expression.object;let x=!D.through.some(w=>w.identifier===b);le.push({key:d,node:p}),x||ce.add(d)});let{suggestedDependencies:yn,unnecessaryDependencies:me,missingDependencies:ne,duplicateDependencies:ct}=Le({dependencies:K,declaredDependencies:le,stableDependencies:fe,externalDependencies:ce,isEffect:v}),de=yn;if(ct.size+ne.size+me.size===0){if(t)return;jn({declaredDependencies:le,declaredDependenciesNode:O,componentScope:D,scope:A}).forEach(({construction:d,isUsedOutsideOfHook:b,depType:x})=>{let w=x==="function"?"useCallback":"useMemo",I=x==="function"?"definition":"initialization",k=`wrap the ${I} of '${d.name.name}' in its own ${w}() Hook.`,P=b?`To fix this, ${k}`:`Move it inside the ${S} callback. Alternatively, ${k}`,X=x==="conditional"||x==="logical expression"?"could make":"makes",ee=`The '${d.name.name}' ${x} ${X} the dependencies of ${S} Hook (at line ${O.loc.start.line}) change on every render. ${P}`,ut;b&&d.type==="Variable"&&x==="function"&&(ut=[{desc:`Wrap the ${I} of '${d.name.name}' in its own ${w}() Hook.`,fix(pt){let[Sn,Tn]=w==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[pt.insertTextBefore(d.node.init,Sn),pt.insertTextAfter(d.node.init,Tn)]}}]),i({node:d.node,message:ee,suggest:ut})});return}!v&&ne.size>0&&(de=Le({dependencies:K,declaredDependencies:[],stableDependencies:fe,externalDependencies:ce,isEffect:v}).suggestedDependencies);function gn(){if(le.length===0)return!0;let p=le.map(b=>b.key),d=p.slice().sort();return p.join(",")===d.join(",")}gn()&&de.sort();function we(p){let d=p.split("."),b="";for(let x=0;x<d.length;x++){if(x!==0){let w=d.slice(0,x+1).join("."),I=Ce.get(w)===!0;b+=I?"?.":"."}b+=d[x]}return b}function Re(p,d,b,x){return p.size===0?null:(p.size>1?"":d+" ")+b+" "+(p.size>1?"dependencies":"dependency")+": "+$n(Array.from(p).sort().map(w=>"'"+we(w)+"'"))+`. Either ${x} ${p.size>1?"them":"it"} or remove the dependency array.`}let Z="";if(me.size>0){let p=null;if(Array.from(me.keys()).forEach(d=>{p===null&&d.endsWith(".current")&&(p=d)}),p!==null)Z=` Mutable values like '${p}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ce.size>0){let d=Array.from(ce)[0];A.set.has(d)||(Z=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!Z&&ne.has("props")){let p=K.get("props");if(p==null)return;let d=p.references;if(!Array.isArray(d))return;let b=!0;for(let x=0;x<d.length;x++){let w=d[x],I=De(D.block,w.identifier);if(!I){b=!1;break}let k=I.parent;if(k==null){b=!1;break}if(k.type!=="MemberExpression"&&k.type!=="OptionalMemberExpression"){b=!1;break}}b&&(Z=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${S} call and refer to those specific props inside ${n(C)}.`)}if(!Z&&ne.size>0){let p=null;ne.forEach(d=>{if(p)return;let b=D.set.get(d),x=K.get(d);if(x.references[0].resolved!==b)return;let w=b.defs[0];if(w==null||w.name==null||w.type!=="Parameter")return;let I=!1,k;for(let P=0;P<x.references.length;P++)if(k=x.references[P].identifier,k!=null&&k.parent!=null&&(k.parent.type==="CallExpression"||k.parent.type==="OptionalCallExpression")&&k.parent.callee===k){I=!0;break}I&&(p=d)}),p!==null&&(Z=` If '${p}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!Z&&ne.size>0){let p=null;if(ne.forEach(d=>{if(p!==null)return;let x=K.get(d).references,w,I;for(let k=0;k<x.length;k++){for(w=x[k].identifier,I=w.parent;I!=null&&I!==D.block;){if(I.type==="CallExpression"){let P=l.get(I.callee);if(P!=null){if(P.name===d)p={missingDep:d,setter:I.callee.name,form:"updater"};else if(c.has(w))p={missingDep:d,setter:I.callee.name,form:"reducer"};else{let X=x[k].resolved;if(X!=null){let ee=X.defs[0];ee!=null&&ee.type==="Parameter"&&(p={missingDep:d,setter:I.callee.name,form:"inlineReducer"})}}break}}I=I.parent}if(p!==null)break}}),p!==null)switch(p.form){case"reducer":Z=` You can also replace multiple useState variables with useReducer if '${p.setter}' needs the current value of '${p.missingDep}'.`;break;case"inlineReducer":Z=` 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":Z=` 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.")}}i({node:O,message:`React Hook ${n(C)} has `+(Re(ne,"a","missing","include")||Re(me,"an","unnecessary","exclude")||Re(ct,"a","duplicate","omit"))+Z,suggest:[{desc:`Update the dependencies array to be: [${de.map(we).join(", ")}]`,fix(p){return p.replaceText(O,`[${de.map(we).join(", ")}]`)}}]})}function E(g){let O=Mn(g.callee,u);if(O===-1)return;let C=g.arguments[O],S=g.callee,v=xt(S).name,A=g.arguments[O+1],L=/Effect($|[^a-z])/g.test(v);if(!C){i({node:S,message:`React Hook ${v} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!L)){if(!A&&!L){(v==="useMemo"||v==="useCallback")&&i({node:S,message:`React Hook ${v} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(C.type){case"FunctionExpression":case"ArrowFunctionExpression":T(C,A,S,v,L);return;case"Identifier":if(!A||A.elements&&A.elements.some(j=>j&&j.type==="Identifier"&&j.name===C.name))return;let D=r(g).set.get(C.name);if(D==null||D.defs==null)return;let R=D.defs[0];if(!R||!R.node||R.type!=="Variable"&&R.type!=="FunctionName")break;switch(R.node.type){case"FunctionDeclaration":T(R.node,A,S,v,L);return;case"VariableDeclarator":let j=R.node.init;if(!j)break;switch(j.type){case"ArrowFunctionExpression":case"FunctionExpression":T(j,A,S,v,L);return}break}break;default:i({node:S,message:`React Hook ${v} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:S,message:`React Hook ${v} has a missing dependency: '${C.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${C.name}]`,fix(D){return D.replaceText(A,`[${C.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(Dn.test(g.value))return t=!0,{CallExpression:O=>E(O,!0)}}return{CallExpression:g=>E(g)}}};function Le({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:s}){let a=u();function u(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,E)=>{let g=i(a,E);g.isUsed=!0,o(a,E,O=>{O.isSubtreeUsed=!0})}),t.forEach(({key:T})=>{let E=i(a,T);E.isSatisfiedRecursively=!0}),n.forEach(T=>{let E=i(a,T);E.isSatisfiedRecursively=!0});function i(T,E){let g=E.split("."),O=T;for(let C of g){let S=O.children.get(C);S||(S=u(),O.children.set(C,S)),O=S}return O}function o(T,E,g){let O=E.split("."),C=T;for(let S of O){let v=C.children.get(S);if(!v)return;g(v),C=v}}let l=new Set,c=new Set;f(a,l,c,T=>T);function f(T,E,g,O){T.children.forEach((C,S)=>{let v=O(S);if(C.isSatisfiedRecursively){C.isSubtreeUsed&&g.add(v);return}if(C.isUsed){E.add(v);return}f(C,E,g,A=>v+"."+A)})}let h=[],m=new Set,y=new Set;return t.forEach(({key:T})=>{c.has(T)?h.indexOf(T)===-1?h.push(T):y.add(T):m.add(T)}),l.forEach(T=>{h.push(T)}),{suggestedDependencies:h,unnecessaryDependencies:m,duplicateDependencies:y,missingDependencies:l}}function re(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 re(e.consequent)!=null||re(e.alternate)!=null?"conditional":null;case"LogicalExpression":return re(e.left)!=null||re(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return re(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return re(e.expression);case"TSAsExpression":return re(e.expression)}return null}function jn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let s=e.map(({key:u})=>{let i=n.variables.find(l=>l.name===u);if(i==null)return null;let o=i.defs[0];if(o==null)return null;if(o.type==="Variable"&&o.node.type==="VariableDeclarator"&&o.node.id.type==="Identifier"&&o.node.init!=null){let l=re(o.node.init);if(l!=null)return[i,l]}return o.type==="FunctionName"&&o.node.type==="FunctionDeclaration"?[i,"function"]:o.type==="ClassName"&&o.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(u){let i=!1;for(let o=0;o<u.references.length;o++){let l=u.references[o];if(l.writeExpr){if(i)return!0;i=!0;continue}let c=l.from;for(;c!==r&&c!=null;)c=c.upper;if(c!==r&&!Ct(t,l.identifier))return!0}return!1}return s.map(([u,i])=>({construction:u.defs[0],depType:i,isUsedOutsideOfHook:a(u)}))}function bt(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)?bt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function _e(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function te(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=te(e.object,t),r=te(e.property,null),s=`${n}.${r}`;return _e(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=te(e.object,t),r=te(e.property,null),s=`${n}.${r}`;return _e(e,t,s),s}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=te(n.object,t),s=te(n.property,null),a=`${r}.${s}`;return _e(n,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function xt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Mn(e,t){let n=xt(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=te(n,null)}catch(s){if(/Unsupported node type/.test(s.message))return 0;throw s}return t.additionalHooks.test(r)?0:-1}else return-1}}function De(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),Un(r,t))return r;if(Ct(r,t))for(let[s,a]of Object.entries(r))s!=="parent"&&(ht(a)?(a.parent=r,n.push(a)):Array.isArray(a)&&a.forEach(u=>{ht(u)&&(u.parent=r,n.push(u))}))}return null}function $n(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 ht(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Un(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 Ct(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Vn(e){return!1}import{AST_NODE_TYPES as Te,ESLintUtils as wt}from"@typescript-eslint/utils";import q from"typescript";var Wn=wt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="improved-no-unnecessary-condition",Hn=_({}),Yn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],zn=new Set(Yn),je={name:It,rule:Wn({name:It,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:[Hn]},defaultOptions:[{}],create(e){let t=wt.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===Te.UnaryExpression&&i.operator==="typeof"}function s(i){return i.flags&q.TypeFlags.Any||i.flags&q.TypeFlags.Unknown?null:i.flags&q.TypeFlags.StringLike?["string"]:i.flags&q.TypeFlags.NumberLike?["number"]:i.flags&q.TypeFlags.BigIntLike?["bigint"]:i.flags&q.TypeFlags.BooleanLike?["boolean"]:i.flags&q.TypeFlags.ESSymbolLike?["symbol"]:i.flags&q.TypeFlags.Undefined||i.flags&q.TypeFlags.Void?["undefined"]:i.flags&q.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&q.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&q.TypeFlags.NonPrimitive?["object"]:i.flags&q.TypeFlags.Never?["never"]:null}function a(i){if(!n)return null;let o=t.esTreeNodeToTSNodeMap.get(i),l=n.getTypeAtLocation(o.expression);if(l.flags&q.TypeFlags.Any||l.flags&q.TypeFlags.Unknown)return null;let c=[];if(l.isUnion()){for(let h of l.types){let m=s(h);if(m)c.push(...m);else return null}return c}let f=s(l);return f?(c.push(...f),c):null}function u(i){if(!(i.operator==="==="||i.operator==="!=="))return;let l=null,c=null;if(r(i.left)?(l=i.left,c=i.right.type===Te.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(l=i.right,c=i.left.type===Te.Literal&&typeof i.left.value=="string"?i.left.value:null),!l||!c||!Bn(c,zn))return;let f=a(l);if(!f)return;let h=i.operator==="!==",m=f.includes(c);f.length===1?m&&!h?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:se(l,e),type:c}}):!m&&h?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:se(l,e),type:Array.from(f)[0]}}):!m&&!h?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:se(l,e),actualType:Se(f),conditionType:c}}):m&&h&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:se(l,e),actualType:Se(f),conditionType:c}}):!m&&!h?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:se(l,e),actualType:Se(f),conditionType:c}}):!m&&h&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:se(l,e),type:Se(f)}})}return{BinaryExpression:u}}})};function Se(e){return Array.from(new Set(e)).join(" | ")||"never"}function se(e,t){let n=e.argument;return n.type===Te.Identifier?n.name:t.sourceCode.getText(n)}function Bn(e,t){return t.has(e)}import{AST_NODE_TYPES as qn,ESLintUtils as Kn}from"@typescript-eslint/utils";var Xn=Kn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="no-call-with-explicit-generics",Jn=_({functions:H(N())}),Gn=Xn({name:Rt,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Jn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:s}=r;s.type===qn.Identifier&&n.has(s.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),Me={name:Rt,rule:Gn};import{AST_NODE_TYPES as he,ESLintUtils as Zn}from"@typescript-eslint/utils";var Qn=Zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="no-call-with-inferred-generics",er=Qn({name:vt,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:s}=r;if(s.type!==he.Identifier)return;let a=n.get(s.name);if(!a)return;let{minGenerics:u=1,allowAny:i,disallowTypes:o=t.disallowTypes}=a;(r.typeArguments?.params.length||0)<(u||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:u||0}}),!(i&&!o)&&r.typeArguments?.params?.some(c=>!i&&c.type===he.TSAnyKeyword||o&&c.type===he.TSTypeReference&&c.typeName.type===he.Identifier&&o.includes(c.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),$e={name:vt,rule:er};import{ESLintUtils as tr,TSESTree as Ot}from"@typescript-eslint/utils";var nr=tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kt="no-commented-out-code",rr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],ir=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],sr=nr({name:kt,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 s of rr)if(r.startsWith(s))return{wrongPattern:s};for(let s of ir)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}return{Program(){let r=e.sourceCode.getAllComments();for(let s of r)if(s.type===Ot.AST_TOKEN_TYPES.Line||s.type===Ot.AST_TOKEN_TYPES.Block){let a=t(s.value);a&&e.report({node:s,messageId:"commentedOutCode",data:{wrongPattern:a.wrongPattern}})}}}}}),Ue={name:kt,rule:sr};import{ESLintUtils as or,TSESTree as ar}from"@typescript-eslint/utils";var lr=or.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-default-export",cr=lr({name:At,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===ar.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Ve={name:At,rule:cr};import{ESLintUtils as ur}from"@typescript-eslint/utils";var pr=ur.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="no-leaked-text-in-jsx",fr=[",",";","[","]","(",")"],mr=pr({name:Pt,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let r="";fr.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),We={name:Pt,rule:mr};import{AST_NODE_TYPES as oe,ESLintUtils as dr}from"@typescript-eslint/utils";var yr=dr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="no-non-camel-case-functions",gr=/^[a-z][a-zA-Z0-9]*$/;function Ft(e){return e.typeName.type===oe.TSQualifiedName&&e.typeName.left.type===oe.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===oe.Identifier&&e.typeName.right.name==="Element"}var Sr=yr({name:Nt,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&&!gr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===oe.TSTypeReference?Ft(n):n.type===oe.TSUnionType&&n.types.some(s=>s.type===oe.TSTypeReference&&Ft(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),He={name:Nt,rule:Sr};import{ESLintUtils as Tr,TSESTree as U}from"@typescript-eslint/utils";import{AST_NODE_TYPES as Lt}from"@typescript-eslint/utils";function ae(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:ae(e.parent,t,n===1/0?n:n-1)}function*Ye(e){yield e,e.parent&&(yield*Ye(e.parent))}function ze(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function _t(e,t,n){let s=n.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Lt.Property&&a.identifiers[0]?.parent.key.type===Lt.Identifier&&a.identifiers[0]?.parent.key.name===t);return s?s.references.filter(a=>!a.init):[]}var hr=Tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dt="no-optional-root-props",Er=hr({name:Dt,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let a=e.sourceCode.getDeclaredVariables(r)[0];if(!a||a.references.length!==1)return!1;let u=a.references[0];if(!u)return!1;for(let i of Ye(u.identifier)){if("returnType"in i||i.type===U.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let o=i.parent;if(!o)return!1;if(o.type===U.AST_NODE_TYPES.TSTypeParameterInstantiation&&o.parent.type===U.AST_NODE_TYPES.TSTypeReference&&o.parent.typeName.type===U.AST_NODE_TYPES.Identifier&&o.parent.typeName.name==="FC"){let c=ae(o.parent.parent,U.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let f=Ee(c,e.sourceCode);return f?!(f.parent.type===U.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===U.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(i.type===U.AST_NODE_TYPES.AssignmentPattern)return!1;if(o.type===U.AST_NODE_TYPES.ArrowFunctionExpression){let l=ae(o,U.AST_NODE_TYPES.VariableDeclaration);return l?!!Ee(l,e.sourceCode):!1}if(o.type===U.AST_NODE_TYPES.FunctionDeclaration)return!!Ee(o,e.sourceCode)}return!1}function n(r){r.key.type!==U.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:s=>{let a=ae(r,U.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let u=e.sourceCode.getText(a);return s.replaceText(a,u.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===U.AST_NODE_TYPES.TSTypeLiteral&&!(be(r)||!t(r)))for(let s of r.typeAnnotation.members)s.type===U.AST_NODE_TYPES.TSPropertySignature&&n(s)},TSInterfaceDeclaration(r){if(!(be(r)||!t(r)))for(let s of r.body.body)s.type===U.AST_NODE_TYPES.TSPropertySignature&&n(s)},TSTypeReference(r){if(r.typeName.type!==U.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let s=r.typeArguments.params[0];if(s.type!==U.AST_NODE_TYPES.TSTypeLiteral)return;let a=ae(r.parent,U.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let u=Ee(a,e.sourceCode);if(!(!u||u.parent.type===U.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===U.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"))for(let o of s.members)o.type===U.AST_NODE_TYPES.TSPropertySignature&&n(o)}}}});function be(e){return e?e.parent?.type===U.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===U.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ee(e,t){if(be(e))return;let n;if(e.type===U.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===U.AST_NODE_TYPES.Identifier&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===U.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let s=r.variables.find(u=>u.identifiers.includes(n));if(!s)return;let a=s.references.filter(u=>u.identifier!==n);if(!(a.length!==1||!a[0])&&!be(a[0].identifier.parent.parent))return a[0].identifier}var Be={name:Dt,rule:Er};import{ESLintUtils as br}from"@typescript-eslint/utils";import qe from"node:path";var xr=br.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jt="no-relative-imports",Cr=_({find:N(),replacement:N()}),Ir=_({aliases:H(Cr),rootDir:F(N()),allowNotFoundAliases:F(ie()),_dev_simulateFileName:F(N())}),wr=xr({name:jt,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[Ir]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(u){return u.startsWith(".")||u.startsWith("..")}function s(u,i){let o=qe.dirname(i);return qe.resolve(o,u)}function a(u){let i=t.rootDir??process.cwd(),o=qe.relative(i,u);if(o.startsWith("."))return null;o.startsWith("/")||(o=`/${o}`);for(let{find:l,replacement:c}of t.aliases)if(o.startsWith(c)){let f=o.replace(c,l);return{alias:l,newPath:f}}return null}return{ImportDeclaration(u){let i=u.source.value;if(!r(i))return;let o=s(i,n),l=a(o);!l&&t.allowNotFoundAliases||e.report({node:u,messageId:l?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:l?.alias},fix:l?c=>c.replaceText(u.source,`'${l.newPath}'`):void 0})}}}}),Ke={name:jt,rule:wr};import{AST_NODE_TYPES as ue,ESLintUtils as $t}from"@typescript-eslint/utils";import*as Xe from"typescript";var Rr=$t.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Mt="no-unnecessary-casting",vr=_({additionalCastFunctions:F(H(_({name:N(),expectedType:ye(["string","number"])})))}),Je={name:Mt,rule:Rr({name:Mt,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[vr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],s=$t.getParserServices(e,!0),a=s.program?.getTypeChecker();if(!a||!s.program)throw new Error("TypeScript services or program not available");function u(c,f){switch(c.type){case ue.Literal:return f==="number"?typeof c.value=="number":typeof c.value=="string";case ue.TemplateLiteral:return f==="string";case ue.UnaryExpression:return f==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function i(c,f){return f==="number"?!!(c.flags&Xe.TypeFlags.NumberLike):!!(c.flags&Xe.TypeFlags.StringLike)}function o(c,f){return h=>h.replaceText(c,e.sourceCode.getText(f))}function l(c){if(!a||c.arguments.length!==1)return;let f=c.arguments[0];if(!f||f.type===ue.SpreadElement)return;let{callee:h}=c;if(h.type!==ue.Identifier)return;let m=h.name,y=r.find(E=>E.name===m);if(!y)return;if(u(f,y.expectedType)||i(a.getTypeAtLocation(s.esTreeNodeToTSNodeMap.get(f)),y.expectedType)){let E,g;m==="Number"?E="unnecessaryNumberCasting":m==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",g={name:y.name,type:y.expectedType}),e.report({node:c,messageId:E,...g?{data:g}:{},fix:o(c,f)})}}return{CallExpression:l}}})};import{AST_NODE_TYPES as W,ESLintUtils as Or}from"@typescript-eslint/utils";var kr=_({selectors:H(_({name:N(),selectorProp:F(N()),selectorArgPos:F(J()),returnProp:F(N())}))}),Ar=Or.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="no-unused-selected-values",Ge={name:Ut,rule:Ar({name:Ut,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[kr]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.map(s=>[s.name,s]));return{VariableDeclarator(s){let a=null;if(s.init?.type===W.CallExpression&&(a=s.init),!a)return;let u=Fr(a);if(!u)return;let i=r.get(u);if(!i)return;let o=Pr(a,i.selectorArgPos??0,i.selectorProp);if(!o)return;let l=Nr(o);if(!l)return;let c=Vt(l.properties,void 0);if(!c)return;if(s.id.type===W.ObjectPattern){let m=Vt(s.id.properties,i.returnProp);if(!m)return;for(let[y,T]of c)m.has(y)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:y}});return}if(s.id.type!==W.Identifier||i.returnProp)return;let f=Lr(s,e.sourceCode);if(f.length===0)return;let h=new Set;for(let m of f){if(m.identifier.parent.type!==W.MemberExpression)return;let y=m.identifier.parent.property;if(y.type!==W.Identifier)return;h.add(y.name)}for(let[m,y]of c)h.has(m)||e.report({node:y,messageId:"unusedSelectedValue",data:{name:m}})}}}})};function Pr(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===W.ArrowFunctionExpression||r.type===W.FunctionExpression)return r;if(n&&r.type===W.ObjectExpression){let s=r.properties.find(u=>u.type===W.Property&&u.key.type===W.Identifier&&u.key.name===n);if(s?.type!==W.Property)return null;let a=s.value;if(a.type===W.ArrowFunctionExpression||a.type===W.FunctionExpression)return a}return null}function Fr(e){return e.callee.type===W.Identifier?e.callee.name:e.callee.type===W.MemberExpression&&e.callee.property.type===W.Identifier?e.callee.property.name:null}function Nr(e){if(e.body.type===W.ObjectExpression)return e.body;if(e.body.type===W.BlockStatement){let t=e.body.body.filter(n=>n.type===W.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==W.ObjectExpression?null:t[0].argument}return null}function Vt(e,t){let n=e;if(t){let s=e.find(a=>a.type===W.Property&&a.key.type===W.Identifier&&a.key.name===t);if(s?.type!==W.Property||s.value.type!==W.ObjectPattern)return null;n=s.value.properties}let r=new Map;for(let s of n){if(s.type!==W.Property||s.key.type!==W.Identifier)return null;r.set(s.key.name,s)}return r.size>0?r:null}function Lr(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as V}from"@typescript-eslint/utils";var Ze=ge({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===V.ImportDeclaration&&a.source.value==="t-state-form"))return{};let r=null,s=!1;return{CallExpression(a){if(s)return;if(!r){let i=_r(a);i&&(r=i);return}let u=Dr(a,e.sourceCode);if(u){s=!0;for(let i of u)r.delete(i);if(r.size!==0)for(let[i,o]of r)e.report({node:o,messageId:"unusedField",data:{name:i}})}}}}});function _r(e){if(!(e.callee.type===V.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==V.ObjectExpression)return null;let r=ze(n.properties,a=>a.type!==V.Property||a.key.type!==V.Identifier||a.key.name!=="initialConfig"?null:a.value.type===V.ObjectExpression?a.value:a.value.type===V.ArrowFunctionExpression||a.value.type===V.FunctionExpression?jr(a.value):null);if(!r)return null;let s=new Map;for(let a of r.properties)a.type===V.Property&&a.key.type===V.Identifier&&s.set(a.key.name,a);return s}function Dr(e,t){if(!(e.callee.type===V.Identifier&&e.callee.name==="useFormState")||e.parent.type!==V.VariableDeclarator||e.parent.id.type!==V.ObjectPattern||!ze(e.parent.id.properties,u=>u.type===V.Property&&u.key.type===V.Identifier&&u.key.name==="formFields"&&u))return null;let s=_t(e.parent,"formFields",t),a=new Set;for(let{identifier:u}of s){if(u.type!==V.Identifier||u.parent.type===V.Property&&u.parent.parent.type===V.ObjectExpression&&u.parent.parent.parent.type===V.ReturnStatement||u.parent.type===V.ReturnStatement)return null;if(u.parent.type===V.MemberExpression){if(u.parent.object.type!==V.Identifier||u.parent.property.type!==V.Identifier)return null;a.add(u.parent.property.name)}}return a}function jr(e){if(e.body.type===V.ObjectExpression)return e.body;if(e.body.type===V.BlockStatement){let t=e.body.body.filter(n=>n.type===V.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==V.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as $,ESLintUtils as Mr}from"@typescript-eslint/utils";var $r=Mr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Wt(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 Ht(e,...t){for(let n of t)e.set(...n);return e}var Ur=_({forceCheckOnFCPropTypesWithName:F(H(N()))}),Yt="no-unused-type-props-in-args",Qe=null,Vr=$r({name:Yt,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&&!Qe&&(Qe=n.map(i=>new RegExp(i)));function r(i,o,l,c,f=!0){let h=l.name,m=e.sourceCode.getScope(o).references.find(E=>E.identifier.name===h)?.resolved,y=i&&Qe?.some(E=>E.test(h));if(!m||!y&&m.references.filter(E=>E.isTypeReference).length>1)return;let T=m?.defs[0]?.node;if(!(f&&T?.parent?.type===$.ExportNamedDeclaration)){if(T?.type===$.TSTypeAliasDeclaration){s(i,o,c,T.typeAnnotation,!0);return}if(T?.type===$.TSInterfaceDeclaration){s(i,o,c,T.body,!0);return}}}function s(i,o,l,c,f){if(c.type===$.TSInterfaceBody){for(let h of c.body)h.type===$.TSPropertySignature&&h.key.type===$.Identifier&&l.set(h.key.name,h);return}if(c.type===$.TSTypeLiteral){Ht(l,...Wt(c));return}if(c.type===$.TSIntersectionType){for(let h of c.types)s(i,o,l,h,!0);return}f||c.type===$.TSTypeReference&&c.typeName.type===$.Identifier&&r(i,o,c.typeName,l)}function a(i,o,l){for(let c of l)if(c.type==="ObjectPattern"&&c.typeAnnotation){let f=new Map;if(s(i,o,f,c.typeAnnotation.typeAnnotation,!1),f.size===0)continue;u(c,f)}else c.type===$.AssignmentPattern&&c.left.type===$.ObjectPattern&&a(i,o,[c.left])}function u(i,o){let l=[];if(i.properties.at(-1)?.type===$.RestElement)return;for(let m of i.properties)m.type===$.Property&&m.key.type===$.Identifier&&l.push(m.key.name);let f=[],h=[];for(let[m,y]of o)l.includes(m)||(h.push(m),f.push({node:y,messageId:"unusedObjectTypeProperty",data:{propertyName:m}}));for(let[m,y]of f.entries())e.report({...y,fix:m===f.length-1?T=>{let E=i.properties.at(-1),g=h.join(", ");return E?E?.type===$.RestElement?null:T.insertTextAfter(E,`, ${g}`):T.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${g}`)}:void 0})}return{VariableDeclaration(i){let o=i.declarations[0];if(!o)return;let l=new Map,c=o.id.type===$.Identifier&&o.id.typeAnnotation?.typeAnnotation.type===$.TSTypeReference&&o.id.typeAnnotation.typeAnnotation.typeName.type===$.Identifier&&o.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&o.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===$.TSTypeReference&&c.typeName.type===$.Identifier)r(!0,i,c.typeName,l,!1);else if(c.type===$.TSTypeLiteral)Ht(l,...Wt(c));else if(c.type===$.TSIntersectionType)for(let f of c.types)f.type===$.TSTypeReference&&f.typeName.type===$.Identifier?r(!0,i,f.typeName,l,!1):s(!0,i,l,f,!0);if(l.size!==0&&o.init?.type===$.ArrowFunctionExpression){let f=o.init.params[0];if(!f){e.report({node:o.init,messageId:"missingComponentParam"});return}f.type===$.ObjectPattern&&u(f,l)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),et={name:Yt,rule:Vr};import{AST_NODE_TYPES as tt,ESLintUtils as Wr}from"@typescript-eslint/utils";var Hr=Wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt="prefer-named-functions",zt=new Map,Yr=Hr({name:Bt,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=zt.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),zt.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===tt.ArrowFunctionExpression&&r.id.type===tt.Identifier){let s=r.id.name;if(r.id.typeAnnotation||n&&n.test(s)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==tt.BlockStatement)return;let a=r.parent,u=r.init.params,i=r.init.body,o=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:l=>l.replaceText(a,`${o.async?"async ":""}function ${s}(${u.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),nt={name:Bt,rule:Yr};import{AST_NODE_TYPES as Y,AST_TOKEN_TYPES as qt,ESLintUtils as zr}from"@typescript-eslint/utils";var Br=zr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xt="prefer-single-line-if",qr=_({maxLineLength:F(J()),maxNonSimpleConditionLength:F(J())}),Kr=Br({name:Xt,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:[qr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==Y.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let a=r.consequent.body[0];if(a.type===Y.ReturnStatement){if(!Gt(a))return}else if(!(a.type===Y.ContinueStatement||a.type===Y.BreakStatement))return;if(r.test.type===Y.LogicalExpression||r.test.type===Y.ConditionalExpression)return;let u;if(t.maxNonSimpleConditionLength){let f=Kt(r.test);if(!f&&r.test.type===Y.UnaryExpression&&r.test.operator==="!"){let h=r.test.argument;Kt(h)&&(f=!0)}if(f&&(u=n.getText(r.test),u.length>t.maxNonSimpleConditionLength))return}u||(u=n.getText(r.test));let i=n.getText(a);if(u.includes(`
15
+ `))return;let o=n.getTokenAfter(r);if(o&&o.type===qt.Punctuator&&o.value==="}"){let f=n.getTokenAfter(o);if(f&&f.type===qt.Keyword&&(f.value==="else"||f.value==="catch"))return}let l=Xr(n,r),c=`if (${u}) ${i}`;t.maxLineLength&&c.length+l.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:f=>f.replaceText(r,c)})}}}});function Kt(e){return e.type===Y.CallExpression||e.type===Y.BinaryExpression||e.type===Y.MemberExpression&&Jt(e)}function Jt(e){return e.object.type===Y.MemberExpression?Jt(e.object):e.object.type!==Y.Identifier}function Xr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Gt(e){if(!e.argument)return!0;let t=e.argument;return t.type===Y.ArrayExpression&&t.elements.length===0||t.type===Y.ObjectExpression&&t.properties.length===0||t.type===Y.Literal||t.type===Y.Identifier||t.type===Y.TemplateLiteral||t.type===Y.TaggedTemplateExpression?!0:t.type===Y.CallExpression?t.arguments.length===0:t.type===Y.UnaryExpression?Gt(t):!1}var rt={name:Xt,rule:Kr};import{AST_NODE_TYPES as G,ESLintUtils as Jr}from"@typescript-eslint/utils";var Gr=Jr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="react-compiler-migration",Zr=_({disallowHooks:F(H(_({name:N(),replacement:N()}))),disallowMethods:F(H(_({name:N(),replacement:F(N()),requireTrueProp:F(N())})))}),Qr=/eslint +react-compiler\/react-compiler: +\["error/;function ei(e){return e.type===G.Identifier?e.name.startsWith("use"):e.type===G.MemberExpression&&e.property.type===G.Identifier?e.property.name.startsWith("use"):!1}var ti=Gr({name:Zt,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:[Zr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(Qr.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let s=null,a=null;if(r.callee.type===G.Identifier?(s=r.callee.name,a=r.callee):r.callee.type===G.MemberExpression&&r.callee.property.type===G.Identifier&&(s=r.callee.property.name,a=r.callee.property),s){let u=t.disallowHooks.find(i=>i.name===s);u&&a&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:u.name,replacement:u.replacement},suggest:[{messageId:"replace",data:{replacement:u.replacement},fix:i=>i.replaceText(a,u.replacement)}]})}}if(t.disallowMethods?.length&&ei(r.callee)){for(let s of r.arguments)if(s.type===G.ObjectExpression){for(let a of s.properties)if(a.type===G.Property&&a.key.type===G.Identifier){let u=a.key.name,i=t.disallowMethods.find(o=>o.name===u);if(i){if(i.requireTrueProp){let o=i.requireTrueProp,l=!1;for(let c of s.properties)if(c.type===G.Property&&c.key.type===G.Identifier&&c.key.name===o&&c.value.type===G.Literal&&c.value.value===!0){l=!0;break}if(!l){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:o}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:o=>o.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),it={name:Zt,rule:ti};import{ESLintUtils as ni,TSESTree as ri}from"@typescript-eslint/utils";var ii=ni.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="require-description",si=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,oi=/^eslint-disable-(next-)?line$/u,ai=ii({name:Qt,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 s of n.getAllComments()){let a=li(s);a!=null&&(r.has(a.kind)||a.description||e.report({loc:ui(s.loc),messageId:"missingDescription"}))}}}}}),en={name:Qt,rule:ai};function li(e){let{text:t,description:n}=ci(e.value);if(!t)return null;let r=si.exec(t);if(!r)return null;let s=r[1];if(!s)return null;let a=oi.test(s);if(e.type===ri.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let u=t.slice(r.index+s.length);return{kind:s,value:u.trim(),description:n}}function ci(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ui(e){return{start:{line:e.start.line,column:-1},end:e.end}}function rn(e){return/^use[A-Z0-9]/.test(e)}function xe(e){return e.type==="Identifier"?rn(e.name):e.type==="MemberExpression"&&!e.computed&&xe(e.property)?e.object.type==="Identifier":!1}function sn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function on(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function an(e){return!!(e.parent&&e.parent.callee&&on(e.parent.callee,"forwardRef"))}function ln(e){return!!(e.parent&&e.parent.callee&&on(e.parent.callee,"memo"))}function st(e){for(;e;){let t=un(e);if(t&&(sn(t)||xe(t))||an(e)||ln(e))return!0;e=e.parent}return!1}function tn(e){return!1}function ot(e){return!1}var pi=/eslint +react-compiler\/react-compiler: +\["error/,cn={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 o of e.sourceCode.getAllComments())if(pi.test(o.value))return{CallExpression(l){let c=null;l.callee.name==="useMemo"?c="useMemo":l.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:l,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?o=>t(o):o=>e.sourceCode.getText(o),n=typeof e.getScope=="function"?()=>n():o=>e.sourceCode.getScope(o),r=null,s=[],a=[],u=new WeakSet;function i(o){for(let l of o.references){let c=l.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&tn(c.init.callee))for(let f of l.resolved.references)f!==l&&u.add(f.identifier)}}return{onCodePathSegmentStart:o=>a.push(o),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(o,l){let c=s.pop();if(c.size===0)return;let f=new Set;function h(S,v){let{cache:A}=h,L=A.get(S.id),D=new Set(v);if(D.has(S.id)){let R=[...D],j=R.slice(R.indexOf(S.id)+1);for(let z of j)f.add(z);return BigInt("0")}if(D.add(S.id),L!==void 0)return L;if(o.thrownSegments.includes(S))L=BigInt("0");else if(S.prevSegments.length===0)L=BigInt("1");else{L=BigInt("0");for(let R of S.prevSegments)L+=h(R,D)}return S.reachable&&L===BigInt("0")?A.delete(S.id):A.set(S.id,L),L}function m(S,v){let{cache:A}=m,L=A.get(S.id),D=new Set(v);if(D.has(S.id)){let R=Array.from(D),j=R.slice(R.indexOf(S.id)+1);for(let z of j)f.add(z);return BigInt("0")}if(D.add(S.id),L!==void 0)return L;if(o.thrownSegments.includes(S))L=BigInt("0");else if(S.nextSegments.length===0)L=BigInt("1");else{L=BigInt("0");for(let R of S.nextSegments)L+=m(R,D)}return A.set(S.id,L),L}function y(S){let{cache:v}=y,A=v.get(S.id);if(A===null)return 1/0;if(A!==void 0)return A;if(v.set(S.id,null),S.prevSegments.length===0)A=1;else{A=1/0;for(let L of S.prevSegments){let D=y(L);D<A&&(A=D)}A+=1}return v.set(S.id,A),A}h.cache=new Map,m.cache=new Map,y.cache=new Map;let T=m(o.initialSegment),E=un(l),g=st(l),O=E?sn(E)||xe(E):an(l)||ln(l),C=1/0;for(let S of o.finalSegments){if(!S.reachable)continue;let v=y(S);v<C&&(C=v)}for(let[S,v]of c){if(!S.reachable)continue;let A=S.nextSegments.length===0?C<=y(S):C<y(S),L=h(S)*m(S),D=f.has(S.id);for(let R of v)if(D&&!ot(R)&&e.report({node:R,message:`React Hook "${t(R)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),O){if(l.async&&e.report({node:R,message:`React Hook "${t(R)}" cannot be called in an async function.`}),!D&&L!==T&&!ot(R)){let z=`React Hook "${t(R)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(A?" Did you accidentally call a React Hook after an early return?":"");e.report({node:R,message:z})}}else if(l.parent&&(l.parent.type==="MethodDefinition"||l.parent.type==="ClassProperty")&&l.parent.value===l){let j=`React Hook "${t(R)}" 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:R,message:j})}else if(E){let j=`React Hook "${t(R)}" is called in function "${t(E)}" 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:R,message:j})}else if(l.type==="Program"){let j=`React Hook "${t(R)}" 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:R,message:j})}else if(g&&!ot(R)){if(l.parent.type==="CallExpression"&&l.parent.callee.type==="Identifier"&&l.parent.callee.name==="useCallback"){let z=l.parent;if(z.parent.type==="VariableDeclarator"&&rn(z.parent.id.name))return}let j=`React Hook "${t(R)}" 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:R,message:j})}}},CallExpression(o){if(xe(o.callee)){let l=nn(s),c=nn(a),f=l.get(c);f||(f=[],l.set(c,f)),f.push(o.callee)}o.callee.type==="Identifier"&&(o.callee.name==="useEffect"||tn(o.callee))&&o.arguments.length>0&&(r=o)},Identifier(o){r==null&&u.has(o)&&o.parent.type!=="CallExpression"&&e.report({node:o,message:`\`${t(o)}\` 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"(o){o===r&&(r=null)},FunctionDeclaration(o){st(o)&&i(n(o))},ArrowFunctionExpression(o){st(o)&&i(n(o))}}}};function un(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 nn(e){return e[e.length-1]}var pn={[et.name]:et.rule,[Ue.name]:Ue.rule,[$e.name]:$e.rule,"rules-of-hooks":cn,"exhaustive-deps":Et,"require-description":en.rule,[Ve.name]:Ve.rule,[He.name]:He.rule,[nt.name]:nt.rule,[Pe.name]:Pe.rule,[Me.name]:Me.rule,[Ke.name]:Ke.rule,[rt.name]:rt.rule,[Be.name]:Be.rule,[We.name]:We.rule,[Ne.name]:Ne.rule,[it.name]:it.rule,[ke.name]:ke.rule,[je.name]:je.rule,[Je.name]:Je.rule,[Ge.name]:Ge.rule,[Ze.name]:Ze.rule};var io={rules:pn};export{io as extendedLintPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ls-stack/extended-lint",
3
- "version": "0.40.1",
3
+ "version": "0.41.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"