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