@ls-stack/extended-lint 0.40.1 → 0.42.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.
- package/dist/extended-lint.js +5 -5
- package/dist/extended-lint.mjs +5 -5
- package/package.json +1 -1
package/dist/extended-lint.js
CHANGED
|
@@ -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;
|
|
3
|
-
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function
|
|
1
|
+
"use strict";var Pn=Object.create;var xe=Object.defineProperty;var Fn=Object.getOwnPropertyDescriptor;var Nn=Object.getOwnPropertyNames;var jn=Object.getPrototypeOf,Dn=Object.prototype.hasOwnProperty;var Ln=(e,t)=>{for(var n in t)xe(e,n,{get:t[n],enumerable:!0})},It=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Nn(t))!Dn.call(e,s)&&s!==n&&xe(e,s,{get:()=>t[s],enumerable:!(r=Fn(t,s))||r.enumerable});return e};var _e=(e,t,n)=>(n=e!=null?Pn(jn(e)):{},It(t||!e||!e.__esModule?xe(n,"default",{value:e,enumerable:!0}):n,e)),_n=e=>It(xe({},"__esModule",{value:!0}),e);var Ei={};Ln(Ei,{extendedLintPlugin:()=>hi});module.exports=_n(Ei);var B=require("@typescript-eslint/utils");var Me=Symbol.for("optional");function N(e){return{...e,[Me]:!0}}function Ce(e,t){return{enum:e,...t}}function ue(e){return{...e,type:"boolean"}}function A(e){return{...e,type:"string"}}function Q(e){return{...e,type:"number"}}function wt(e){return{...e,type:"integer"}}function z(e,t){return{...t,type:"array",items:e}}function j(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,s=[];for(r in e)e[r][Me]?e[r][Me]=void 0:s.push(r);s.length>0&&(n.required=s)}return n}function $e(...e){return{anyOf:e}}var Mn=B.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="react-compiler-extra",$n=j({runOnlyWithEnableCompilerDirective:N(ue())}),Un=/eslint +react-compiler\/react-compiler: +\["error/;function Vn(e){return e.type===B.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===B.AST_NODE_TYPES.MemberExpression&&e.property.type===B.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Wn=/\bthis[.[]/;function Rt(e){return Wn.test(e)}var Hn=Mn({name:vt,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:[$n]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(Un.test(a.value)){n=!0;break}if(!n)return{}}function r(a){for(let o of a.properties)if(o.type===B.AST_NODE_TYPES.Property&&o.method&&o.value.type===B.AST_NODE_TYPES.FunctionExpression){let i=e.sourceCode,l=i.getText(o.key),c=o.value,p=i.getText(c.body);if(Rt(p))e.report({node:o,messageId:"thisKeywordInMethod"});else{let f=c.params.map(m=>i.getText(m)).join(", "),h="";c.generator?h=`${l}: function* (${f}) ${p}`:h=`${l}: (${f}) => ${p}`,e.report({node:o,messageId:"objectMethodIsNotSupported",fix:m=>m.replaceText(o,h)})}}}function s(a){for(let o of a.properties)if(o.type===B.AST_NODE_TYPES.Property&&o.value.type===B.AST_NODE_TYPES.ObjectExpression){for(let i of o.value.properties)if(i.type===B.AST_NODE_TYPES.Property&&i.method&&i.value.type===B.AST_NODE_TYPES.FunctionExpression){let c=e.sourceCode.getText(i.value.body);Rt(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Vn(a.callee))for(let o of a.arguments){if(o.type===B.AST_NODE_TYPES.ObjectExpression&&(r(o),s(o)),o.type===B.AST_NODE_TYPES.ArrowFunctionExpression&&(o.body.type===B.AST_NODE_TYPES.ObjectExpression&&(r(o.body),s(o.body)),o.body.type===B.AST_NODE_TYPES.BlockStatement))for(let i of o.body.body)i.type===B.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===B.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),s(i.argument));if(o.type===B.AST_NODE_TYPES.FunctionExpression)for(let i of o.body.body)i.type===B.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===B.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),s(i.argument))}}}}}),Ue={name:vt,rule:Hn};var Ie=require("@typescript-eslint/utils");var kt=require("@typescript-eslint/utils");function ae(e){let n=kt.ESLintUtils.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}var Yn=j({disallow:N(z(j({selector:A(),message:A(),replace:N($e(A(),j({regex:A(),with:A()}))),replaceType:N(Ce(["suggestion","autofix"]))}))),__dev_simulateFileName:N(A()),mustMatchSyntax:N(z(j({includeRegex:A(),mustCallFn:N(z(j({anyCall:z(j({fn:A(),withArgs:z(j({atIndex:wt(),literal:$e(A(),Q(),ue())}))})),message:N(A())}))),mustMatchSelector:N(z(j({selector:A(),message:A()})))})))}),Ve=ae({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Yn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:s,disallow:a}=t,o=s??e.filename,i=[],l=new Map,c=new Set,p=new Map;for(let{includeRegex:m,mustCallFn:y,mustMatchSelector:T}of r??[]){let E=zn(o,new RegExp(m));if(!E)continue;let g=k=>{let C=k;for(let{name:S,value:v}of E)C=C.replaceAll(S,v);return C};for(let{anyCall:k,message:C}of y??[]){let S=`Expected file to call the function: ${k.map(({fn:v})=>v).join(" or ")}`;c.add(S),i.push(v=>{let{callee:P}=v;if(P.type===Ie.AST_NODE_TYPES.Identifier){for(let{fn:D,withArgs:_}of k)if(P.name===D){c.delete(S);for(let R of _){let V=v.arguments[R.atIndex],q=typeof R.literal=="string"?g(R.literal):R.literal;if(!V){e.report({node:v,messageId:"default",data:{message:`Missing argument with value "${q}" at index ${R.atIndex}${C?`: ${g(C)}`:""}`}});continue}if(V.type!==Ie.AST_NODE_TYPES.Literal){e.report({node:V,messageId:"default",data:{message:`Argument at position ${R.atIndex} should the literal "${q}"${C?`: ${g(C)}`:""}`}});continue}V.value!==q&&e.report({node:V,messageId:"default",data:{message:`Argument should have the value "${q}"${C?`: ${g(C)}`:""}`},fix:Te=>Te.replaceText(V,typeof q=="string"?`'${q}'`:String(q))})}break}}})}for(let{selector:k,message:C}of T??[])p.set(k,g(C)),l.set(g(k),()=>{p.delete(k)})}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(l.size>0)for(let[m,y]of l)f(m,y);return i.length>0&&(n.CallExpression=m=>{if(m.type===Ie.AST_NODE_TYPES.CallExpression)for(let y of i)y(m)}),n["Program:exit"]=m=>{for(let y of c)e.report({node:m,messageId:"default",data:{message:y}});for(let[,y]of p)e.report({node:m,messageId:"default",data:{message:y}})},n;function h(m,y,T,E){let g=k=>{if(!m)return null;if(typeof m=="string")return k.replaceText(y,m);{let C=new RegExp(m.regex),S=e.sourceCode.getText(y);return k.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 zn(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:Ot(s)}),n.push({name:"$0_uncapitalize",value:At(s)}),n.push({name:"$0",value:s});for(let o=0;o<a.length;o++){let i=`$${o+1}`,l=a[o];n.push({name:`${i}_lowercase`,value:l.toLowerCase()}),n.push({name:`${i}_capitalize`,value:Ot(l)}),n.push({name:`${i}_uncapitalize`,value:At(l)}),n.push({name:i,value:l})}return n}function Ot(e){return e.charAt(0).toUpperCase()+e.slice(1)}function At(e){return e.charAt(0).toLowerCase()+e.slice(1)}var L=require("@typescript-eslint/utils");var Bn=L.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="collapse-simple-objs-in-one-line",qn=j({maxLineLength:N(Q()),maxProperties:N(Q()),nestedObjMaxLineLength:N(Q()),nestedObjMaxProperties:N(Q()),ignoreTypesWithSuffix:N(z(A()))}),Xn=Bn({name:Ft,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:[qn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,o=t.nestedObjMaxProperties??3;function i(c){if(c.type===L.AST_NODE_TYPES.ObjectExpression){let p=c.parent.type===L.AST_NODE_TYPES.Property,f=p?o:s,h=c.properties.length;if(h>f)return!1;if(h===1){let y=c.properties[0];return y.type===L.AST_NODE_TYPES.Property&&y.value.type===L.AST_NODE_TYPES.ObjectExpression||y.type===L.AST_NODE_TYPES.Property&&y.value.type===L.AST_NODE_TYPES.ArrayExpression&&!y.value.elements.every(E=>E&&We(E))?!1:{text:n.getText(y),isNested:p,propsSize:h}}let m=[];for(let y of c.properties){if(y.type===L.AST_NODE_TYPES.Property&&!We(y.value))return!1;m.push(n.getText(y))}return{text:m.join(", "),isNested:p,propsSize:h}}else{let p=c.parent.parent?.type===L.AST_NODE_TYPES.TSPropertySignature,f=p?o:s,h=c.members.length;if(h>f)return!1;if(r.length>0&&c.parent.type===L.AST_NODE_TYPES.TSTypeAliasDeclaration){let y=c.parent.id.name;if(r.some(T=>y.endsWith(T)))return!1}if(h===1){let y=c.members[0];return y.type===L.AST_NODE_TYPES.TSPropertySignature&&y.typeAnnotation?.typeAnnotation.type===L.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(y),isNested:p,propsSize:1}}if(c.parent.type===L.AST_NODE_TYPES.TSIntersectionType||c.parent.type===L.AST_NODE_TYPES.TSUnionType)return!1;let m=[];for(let y of c.members){if(y.type!==L.AST_NODE_TYPES.TSPropertySignature)return!1;let T=y.typeAnnotation?.typeAnnotation;if(!T||T.type===L.AST_NODE_TYPES.TSTypeLiteral||!Pt(T))return!1;if(T.type===L.AST_NODE_TYPES.TSTypeReference&&T.typeArguments){if(T.typeArguments.params.length>1)return!1;let g=T.typeArguments.params[0];if(!Pt(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:p,propsSize:h}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==L.AST_NODE_TYPES.JSXExpressionContainer){let T=0,E=n.getTokenAfter(c,{filter:g=>g.type!==L.AST_TOKEN_TYPES.Punctuator?!0:g.value===","||g.value===";"||g.value===")"||g.value==="}"?(T++,!1):!0});if(T>4||E?.loc.start.line===c.loc.end.line)return}let p=i(c);if(!p)return;let f=p.text;if(f.includes(`
|
|
2
|
+
`)||n.getCommentsInside(c).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let h=`{ ${f} }`,m=Jn(n,c),y=p.isNested&&p.propsSize>2?a:t.maxLineLength;y&&h.length+m.length+Kn(c,n)>y||e.report({node:c,messageId:"singleLineProp",fix:T=>T.replaceText(c,h)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function Pt(e){return e.type===L.AST_NODE_TYPES.TSLiteralType||e.type===L.AST_NODE_TYPES.TSTypeReference||e.type===L.AST_NODE_TYPES.TSNumberKeyword||e.type===L.AST_NODE_TYPES.TSStringKeyword||e.type===L.AST_NODE_TYPES.TSBooleanKeyword||e.type===L.AST_NODE_TYPES.TSNullKeyword||e.type===L.AST_NODE_TYPES.TSUndefinedKeyword}function We(e,t){return!!(e.type===L.AST_NODE_TYPES.Literal||e.type===L.AST_NODE_TYPES.Identifier||e.type===L.AST_NODE_TYPES.TemplateLiteral||e.type===L.AST_NODE_TYPES.TaggedTemplateExpression||!t&&e.type===L.AST_NODE_TYPES.ArrayExpression&&e.elements.every(n=>n&&We(n,!0)))}function Kn(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 Jn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var He={name:Ft,rule:Xn};var Gn=/eslint +react-compiler\/react-compiler: +\["error/,jt={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,o={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 l=e.getSourceCode().scopeManager,c=new WeakMap,p=new WeakSet,f=new WeakMap,h=new WeakMap,m=new WeakSet;function y(g,k){return function(C){if(k.has(C))return k.get(C);let S=g(C);return k.set(C,S),S}}function T(g,k,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 P=l.acquire(g),D=new Set,_=null;{let u=P.upper;for(;u&&(D.add(u),u.type!=="function");)u=u.upper;if(!u)return;_=u}let R=Array.isArray;function V(u){if(!R(u.defs))return!1;let d=u.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&&(Be(_.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:O}=w;if(O==="useRef"&&I.type==="Identifier")return!0;if(nr(w)&&I.type==="Identifier"){for(let F of u.references)F!==I&&m.add(F.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(I.type==="ArrayPattern"&&I.elements.length===2&&R(u.identifiers)){if(I.elements[1]===u.identifiers[0]){if(O==="useState"){let F=u.references,Z=0;for(let ne=0;ne<F.length;ne++){if(F[ne].isWrite()&&Z++,Z>1)return!1;c.set(F[ne].identifier,I.elements[0])}}return!0}else if(I.elements[0]===u.identifiers[0]){if(O==="useState"){let F=u.references;for(let Z=0;Z<F.length;Z++)p.add(F[Z].identifier)}return!1}}}else if(O==="useTransition"&&I.type==="ArrayPattern"&&I.elements.length===2&&Array.isArray(u.identifiers)&&I.elements[1]===u.identifiers[0])return!0;return!1}function q(u){if(!R(u.defs))return!1;let d=u.defs[0];if(d==null||d.node==null||d.node.id==null)return!1;let b=d.node,x=_.childScopes,w=null,I;for(I=0;I<x.length;I++){let O=x[I],F=O.block;if(b.type==="FunctionDeclaration"&&F===b||b.type==="VariableDeclarator"&&F.parent===b){w=O;break}}if(w==null)return!1;for(I=0;I<w.through.length;I++){let O=w.through[I];if(O.resolved!=null&&D.has(O.resolved.scope)&&!Te(O.resolved))return!1}return!0}let Te=y(V,f),In=y(q,h),ht=new Map;function wn(u){let d=u.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 G=new Map,Ne=new Map;Et(P);function Et(u){for(let d of u.references){if(!d.resolved||!D.has(d.resolved.scope))continue;let b=Be(g,d.identifier),x=Dt(b),w=re(x,Ne);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"&&wn(d)&&ht.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(G.has(w))G.get(w).references.push(d);else{let O=d.resolved,F=Te(O)||In(O);G.set(w,{isStable:F,references:[d]})}}for(let d of u.childScopes)Et(d)}ht.forEach(({reference:u,dependencyNode:d},b)=>{let x=u.resolved.references,w=!1;for(let I=0;I<x.length;I++){let{identifier:O}=x[I],{parent:F}=O;if(F!=null&&F.type==="MemberExpression"&&!F.computed&&F.property.type==="Identifier"&&F.property.name==="current"&&F.parent.type==="AssignmentExpression"&&F.parent.left===F){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 je=new Set;function Rn(u,d){je.has(d)||(je.add(d),i({node:u,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 he=new Set;if(G.forEach(({isStable:u,references:d},b)=>{u&&he.add(b),d.forEach(x=>{x.writeExpr&&Rn(x.writeExpr,b)})}),je.size>0)return;if(!k){let u=null;if(G.forEach(({isStable:d,references:b},x)=>{u||b.forEach(w=>{if(u)return;let I=w.identifier;if(!c.has(I))return;let F=w.from;for(;F.type!=="function";)F=F.upper;F.block===g&&(u=x)})}),u){let{suggestedDependencies:d}=Ye({dependencies:G,declaredDependencies:[],stableDependencies:he,externalDependencies:new Set,isEffect:!0});i({node:C,message:`React Hook ${S} contains a call to '${u}'. 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 ye=[],ge=new Set;k.type!=="ArrayExpression"?i({node:k,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.`}):k.elements.forEach(u=>{if(u===null)return;if(u.type==="SpreadElement"){i({node:u,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(u)&&i({node:u,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(u)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(u)}\``,fix(w){return w.removeRange(u.range)}}]});let d;try{d=re(u,Ne)}catch(w){if(/Unsupported node type/.test(w.message)){u.type==="Literal"?G.has(u.value)?i({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. Did you mean to include ${u.value} in the array instead?`}):i({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:u,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=u;for(;b.type==="MemberExpression"||b.type==="OptionalMemberExpression"||b.type==="ChainExpression";)b=b.object||b.expression.object;let x=!_.through.some(w=>w.identifier===b);ye.push({key:d,node:u}),x||ge.add(d)});let{suggestedDependencies:vn,unnecessaryDependencies:Ee,missingDependencies:oe,duplicateDependencies:bt}=Ye({dependencies:G,declaredDependencies:ye,stableDependencies:he,externalDependencies:ge,isEffect:v}),be=vn;if(bt.size+oe.size+Ee.size===0){if(t)return;Zn({declaredDependencies:ye,declaredDependenciesNode:k,componentScope:_,scope:P}).forEach(({construction:d,isUsedOutsideOfHook:b,depType:x})=>{let w=x==="function"?"useCallback":"useMemo",I=x==="function"?"definition":"initialization",O=`wrap the ${I} of '${d.name.name}' in its own ${w}() Hook.`,F=b?`To fix this, ${O}`:`Move it inside the ${S} callback. Alternatively, ${O}`,Z=x==="conditional"||x==="logical expression"?"could make":"makes",ne=`The '${d.name.name}' ${x} ${Z} the dependencies of ${S} Hook (at line ${k.loc.start.line}) change on every render. ${F}`,xt;b&&d.type==="Variable"&&x==="function"&&(xt=[{desc:`Wrap the ${I} of '${d.name.name}' in its own ${w}() Hook.`,fix(Ct){let[On,An]=w==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Ct.insertTextBefore(d.node.init,On),Ct.insertTextAfter(d.node.init,An)]}}]),i({node:d.node,message:ne,suggest:xt})});return}!v&&oe.size>0&&(be=Ye({dependencies:G,declaredDependencies:[],stableDependencies:he,externalDependencies:ge,isEffect:v}).suggestedDependencies);function kn(){if(ye.length===0)return!0;let u=ye.map(b=>b.key),d=u.slice().sort();return u.join(",")===d.join(",")}kn()&&be.sort();function De(u){let d=u.split("."),b="";for(let x=0;x<d.length;x++){if(x!==0){let w=d.slice(0,x+1).join("."),I=Ne.get(w)===!0;b+=I?"?.":"."}b+=d[x]}return b}function Le(u,d,b,x){return u.size===0?null:(u.size>1?"":d+" ")+b+" "+(u.size>1?"dependencies":"dependency")+": "+er(Array.from(u).sort().map(w=>"'"+De(w)+"'"))+`. Either ${x} ${u.size>1?"them":"it"} or remove the dependency array.`}let te="";if(Ee.size>0){let u=null;if(Array.from(Ee.keys()).forEach(d=>{u===null&&d.endsWith(".current")&&(u=d)}),u!==null)te=` Mutable values like '${u}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ge.size>0){let d=Array.from(ge)[0];P.set.has(d)||(te=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!te&&oe.has("props")){let u=G.get("props");if(u==null)return;let d=u.references;if(!Array.isArray(d))return;let b=!0;for(let x=0;x<d.length;x++){let w=d[x],I=Be(_.block,w.identifier);if(!I){b=!1;break}let O=I.parent;if(O==null){b=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){b=!1;break}}b&&(te=` 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(!te&&oe.size>0){let u=null;oe.forEach(d=>{if(u)return;let b=_.set.get(d),x=G.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,O;for(let F=0;F<x.references.length;F++)if(O=x.references[F].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){I=!0;break}I&&(u=d)}),u!==null&&(te=` If '${u}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!te&&oe.size>0){let u=null;if(oe.forEach(d=>{if(u!==null)return;let x=G.get(d).references,w,I;for(let O=0;O<x.length;O++){for(w=x[O].identifier,I=w.parent;I!=null&&I!==_.block;){if(I.type==="CallExpression"){let F=c.get(I.callee);if(F!=null){if(F.name===d)u={missingDep:d,setter:I.callee.name,form:"updater"};else if(p.has(w))u={missingDep:d,setter:I.callee.name,form:"reducer"};else{let Z=x[O].resolved;if(Z!=null){let ne=Z.defs[0];ne!=null&&ne.type==="Parameter"&&(u={missingDep:d,setter:I.callee.name,form:"inlineReducer"})}}break}}I=I.parent}if(u!==null)break}}),u!==null)switch(u.form){case"reducer":te=` You can also replace multiple useState variables with useReducer if '${u.setter}' needs the current value of '${u.missingDep}'.`;break;case"inlineReducer":te=` If '${u.setter}' needs the current value of '${u.missingDep}', you can also switch to useReducer instead of useState and read '${u.missingDep}' in the reducer.`;break;case"updater":te=` You can also do a functional update '${u.setter}(${u.missingDep.slice(0,1)} => ...)' if you only need '${u.missingDep}' in the '${u.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:k,message:`React Hook ${n(C)} has `+(Le(oe,"a","missing","include")||Le(Ee,"an","unnecessary","exclude")||Le(bt,"a","duplicate","omit"))+te,suggest:[{desc:`Update the dependencies array to be: [${be.map(De).join(", ")}]`,fix(u){return u.replaceText(k,`[${be.map(De).join(", ")}]`)}}]})}function E(g){let k=Qn(g.callee,o);if(k===-1)return;let C=g.arguments[k],S=g.callee,v=Lt(S).name,P=g.arguments[k+1],D=/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&&!D)){if(!P&&!D){(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,P,S,v,D);return;case"Identifier":if(!P||P.elements&&P.elements.some(V=>V&&V.type==="Identifier"&&V.name===C.name))return;let _=r(g).set.get(C.name);if(_==null||_.defs==null)return;let R=_.defs[0];if(!R||!R.node||R.type!=="Variable"&&R.type!=="FunctionName")break;switch(R.node.type){case"FunctionDeclaration":T(R.node,P,S,v,D);return;case"VariableDeclarator":let V=R.node.init;if(!V)break;switch(V.type){case"ArrowFunctionExpression":case"FunctionExpression":T(V,P,S,v,D);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(_){return _.replaceText(P,`[${C.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(Gn.test(g.value))return t=!0,{CallExpression:k=>E(k,!0)}}return{CallExpression:g=>E(g)}}};function Ye({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:s}){let a=o();function o(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,E)=>{let g=i(a,E);g.isUsed=!0,l(a,E,k=>{k.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("."),k=T;for(let C of g){let S=k.children.get(C);S||(S=o(),k.children.set(C,S)),k=S}return k}function l(T,E,g){let k=E.split("."),C=T;for(let S of k){let v=C.children.get(S);if(!v)return;g(v),C=v}}let c=new Set,p=new Set;f(a,c,p,T=>T);function f(T,E,g,k){T.children.forEach((C,S)=>{let v=k(S);if(C.isSatisfiedRecursively){C.isSubtreeUsed&&g.add(v);return}if(C.isUsed){E.add(v);return}f(C,E,g,P=>v+"."+P)})}let h=[],m=new Set,y=new Set;return t.forEach(({key:T})=>{p.has(T)?h.indexOf(T)===-1?h.push(T):y.add(T):m.add(T)}),c.forEach(T=>{h.push(T)}),{suggestedDependencies:h,unnecessaryDependencies:m,duplicateDependencies:y,missingDependencies:c}}function le(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 le(e.consequent)!=null||le(e.alternate)!=null?"conditional":null;case"LogicalExpression":return le(e.left)!=null||le(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return le(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return le(e.expression);case"TSAsExpression":return le(e.expression)}return null}function Zn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let s=e.map(({key:o})=>{let i=n.variables.find(c=>c.name===o);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=le(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(o){let i=!1;for(let l=0;l<o.references.length;l++){let c=o.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==r&&p!=null;)p=p.upper;if(p!==r&&!_t(t,c.identifier))return!0}return!1}return s.map(([o,i])=>({construction:o.defs[0],depType:i,isUsedOutsideOfHook:a(o)}))}function Dt(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)?Dt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function ze(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function re(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=re(e.object,t),r=re(e.property,null),s=`${n}.${r}`;return ze(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=re(e.object,t),r=re(e.property,null),s=`${n}.${r}`;return ze(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=re(n.object,t),s=re(n.property,null),a=`${r}.${s}`;return ze(n,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Lt(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=Lt(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=re(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 Be(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),tr(r,t))return r;if(_t(r,t))for(let[s,a]of Object.entries(r))s!=="parent"&&(Nt(a)?(a.parent=r,n.push(a)):Array.isArray(a)&&a.forEach(o=>{Nt(o)&&(o.parent=r,n.push(o))}))}return null}function er(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Nt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function tr(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 _t(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function nr(e){return!1}var ce=require("@typescript-eslint/utils");var X=_e(require("typescript")),rr=ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Mt="improved-no-unnecessary-condition",ir=j({}),sr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],or=new Set(sr),qe={name:Mt,rule:rr({name:Mt,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:[ir]},defaultOptions:[{}],create(e){let t=ce.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===ce.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function s(i){return i.flags&X.default.TypeFlags.Any||i.flags&X.default.TypeFlags.Unknown?null:i.flags&X.default.TypeFlags.StringLike?["string"]:i.flags&X.default.TypeFlags.NumberLike?["number"]:i.flags&X.default.TypeFlags.BigIntLike?["bigint"]:i.flags&X.default.TypeFlags.BooleanLike?["boolean"]:i.flags&X.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&X.default.TypeFlags.Undefined||i.flags&X.default.TypeFlags.Void?["undefined"]:i.flags&X.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&X.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&X.default.TypeFlags.NonPrimitive?["object"]:i.flags&X.default.TypeFlags.Never?["never"]:null}function a(i){if(!n)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=n.getTypeAtLocation(l.expression);if(c.flags&X.default.TypeFlags.Any||c.flags&X.default.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let h of c.types){let m=s(h);if(m)p.push(...m);else return null}return p}let f=s(c);return f?(p.push(...f),p):null}function o(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(r(i.left)?(c=i.left,p=i.right.type===ce.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(c=i.right,p=i.left.type===ce.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!ar(p,or))return;let f=a(c);if(!f)return;let h=i.operator==="!==",m=f.includes(p);f.length===1?m&&!h?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:fe(c,e),type:p}}):!m&&h?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:fe(c,e),type:Array.from(f)[0]}}):!m&&!h?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:fe(c,e),actualType:we(f),conditionType:p}}):m&&h&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:fe(c,e),actualType:we(f),conditionType:p}}):!m&&!h?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:fe(c,e),actualType:we(f),conditionType:p}}):!m&&h&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:fe(c,e),type:we(f)}})}return{BinaryExpression:o}}})};function we(e){return Array.from(new Set(e)).join(" | ")||"never"}function fe(e,t){let n=e.argument;return n.type===ce.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function ar(e,t){return t.has(e)}var Re=require("@typescript-eslint/utils");var lr=Re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="no-call-with-explicit-generics",cr=j({functions:z(A())}),pr=lr({name:$t,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:[cr]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:s}=r;s.type===Re.AST_NODE_TYPES.Identifier&&n.has(s.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),Xe={name:$t,rule:pr};var pe=require("@typescript-eslint/utils"),ur=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="no-call-with-inferred-generics",fr=ur({name:Ut,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!==pe.AST_NODE_TYPES.Identifier)return;let a=n.get(s.name);if(!a)return;let{minGenerics:o=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(r.typeArguments?.params.length||0)<(o||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:o||0}}),!(i&&!l)&&r.typeArguments?.params?.some(p=>!i&&p.type===pe.AST_NODE_TYPES.TSAnyKeyword||l&&p.type===pe.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===pe.AST_NODE_TYPES.Identifier&&l.includes(p.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),Ke={name:Ut,rule:fr};var Se=require("@typescript-eslint/utils"),mr=Se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vt="no-commented-out-code",dr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],yr=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],gr=mr({name:Vt,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 dr)if(r.startsWith(s))return{wrongPattern:s};for(let s of yr)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===Se.TSESTree.AST_TOKEN_TYPES.Line||s.type===Se.TSESTree.AST_TOKEN_TYPES.Block){let a=t(s.value);a&&e.report({node:s,messageId:"commentedOutCode",data:{wrongPattern:a.wrongPattern}})}}}}}),Je={name:Vt,rule:gr};var ve=require("@typescript-eslint/utils"),Sr=ve.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="no-default-export",Tr=Sr({name:Wt,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===ve.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Ge={name:Wt,rule:Tr};var Ht=require("@typescript-eslint/utils"),hr=Ht.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="no-leaked-text-in-jsx",Er=[",",";","[","]","(",")"],br=hr({name:Yt,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="";Er.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),Ze={name:Yt,rule:br};var ie=require("@typescript-eslint/utils"),xr=ie.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt="no-non-camel-case-functions",Cr=/^[a-z][a-zA-Z0-9]*$/;function zt(e){return e.typeName.type===ie.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===ie.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ie.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var Ir=xr({name:Bt,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Cr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ie.AST_NODE_TYPES.TSTypeReference?zt(n):n.type===ie.AST_NODE_TYPES.TSUnionType&&n.types.some(s=>s.type===ie.AST_NODE_TYPES.TSTypeReference&&zt(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Qe={name:Bt,rule:Ir};var $=require("@typescript-eslint/utils");var et=require("@typescript-eslint/utils");function me(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:me(e.parent,t,n===1/0?n:n-1)}function*tt(e){yield e,e.parent&&(yield*tt(e.parent))}function nt(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function qt(e,t,n){let s=n.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===et.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===et.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return s?s.references.filter(a=>!a.init):[]}var wr=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xt="no-optional-root-props",Rr=wr({name:Xt,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let a=e.sourceCode.getDeclaredVariables(r)[0];if(!a||a.references.length!==1)return!1;let o=a.references[0];if(!o)return!1;for(let i of tt(o.identifier)){if("returnType"in i||i.type===$.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===$.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===$.TSESTree.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===$.TSESTree.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=me(l.parent.parent,$.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let f=ke(p,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(l.type===$.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let c=me(l,$.TSESTree.AST_NODE_TYPES.VariableDeclaration);return c?!!ke(c,e.sourceCode):!1}if(l.type===$.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!ke(l,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=me(r,$.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let o=e.sourceCode.getText(a);return s.replaceText(a,o.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===$.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Oe(r)||!t(r)))for(let s of r.typeAnnotation.members)s.type===$.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(s)},TSInterfaceDeclaration(r){if(!(Oe(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=me(r.parent,$.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let o=ke(a,e.sourceCode);if(!(!o||o.parent.type===$.TSESTree.AST_NODE_TYPES.CallExpression&&o.parent.callee.type===$.TSESTree.AST_NODE_TYPES.Identifier&&o.parent.callee.name==="memo"))for(let l of s.members)l.type===$.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(l)}}}});function Oe(e){return e?e.parent?.type===$.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===$.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function ke(e,t){if(Oe(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(o=>o.identifiers.includes(n));if(!s)return;let a=s.references.filter(o=>o.identifier!==n);if(!(a.length!==1||!a[0])&&!Oe(a[0].identifier.parent.parent))return a[0].identifier}var rt={name:Xt,rule:Rr};var Kt=require("@typescript-eslint/utils"),Ae=_e(require("path"));var vr=Kt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-relative-imports",kr=j({find:A(),replacement:A()}),Or=j({aliases:z(kr),rootDir:N(A()),allowNotFoundAliases:N(ue()),_dev_simulateFileName:N(A())}),Ar=vr({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:[Or]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(o){return o.startsWith(".")||o.startsWith("..")}function s(o,i){let l=Ae.default.dirname(i);return Ae.default.resolve(l,o)}function a(o){let i=t.rootDir??process.cwd(),l=Ae.default.relative(i,o);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let f=l.replace(p,c);return{alias:c,newPath:f}}return null}return{ImportDeclaration(o){let i=o.source.value;if(!r(i))return;let l=s(i,n),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:o,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(o.source,`'${c.newPath}'`):void 0})}}}}),it={name:Jt,rule:Ar};var se=require("@typescript-eslint/utils");var st=_e(require("typescript")),Pr=se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="no-unnecessary-casting",Fr=j({additionalCastFunctions:N(z(j({name:A(),expectedType:Ce(["string","number"])})))}),ot={name:Gt,rule:Pr({name:Gt,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:[Fr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],s=se.ESLintUtils.getParserServices(e,!0),a=s.program?.getTypeChecker();if(!a||!s.program)throw new Error("TypeScript services or program not available");function o(p,f){switch(p.type){case se.AST_NODE_TYPES.Literal:return f==="number"?typeof p.value=="number":typeof p.value=="string";case se.AST_NODE_TYPES.TemplateLiteral:return f==="string";case se.AST_NODE_TYPES.UnaryExpression:return f==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,f){return f==="number"?!!(p.flags&st.TypeFlags.NumberLike):!!(p.flags&st.TypeFlags.StringLike)}function l(p,f){return h=>h.replaceText(p,e.sourceCode.getText(f))}function c(p){if(!a||p.arguments.length!==1)return;let f=p.arguments[0];if(!f||f.type===se.AST_NODE_TYPES.SpreadElement)return;let{callee:h}=p;if(h.type!==se.AST_NODE_TYPES.Identifier)return;let m=h.name,y=r.find(E=>E.name===m);if(!y)return;if(o(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:p,messageId:E,...g?{data:g}:{},fix:l(p,f)})}}return{CallExpression:c}}})};var J=require("@typescript-eslint/utils");var at=ae({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(t){if(t.id.type===J.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==J.AST_NODE_TYPES.ObjectExpression||t.id.type===J.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===J.AST_NODE_TYPES.ExportNamedDeclaration)return;let n=new Map;for(let o of t.init.properties)o.type===J.AST_NODE_TYPES.Property&&o.key.type===J.AST_NODE_TYPES.Identifier&&n.set(o.key.name,o);if(n.size===0||t.id.type!==J.AST_NODE_TYPES.Identifier)return;let r=Nr(t,e.sourceCode);if(r.length===0)return;let s=t.init.properties.some(o=>o.type!==J.AST_NODE_TYPES.Property?!1:o.value.type===J.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let o of r){if(o.identifier.parent.type!==J.AST_NODE_TYPES.MemberExpression)return;let i=o.identifier.parent;if(i.object!==o.identifier)return;if(i.computed)if(i.property.type===J.AST_NODE_TYPES.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==J.AST_NODE_TYPES.Identifier)return;a.add(i.property.name)}if(i.parent.type===J.AST_NODE_TYPES.CallExpression&&s)return}for(let[o,i]of n)a.has(o)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:o}})}}}});function Nr(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 jr=j({selectors:z(j({name:A(),selectorProp:N(A()),selectorArgPos:N(Q()),returnProp:N(A())}))}),Dr=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-unused-selected-values",lt={name:Zt,rule:Dr({name:Zt,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[jr]},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.AST_NODE_TYPES.CallExpression&&(a=s.init),!a)return;let o=_r(a);if(!o)return;let i=r.get(o);if(!i)return;let l=Lr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=Mr(l);if(!c)return;let p=Qt(c.properties,void 0);if(!p)return;if(s.id.type===W.AST_NODE_TYPES.ObjectPattern){let m=Qt(s.id.properties,i.returnProp);if(!m)return;for(let[y,T]of p)m.has(y)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:y}});return}if(s.id.type!==W.AST_NODE_TYPES.Identifier||i.returnProp)return;let f=$r(s,e.sourceCode);if(f.length===0)return;let h=new Set;for(let m of f){if(m.identifier.parent.type!==W.AST_NODE_TYPES.MemberExpression)return;let y=m.identifier.parent.property;if(y.type!==W.AST_NODE_TYPES.Identifier)return;h.add(y.name)}for(let[m,y]of p)h.has(m)||e.report({node:y,messageId:"unusedSelectedValue",data:{name:m}})}}}})};function Lr(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===W.AST_NODE_TYPES.ArrowFunctionExpression||r.type===W.AST_NODE_TYPES.FunctionExpression)return r;if(n&&r.type===W.AST_NODE_TYPES.ObjectExpression){let s=r.properties.find(o=>o.type===W.AST_NODE_TYPES.Property&&o.key.type===W.AST_NODE_TYPES.Identifier&&o.key.name===n);if(s?.type!==W.AST_NODE_TYPES.Property)return null;let a=s.value;if(a.type===W.AST_NODE_TYPES.ArrowFunctionExpression||a.type===W.AST_NODE_TYPES.FunctionExpression)return a}return null}function _r(e){return e.callee.type===W.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===W.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===W.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Mr(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}function Qt(e,t){let n=e;if(t){let s=e.find(a=>a.type===W.AST_NODE_TYPES.Property&&a.key.type===W.AST_NODE_TYPES.Identifier&&a.key.name===t);if(s?.type!==W.AST_NODE_TYPES.Property||s.value.type!==W.AST_NODE_TYPES.ObjectPattern)return null;n=s.value.properties}let r=new Map;for(let s of n){if(s.type!==W.AST_NODE_TYPES.Property||s.key.type!==W.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 H=require("@typescript-eslint/utils");var ct=ae({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===H.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=Ur(a);i&&(r=i);return}let o=Vr(a,e.sourceCode);if(o){s=!0;for(let i of o)r.delete(i);if(r.size!==0)for(let[i,l]of r)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function Ur(e){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==H.AST_NODE_TYPES.ObjectExpression)return null;let r=nt(n.properties,a=>a.type!==H.AST_NODE_TYPES.Property||a.key.type!==H.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===H.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===H.AST_NODE_TYPES.FunctionExpression?Wr(a.value):null);if(!r)return null;let s=new Map;for(let a of r.properties)a.type===H.AST_NODE_TYPES.Property&&a.key.type===H.AST_NODE_TYPES.Identifier&&s.set(a.key.name,a);return s}function Vr(e,t){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==H.AST_NODE_TYPES.ObjectPattern||!nt(e.parent.id.properties,o=>o.type===H.AST_NODE_TYPES.Property&&o.key.type===H.AST_NODE_TYPES.Identifier&&o.key.name==="formFields"&&o))return null;let s=qt(e.parent,"formFields",t),a=new Set;for(let{identifier:o}of s){if(o.type!==H.AST_NODE_TYPES.Identifier||o.parent.type===H.AST_NODE_TYPES.Property&&o.parent.parent.type===H.AST_NODE_TYPES.ObjectExpression&&o.parent.parent.parent.type===H.AST_NODE_TYPES.ReturnStatement||o.parent.type===H.AST_NODE_TYPES.ReturnStatement)return null;if(o.parent.type===H.AST_NODE_TYPES.MemberExpression){if(o.parent.object.type!==H.AST_NODE_TYPES.Identifier||o.parent.property.type!==H.AST_NODE_TYPES.Identifier)return null;a.add(o.parent.property.name)}}return a}function Wr(e){if(e.body.type===H.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===H.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===H.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var M=require("@typescript-eslint/utils");var Hr=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function en(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 tn(e,...t){for(let n of t)e.set(...n);return e}var Yr=j({forceCheckOnFCPropTypesWithName:N(z(A()))}),nn="no-unused-type-props-in-args",pt=null,zr=Hr({name:nn,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&&!pt&&(pt=n.map(i=>new RegExp(i)));function r(i,l,c,p,f=!0){let h=c.name,m=e.sourceCode.getScope(l).references.find(E=>E.identifier.name===h)?.resolved,y=i&&pt?.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,l,p,T.typeAnnotation,!0);return}if(T?.type===M.AST_NODE_TYPES.TSInterfaceDeclaration){s(i,l,p,T.body,!0);return}}}function s(i,l,c,p,f){if(p.type===M.AST_NODE_TYPES.TSInterfaceBody){for(let h of p.body)h.type===M.AST_NODE_TYPES.TSPropertySignature&&h.key.type===M.AST_NODE_TYPES.Identifier&&c.set(h.key.name,h);return}if(p.type===M.AST_NODE_TYPES.TSTypeLiteral){tn(c,...en(p));return}if(p.type===M.AST_NODE_TYPES.TSIntersectionType){for(let h of p.types)s(i,l,c,h,!0);return}f||p.type===M.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===M.AST_NODE_TYPES.Identifier&&r(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let f=new Map;if(s(i,l,f,p.typeAnnotation.typeAnnotation,!1),f.size===0)continue;o(p,f)}else p.type===M.AST_NODE_TYPES.AssignmentPattern&&p.left.type===M.AST_NODE_TYPES.ObjectPattern&&a(i,l,[p.left])}function o(i,l){let c=[];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&&c.push(m.key.name);let f=[],h=[];for(let[m,y]of l)c.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 l=i.declarations[0];if(!l)return;let c=new Map,p=l.id.type===M.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===M.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(p){if(p.type===M.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===M.AST_NODE_TYPES.Identifier)r(!0,i,p.typeName,c,!1);else if(p.type===M.AST_NODE_TYPES.TSTypeLiteral)tn(c,...en(p));else if(p.type===M.AST_NODE_TYPES.TSIntersectionType)for(let f of p.types)f.type===M.AST_NODE_TYPES.TSTypeReference&&f.typeName.type===M.AST_NODE_TYPES.Identifier?r(!0,i,f.typeName,c,!1):s(!0,i,c,f,!0);if(c.size!==0&&l.init?.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let f=l.init.params[0];if(!f){e.report({node:l.init,messageId:"missingComponentParam"});return}f.type===M.AST_NODE_TYPES.ObjectPattern&&o(f,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),ut={name:nn,rule:zr};var de=require("@typescript-eslint/utils"),Br=de.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="prefer-named-functions",rn=new Map,qr=Br({name:sn,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=rn.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),rn.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===de.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===de.AST_NODE_TYPES.Identifier){let s=r.id.name;if(r.id.typeAnnotation||n&&n.test(s)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==de.AST_NODE_TYPES.BlockStatement)return;let a=r.parent,o=r.init.params,i=r.init.body,l=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(a,`${l.async?"async ":""}function ${s}(${o.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),ft={name:sn,rule:qr};var U=require("@typescript-eslint/utils");var Xr=j({disallowedFunctions:z(j({name:A(),hookAlternative:A()}))});function mt(e){return/^use[A-Z]/.test(e)}function Kr(e){return/^[A-Z]/.test(e)}function Jr(e){return e.type===U.AST_NODE_TYPES.Identifier?mt(e.name):e.type===U.AST_NODE_TYPES.MemberExpression&&e.property.type===U.AST_NODE_TYPES.Identifier?mt(e.property.name):!1}function on(e,t){return e.type===U.AST_NODE_TYPES.Identifier?e.name===t:e.type===U.AST_NODE_TYPES.MemberExpression&&e.object.type===U.AST_NODE_TYPES.Identifier&&e.property.type===U.AST_NODE_TYPES.Identifier?e.object.name==="React"&&e.property.name===t:!1}function Gr(e){return!!(e.parent&&e.parent.type===U.AST_NODE_TYPES.CallExpression&&on(e.parent.callee,"forwardRef"))}function Zr(e){return!!(e.parent&&e.parent.type===U.AST_NODE_TYPES.CallExpression&&on(e.parent.callee,"memo"))}function Qr(e){if(e.type===U.AST_NODE_TYPES.FunctionDeclaration||e.type===U.AST_NODE_TYPES.FunctionExpression&&e.id)return e.id||void 0;if(e.type===U.AST_NODE_TYPES.FunctionExpression||e.type===U.AST_NODE_TYPES.ArrowFunctionExpression){if(e.parent.type===U.AST_NODE_TYPES.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===U.AST_NODE_TYPES.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===U.AST_NODE_TYPES.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===U.AST_NODE_TYPES.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function ei(e){let t=e.parent,n=!1;for(;t;){if(t.type===U.AST_NODE_TYPES.FunctionDeclaration||t.type===U.AST_NODE_TYPES.FunctionExpression||t.type===U.AST_NODE_TYPES.ArrowFunctionExpression){let r=Qr(t);if(r&&r.type===U.AST_NODE_TYPES.Identifier){if(Kr(r.name)||mt(r.name))return!n;n=!0}else{if(Gr(t)||Zr(t))return!n;if(t.parent.type===U.AST_NODE_TYPES.CallExpression){let s=t.parent;Jr(s.callee)||(n=!0)}else t.parent.type===U.AST_NODE_TYPES.JSXExpressionContainer||(n=!0)}}t=t.parent}return!1}function ti(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}var dt=ae({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react use the hook {{hookAlternative}} instead."},schema:[Xr],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:n}=t,r=new Map(n.map(s=>[s.name,s]));return{CallExpression(s){if(!ei(s))return;let a=ti(s);if(!a)return;let o=r.get(a);o&&e.report({node:s,messageId:"preferHookAlternative",data:{hookAlternative:o.hookAlternative},suggest:[{messageId:"preferHookAlternative",data:{message:`Replace with ${o.hookAlternative}`,hookAlternative:o.hookAlternative},fix:i=>s.callee.type===U.AST_NODE_TYPES.Identifier?i.replaceText(s.callee,o.hookAlternative):s.callee.type===U.AST_NODE_TYPES.MemberExpression&&s.callee.property.type===U.AST_NODE_TYPES.Identifier?i.replaceText(s.callee.property,o.hookAlternative):null}]})}}}});var Y=require("@typescript-eslint/utils");var ni=Y.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ln="prefer-single-line-if",ri=j({maxLineLength:N(Q()),maxNonSimpleConditionLength:N(Q())}),ii=ni({name:ln,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:[ri]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==Y.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===Y.AST_NODE_TYPES.ReturnStatement){if(!pn(a))return}else if(!(a.type===Y.AST_NODE_TYPES.ContinueStatement||a.type===Y.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===Y.AST_NODE_TYPES.LogicalExpression||r.test.type===Y.AST_NODE_TYPES.ConditionalExpression)return;let o;if(t.maxNonSimpleConditionLength){let f=an(r.test);if(!f&&r.test.type===Y.AST_NODE_TYPES.UnaryExpression&&r.test.operator==="!"){let h=r.test.argument;an(h)&&(f=!0)}if(f&&(o=n.getText(r.test),o.length>t.maxNonSimpleConditionLength))return}o||(o=n.getText(r.test));let i=n.getText(a);if(o.includes(`
|
|
15
|
+
`))return;let l=n.getTokenAfter(r);if(l&&l.type===Y.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let f=n.getTokenAfter(l);if(f&&f.type===Y.AST_TOKEN_TYPES.Keyword&&(f.value==="else"||f.value==="catch"))return}let c=si(n,r),p=`if (${o}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:f=>f.replaceText(r,p)})}}}});function an(e){return e.type===Y.AST_NODE_TYPES.CallExpression||e.type===Y.AST_NODE_TYPES.BinaryExpression||e.type===Y.AST_NODE_TYPES.MemberExpression&&cn(e)}function cn(e){return e.object.type===Y.AST_NODE_TYPES.MemberExpression?cn(e.object):e.object.type!==Y.AST_NODE_TYPES.Identifier}function si(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function pn(e){if(!e.argument)return!0;let t=e.argument;return t.type===Y.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===Y.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===Y.AST_NODE_TYPES.Literal||t.type===Y.AST_NODE_TYPES.Identifier||t.type===Y.AST_NODE_TYPES.TemplateLiteral||t.type===Y.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===Y.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===Y.AST_NODE_TYPES.UnaryExpression?pn(t):!1}var yt={name:ln,rule:ii};var K=require("@typescript-eslint/utils");var oi=K.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),un="react-compiler-migration",ai=j({disallowHooks:N(z(j({name:A(),replacement:A()}))),disallowMethods:N(z(j({name:A(),replacement:N(A()),requireTrueProp:N(A())})))}),li=/eslint +react-compiler\/react-compiler: +\["error/;function ci(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 pi=oi({name:un,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:[ai]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(li.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 o=t.disallowHooks.find(i=>i.name===s);o&&a&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:o.name,replacement:o.replacement},suggest:[{messageId:"replace",data:{replacement:o.replacement},fix:i=>i.replaceText(a,o.replacement)}]})}}if(t.disallowMethods?.length&&ci(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 o=a.key.name,i=t.disallowMethods.find(l=>l.name===o);if(i){if(i.requireTrueProp){let l=i.requireTrueProp,c=!1;for(let p of s.properties)if(p.type===K.AST_NODE_TYPES.Property&&p.key.type===K.AST_NODE_TYPES.Identifier&&p.key.name===l&&p.value.type===K.AST_NODE_TYPES.Literal&&p.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:l}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),gt={name:un,rule:pi};var Pe=require("@typescript-eslint/utils"),ui=Pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="require-description",fi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,mi=/^eslint-disable-(next-)?line$/u,di=ui({name:fn,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=yi(s);a!=null&&(r.has(a.kind)||a.description||e.report({loc:Si(s.loc),messageId:"missingDescription"}))}}}}}),mn={name:fn,rule:di};function yi(e){let{text:t,description:n}=gi(e.value);if(!t)return null;let r=fi.exec(t);if(!r)return null;let s=r[1];if(!s)return null;let a=mi.test(s);if(e.type===Pe.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let o=t.slice(r.index+s.length);return{kind:s,value:o.trim(),description:n}}function gi(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 gn(e){return/^use[A-Z0-9]/.test(e)}function Fe(e){return e.type==="Identifier"?gn(e.name):e.type==="MemberExpression"&&!e.computed&&Fe(e.property)?e.object.type==="Identifier":!1}function Sn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Tn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function hn(e){return!!(e.parent&&e.parent.callee&&Tn(e.parent.callee,"forwardRef"))}function En(e){return!!(e.parent&&e.parent.callee&&Tn(e.parent.callee,"memo"))}function St(e){for(;e;){let t=xn(e);if(t&&(Sn(t)||Fe(t))||hn(e)||En(e))return!0;e=e.parent}return!1}function dn(e){return!1}function Tt(e){return!1}var Ti=/eslint +react-compiler\/react-compiler: +\["error/,bn={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 l of e.sourceCode.getAllComments())if(Ti.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),n=typeof e.getScope=="function"?()=>n():l=>e.sourceCode.getScope(l),r=null,s=[],a=[],o=new WeakSet;function i(l){for(let c of l.references){let p=c.identifier.parent;if(p.type==="VariableDeclarator"&&p.init&&p.init.type==="CallExpression"&&p.init.callee&&dn(p.init.callee))for(let f of c.resolved.references)f!==c&&o.add(f.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(l,c){let p=s.pop();if(p.size===0)return;let f=new Set;function h(S,v){let{cache:P}=h,D=P.get(S.id),_=new Set(v);if(_.has(S.id)){let R=[..._],V=R.slice(R.indexOf(S.id)+1);for(let q of V)f.add(q);return BigInt("0")}if(_.add(S.id),D!==void 0)return D;if(l.thrownSegments.includes(S))D=BigInt("0");else if(S.prevSegments.length===0)D=BigInt("1");else{D=BigInt("0");for(let R of S.prevSegments)D+=h(R,_)}return S.reachable&&D===BigInt("0")?P.delete(S.id):P.set(S.id,D),D}function m(S,v){let{cache:P}=m,D=P.get(S.id),_=new Set(v);if(_.has(S.id)){let R=Array.from(_),V=R.slice(R.indexOf(S.id)+1);for(let q of V)f.add(q);return BigInt("0")}if(_.add(S.id),D!==void 0)return D;if(l.thrownSegments.includes(S))D=BigInt("0");else if(S.nextSegments.length===0)D=BigInt("1");else{D=BigInt("0");for(let R of S.nextSegments)D+=m(R,_)}return P.set(S.id,D),D}function y(S){let{cache:v}=y,P=v.get(S.id);if(P===null)return 1/0;if(P!==void 0)return P;if(v.set(S.id,null),S.prevSegments.length===0)P=1;else{P=1/0;for(let D of S.prevSegments){let _=y(D);_<P&&(P=_)}P+=1}return v.set(S.id,P),P}h.cache=new Map,m.cache=new Map,y.cache=new Map;let T=m(l.initialSegment),E=xn(c),g=St(c),k=E?Sn(E)||Fe(E):hn(c)||En(c),C=1/0;for(let S of l.finalSegments){if(!S.reachable)continue;let v=y(S);v<C&&(C=v)}for(let[S,v]of p){if(!S.reachable)continue;let P=S.nextSegments.length===0?C<=y(S):C<y(S),D=h(S)*m(S),_=f.has(S.id);for(let R of v)if(_&&!Tt(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.`}),k){if(c.async&&e.report({node:R,message:`React Hook "${t(R)}" cannot be called in an async function.`}),!_&&D!==T&&!Tt(R)){let q=`React Hook "${t(R)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(P?" Did you accidentally call a React Hook after an early return?":"");e.report({node:R,message:q})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let V=`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:V})}else if(E){let V=`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:V})}else if(c.type==="Program"){let V=`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:V})}else if(g&&!Tt(R)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let q=c.parent;if(q.parent.type==="VariableDeclarator"&&gn(q.parent.id.name))return}let V=`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:V})}}},CallExpression(l){if(Fe(l.callee)){let c=yn(s),p=yn(a),f=c.get(p);f||(f=[],c.set(p,f)),f.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||dn(l.callee))&&l.arguments.length>0&&(r=l)},Identifier(l){r==null&&o.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` 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"(l){l===r&&(r=null)},FunctionDeclaration(l){St(l)&&i(n(l))},ArrowFunctionExpression(l){St(l)&&i(n(l))}}}};function xn(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 yn(e){return e[e.length-1]}var Cn={[ut.name]:ut.rule,[Je.name]:Je.rule,[Ke.name]:Ke.rule,"rules-of-hooks":bn,"exhaustive-deps":jt,"require-description":mn.rule,[Ge.name]:Ge.rule,[Qe.name]:Qe.rule,[ft.name]:ft.rule,[Ve.name]:Ve.rule,[Xe.name]:Xe.rule,[it.name]:it.rule,[yt.name]:yt.rule,[rt.name]:rt.rule,[Ze.name]:Ze.rule,[He.name]:He.rule,[gt.name]:gt.rule,[Ue.name]:Ue.rule,[qe.name]:qe.rule,[ot.name]:ot.rule,[lt.name]:lt.rule,[ct.name]:ct.rule,[at.name]:at.rule,[dt.name]:dt.rule};var hi={rules:Cn};0&&(module.exports={extendedLintPlugin});
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{AST_NODE_TYPES as
|
|
2
|
-
`)||n.getCommentsInside(c).length>0)return;
|
|
3
|
-
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function
|
|
1
|
+
import{AST_NODE_TYPES as q,ESLintUtils as wn}from"@typescript-eslint/utils";var Oe=Symbol.for("optional");function N(e){return{...e,[Oe]:!0}}function Te(e,t){return{enum:e,...t}}function ae(e){return{...e,type:"boolean"}}function A(e){return{...e,type:"string"}}function Z(e){return{...e,type:"number"}}function St(e){return{...e,type:"integer"}}function Y(e,t){return{...t,type:"array",items:e}}function j(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,s=[];for(r in e)e[r][Oe]?e[r][Oe]=void 0:s.push(r);s.length>0&&(n.required=s)}return n}function Ae(...e){return{anyOf:e}}var Rn=wn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ht="react-compiler-extra",vn=j({runOnlyWithEnableCompilerDirective:N(ae())}),kn=/eslint +react-compiler\/react-compiler: +\["error/;function On(e){return e.type===q.Identifier?e.name.startsWith("use"):e.type===q.MemberExpression&&e.property.type===q.Identifier?e.property.name.startsWith("use"):!1}var An=/\bthis[.[]/;function Tt(e){return An.test(e)}var Pn=Rn({name:ht,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:[vn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(kn.test(a.value)){n=!0;break}if(!n)return{}}function r(a){for(let o of a.properties)if(o.type===q.Property&&o.method&&o.value.type===q.FunctionExpression){let i=e.sourceCode,l=i.getText(o.key),c=o.value,p=i.getText(c.body);if(Tt(p))e.report({node:o,messageId:"thisKeywordInMethod"});else{let f=c.params.map(m=>i.getText(m)).join(", "),h="";c.generator?h=`${l}: function* (${f}) ${p}`:h=`${l}: (${f}) => ${p}`,e.report({node:o,messageId:"objectMethodIsNotSupported",fix:m=>m.replaceText(o,h)})}}}function s(a){for(let o of a.properties)if(o.type===q.Property&&o.value.type===q.ObjectExpression){for(let i of o.value.properties)if(i.type===q.Property&&i.method&&i.value.type===q.FunctionExpression){let c=e.sourceCode.getText(i.value.body);Tt(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(On(a.callee))for(let o of a.arguments){if(o.type===q.ObjectExpression&&(r(o),s(o)),o.type===q.ArrowFunctionExpression&&(o.body.type===q.ObjectExpression&&(r(o.body),s(o.body)),o.body.type===q.BlockStatement))for(let i of o.body.body)i.type===q.ReturnStatement&&i.argument?.type===q.ObjectExpression&&(r(i.argument),s(i.argument));if(o.type===q.FunctionExpression)for(let i of o.body.body)i.type===q.ReturnStatement&&i.argument?.type===q.ObjectExpression&&(r(i.argument),s(i.argument))}}}}}),Pe={name:ht,rule:Pn};import{AST_NODE_TYPES as Fe}from"@typescript-eslint/utils";import{ESLintUtils as Fn}from"@typescript-eslint/utils";function se(e){let n=Fn.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}var Nn=j({disallow:N(Y(j({selector:A(),message:A(),replace:N(Ae(A(),j({regex:A(),with:A()}))),replaceType:N(Te(["suggestion","autofix"]))}))),__dev_simulateFileName:N(A()),mustMatchSyntax:N(Y(j({includeRegex:A(),mustCallFn:N(Y(j({anyCall:Y(j({fn:A(),withArgs:Y(j({atIndex:St(),literal:Ae(A(),Z(),ae())}))})),message:N(A())}))),mustMatchSelector:N(Y(j({selector:A(),message:A()})))})))}),Ne=se({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Nn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:s,disallow:a}=t,o=s??e.filename,i=[],l=new Map,c=new Set,p=new Map;for(let{includeRegex:m,mustCallFn:y,mustMatchSelector:T}of r??[]){let E=jn(o,new RegExp(m));if(!E)continue;let g=k=>{let C=k;for(let{name:S,value:v}of E)C=C.replaceAll(S,v);return C};for(let{anyCall:k,message:C}of y??[]){let S=`Expected file to call the function: ${k.map(({fn:v})=>v).join(" or ")}`;c.add(S),i.push(v=>{let{callee:P}=v;if(P.type===Fe.Identifier){for(let{fn:D,withArgs:L}of k)if(P.name===D){c.delete(S);for(let R of L){let _=v.arguments[R.atIndex],B=typeof R.literal=="string"?g(R.literal):R.literal;if(!_){e.report({node:v,messageId:"default",data:{message:`Missing argument with value "${B}" at index ${R.atIndex}${C?`: ${g(C)}`:""}`}});continue}if(_.type!==Fe.Literal){e.report({node:_,messageId:"default",data:{message:`Argument at position ${R.atIndex} should the literal "${B}"${C?`: ${g(C)}`:""}`}});continue}_.value!==B&&e.report({node:_,messageId:"default",data:{message:`Argument should have the value "${B}"${C?`: ${g(C)}`:""}`},fix:de=>de.replaceText(_,typeof B=="string"?`'${B}'`:String(B))})}break}}})}for(let{selector:k,message:C}of T??[])p.set(k,g(C)),l.set(g(k),()=>{p.delete(k)})}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(l.size>0)for(let[m,y]of l)f(m,y);return i.length>0&&(n.CallExpression=m=>{if(m.type===Fe.CallExpression)for(let y of i)y(m)}),n["Program:exit"]=m=>{for(let y of c)e.report({node:m,messageId:"default",data:{message:y}});for(let[,y]of p)e.report({node:m,messageId:"default",data:{message:y}})},n;function h(m,y,T,E){let g=k=>{if(!m)return null;if(typeof m=="string")return k.replaceText(y,m);{let C=new RegExp(m.regex),S=e.sourceCode.getText(y);return k.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 jn(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:Et(s)}),n.push({name:"$0_uncapitalize",value:bt(s)}),n.push({name:"$0",value:s});for(let o=0;o<a.length;o++){let i=`$${o+1}`,l=a[o];n.push({name:`${i}_lowercase`,value:l.toLowerCase()}),n.push({name:`${i}_capitalize`,value:Et(l)}),n.push({name:`${i}_uncapitalize`,value:bt(l)}),n.push({name:i,value:l})}return n}function Et(e){return e.charAt(0).toUpperCase()+e.slice(1)}function bt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as M,AST_TOKEN_TYPES as Dn,ESLintUtils as Ln}from"@typescript-eslint/utils";var _n=Ln.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ct="collapse-simple-objs-in-one-line",Mn=j({maxLineLength:N(Z()),maxProperties:N(Z()),nestedObjMaxLineLength:N(Z()),nestedObjMaxProperties:N(Z()),ignoreTypesWithSuffix:N(Y(A()))}),$n=_n({name:Ct,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:[Mn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,o=t.nestedObjMaxProperties??3;function i(c){if(c.type===M.ObjectExpression){let p=c.parent.type===M.Property,f=p?o:s,h=c.properties.length;if(h>f)return!1;if(h===1){let y=c.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&&je(E))?!1:{text:n.getText(y),isNested:p,propsSize:h}}let m=[];for(let y of c.properties){if(y.type===M.Property&&!je(y.value))return!1;m.push(n.getText(y))}return{text:m.join(", "),isNested:p,propsSize:h}}else{let p=c.parent.parent?.type===M.TSPropertySignature,f=p?o:s,h=c.members.length;if(h>f)return!1;if(r.length>0&&c.parent.type===M.TSTypeAliasDeclaration){let y=c.parent.id.name;if(r.some(T=>y.endsWith(T)))return!1}if(h===1){let y=c.members[0];return y.type===M.TSPropertySignature&&y.typeAnnotation?.typeAnnotation.type===M.TSTypeLiteral?!1:{text:n.getText(y),isNested:p,propsSize:1}}if(c.parent.type===M.TSIntersectionType||c.parent.type===M.TSUnionType)return!1;let m=[];for(let y of c.members){if(y.type!==M.TSPropertySignature)return!1;let T=y.typeAnnotation?.typeAnnotation;if(!T||T.type===M.TSTypeLiteral||!xt(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(!xt(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:p,propsSize:h}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==M.JSXExpressionContainer){let T=0,E=n.getTokenAfter(c,{filter:g=>g.type!==Dn.Punctuator?!0:g.value===","||g.value===";"||g.value===")"||g.value==="}"?(T++,!1):!0});if(T>4||E?.loc.start.line===c.loc.end.line)return}let p=i(c);if(!p)return;let f=p.text;if(f.includes(`
|
|
2
|
+
`)||n.getCommentsInside(c).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let h=`{ ${f} }`,m=Vn(n,c),y=p.isNested&&p.propsSize>2?a:t.maxLineLength;y&&h.length+m.length+Un(c,n)>y||e.report({node:c,messageId:"singleLineProp",fix:T=>T.replaceText(c,h)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function xt(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 je(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&&je(n,!0)))}function Un(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 Vn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var De={name:Ct,rule:$n};var Wn=/eslint +react-compiler\/react-compiler: +\["error/,wt={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,o={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 l=e.getSourceCode().scopeManager,c=new WeakMap,p=new WeakSet,f=new WeakMap,h=new WeakMap,m=new WeakSet;function y(g,k){return function(C){if(k.has(C))return k.get(C);let S=g(C);return k.set(C,S),S}}function T(g,k,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 P=l.acquire(g),D=new Set,L=null;{let u=P.upper;for(;u&&(D.add(u),u.type!=="function");)u=u.upper;if(!u)return;L=u}let R=Array.isArray;function _(u){if(!R(u.defs))return!1;let d=u.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&&(Me(L.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:O}=w;if(O==="useRef"&&I.type==="Identifier")return!0;if(qn(w)&&I.type==="Identifier"){for(let F of u.references)F!==I&&m.add(F.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(I.type==="ArrayPattern"&&I.elements.length===2&&R(u.identifiers)){if(I.elements[1]===u.identifiers[0]){if(O==="useState"){let F=u.references,G=0;for(let ne=0;ne<F.length;ne++){if(F[ne].isWrite()&&G++,G>1)return!1;c.set(F[ne].identifier,I.elements[0])}}return!0}else if(I.elements[0]===u.identifiers[0]){if(O==="useState"){let F=u.references;for(let G=0;G<F.length;G++)p.add(F[G].identifier)}return!1}}}else if(O==="useTransition"&&I.type==="ArrayPattern"&&I.elements.length===2&&Array.isArray(u.identifiers)&&I.elements[1]===u.identifiers[0])return!0;return!1}function B(u){if(!R(u.defs))return!1;let d=u.defs[0];if(d==null||d.node==null||d.node.id==null)return!1;let b=d.node,x=L.childScopes,w=null,I;for(I=0;I<x.length;I++){let O=x[I],F=O.block;if(b.type==="FunctionDeclaration"&&F===b||b.type==="VariableDeclarator"&&F.parent===b){w=O;break}}if(w==null)return!1;for(I=0;I<w.through.length;I++){let O=w.through[I];if(O.resolved!=null&&D.has(O.resolved.scope)&&!de(O.resolved))return!1}return!0}let de=y(_,f),Tn=y(B,h),ft=new Map;function hn(u){let d=u.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 J=new Map,we=new Map;mt(P);function mt(u){for(let d of u.references){if(!d.resolved||!D.has(d.resolved.scope))continue;let b=Me(g,d.identifier),x=Rt(b),w=re(x,we);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)&&ft.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(J.has(w))J.get(w).references.push(d);else{let O=d.resolved,F=de(O)||Tn(O);J.set(w,{isStable:F,references:[d]})}}for(let d of u.childScopes)mt(d)}ft.forEach(({reference:u,dependencyNode:d},b)=>{let x=u.resolved.references,w=!1;for(let I=0;I<x.length;I++){let{identifier:O}=x[I],{parent:F}=O;if(F!=null&&F.type==="MemberExpression"&&!F.computed&&F.property.type==="Identifier"&&F.property.name==="current"&&F.parent.type==="AssignmentExpression"&&F.parent.left===F){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 Re=new Set;function En(u,d){Re.has(d)||(Re.add(d),i({node:u,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 ye=new Set;if(J.forEach(({isStable:u,references:d},b)=>{u&&ye.add(b),d.forEach(x=>{x.writeExpr&&En(x.writeExpr,b)})}),Re.size>0)return;if(!k){let u=null;if(J.forEach(({isStable:d,references:b},x)=>{u||b.forEach(w=>{if(u)return;let I=w.identifier;if(!c.has(I))return;let F=w.from;for(;F.type!=="function";)F=F.upper;F.block===g&&(u=x)})}),u){let{suggestedDependencies:d}=Le({dependencies:J,declaredDependencies:[],stableDependencies:ye,externalDependencies:new Set,isEffect:!0});i({node:C,message:`React Hook ${S} contains a call to '${u}'. 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 ue=[],fe=new Set;k.type!=="ArrayExpression"?i({node:k,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.`}):k.elements.forEach(u=>{if(u===null)return;if(u.type==="SpreadElement"){i({node:u,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(u)&&i({node:u,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(u)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(u)}\``,fix(w){return w.removeRange(u.range)}}]});let d;try{d=re(u,we)}catch(w){if(/Unsupported node type/.test(w.message)){u.type==="Literal"?J.has(u.value)?i({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. Did you mean to include ${u.value} in the array instead?`}):i({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:u,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=u;for(;b.type==="MemberExpression"||b.type==="OptionalMemberExpression"||b.type==="ChainExpression";)b=b.object||b.expression.object;let x=!L.through.some(w=>w.identifier===b);ue.push({key:d,node:u}),x||fe.add(d)});let{suggestedDependencies:bn,unnecessaryDependencies:ge,missingDependencies:ie,duplicateDependencies:dt}=Le({dependencies:J,declaredDependencies:ue,stableDependencies:ye,externalDependencies:fe,isEffect:v}),Se=bn;if(dt.size+ie.size+ge.size===0){if(t)return;Hn({declaredDependencies:ue,declaredDependenciesNode:k,componentScope:L,scope:P}).forEach(({construction:d,isUsedOutsideOfHook:b,depType:x})=>{let w=x==="function"?"useCallback":"useMemo",I=x==="function"?"definition":"initialization",O=`wrap the ${I} of '${d.name.name}' in its own ${w}() Hook.`,F=b?`To fix this, ${O}`:`Move it inside the ${S} callback. Alternatively, ${O}`,G=x==="conditional"||x==="logical expression"?"could make":"makes",ne=`The '${d.name.name}' ${x} ${G} the dependencies of ${S} Hook (at line ${k.loc.start.line}) change on every render. ${F}`,yt;b&&d.type==="Variable"&&x==="function"&&(yt=[{desc:`Wrap the ${I} of '${d.name.name}' in its own ${w}() Hook.`,fix(gt){let[Cn,In]=w==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[gt.insertTextBefore(d.node.init,Cn),gt.insertTextAfter(d.node.init,In)]}}]),i({node:d.node,message:ne,suggest:yt})});return}!v&&ie.size>0&&(Se=Le({dependencies:J,declaredDependencies:[],stableDependencies:ye,externalDependencies:fe,isEffect:v}).suggestedDependencies);function xn(){if(ue.length===0)return!0;let u=ue.map(b=>b.key),d=u.slice().sort();return u.join(",")===d.join(",")}xn()&&Se.sort();function ve(u){let d=u.split("."),b="";for(let x=0;x<d.length;x++){if(x!==0){let w=d.slice(0,x+1).join("."),I=we.get(w)===!0;b+=I?"?.":"."}b+=d[x]}return b}function ke(u,d,b,x){return u.size===0?null:(u.size>1?"":d+" ")+b+" "+(u.size>1?"dependencies":"dependency")+": "+zn(Array.from(u).sort().map(w=>"'"+ve(w)+"'"))+`. Either ${x} ${u.size>1?"them":"it"} or remove the dependency array.`}let te="";if(ge.size>0){let u=null;if(Array.from(ge.keys()).forEach(d=>{u===null&&d.endsWith(".current")&&(u=d)}),u!==null)te=` Mutable values like '${u}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(fe.size>0){let d=Array.from(fe)[0];P.set.has(d)||(te=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!te&&ie.has("props")){let u=J.get("props");if(u==null)return;let d=u.references;if(!Array.isArray(d))return;let b=!0;for(let x=0;x<d.length;x++){let w=d[x],I=Me(L.block,w.identifier);if(!I){b=!1;break}let O=I.parent;if(O==null){b=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){b=!1;break}}b&&(te=` 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(!te&&ie.size>0){let u=null;ie.forEach(d=>{if(u)return;let b=L.set.get(d),x=J.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,O;for(let F=0;F<x.references.length;F++)if(O=x.references[F].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){I=!0;break}I&&(u=d)}),u!==null&&(te=` If '${u}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!te&&ie.size>0){let u=null;if(ie.forEach(d=>{if(u!==null)return;let x=J.get(d).references,w,I;for(let O=0;O<x.length;O++){for(w=x[O].identifier,I=w.parent;I!=null&&I!==L.block;){if(I.type==="CallExpression"){let F=c.get(I.callee);if(F!=null){if(F.name===d)u={missingDep:d,setter:I.callee.name,form:"updater"};else if(p.has(w))u={missingDep:d,setter:I.callee.name,form:"reducer"};else{let G=x[O].resolved;if(G!=null){let ne=G.defs[0];ne!=null&&ne.type==="Parameter"&&(u={missingDep:d,setter:I.callee.name,form:"inlineReducer"})}}break}}I=I.parent}if(u!==null)break}}),u!==null)switch(u.form){case"reducer":te=` You can also replace multiple useState variables with useReducer if '${u.setter}' needs the current value of '${u.missingDep}'.`;break;case"inlineReducer":te=` If '${u.setter}' needs the current value of '${u.missingDep}', you can also switch to useReducer instead of useState and read '${u.missingDep}' in the reducer.`;break;case"updater":te=` You can also do a functional update '${u.setter}(${u.missingDep.slice(0,1)} => ...)' if you only need '${u.missingDep}' in the '${u.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:k,message:`React Hook ${n(C)} has `+(ke(ie,"a","missing","include")||ke(ge,"an","unnecessary","exclude")||ke(dt,"a","duplicate","omit"))+te,suggest:[{desc:`Update the dependencies array to be: [${Se.map(ve).join(", ")}]`,fix(u){return u.replaceText(k,`[${Se.map(ve).join(", ")}]`)}}]})}function E(g){let k=Yn(g.callee,o);if(k===-1)return;let C=g.arguments[k],S=g.callee,v=vt(S).name,P=g.arguments[k+1],D=/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&&!D)){if(!P&&!D){(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,P,S,v,D);return;case"Identifier":if(!P||P.elements&&P.elements.some(_=>_&&_.type==="Identifier"&&_.name===C.name))return;let L=r(g).set.get(C.name);if(L==null||L.defs==null)return;let R=L.defs[0];if(!R||!R.node||R.type!=="Variable"&&R.type!=="FunctionName")break;switch(R.node.type){case"FunctionDeclaration":T(R.node,P,S,v,D);return;case"VariableDeclarator":let _=R.node.init;if(!_)break;switch(_.type){case"ArrowFunctionExpression":case"FunctionExpression":T(_,P,S,v,D);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(L){return L.replaceText(P,`[${C.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(Wn.test(g.value))return t=!0,{CallExpression:k=>E(k,!0)}}return{CallExpression:g=>E(g)}}};function Le({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:s}){let a=o();function o(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,E)=>{let g=i(a,E);g.isUsed=!0,l(a,E,k=>{k.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("."),k=T;for(let C of g){let S=k.children.get(C);S||(S=o(),k.children.set(C,S)),k=S}return k}function l(T,E,g){let k=E.split("."),C=T;for(let S of k){let v=C.children.get(S);if(!v)return;g(v),C=v}}let c=new Set,p=new Set;f(a,c,p,T=>T);function f(T,E,g,k){T.children.forEach((C,S)=>{let v=k(S);if(C.isSatisfiedRecursively){C.isSubtreeUsed&&g.add(v);return}if(C.isUsed){E.add(v);return}f(C,E,g,P=>v+"."+P)})}let h=[],m=new Set,y=new Set;return t.forEach(({key:T})=>{p.has(T)?h.indexOf(T)===-1?h.push(T):y.add(T):m.add(T)}),c.forEach(T=>{h.push(T)}),{suggestedDependencies:h,unnecessaryDependencies:m,duplicateDependencies:y,missingDependencies:c}}function oe(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 oe(e.consequent)!=null||oe(e.alternate)!=null?"conditional":null;case"LogicalExpression":return oe(e.left)!=null||oe(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return oe(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return oe(e.expression);case"TSAsExpression":return oe(e.expression)}return null}function Hn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let s=e.map(({key:o})=>{let i=n.variables.find(c=>c.name===o);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=oe(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(o){let i=!1;for(let l=0;l<o.references.length;l++){let c=o.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==r&&p!=null;)p=p.upper;if(p!==r&&!kt(t,c.identifier))return!0}return!1}return s.map(([o,i])=>({construction:o.defs[0],depType:i,isUsedOutsideOfHook:a(o)}))}function Rt(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?Rt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function _e(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function re(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=re(e.object,t),r=re(e.property,null),s=`${n}.${r}`;return _e(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=re(e.object,t),r=re(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=re(n.object,t),s=re(n.property,null),a=`${r}.${s}`;return _e(n,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function vt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Yn(e,t){let n=vt(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=re(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 Me(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),Bn(r,t))return r;if(kt(r,t))for(let[s,a]of Object.entries(r))s!=="parent"&&(It(a)?(a.parent=r,n.push(a)):Array.isArray(a)&&a.forEach(o=>{It(o)&&(o.parent=r,n.push(o))}))}return null}function zn(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function It(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Bn(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 kt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function qn(e){return!1}import{AST_NODE_TYPES as Ee,ESLintUtils as At}from"@typescript-eslint/utils";import X from"typescript";var Xn=At.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ot="improved-no-unnecessary-condition",Kn=j({}),Jn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Gn=new Set(Jn),$e={name:Ot,rule:Xn({name:Ot,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[Kn]},defaultOptions:[{}],create(e){let t=At.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===Ee.UnaryExpression&&i.operator==="typeof"}function s(i){return i.flags&X.TypeFlags.Any||i.flags&X.TypeFlags.Unknown?null:i.flags&X.TypeFlags.StringLike?["string"]:i.flags&X.TypeFlags.NumberLike?["number"]:i.flags&X.TypeFlags.BigIntLike?["bigint"]:i.flags&X.TypeFlags.BooleanLike?["boolean"]:i.flags&X.TypeFlags.ESSymbolLike?["symbol"]:i.flags&X.TypeFlags.Undefined||i.flags&X.TypeFlags.Void?["undefined"]:i.flags&X.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&X.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&X.TypeFlags.NonPrimitive?["object"]:i.flags&X.TypeFlags.Never?["never"]:null}function a(i){if(!n)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=n.getTypeAtLocation(l.expression);if(c.flags&X.TypeFlags.Any||c.flags&X.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let h of c.types){let m=s(h);if(m)p.push(...m);else return null}return p}let f=s(c);return f?(p.push(...f),p):null}function o(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(r(i.left)?(c=i.left,p=i.right.type===Ee.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(c=i.right,p=i.left.type===Ee.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!Zn(p,Gn))return;let f=a(c);if(!f)return;let h=i.operator==="!==",m=f.includes(p);f.length===1?m&&!h?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:le(c,e),type:p}}):!m&&h?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:le(c,e),type:Array.from(f)[0]}}):!m&&!h?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:le(c,e),actualType:he(f),conditionType:p}}):m&&h&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:le(c,e),actualType:he(f),conditionType:p}}):!m&&!h?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:le(c,e),actualType:he(f),conditionType:p}}):!m&&h&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:le(c,e),type:he(f)}})}return{BinaryExpression:o}}})};function he(e){return Array.from(new Set(e)).join(" | ")||"never"}function le(e,t){let n=e.argument;return n.type===Ee.Identifier?n.name:t.sourceCode.getText(n)}function Zn(e,t){return t.has(e)}import{AST_NODE_TYPES as Qn,ESLintUtils as er}from"@typescript-eslint/utils";var tr=er.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="no-call-with-explicit-generics",nr=j({functions:Y(A())}),rr=tr({name:Pt,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:[nr]},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}})}}}}),Ue={name:Pt,rule:rr};import{AST_NODE_TYPES as be,ESLintUtils as ir}from"@typescript-eslint/utils";var sr=ir.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="no-call-with-inferred-generics",or=sr({name:Ft,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!==be.Identifier)return;let a=n.get(s.name);if(!a)return;let{minGenerics:o=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(r.typeArguments?.params.length||0)<(o||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:o||0}}),!(i&&!l)&&r.typeArguments?.params?.some(p=>!i&&p.type===be.TSAnyKeyword||l&&p.type===be.TSTypeReference&&p.typeName.type===be.Identifier&&l.includes(p.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),Ve={name:Ft,rule:or};import{ESLintUtils as ar,TSESTree as Nt}from"@typescript-eslint/utils";var lr=ar.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jt="no-commented-out-code",cr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],pr=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],ur=lr({name:jt,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 cr)if(r.startsWith(s))return{wrongPattern:s};for(let s of pr)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===Nt.AST_TOKEN_TYPES.Line||s.type===Nt.AST_TOKEN_TYPES.Block){let a=t(s.value);a&&e.report({node:s,messageId:"commentedOutCode",data:{wrongPattern:a.wrongPattern}})}}}}}),We={name:jt,rule:ur};import{ESLintUtils as fr,TSESTree as mr}from"@typescript-eslint/utils";var dr=fr.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===mr.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),He={name:Dt,rule:yr};import{ESLintUtils as gr}from"@typescript-eslint/utils";var Sr=gr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="no-leaked-text-in-jsx",Tr=[",",";","[","]","(",")"],hr=Sr({name:Lt,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let r="";Tr.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),Ye={name:Lt,rule:hr};import{AST_NODE_TYPES as ce,ESLintUtils as Er}from"@typescript-eslint/utils";var br=Er.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Mt="no-non-camel-case-functions",xr=/^[a-z][a-zA-Z0-9]*$/;function _t(e){return e.typeName.type===ce.TSQualifiedName&&e.typeName.left.type===ce.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ce.Identifier&&e.typeName.right.name==="Element"}var Cr=br({name:Mt,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!xr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ce.TSTypeReference?_t(n):n.type===ce.TSUnionType&&n.types.some(s=>s.type===ce.TSTypeReference&&_t(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ze={name:Mt,rule:Cr};import{ESLintUtils as Ir,TSESTree as V}from"@typescript-eslint/utils";import{AST_NODE_TYPES as $t}from"@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*Be(e){yield e,e.parent&&(yield*Be(e.parent))}function qe(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function Ut(e,t,n){let s=n.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===$t.Property&&a.identifiers[0]?.parent.key.type===$t.Identifier&&a.identifiers[0]?.parent.key.name===t);return s?s.references.filter(a=>!a.init):[]}var wr=Ir.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vt="no-optional-root-props",Rr=wr({name:Vt,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 o=a.references[0];if(!o)return!1;for(let i of Be(o.identifier)){if("returnType"in i||i.type===V.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===V.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===V.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===V.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=pe(l.parent.parent,V.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let f=xe(p,e.sourceCode);return f?!(f.parent.type===V.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===V.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(i.type===V.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===V.AST_NODE_TYPES.ArrowFunctionExpression){let c=pe(l,V.AST_NODE_TYPES.VariableDeclaration);return c?!!xe(c,e.sourceCode):!1}if(l.type===V.AST_NODE_TYPES.FunctionDeclaration)return!!xe(l,e.sourceCode)}return!1}function n(r){r.key.type!==V.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=pe(r,V.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let o=e.sourceCode.getText(a);return s.replaceText(a,o.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===V.AST_NODE_TYPES.TSTypeLiteral&&!(Ce(r)||!t(r)))for(let s of r.typeAnnotation.members)s.type===V.AST_NODE_TYPES.TSPropertySignature&&n(s)},TSInterfaceDeclaration(r){if(!(Ce(r)||!t(r)))for(let s of r.body.body)s.type===V.AST_NODE_TYPES.TSPropertySignature&&n(s)},TSTypeReference(r){if(r.typeName.type!==V.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let s=r.typeArguments.params[0];if(s.type!==V.AST_NODE_TYPES.TSTypeLiteral)return;let a=pe(r.parent,V.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let o=xe(a,e.sourceCode);if(!(!o||o.parent.type===V.AST_NODE_TYPES.CallExpression&&o.parent.callee.type===V.AST_NODE_TYPES.Identifier&&o.parent.callee.name==="memo"))for(let l of s.members)l.type===V.AST_NODE_TYPES.TSPropertySignature&&n(l)}}}});function Ce(e){return e?e.parent?.type===V.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===V.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function xe(e,t){if(Ce(e))return;let n;if(e.type===V.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===V.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===V.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let s=r.variables.find(o=>o.identifiers.includes(n));if(!s)return;let a=s.references.filter(o=>o.identifier!==n);if(!(a.length!==1||!a[0])&&!Ce(a[0].identifier.parent.parent))return a[0].identifier}var Xe={name:Vt,rule:Rr};import{ESLintUtils as vr}from"@typescript-eslint/utils";import Ke from"node:path";var kr=vr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="no-relative-imports",Or=j({find:A(),replacement:A()}),Ar=j({aliases:Y(Or),rootDir:N(A()),allowNotFoundAliases:N(ae()),_dev_simulateFileName:N(A())}),Pr=kr({name:Wt,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[Ar]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(o){return o.startsWith(".")||o.startsWith("..")}function s(o,i){let l=Ke.dirname(i);return Ke.resolve(l,o)}function a(o){let i=t.rootDir??process.cwd(),l=Ke.relative(i,o);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let f=l.replace(p,c);return{alias:c,newPath:f}}return null}return{ImportDeclaration(o){let i=o.source.value;if(!r(i))return;let l=s(i,n),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:o,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(o.source,`'${c.newPath}'`):void 0})}}}}),Je={name:Wt,rule:Pr};import{AST_NODE_TYPES as me,ESLintUtils as Yt}from"@typescript-eslint/utils";import*as Ge from"typescript";var Fr=Yt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="no-unnecessary-casting",Nr=j({additionalCastFunctions:N(Y(j({name:A(),expectedType:Te(["string","number"])})))}),Ze={name:Ht,rule:Fr({name:Ht,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:[Nr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],s=Yt.getParserServices(e,!0),a=s.program?.getTypeChecker();if(!a||!s.program)throw new Error("TypeScript services or program not available");function o(p,f){switch(p.type){case me.Literal:return f==="number"?typeof p.value=="number":typeof p.value=="string";case me.TemplateLiteral:return f==="string";case me.UnaryExpression:return f==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,f){return f==="number"?!!(p.flags&Ge.TypeFlags.NumberLike):!!(p.flags&Ge.TypeFlags.StringLike)}function l(p,f){return h=>h.replaceText(p,e.sourceCode.getText(f))}function c(p){if(!a||p.arguments.length!==1)return;let f=p.arguments[0];if(!f||f.type===me.SpreadElement)return;let{callee:h}=p;if(h.type!==me.Identifier)return;let m=h.name,y=r.find(E=>E.name===m);if(!y)return;if(o(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:p,messageId:E,...g?{data:g}:{},fix:l(p,f)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as K}from"@typescript-eslint/utils";var Qe=se({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(t){if(t.id.type===K.ObjectPattern||!t.init||t.init.type!==K.ObjectExpression||t.id.type===K.Identifier&&t.id.typeAnnotation||t.parent.parent.type===K.ExportNamedDeclaration)return;let n=new Map;for(let o of t.init.properties)o.type===K.Property&&o.key.type===K.Identifier&&n.set(o.key.name,o);if(n.size===0||t.id.type!==K.Identifier)return;let r=jr(t,e.sourceCode);if(r.length===0)return;let s=t.init.properties.some(o=>o.type!==K.Property?!1:o.value.type===K.FunctionExpression),a=new Set;for(let o of r){if(o.identifier.parent.type!==K.MemberExpression)return;let i=o.identifier.parent;if(i.object!==o.identifier)return;if(i.computed)if(i.property.type===K.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==K.Identifier)return;a.add(i.property.name)}if(i.parent.type===K.CallExpression&&s)return}for(let[o,i]of n)a.has(o)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:o}})}}}});function jr(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 H,ESLintUtils as Dr}from"@typescript-eslint/utils";var Lr=j({selectors:Y(j({name:A(),selectorProp:N(A()),selectorArgPos:N(Z()),returnProp:N(A())}))}),_r=Dr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="no-unused-selected-values",et={name:zt,rule:_r({name:zt,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Lr]},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===H.CallExpression&&(a=s.init),!a)return;let o=$r(a);if(!o)return;let i=r.get(o);if(!i)return;let l=Mr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=Ur(l);if(!c)return;let p=Bt(c.properties,void 0);if(!p)return;if(s.id.type===H.ObjectPattern){let m=Bt(s.id.properties,i.returnProp);if(!m)return;for(let[y,T]of p)m.has(y)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:y}});return}if(s.id.type!==H.Identifier||i.returnProp)return;let f=Vr(s,e.sourceCode);if(f.length===0)return;let h=new Set;for(let m of f){if(m.identifier.parent.type!==H.MemberExpression)return;let y=m.identifier.parent.property;if(y.type!==H.Identifier)return;h.add(y.name)}for(let[m,y]of p)h.has(m)||e.report({node:y,messageId:"unusedSelectedValue",data:{name:m}})}}}})};function Mr(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===H.ArrowFunctionExpression||r.type===H.FunctionExpression)return r;if(n&&r.type===H.ObjectExpression){let s=r.properties.find(o=>o.type===H.Property&&o.key.type===H.Identifier&&o.key.name===n);if(s?.type!==H.Property)return null;let a=s.value;if(a.type===H.ArrowFunctionExpression||a.type===H.FunctionExpression)return a}return null}function $r(e){return e.callee.type===H.Identifier?e.callee.name:e.callee.type===H.MemberExpression&&e.callee.property.type===H.Identifier?e.callee.property.name:null}function Ur(e){if(e.body.type===H.ObjectExpression)return e.body;if(e.body.type===H.BlockStatement){let t=e.body.body.filter(n=>n.type===H.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.ObjectExpression?null:t[0].argument}return null}function Bt(e,t){let n=e;if(t){let s=e.find(a=>a.type===H.Property&&a.key.type===H.Identifier&&a.key.name===t);if(s?.type!==H.Property||s.value.type!==H.ObjectPattern)return null;n=s.value.properties}let r=new Map;for(let s of n){if(s.type!==H.Property||s.key.type!==H.Identifier)return null;r.set(s.key.name,s)}return r.size>0?r:null}function Vr(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 W}from"@typescript-eslint/utils";var tt=se({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.ImportDeclaration&&a.source.value==="t-state-form"))return{};let r=null,s=!1;return{CallExpression(a){if(s)return;if(!r){let i=Wr(a);i&&(r=i);return}let o=Hr(a,e.sourceCode);if(o){s=!0;for(let i of o)r.delete(i);if(r.size!==0)for(let[i,l]of r)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function Wr(e){if(!(e.callee.type===W.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==W.ObjectExpression)return null;let r=qe(n.properties,a=>a.type!==W.Property||a.key.type!==W.Identifier||a.key.name!=="initialConfig"?null:a.value.type===W.ObjectExpression?a.value:a.value.type===W.ArrowFunctionExpression||a.value.type===W.FunctionExpression?Yr(a.value):null);if(!r)return null;let s=new Map;for(let a of r.properties)a.type===W.Property&&a.key.type===W.Identifier&&s.set(a.key.name,a);return s}function Hr(e,t){if(!(e.callee.type===W.Identifier&&e.callee.name==="useFormState")||e.parent.type!==W.VariableDeclarator||e.parent.id.type!==W.ObjectPattern||!qe(e.parent.id.properties,o=>o.type===W.Property&&o.key.type===W.Identifier&&o.key.name==="formFields"&&o))return null;let s=Ut(e.parent,"formFields",t),a=new Set;for(let{identifier:o}of s){if(o.type!==W.Identifier||o.parent.type===W.Property&&o.parent.parent.type===W.ObjectExpression&&o.parent.parent.parent.type===W.ReturnStatement||o.parent.type===W.ReturnStatement)return null;if(o.parent.type===W.MemberExpression){if(o.parent.object.type!==W.Identifier||o.parent.property.type!==W.Identifier)return null;a.add(o.parent.property.name)}}return a}function Yr(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}import{AST_NODE_TYPES as $,ESLintUtils as zr}from"@typescript-eslint/utils";var Br=zr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function qt(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 Xt(e,...t){for(let n of t)e.set(...n);return e}var qr=j({forceCheckOnFCPropTypesWithName:N(Y(A()))}),Kt="no-unused-type-props-in-args",nt=null,Xr=Br({name:Kt,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[qr],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!nt&&(nt=n.map(i=>new RegExp(i)));function r(i,l,c,p,f=!0){let h=c.name,m=e.sourceCode.getScope(l).references.find(E=>E.identifier.name===h)?.resolved,y=i&&nt?.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,l,p,T.typeAnnotation,!0);return}if(T?.type===$.TSInterfaceDeclaration){s(i,l,p,T.body,!0);return}}}function s(i,l,c,p,f){if(p.type===$.TSInterfaceBody){for(let h of p.body)h.type===$.TSPropertySignature&&h.key.type===$.Identifier&&c.set(h.key.name,h);return}if(p.type===$.TSTypeLiteral){Xt(c,...qt(p));return}if(p.type===$.TSIntersectionType){for(let h of p.types)s(i,l,c,h,!0);return}f||p.type===$.TSTypeReference&&p.typeName.type===$.Identifier&&r(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let f=new Map;if(s(i,l,f,p.typeAnnotation.typeAnnotation,!1),f.size===0)continue;o(p,f)}else p.type===$.AssignmentPattern&&p.left.type===$.ObjectPattern&&a(i,l,[p.left])}function o(i,l){let c=[];if(i.properties.at(-1)?.type===$.RestElement)return;for(let m of i.properties)m.type===$.Property&&m.key.type===$.Identifier&&c.push(m.key.name);let f=[],h=[];for(let[m,y]of l)c.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 l=i.declarations[0];if(!l)return;let c=new Map,p=l.id.type===$.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===$.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===$.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(p){if(p.type===$.TSTypeReference&&p.typeName.type===$.Identifier)r(!0,i,p.typeName,c,!1);else if(p.type===$.TSTypeLiteral)Xt(c,...qt(p));else if(p.type===$.TSIntersectionType)for(let f of p.types)f.type===$.TSTypeReference&&f.typeName.type===$.Identifier?r(!0,i,f.typeName,c,!1):s(!0,i,c,f,!0);if(c.size!==0&&l.init?.type===$.ArrowFunctionExpression){let f=l.init.params[0];if(!f){e.report({node:l.init,messageId:"missingComponentParam"});return}f.type===$.ObjectPattern&&o(f,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),rt={name:Kt,rule:Xr};import{AST_NODE_TYPES as it,ESLintUtils as Kr}from"@typescript-eslint/utils";var Jr=Kr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="prefer-named-functions",Jt=new Map,Gr=Jr({name:Gt,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=Jt.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),Jt.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===it.ArrowFunctionExpression&&r.id.type===it.Identifier){let s=r.id.name;if(r.id.typeAnnotation||n&&n.test(s)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==it.BlockStatement)return;let a=r.parent,o=r.init.params,i=r.init.body,l=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:c=>c.replaceText(a,`${l.async?"async ":""}function ${s}(${o.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),st={name:Gt,rule:Gr};import{AST_NODE_TYPES as U}from"@typescript-eslint/utils";var Zr=j({disallowedFunctions:Y(j({name:A(),hookAlternative:A()}))});function ot(e){return/^use[A-Z]/.test(e)}function Qr(e){return/^[A-Z]/.test(e)}function ei(e){return e.type===U.Identifier?ot(e.name):e.type===U.MemberExpression&&e.property.type===U.Identifier?ot(e.property.name):!1}function Zt(e,t){return e.type===U.Identifier?e.name===t:e.type===U.MemberExpression&&e.object.type===U.Identifier&&e.property.type===U.Identifier?e.object.name==="React"&&e.property.name===t:!1}function ti(e){return!!(e.parent&&e.parent.type===U.CallExpression&&Zt(e.parent.callee,"forwardRef"))}function ni(e){return!!(e.parent&&e.parent.type===U.CallExpression&&Zt(e.parent.callee,"memo"))}function ri(e){if(e.type===U.FunctionDeclaration||e.type===U.FunctionExpression&&e.id)return e.id||void 0;if(e.type===U.FunctionExpression||e.type===U.ArrowFunctionExpression){if(e.parent.type===U.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===U.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===U.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===U.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function ii(e){let t=e.parent,n=!1;for(;t;){if(t.type===U.FunctionDeclaration||t.type===U.FunctionExpression||t.type===U.ArrowFunctionExpression){let r=ri(t);if(r&&r.type===U.Identifier){if(Qr(r.name)||ot(r.name))return!n;n=!0}else{if(ti(t)||ni(t))return!n;if(t.parent.type===U.CallExpression){let s=t.parent;ei(s.callee)||(n=!0)}else t.parent.type===U.JSXExpressionContainer||(n=!0)}}t=t.parent}return!1}function si(e){return e.callee.type===U.Identifier?e.callee.name:e.callee.type===U.MemberExpression&&e.callee.property.type===U.Identifier?e.callee.property.name:null}var at=se({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react use the hook {{hookAlternative}} instead."},schema:[Zr],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:n}=t,r=new Map(n.map(s=>[s.name,s]));return{CallExpression(s){if(!ii(s))return;let a=si(s);if(!a)return;let o=r.get(a);o&&e.report({node:s,messageId:"preferHookAlternative",data:{hookAlternative:o.hookAlternative},suggest:[{messageId:"preferHookAlternative",data:{message:`Replace with ${o.hookAlternative}`,hookAlternative:o.hookAlternative},fix:i=>s.callee.type===U.Identifier?i.replaceText(s.callee,o.hookAlternative):s.callee.type===U.MemberExpression&&s.callee.property.type===U.Identifier?i.replaceText(s.callee.property,o.hookAlternative):null}]})}}}});import{AST_NODE_TYPES as z,AST_TOKEN_TYPES as Qt,ESLintUtils as oi}from"@typescript-eslint/utils";var ai=oi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="prefer-single-line-if",li=j({maxLineLength:N(Z()),maxNonSimpleConditionLength:N(Z())}),ci=ai({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:[li]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==z.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===z.ReturnStatement){if(!rn(a))return}else if(!(a.type===z.ContinueStatement||a.type===z.BreakStatement))return;if(r.test.type===z.LogicalExpression||r.test.type===z.ConditionalExpression)return;let o;if(t.maxNonSimpleConditionLength){let f=en(r.test);if(!f&&r.test.type===z.UnaryExpression&&r.test.operator==="!"){let h=r.test.argument;en(h)&&(f=!0)}if(f&&(o=n.getText(r.test),o.length>t.maxNonSimpleConditionLength))return}o||(o=n.getText(r.test));let i=n.getText(a);if(o.includes(`
|
|
15
|
+
`))return;let l=n.getTokenAfter(r);if(l&&l.type===Qt.Punctuator&&l.value==="}"){let f=n.getTokenAfter(l);if(f&&f.type===Qt.Keyword&&(f.value==="else"||f.value==="catch"))return}let c=pi(n,r),p=`if (${o}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:f=>f.replaceText(r,p)})}}}});function en(e){return e.type===z.CallExpression||e.type===z.BinaryExpression||e.type===z.MemberExpression&&nn(e)}function nn(e){return e.object.type===z.MemberExpression?nn(e.object):e.object.type!==z.Identifier}function pi(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===z.ArrayExpression&&t.elements.length===0||t.type===z.ObjectExpression&&t.properties.length===0||t.type===z.Literal||t.type===z.Identifier||t.type===z.TemplateLiteral||t.type===z.TaggedTemplateExpression?!0:t.type===z.CallExpression?t.arguments.length===0:t.type===z.UnaryExpression?rn(t):!1}var lt={name:tn,rule:ci};import{AST_NODE_TYPES as ee,ESLintUtils as ui}from"@typescript-eslint/utils";var fi=ui.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="react-compiler-migration",mi=j({disallowHooks:N(Y(j({name:A(),replacement:A()}))),disallowMethods:N(Y(j({name:A(),replacement:N(A()),requireTrueProp:N(A())})))}),di=/eslint +react-compiler\/react-compiler: +\["error/;function yi(e){return e.type===ee.Identifier?e.name.startsWith("use"):e.type===ee.MemberExpression&&e.property.type===ee.Identifier?e.property.name.startsWith("use"):!1}var gi=fi({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:[mi]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(di.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let s=null,a=null;if(r.callee.type===ee.Identifier?(s=r.callee.name,a=r.callee):r.callee.type===ee.MemberExpression&&r.callee.property.type===ee.Identifier&&(s=r.callee.property.name,a=r.callee.property),s){let o=t.disallowHooks.find(i=>i.name===s);o&&a&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:o.name,replacement:o.replacement},suggest:[{messageId:"replace",data:{replacement:o.replacement},fix:i=>i.replaceText(a,o.replacement)}]})}}if(t.disallowMethods?.length&&yi(r.callee)){for(let s of r.arguments)if(s.type===ee.ObjectExpression){for(let a of s.properties)if(a.type===ee.Property&&a.key.type===ee.Identifier){let o=a.key.name,i=t.disallowMethods.find(l=>l.name===o);if(i){if(i.requireTrueProp){let l=i.requireTrueProp,c=!1;for(let p of s.properties)if(p.type===ee.Property&&p.key.type===ee.Identifier&&p.key.name===l&&p.value.type===ee.Literal&&p.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:l}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),ct={name:sn,rule:gi};import{ESLintUtils as Si,TSESTree as Ti}from"@typescript-eslint/utils";var hi=Si.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="require-description",Ei=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,bi=/^eslint-disable-(next-)?line$/u,xi=hi({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=Ci(s);a!=null&&(r.has(a.kind)||a.description||e.report({loc:wi(s.loc),messageId:"missingDescription"}))}}}}}),an={name:on,rule:xi};function Ci(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 a=bi.test(s);if(e.type===Ti.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let o=t.slice(r.index+s.length);return{kind:s,value:o.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 wi(e){return{start:{line:e.start.line,column:-1},end:e.end}}function pn(e){return/^use[A-Z0-9]/.test(e)}function Ie(e){return e.type==="Identifier"?pn(e.name):e.type==="MemberExpression"&&!e.computed&&Ie(e.property)?e.object.type==="Identifier":!1}function un(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 pt(e){for(;e;){let t=gn(e);if(t&&(un(t)||Ie(t))||mn(e)||dn(e))return!0;e=e.parent}return!1}function ln(e){return!1}function ut(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 l of e.sourceCode.getAllComments())if(Ri.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),n=typeof e.getScope=="function"?()=>n():l=>e.sourceCode.getScope(l),r=null,s=[],a=[],o=new WeakSet;function i(l){for(let c of l.references){let p=c.identifier.parent;if(p.type==="VariableDeclarator"&&p.init&&p.init.type==="CallExpression"&&p.init.callee&&ln(p.init.callee))for(let f of c.resolved.references)f!==c&&o.add(f.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(l,c){let p=s.pop();if(p.size===0)return;let f=new Set;function h(S,v){let{cache:P}=h,D=P.get(S.id),L=new Set(v);if(L.has(S.id)){let R=[...L],_=R.slice(R.indexOf(S.id)+1);for(let B of _)f.add(B);return BigInt("0")}if(L.add(S.id),D!==void 0)return D;if(l.thrownSegments.includes(S))D=BigInt("0");else if(S.prevSegments.length===0)D=BigInt("1");else{D=BigInt("0");for(let R of S.prevSegments)D+=h(R,L)}return S.reachable&&D===BigInt("0")?P.delete(S.id):P.set(S.id,D),D}function m(S,v){let{cache:P}=m,D=P.get(S.id),L=new Set(v);if(L.has(S.id)){let R=Array.from(L),_=R.slice(R.indexOf(S.id)+1);for(let B of _)f.add(B);return BigInt("0")}if(L.add(S.id),D!==void 0)return D;if(l.thrownSegments.includes(S))D=BigInt("0");else if(S.nextSegments.length===0)D=BigInt("1");else{D=BigInt("0");for(let R of S.nextSegments)D+=m(R,L)}return P.set(S.id,D),D}function y(S){let{cache:v}=y,P=v.get(S.id);if(P===null)return 1/0;if(P!==void 0)return P;if(v.set(S.id,null),S.prevSegments.length===0)P=1;else{P=1/0;for(let D of S.prevSegments){let L=y(D);L<P&&(P=L)}P+=1}return v.set(S.id,P),P}h.cache=new Map,m.cache=new Map,y.cache=new Map;let T=m(l.initialSegment),E=gn(c),g=pt(c),k=E?un(E)||Ie(E):mn(c)||dn(c),C=1/0;for(let S of l.finalSegments){if(!S.reachable)continue;let v=y(S);v<C&&(C=v)}for(let[S,v]of p){if(!S.reachable)continue;let P=S.nextSegments.length===0?C<=y(S):C<y(S),D=h(S)*m(S),L=f.has(S.id);for(let R of v)if(L&&!ut(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.`}),k){if(c.async&&e.report({node:R,message:`React Hook "${t(R)}" cannot be called in an async function.`}),!L&&D!==T&&!ut(R)){let B=`React Hook "${t(R)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(P?" Did you accidentally call a React Hook after an early return?":"");e.report({node:R,message:B})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let _=`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:_})}else if(E){let _=`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:_})}else if(c.type==="Program"){let _=`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:_})}else if(g&&!ut(R)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let B=c.parent;if(B.parent.type==="VariableDeclarator"&&pn(B.parent.id.name))return}let _=`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:_})}}},CallExpression(l){if(Ie(l.callee)){let c=cn(s),p=cn(a),f=c.get(p);f||(f=[],c.set(p,f)),f.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||ln(l.callee))&&l.arguments.length>0&&(r=l)},Identifier(l){r==null&&o.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` 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"(l){l===r&&(r=null)},FunctionDeclaration(l){pt(l)&&i(n(l))},ArrowFunctionExpression(l){pt(l)&&i(n(l))}}}};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={[rt.name]:rt.rule,[We.name]:We.rule,[Ve.name]:Ve.rule,"rules-of-hooks":yn,"exhaustive-deps":wt,"require-description":an.rule,[He.name]:He.rule,[ze.name]:ze.rule,[st.name]:st.rule,[Ne.name]:Ne.rule,[Ue.name]:Ue.rule,[Je.name]:Je.rule,[lt.name]:lt.rule,[Xe.name]:Xe.rule,[Ye.name]:Ye.rule,[De.name]:De.rule,[ct.name]:ct.rule,[Pe.name]:Pe.rule,[$e.name]:$e.rule,[Ze.name]:Ze.rule,[et.name]:et.rule,[tt.name]:tt.rule,[Qe.name]:Qe.rule,[at.name]:at.rule};var Po={rules:Sn};export{Po as extendedLintPlugin};
|