@ls-stack/extended-lint 0.53.3 → 0.54.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 +6 -6
- package/dist/extended-lint.mjs +6 -6
- package/package.json +1 -1
package/dist/extended-lint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var er=Object.create;var We=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var rr=Object.getPrototypeOf,ir=Object.prototype.hasOwnProperty;var sr=(e,t)=>{for(var r in t)We(e,r,{get:t[r],enumerable:!0})},Ht=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of nr(t))!ir.call(e,s)&&s!==r&&We(e,s,{get:()=>t[s],enumerable:!(n=tr(t,s))||n.enumerable});return e};var ve=(e,t,r)=>(r=e!=null?er(rr(e)):{},Ht(t||!e||!e.__esModule?We(r,"default",{value:e,enumerable:!0}):r,e)),or=e=>Ht(We({},"__esModule",{value:!0}),e);var Zi={};sr(Zi,{extendedLintPlugin:()=>Ki});module.exports=or(Zi);var X=require("@typescript-eslint/utils");var Qe=Symbol.for("optional");function _(e){return{...e,[Qe]:!0}}function zt(e,t){return{enum:e,...t}}function ke(e){return{...e,type:"boolean"}}function V(e){return{...e,type:"string"}}function fe(e){return{...e,type:"number"}}function K(e,t){return{...t,type:"array",items:e}}function H(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let n,s=[];for(n in e)e[n][Qe]?e[n][Qe]=void 0:s.push(n);s.length>0&&(r.required=s)}return r}var ar=X.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="react-compiler-extra",lr=H({runOnlyWithEnableCompilerDirective:_(ke())}),pr=/eslint +react-compiler\/react-compiler: +\["error/;function cr(e){return e.type===X.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===X.AST_NODE_TYPES.MemberExpression&&e.property.type===X.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var ur=/\bthis[.[]/;function Yt(e){return ur.test(e)}var fr=ar({name:Jt,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:[lr]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(pr.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let o of a.properties)if(o.type===X.AST_NODE_TYPES.Property&&o.method&&o.value.type===X.AST_NODE_TYPES.FunctionExpression){let i=e.sourceCode,l=i.getText(o.key),p=o.value,c=i.getText(p.body);if(Yt(c))e.report({node:o,messageId:"thisKeywordInMethod"});else{let u=p.params.map(y=>i.getText(y)).join(", "),S="";p.generator?S=`${l}: function* (${u}) ${c}`:S=`${l}: (${u}) => ${c}`,e.report({node:o,messageId:"objectMethodIsNotSupported",fix:y=>y.replaceText(o,S)})}}}function s(a){for(let o of a.properties)if(o.type===X.AST_NODE_TYPES.Property&&o.value.type===X.AST_NODE_TYPES.ObjectExpression){for(let i of o.value.properties)if(i.type===X.AST_NODE_TYPES.Property&&i.method&&i.value.type===X.AST_NODE_TYPES.FunctionExpression){let p=e.sourceCode.getText(i.value.body);Yt(p)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(cr(a.callee))for(let o of a.arguments){if(o.type===X.AST_NODE_TYPES.ObjectExpression&&(n(o),s(o)),o.type===X.AST_NODE_TYPES.ArrowFunctionExpression&&(o.body.type===X.AST_NODE_TYPES.ObjectExpression&&(n(o.body),s(o.body)),o.body.type===X.AST_NODE_TYPES.BlockStatement))for(let i of o.body.body)i.type===X.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===X.AST_NODE_TYPES.ObjectExpression&&(n(i.argument),s(i.argument));if(o.type===X.AST_NODE_TYPES.FunctionExpression)for(let i of o.body.body)i.type===X.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===X.AST_NODE_TYPES.ObjectExpression&&(n(i.argument),s(i.argument))}}}}}),et={name:Jt,rule:fr};var Q=require("@typescript-eslint/utils"),h=require("zod/v4");var Bt=require("@typescript-eslint/utils"),qt=ve(require("zod/v4"));function G(e){let r=Bt.ESLintUtils.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function Oe(e){return qt.toJSONSchema(e)}var mr=h.z.object({disallow:h.z.array(h.z.object({selector:h.z.string(),message:h.z.string(),replace:h.z.optional(h.z.union([h.z.string(),h.z.object({regex:h.z.string(),with:h.z.string()})])),replaceType:h.z.optional(h.z.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:h.z.optional(h.z.array(h.z.object({fn:h.z.string(),withArgs:h.z.optional(h.z.array(h.z.object({atIndex:h.z.number(),value:h.z.union([h.z.string(),h.z.number(),h.z.boolean()])}))),message:h.z.string(),replaceWith:h.z.optional(h.z.string()),ignoreRegex:h.z.optional(h.z.string())}))),__dev_simulateFileName:h.z.optional(h.z.string()),mustMatchSyntax:h.z.optional(h.z.array(h.z.object({includeRegex:h.z.string(),mustCallFn:h.z.optional(h.z.array(h.z.object({anyCall:h.z.array(h.z.object({fn:h.z.string(),withArgs:h.z.array(h.z.object({atIndex:h.z.number(),literal:h.z.union([h.z.string(),h.z.number(),h.z.boolean()])}))})),message:h.z.optional(h.z.string())}))),mustMatchSelector:h.z.optional(h.z.array(h.z.object({selector:h.z.string(),message:h.z.string()}))),mustHaveExport:h.z.optional(h.z.array(h.z.object({name:h.z.string(),type:h.z.enum(["function","variable","any"]).default("any"),message:h.z.string()})))})))}),tt=G({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Oe(mr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:s,disallow:a,disallowFnCalls:o}=t,i=s??e.filename,l=[],p=new Map,c=new Set,u=new Map,S=new Set,y=new Map;function E(m){for(let g of m.specifiers)g.type===Q.AST_NODE_TYPES.ImportSpecifier&&g.imported.type===Q.AST_NODE_TYPES.Identifier&&g.imported.name!==g.local.name&&y.set(g.local.name,g.imported.name)}function x(m){if(m.declaration){if(m.declaration.type===Q.AST_NODE_TYPES.FunctionDeclaration&&m.declaration.id){let g=m.declaration.id.name;for(let R of Array.from(S)){let[w,b]=R.split(":");w===g&&(b==="function"||b==="any")&&S.delete(R)}}else if(m.declaration.type===Q.AST_NODE_TYPES.VariableDeclaration){for(let g of m.declaration.declarations)if(g.id.type===Q.AST_NODE_TYPES.Identifier){let R=g.id.name;for(let w of Array.from(S)){let[b,F]=w.split(":");b===R&&(F==="variable"||F==="any")&&S.delete(w)}}}}for(let g of m.specifiers)if(g.exported.type===Q.AST_NODE_TYPES.Identifier){let R=g.exported.name;for(let w of Array.from(S)){let[b,F]=w.split(":");b===R&&F==="any"&&S.delete(w)}}}function v(m){m.id.type===Q.AST_NODE_TYPES.Identifier&&m.init?.type===Q.AST_NODE_TYPES.Identifier&&y.set(m.id.name,m.init.name)}function C(m){return y.get(m)??m}function M(m,g){return C(m)===g||m===g}for(let{includeRegex:m,mustCallFn:g,mustMatchSelector:R,mustHaveExport:w}of n??[]){let b=dr(i,new RegExp(m));if(!b)continue;let F=Y=>{let q=Y;for(let{name:ne,value:ee}of b)q=q.replaceAll(ne,ee);return q};for(let{anyCall:Y,message:q}of g??[]){let ne=`Expected file to call the function: ${Y.map(({fn:ee})=>ee).join(" or ")}`;c.add(ne),l.push(ee=>{let{callee:Re}=ee;if(Re.type===Q.AST_NODE_TYPES.Identifier){for(let{fn:ie,withArgs:De}of Y)if(Re.name===ie){c.delete(ne);for(let me of De){let ue=ee.arguments[me.atIndex],de=typeof me.literal=="string"?F(me.literal):me.literal;if(!ue){e.report({node:ee,messageId:"default",data:{message:`Missing argument with value "${de}" at index ${me.atIndex}${q?`: ${F(q)}`:""}`}});continue}if(ue.type!==Q.AST_NODE_TYPES.Literal){e.report({node:ue,messageId:"default",data:{message:`Argument at position ${me.atIndex} should the literal "${de}"${q?`: ${F(q)}`:""}`}});continue}ue.value!==de&&e.report({node:ue,messageId:"default",data:{message:`Argument should have the value "${de}"${q?`: ${F(q)}`:""}`},fix:Ae=>Ae.replaceText(ue,typeof de=="string"?`'${de}'`:String(de))})}break}}})}for(let{selector:Y,message:q}of R??[])u.set(Y,F(q)),p.set(F(Y),()=>{u.delete(Y)});for(let{name:Y,type:q,message:ne}of w??[]){let ee=F(Y),Re=F(ne);S.add(`${ee}:${q}:${Re}`)}}for(let{fn:m,withArgs:g,message:R,replaceWith:w,ignoreRegex:b}of o??[])b&&new RegExp(b).test(i)||l.push(F=>{let{callee:Y}=F;if(Y.type!==Q.AST_NODE_TYPES.Identifier||!M(Y.name,m))return;if(g)for(let ne of g){let ee=F.arguments[ne.atIndex];if(!ee){e.report({node:F,messageId:"default",data:{message:`Missing argument with value "${ne.value}" at index ${ne.atIndex}: ${R}`}});return}if(ee.type!==Q.AST_NODE_TYPES.Literal||ee.value!==ne.value)return}let q=ne=>w?ne.replaceText(F,w):null;e.report({node:F,messageId:"default",data:{message:R},suggest:w?[{messageId:"default",data:{message:`Replace with "${w}"`},fix:q}]:void 0})});function P(m,g){let R=r[m];R?r[m]=w=>{R(w),g(w)}:r[m]=g}for(let{selector:m,message:g,replace:R,replaceType:w="suggestion"}of a??[]){if(m==="CallExpression"){l.push(b=>{T(R,b,g,w)});continue}r[m]=b=>{T(R,b,g,w)}}if(p.size>0)for(let[m,g]of p)P(m,g);return l.length>0&&(r.CallExpression=m=>{if(m.type===Q.AST_NODE_TYPES.CallExpression)for(let g of l)g(m)}),r.ImportDeclaration=m=>{m.type===Q.AST_NODE_TYPES.ImportDeclaration&&E(m)},r.ExportNamedDeclaration=m=>{m.type===Q.AST_NODE_TYPES.ExportNamedDeclaration&&x(m)},r.VariableDeclarator=m=>{m.type===Q.AST_NODE_TYPES.VariableDeclarator&&v(m)},r["Program:exit"]=m=>{for(let g of c)e.report({node:m,messageId:"default",data:{message:g}});for(let[,g]of u)e.report({node:m,messageId:"default",data:{message:g}});for(let g of S){let[R,w,b]=g.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${R}" of type ${w}: ${b}`}})}},r;function T(m,g,R,w){let b=F=>{if(!m)return null;if(typeof m=="string")return F.replaceText(g,m);{let Y=new RegExp(m.regex),q=e.sourceCode.getText(g);return F.replaceText(g,q.replace(Y,m.with))}};e.report({node:g,messageId:"default",data:{message:R},fix:m&&w==="autofix"?b:void 0,suggest:m&&w==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:b}]:void 0})}}});function dr(e,t){let r=[],n=t.exec(e);if(!n)return null;let[s,...a]=n;r.push({name:"$0_lowercase",value:s.toLowerCase()}),r.push({name:"$0_capitalize",value:Xt(s)}),r.push({name:"$0_uncapitalize",value:Gt(s)}),r.push({name:"$0",value:s});for(let o=0;o<a.length;o++){let i=`$${o+1}`,l=a[o];r.push({name:`${i}_lowercase`,value:l.toLowerCase()}),r.push({name:`${i}_capitalize`,value:Xt(l)}),r.push({name:`${i}_uncapitalize`,value:Gt(l)}),r.push({name:i,value:l})}return r}function Xt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Gt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var L=require("@typescript-eslint/utils");var yr=L.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="collapse-simple-objs-in-one-line",gr=H({maxLineLength:_(fe()),maxProperties:_(fe()),nestedObjMaxLineLength:_(fe()),nestedObjMaxProperties:_(fe()),ignoreTypesWithSuffix:_(K(V()))}),Sr=yr({name:Zt,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:[gr]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,o=t.nestedObjMaxProperties??3;function i(p){if(p.type===L.AST_NODE_TYPES.ObjectExpression){let c=p.parent.type===L.AST_NODE_TYPES.Property,u=c?o:s,S=p.properties.length;if(S>u)return!1;if(S===1){let E=p.properties[0];return E.type===L.AST_NODE_TYPES.Property&&E.value.type===L.AST_NODE_TYPES.ObjectExpression||E.type===L.AST_NODE_TYPES.Property&&E.value.type===L.AST_NODE_TYPES.ArrayExpression&&!E.value.elements.every(v=>v&&nt(v))?!1:{text:r.getText(E),isNested:c,propsSize:S}}let y=[];for(let E of p.properties){if(E.type===L.AST_NODE_TYPES.Property&&!nt(E.value))return!1;y.push(r.getText(E))}return{text:y.join(", "),isNested:c,propsSize:S}}else{let c=p.parent.parent?.type===L.AST_NODE_TYPES.TSPropertySignature,u=c?o:s,S=p.members.length;if(S>u)return!1;if(n.length>0&&p.parent.type===L.AST_NODE_TYPES.TSTypeAliasDeclaration){let E=p.parent.id.name;if(n.some(x=>E.endsWith(x)))return!1}if(S===1){let E=p.members[0];return E.type===L.AST_NODE_TYPES.TSPropertySignature&&E.typeAnnotation?.typeAnnotation.type===L.AST_NODE_TYPES.TSTypeLiteral?!1:{text:r.getText(E),isNested:c,propsSize:1}}if(p.parent.type===L.AST_NODE_TYPES.TSIntersectionType||p.parent.type===L.AST_NODE_TYPES.TSUnionType&&p.parent.types[0]!==p)return!1;let y=[];for(let E of p.members){if(E.type!==L.AST_NODE_TYPES.TSPropertySignature)return!1;let x=E.typeAnnotation?.typeAnnotation;if(!x||x.type===L.AST_NODE_TYPES.TSTypeLiteral||!Kt(x))return!1;if(x.type===L.AST_NODE_TYPES.TSTypeReference&&x.typeArguments){if(x.typeArguments.params.length>1)return!1;let C=x.typeArguments.params[0];if(!Kt(C))return!1}let v=r.getText(E).trim();(v.endsWith(";")||v.endsWith(","))&&(v=v.slice(0,-1)),y.push(v)}return{text:y.join("; "),isNested:c,propsSize:S}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==L.AST_NODE_TYPES.JSXExpressionContainer){let x=0,v=!1,C=r.getTokenAfter(p,{filter:P=>P.type!==L.AST_TOKEN_TYPES.Punctuator||v?!0:P.value===","?(x++,!1):P.value===";"?(x++,v=!0,!1):P.value===")"||P.value==="}"?(x++,!1):!0});if(x>4)return;let M=C?.type===L.AST_TOKEN_TYPES.Template&&C.value.startsWith(`}
|
|
2
|
-
`);if(
|
|
3
|
-
`)||
|
|
4
|
-
`,
|
|
1
|
+
"use strict";var Qr=Object.create;var We=Object.defineProperty;var en=Object.getOwnPropertyDescriptor;var tn=Object.getOwnPropertyNames;var rn=Object.getPrototypeOf,nn=Object.prototype.hasOwnProperty;var sn=(e,t)=>{for(var n in t)We(e,n,{get:t[n],enumerable:!0})},zt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of tn(t))!nn.call(e,o)&&o!==n&&We(e,o,{get:()=>t[o],enumerable:!(r=en(t,o))||r.enumerable});return e};var ve=(e,t,n)=>(n=e!=null?Qr(rn(e)):{},zt(t||!e||!e.__esModule?We(n,"default",{value:e,enumerable:!0}):n,e)),on=e=>zt(We({},"__esModule",{value:!0}),e);var Zi={};sn(Zi,{extendedLintPlugin:()=>Ki});module.exports=on(Zi);var G=require("@typescript-eslint/utils");var Qe=Symbol.for("optional");function $(e){return{...e,[Qe]:!0}}function Ht(e,t){return{enum:e,...t}}function ke(e){return{...e,type:"boolean"}}function z(e){return{...e,type:"string"}}function fe(e){return{...e,type:"number"}}function Z(e,t){return{...t,type:"array",items:e}}function H(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,o=[];for(r in e)e[r][Qe]?e[r][Qe]=void 0:o.push(r);o.length>0&&(n.required=o)}return n}var an=G.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="react-compiler-extra",ln=H({runOnlyWithEnableCompilerDirective:$(ke())}),pn=/eslint +react-compiler\/react-compiler: +\["error/;function cn(e){return e.type===G.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===G.AST_NODE_TYPES.MemberExpression&&e.property.type===G.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var un=/\bthis[.[]/;function Yt(e){return un.test(e)}var fn=an({name:qt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[ln]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let l of e.sourceCode.getAllComments())if(pn.test(l.value)){n=!0;break}if(!n)return{}}function r(l){for(let i of l.properties)if(i.type===G.AST_NODE_TYPES.Property&&i.method&&i.value.type===G.AST_NODE_TYPES.FunctionExpression){let s=e.sourceCode,a=s.getText(i.key),p=i.value,c=s.getText(p.body);if(Yt(c))e.report({node:i,messageId:"thisKeywordInMethod"});else{let u=p.params.map(y=>s.getText(y)).join(", "),d="";p.generator?d=`${a}: function* (${u}) ${c}`:d=`${a}: (${u}) => ${c}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:y=>y.replaceText(i,d)})}}}function o(l){for(let i of l.properties)if(i.type===G.AST_NODE_TYPES.Property&&i.value.type===G.AST_NODE_TYPES.ObjectExpression){for(let s of i.value.properties)if(s.type===G.AST_NODE_TYPES.Property&&s.method&&s.value.type===G.AST_NODE_TYPES.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Yt(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(l){if(cn(l.callee))for(let i of l.arguments){if(i.type===G.AST_NODE_TYPES.ObjectExpression&&(r(i),o(i)),i.type===G.AST_NODE_TYPES.ArrowFunctionExpression&&(i.body.type===G.AST_NODE_TYPES.ObjectExpression&&(r(i.body),o(i.body)),i.body.type===G.AST_NODE_TYPES.BlockStatement))for(let s of i.body.body)s.type===G.AST_NODE_TYPES.ReturnStatement&&s.argument?.type===G.AST_NODE_TYPES.ObjectExpression&&(r(s.argument),o(s.argument));if(i.type===G.AST_NODE_TYPES.FunctionExpression)for(let s of i.body.body)s.type===G.AST_NODE_TYPES.ReturnStatement&&s.argument?.type===G.AST_NODE_TYPES.ObjectExpression&&(r(s.argument),o(s.argument))}}}}}),et={name:qt,rule:fn};var Q=require("@typescript-eslint/utils"),C=require("zod/v4");var Jt=require("@typescript-eslint/utils"),Bt=ve(require("zod/v4"));function K(e){let n=Jt.ESLintUtils.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}function Oe(e){return Bt.toJSONSchema(e)}var mn=C.z.object({disallow:C.z.array(C.z.object({selector:C.z.string(),message:C.z.string(),replace:C.z.optional(C.z.union([C.z.string(),C.z.object({regex:C.z.string(),with:C.z.string()})])),replaceType:C.z.optional(C.z.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:C.z.optional(C.z.array(C.z.object({fn:C.z.string(),withArgs:C.z.optional(C.z.array(C.z.object({atIndex:C.z.number(),value:C.z.union([C.z.string(),C.z.number(),C.z.boolean()])}))),message:C.z.string(),replaceWith:C.z.optional(C.z.string()),ignoreRegex:C.z.optional(C.z.string())}))),__dev_simulateFileName:C.z.optional(C.z.string()),mustMatchSyntax:C.z.optional(C.z.array(C.z.object({includeRegex:C.z.string(),mustCallFn:C.z.optional(C.z.array(C.z.object({anyCall:C.z.array(C.z.object({fn:C.z.string(),withArgs:C.z.array(C.z.object({atIndex:C.z.number(),literal:C.z.union([C.z.string(),C.z.number(),C.z.boolean()])}))})),message:C.z.optional(C.z.string())}))),mustMatchSelector:C.z.optional(C.z.array(C.z.object({selector:C.z.string(),message:C.z.string()}))),mustHaveExport:C.z.optional(C.z.array(C.z.object({name:C.z.string(),type:C.z.enum(["function","variable","any"]).default("any"),message:C.z.string()})))})))}),tt=K({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Oe(mn)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:o,disallow:l,disallowFnCalls:i}=t,s=o??e.filename,a=[],p=new Map,c=new Set,u=new Map,d=new Set,y=new Map;function E(m){for(let S of m.specifiers)S.type===Q.AST_NODE_TYPES.ImportSpecifier&&S.imported.type===Q.AST_NODE_TYPES.Identifier&&S.imported.name!==S.local.name&&y.set(S.local.name,S.imported.name)}function h(m){if(m.declaration){if(m.declaration.type===Q.AST_NODE_TYPES.FunctionDeclaration&&m.declaration.id){let S=m.declaration.id.name;for(let R of Array.from(d)){let[A,I]=R.split(":");A===S&&(I==="function"||I==="any")&&d.delete(R)}}else if(m.declaration.type===Q.AST_NODE_TYPES.VariableDeclaration){for(let S of m.declaration.declarations)if(S.id.type===Q.AST_NODE_TYPES.Identifier){let R=S.id.name;for(let A of Array.from(d)){let[I,F]=A.split(":");I===R&&(F==="variable"||F==="any")&&d.delete(A)}}}}for(let S of m.specifiers)if(S.exported.type===Q.AST_NODE_TYPES.Identifier){let R=S.exported.name;for(let A of Array.from(d)){let[I,F]=A.split(":");I===R&&F==="any"&&d.delete(A)}}}function T(m){m.id.type===Q.AST_NODE_TYPES.Identifier&&m.init?.type===Q.AST_NODE_TYPES.Identifier&&y.set(m.id.name,m.init.name)}function x(m){return y.get(m)??m}function L(m,S){return x(m)===S||m===S}for(let{includeRegex:m,mustCallFn:S,mustMatchSelector:R,mustHaveExport:A}of r??[]){let I=dn(s,new RegExp(m));if(!I)continue;let F=q=>{let X=q;for(let{name:re,value:ee}of I)X=X.replaceAll(re,ee);return X};for(let{anyCall:q,message:X}of S??[]){let re=`Expected file to call the function: ${q.map(({fn:ee})=>ee).join(" or ")}`;c.add(re),a.push(ee=>{let{callee:Ae}=ee;if(Ae.type===Q.AST_NODE_TYPES.Identifier){for(let{fn:ie,withArgs:De}of q)if(Ae.name===ie){c.delete(re);for(let de of De){let ue=ee.arguments[de.atIndex],ye=typeof de.literal=="string"?F(de.literal):de.literal;if(!ue){e.report({node:ee,messageId:"default",data:{message:`Missing argument with value "${ye}" at index ${de.atIndex}${X?`: ${F(X)}`:""}`}});continue}if(ue.type!==Q.AST_NODE_TYPES.Literal){e.report({node:ue,messageId:"default",data:{message:`Argument at position ${de.atIndex} should the literal "${ye}"${X?`: ${F(X)}`:""}`}});continue}ue.value!==ye&&e.report({node:ue,messageId:"default",data:{message:`Argument should have the value "${ye}"${X?`: ${F(X)}`:""}`},fix:Re=>Re.replaceText(ue,typeof ye=="string"?`'${ye}'`:String(ye))})}break}}})}for(let{selector:q,message:X}of R??[])u.set(q,F(X)),p.set(F(q),()=>{u.delete(q)});for(let{name:q,type:X,message:re}of A??[]){let ee=F(q),Ae=F(re);d.add(`${ee}:${X}:${Ae}`)}}for(let{fn:m,withArgs:S,message:R,replaceWith:A,ignoreRegex:I}of i??[])I&&new RegExp(I).test(s)||a.push(F=>{let{callee:q}=F;if(q.type!==Q.AST_NODE_TYPES.Identifier||!L(q.name,m))return;if(S)for(let re of S){let ee=F.arguments[re.atIndex];if(!ee){e.report({node:F,messageId:"default",data:{message:`Missing argument with value "${re.value}" at index ${re.atIndex}: ${R}`}});return}if(ee.type!==Q.AST_NODE_TYPES.Literal||ee.value!==re.value)return}let X=re=>A?re.replaceText(F,A):null;e.report({node:F,messageId:"default",data:{message:R},suggest:A?[{messageId:"default",data:{message:`Replace with "${A}"`},fix:X}]:void 0})});function P(m,S){let R=n[m];R?n[m]=A=>{R(A),S(A)}:n[m]=S}for(let{selector:m,message:S,replace:R,replaceType:A="suggestion"}of l??[]){if(m==="CallExpression"){a.push(I=>{b(R,I,S,A)});continue}n[m]=I=>{b(R,I,S,A)}}if(p.size>0)for(let[m,S]of p)P(m,S);return a.length>0&&(n.CallExpression=m=>{if(m.type===Q.AST_NODE_TYPES.CallExpression)for(let S of a)S(m)}),n.ImportDeclaration=m=>{m.type===Q.AST_NODE_TYPES.ImportDeclaration&&E(m)},n.ExportNamedDeclaration=m=>{m.type===Q.AST_NODE_TYPES.ExportNamedDeclaration&&h(m)},n.VariableDeclarator=m=>{m.type===Q.AST_NODE_TYPES.VariableDeclarator&&T(m)},n["Program:exit"]=m=>{for(let S of c)e.report({node:m,messageId:"default",data:{message:S}});for(let[,S]of u)e.report({node:m,messageId:"default",data:{message:S}});for(let S of d){let[R,A,I]=S.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${R}" of type ${A}: ${I}`}})}},n;function b(m,S,R,A){let I=F=>{if(!m)return null;if(typeof m=="string")return F.replaceText(S,m);{let q=new RegExp(m.regex),X=e.sourceCode.getText(S);return F.replaceText(S,X.replace(q,m.with))}};e.report({node:S,messageId:"default",data:{message:R},fix:m&&A==="autofix"?I:void 0,suggest:m&&A==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:I}]:void 0})}}});function dn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[o,...l]=r;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:Xt(o)}),n.push({name:"$0_uncapitalize",value:Gt(o)}),n.push({name:"$0",value:o});for(let i=0;i<l.length;i++){let s=`$${i+1}`,a=l[i];n.push({name:`${s}_lowercase`,value:a.toLowerCase()}),n.push({name:`${s}_capitalize`,value:Xt(a)}),n.push({name:`${s}_uncapitalize`,value:Gt(a)}),n.push({name:s,value:a})}return n}function Xt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Gt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var _=require("@typescript-eslint/utils");var yn=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="collapse-simple-objs-in-one-line",gn=H({maxLineLength:$(fe()),maxProperties:$(fe()),nestedObjMaxLineLength:$(fe()),nestedObjMaxProperties:$(fe()),ignoreTypesWithSuffix:$(Z(z()))}),Sn=yn({name:Zt,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:[gn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,l=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function s(p){if(p.type===_.AST_NODE_TYPES.ObjectExpression){let c=p.parent.type===_.AST_NODE_TYPES.Property,u=c?i:o,d=p.properties.length;if(d>u)return!1;if(d===1){let E=p.properties[0];return E.type===_.AST_NODE_TYPES.Property&&E.value.type===_.AST_NODE_TYPES.ObjectExpression||E.type===_.AST_NODE_TYPES.Property&&E.value.type===_.AST_NODE_TYPES.ArrayExpression&&!E.value.elements.every(T=>T&&rt(T))?!1:{text:n.getText(E),isNested:c,propsSize:d}}let y=[];for(let E of p.properties){if(E.type===_.AST_NODE_TYPES.Property&&!rt(E.value))return!1;y.push(n.getText(E))}return{text:y.join(", "),isNested:c,propsSize:d}}else{let c=p.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,u=c?i:o,d=p.members.length;if(d>u)return!1;if(r.length>0&&p.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let E=p.parent.id.name;if(r.some(h=>E.endsWith(h)))return!1}if(d===1){let E=p.members[0];return E.type===_.AST_NODE_TYPES.TSPropertySignature&&E.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(E),isNested:c,propsSize:1}}if(p.parent.type===_.AST_NODE_TYPES.TSIntersectionType||p.parent.type===_.AST_NODE_TYPES.TSUnionType&&p.parent.types[0]!==p)return!1;let y=[];for(let E of p.members){if(E.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let h=E.typeAnnotation?.typeAnnotation;if(!h||h.type===_.AST_NODE_TYPES.TSTypeLiteral||!Kt(h))return!1;if(h.type===_.AST_NODE_TYPES.TSTypeReference&&h.typeArguments){if(h.typeArguments.params.length>1)return!1;let x=h.typeArguments.params[0];if(!Kt(x))return!1}let T=n.getText(E).trim();(T.endsWith(";")||T.endsWith(","))&&(T=T.slice(0,-1)),y.push(T)}return{text:y.join("; "),isNested:c,propsSize:d}}}function a(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer){let h=0,T=!1,x=n.getTokenAfter(p,{filter:P=>P.type!==_.AST_TOKEN_TYPES.Punctuator||T?!0:P.value===","?(h++,!1):P.value===";"?(h++,T=!0,!1):P.value===")"||P.value==="}"?(h++,!1):!0});if(h>4)return;let L=x?.type===_.AST_TOKEN_TYPES.Template&&x.value.startsWith(`}
|
|
2
|
+
`);if(x?.loc.start.line===p.loc.end.line&&!L)return}let c=s(p);if(!c)return;let u=c.text;if(u.includes(`
|
|
3
|
+
`)||n.getCommentsInside(p).length>0)return;u.endsWith(";")&&(u=u.slice(0,-1));let d=`{ ${u} }`,y=hn(n,p),E=c.isNested&&c.propsSize>2?l:t.maxLineLength;E&&d.length+y.length+Tn(p,n)>E||e.report({node:p,messageId:"singleLineProp",fix:h=>h.replaceText(p,d)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function Kt(e){return e.type===_.AST_NODE_TYPES.TSLiteralType||e.type===_.AST_NODE_TYPES.TSTypeReference||e.type===_.AST_NODE_TYPES.TSNumberKeyword||e.type===_.AST_NODE_TYPES.TSStringKeyword||e.type===_.AST_NODE_TYPES.TSBooleanKeyword||e.type===_.AST_NODE_TYPES.TSNullKeyword||e.type===_.AST_NODE_TYPES.TSUndefinedKeyword}function rt(e,t){return!!(e.type===_.AST_NODE_TYPES.Literal||e.type===_.AST_NODE_TYPES.Identifier||e.type===_.AST_NODE_TYPES.TemplateLiteral||e.type===_.AST_NODE_TYPES.TaggedTemplateExpression||!t&&e.type===_.AST_NODE_TYPES.ArrayExpression&&e.elements.every(n=>n&&rt(n,!0)))}function Tn(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
|
|
4
|
+
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function hn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var nt={name:Zt,rule:Sn};var En=/eslint +react-compiler\/react-compiler: +\["error/,er={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"?x=>n(x):x=>e.sourceCode.getText(x),r=typeof e.getScope=="function"?()=>r():x=>e.sourceCode.getScope(x),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,l=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:l};function s(x){l&&Array.isArray(x.suggest)&&x.suggest.length>0&&(x.fix=x.suggest[0].fix),e.report(x)}let a=e.getSourceCode().scopeManager,p=new WeakMap,c=new WeakSet,u=new WeakMap,d=new WeakMap,y=new WeakSet;function E(x,L){return function(P){if(L.has(P))return L.get(P);let b=x(P);return L.set(P,b),b}}function h(x,L,P,b,m){m&&x.async&&s({node:x,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
5
5
|
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
async function fetchData() {
|
|
@@ -12,5 +12,5 @@ useEffect(() => {
|
|
|
12
12
|
fetchData();
|
|
13
13
|
}, [someId]); // Or [] if effect doesn't need props or state
|
|
14
14
|
|
|
15
|
-
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let g=l.acquire(C),R=new Set,w=null;{let f=g.upper;for(;f&&(R.add(f),f.type!=="function");)f=f.upper;if(!f)return;w=f}let b=Array.isArray;function F(f){if(!b(f.defs))return!1;let d=f.defs[0];if(d==null||d.node.type!=="VariableDeclarator")return!1;let I=d.node.init;if(I==null)return!1;for(;I.type==="TSAsExpression";)I=I.expression;let A=d.node.parent;if(A==null&&(ot(w.block,d.node.id),A=d.node.parent,A==null))return!1;if(A.kind==="const"&&I.type==="Literal"&&(typeof I.value=="string"||typeof I.value=="number"||I.value===null))return!0;if(I.type!=="CallExpression")return!1;let O=I.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let k=d.node.id,{name:D}=O;if(D==="useRef"&&k.type==="Identifier")return!0;if(wr(O)&&k.type==="Identifier"){for(let j of f.references)j!==k&&y.add(j.identifier);return!0}else if(D==="useState"||D==="useReducer"){if(k.type==="ArrayPattern"&&k.elements.length===2&&b(f.identifiers)){if(k.elements[1]===f.identifiers[0]){if(D==="useState"){let j=f.references,oe=0;for(let ye=0;ye<j.length;ye++){if(j[ye].isWrite()&&oe++,oe>1)return!1;p.set(j[ye].identifier,k.elements[0])}}return!0}else if(k.elements[0]===f.identifiers[0]){if(D==="useState"){let j=f.references;for(let oe=0;oe<j.length;oe++)c.add(j[oe].identifier)}return!1}}}else if(D==="useTransition"&&k.type==="ArrayPattern"&&k.elements.length===2&&Array.isArray(f.identifiers)&&k.elements[1]===f.identifiers[0])return!0;return!1}function Y(f){if(!b(f.defs))return!1;let d=f.defs[0];if(d==null||d.node==null||d.node.id==null)return!1;let I=d.node,A=w.childScopes,O=null,k;for(k=0;k<A.length;k++){let D=A[k],j=D.block;if(I.type==="FunctionDeclaration"&&j===I||I.type==="VariableDeclarator"&&j.parent===I){O=D;break}}if(O==null)return!1;for(k=0;k<O.through.length;k++){let D=O.through[k];if(D.resolved!=null&&R.has(D.resolved.scope)&&!q(D.resolved))return!1}return!0}let q=E(F,u),ne=E(Y,S),ee=new Map;function Re(f){let d=f.from,I=!1;for(;d.block!==C;)d.type==="function"&&(I=d.block.parent!=null&&d.block.parent.type==="ReturnStatement"),d=d.upper;return I}let ie=new Map,De=new Map;me(g);function me(f){for(let d of f.references){if(!d.resolved||!R.has(d.resolved.scope))continue;let I=ot(C,d.identifier),A=tn(I),O=ge(A,De);if(m&&A.type==="Identifier"&&(A.parent.type==="MemberExpression"||A.parent.type==="OptionalMemberExpression")&&!A.parent.computed&&A.parent.property.type==="Identifier"&&A.parent.property.name==="current"&&Re(d)&&ee.set(O,{reference:d,dependencyNode:A}),A.parent.type==="TSTypeQuery"||A.parent.type==="TSTypeReference")continue;let k=d.resolved.defs[0];if(k!=null&&!(k.node!=null&&k.node.init===C.parent)&&k.type!=="TypeParameter")if(ie.has(O))ie.get(O).references.push(d);else{let D=d.resolved,j=q(D)||ne(D);ie.set(O,{isStable:j,references:[d]})}}for(let d of f.childScopes)me(d)}ee.forEach(({reference:f,dependencyNode:d},I)=>{let A=f.resolved.references,O=!1;for(let k=0;k<A.length;k++){let{identifier:D}=A[k],{parent:j}=D;if(j!=null&&j.type==="MemberExpression"&&!j.computed&&j.property.type==="Identifier"&&j.property.name==="current"&&j.parent.type==="AssignmentExpression"&&j.parent.left===j){O=!0;break}}O||i({node:d.parent.property,message:`The ref value '${I}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${I}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ue=new Set;function de(f,d){ue.has(d)||(ue.add(d),i({node:f,message:`Assignments to the '${d}' variable from inside React Hook ${r(P)} 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 ${r(P)}.`}))}let Ae=new Set;if(ie.forEach(({isStable:f,references:d},I)=>{f&&Ae.add(I),d.forEach(A=>{A.writeExpr&&de(A.writeExpr,I)})}),ue.size>0)return;if(!M){let f=null;if(ie.forEach(({isStable:d,references:I},A)=>{f||I.forEach(O=>{if(f)return;let k=O.identifier;if(!p.has(k))return;let j=O.from;for(;j.type!=="function";)j=j.upper;j.block===C&&(f=A)})}),f){let{suggestedDependencies:d}=it({dependencies:ie,declaredDependencies:[],stableDependencies:Ae,externalDependencies:new Set,isEffect:!0});i({node:P,message:`React Hook ${T} contains a call to '${f}'. 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 ${T} Hook.`,suggest:[{desc:`Add dependencies array: [${d.join(", ")}]`,fix(I){return I.insertTextAfter(C,`, [${d.join(", ")}]`)}}]})}return}let je=[],Me=new Set;M.type!=="ArrayExpression"?i({node:M,message:`React Hook ${r(P)} 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.`}):M.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(P)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}y.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(O){return O.removeRange(f.range)}}]});let d;try{d=ge(f,De)}catch(O){if(/Unsupported node type/.test(O.message)){f.type==="Literal"?ie.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(P)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let I=f;for(;I.type==="MemberExpression"||I.type==="OptionalMemberExpression"||I.type==="ChainExpression";)I=I.object||I.expression.object;let A=!w.through.some(O=>O.identifier===I);je.push({key:d,node:f}),A||Me.add(d)});let{suggestedDependencies:Gn,unnecessaryDependencies:$e,missingDependencies:Te,duplicateDependencies:Ut}=it({dependencies:ie,declaredDependencies:je,stableDependencies:Ae,externalDependencies:Me,isEffect:m}),Ue=Gn;if(Ut.size+Te.size+$e.size===0){if(t)return;br({declaredDependencies:je,declaredDependenciesNode:M,componentScope:w,scope:g}).forEach(({construction:d,isUsedOutsideOfHook:I,depType:A})=>{let O=A==="function"?"useCallback":"useMemo",k=A==="function"?"definition":"initialization",D=`wrap the ${k} of '${d.name.name}' in its own ${O}() Hook.`,j=I?`To fix this, ${D}`:`Move it inside the ${T} callback. Alternatively, ${D}`,oe=A==="conditional"||A==="logical expression"?"could make":"makes",ye=`The '${d.name.name}' ${A} ${oe} the dependencies of ${T} Hook (at line ${M.loc.start.line}) change on every render. ${j}`,Wt;I&&d.type==="Variable"&&A==="function"&&(Wt=[{desc:`Wrap the ${k} of '${d.name.name}' in its own ${O}() Hook.`,fix(Vt){let[Zn,Qn]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Vt.insertTextBefore(d.node.init,Zn),Vt.insertTextAfter(d.node.init,Qn)]}}]),i({node:d.node,message:ye,suggest:Wt})});return}!m&&Te.size>0&&(Ue=it({dependencies:ie,declaredDependencies:[],stableDependencies:Ae,externalDependencies:Me,isEffect:m}).suggestedDependencies);function Kn(){if(je.length===0)return!0;let f=je.map(I=>I.key),d=f.slice().sort();return f.join(",")===d.join(",")}Kn()&&Ue.sort();function Ke(f){let d=f.split("."),I="";for(let A=0;A<d.length;A++){if(A!==0){let O=d.slice(0,A+1).join("."),k=De.get(O)===!0;I+=k?"?.":"."}I+=d[A]}return I}function Ze(f,d,I,A){return f.size===0?null:(f.size>1?"":d+" ")+I+" "+(f.size>1?"dependencies":"dependency")+": "+Cr(Array.from(f).sort().map(O=>"'"+Ke(O)+"'"))+`. Either ${A} ${f.size>1?"them":"it"} or remove the dependency array.`}let pe="";if($e.size>0){let f=null;if(Array.from($e.keys()).forEach(d=>{f===null&&d.endsWith(".current")&&(f=d)}),f!==null)pe=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Me.size>0){let d=Array.from(Me)[0];g.set.has(d)||(pe=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!pe&&Te.has("props")){let f=ie.get("props");if(f==null)return;let d=f.references;if(!Array.isArray(d))return;let I=!0;for(let A=0;A<d.length;A++){let O=d[A],k=ot(w.block,O.identifier);if(!k){I=!1;break}let D=k.parent;if(D==null){I=!1;break}if(D.type!=="MemberExpression"&&D.type!=="OptionalMemberExpression"){I=!1;break}}I&&(pe=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${T} call and refer to those specific props inside ${r(P)}.`)}if(!pe&&Te.size>0){let f=null;Te.forEach(d=>{if(f)return;let I=w.set.get(d),A=ie.get(d);if(A.references[0].resolved!==I)return;let O=I.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let k=!1,D;for(let j=0;j<A.references.length;j++)if(D=A.references[j].identifier,D!=null&&D.parent!=null&&(D.parent.type==="CallExpression"||D.parent.type==="OptionalCallExpression")&&D.parent.callee===D){k=!0;break}k&&(f=d)}),f!==null&&(pe=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!pe&&Te.size>0){let f=null;if(Te.forEach(d=>{if(f!==null)return;let A=ie.get(d).references,O,k;for(let D=0;D<A.length;D++){for(O=A[D].identifier,k=O.parent;k!=null&&k!==w.block;){if(k.type==="CallExpression"){let j=p.get(k.callee);if(j!=null){if(j.name===d)f={missingDep:d,setter:k.callee.name,form:"updater"};else if(c.has(O))f={missingDep:d,setter:k.callee.name,form:"reducer"};else{let oe=A[D].resolved;if(oe!=null){let ye=oe.defs[0];ye!=null&&ye.type==="Parameter"&&(f={missingDep:d,setter:k.callee.name,form:"inlineReducer"})}}break}}k=k.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":pe=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":pe=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":pe=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:M,message:`React Hook ${r(P)} has `+(Ze(Te,"a","missing","include")||Ze($e,"an","unnecessary","exclude")||Ze(Ut,"a","duplicate","omit"))+pe,suggest:[{desc:`Update the dependencies array to be: [${Ue.map(Ke).join(", ")}]`,fix(f){return f.replaceText(M,`[${Ue.map(Ke).join(", ")}]`)}}]})}function v(C){let M=xr(C.callee,o);if(M===-1)return;let P=C.arguments[M],T=C.callee,m=nn(T).name,g=C.arguments[M+1],R=/Effect($|[^a-z])/g.test(m);if(!P){i({node:T,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!R)){if(!g&&!R){(m==="useMemo"||m==="useCallback")&&i({node:T,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(P.type){case"FunctionExpression":case"ArrowFunctionExpression":x(P,g,T,m,R);return;case"Identifier":if(!g||g.elements&&g.elements.some(F=>F&&F.type==="Identifier"&&F.name===P.name))return;let w=n(C).set.get(P.name);if(w==null||w.defs==null)return;let b=w.defs[0];if(!b||!b.node||b.type!=="Variable"&&b.type!=="FunctionName")break;switch(b.node.type){case"FunctionDeclaration":x(b.node,g,T,m,R);return;case"VariableDeclarator":let F=b.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":x(F,g,T,m,R);return}break}break;default:i({node:T,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:T,message:`React Hook ${m} has a missing dependency: '${P.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${P.name}]`,fix(w){return w.replaceText(g,`[${P.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let C of e.sourceCode.getAllComments())if(Er.test(C.value))return t=!0,{CallExpression:M=>v(M,!0)}}return{CallExpression:C=>v(C)}}};function it({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:s}){let a=o();function o(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((x,v)=>{let C=i(a,v);C.isUsed=!0,l(a,v,M=>{M.isSubtreeUsed=!0})}),t.forEach(({key:x})=>{let v=i(a,x);v.isSatisfiedRecursively=!0}),r.forEach(x=>{let v=i(a,x);v.isSatisfiedRecursively=!0});function i(x,v){let C=v.split("."),M=x;for(let P of C){let T=M.children.get(P);T||(T=o(),M.children.set(P,T)),M=T}return M}function l(x,v,C){let M=v.split("."),P=x;for(let T of M){let m=P.children.get(T);if(!m)return;C(m),P=m}}let p=new Set,c=new Set;u(a,p,c,x=>x);function u(x,v,C,M){x.children.forEach((P,T)=>{let m=M(T);if(P.isSatisfiedRecursively){P.isSubtreeUsed&&C.add(m);return}if(P.isUsed){v.add(m);return}u(P,v,C,g=>m+"."+g)})}let S=[],y=new Set,E=new Set;return t.forEach(({key:x})=>{c.has(x)?S.indexOf(x)===-1?S.push(x):E.add(x):y.add(x)}),p.forEach(x=>{S.push(x)}),{suggestedDependencies:S,unnecessaryDependencies:y,duplicateDependencies:E,missingDependencies:p}}function he(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 he(e.consequent)!=null||he(e.alternate)!=null?"conditional":null;case"LogicalExpression":return he(e.left)!=null||he(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return he(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return he(e.expression);case"TSAsExpression":return he(e.expression)}return null}function br({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let s=e.map(({key:o})=>{let i=r.variables.find(p=>p.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 p=he(l.node.init);if(p!=null)return[i,p]}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 p=o.references[l];if(p.writeExpr){if(i)return!0;i=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!rn(t,p.identifier))return!0}return!1}return s.map(([o,i])=>({construction:o.defs[0],depType:i,isUsedOutsideOfHook:a(o)}))}function tn(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)?tn(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function st(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function ge(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=ge(e.object,t),n=ge(e.property,null),s=`${r}.${n}`;return st(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=ge(e.object,t),n=ge(e.property,null),s=`${r}.${n}`;return st(e,t,s),s}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=ge(r.object,t),s=ge(r.property,null),a=`${n}.${s}`;return st(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function nn(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function xr(e,t){let r=nn(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let n;try{n=ge(r,null)}catch(s){if(/Unsupported node type/.test(s.message))return 0;throw s}return t.additionalHooks.test(n)?0:-1}else return-1}}function ot(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),Ir(n,t))return n;if(rn(n,t))for(let[s,a]of Object.entries(n))s!=="parent"&&(Qt(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(o=>{Qt(o)&&(o.parent=n,r.push(o))}))}return null}function Cr(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function Qt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Ir(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 rn(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function wr(e){return!1}var Ee=require("@typescript-eslint/utils");var te=ve(require("typescript")),Rr=Ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="improved-no-unnecessary-condition",Ar=H({}),vr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],kr=new Set(vr),at={name:sn,rule:Rr({name:sn,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:[Ar]},defaultOptions:[{}],create(e){let t=Ee.ESLintUtils.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===Ee.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function s(i){return i.flags&te.default.TypeFlags.Any||i.flags&te.default.TypeFlags.Unknown?null:i.flags&te.default.TypeFlags.StringLike?["string"]:i.flags&te.default.TypeFlags.NumberLike?["number"]:i.flags&te.default.TypeFlags.BigIntLike?["bigint"]:i.flags&te.default.TypeFlags.BooleanLike?["boolean"]:i.flags&te.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&te.default.TypeFlags.Undefined||i.flags&te.default.TypeFlags.Void?["undefined"]:i.flags&te.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&te.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&te.default.TypeFlags.NonPrimitive?["object"]:i.flags&te.default.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),p=r.getTypeAtLocation(l.expression);if(p.flags&te.default.TypeFlags.Any||p.flags&te.default.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let S of p.types){let y=s(S);if(y)c.push(...y);else return null}return c}let u=s(p);return u?(c.push(...u),c):null}function o(i){if(!(i.operator==="==="||i.operator==="!=="))return;let p=null,c=null;if(n(i.left)?(p=i.left,c=i.right.type===Ee.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(p=i.right,c=i.left.type===Ee.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!p||!c||!Or(c,kr))return;let u=a(p);if(!u)return;let S=i.operator==="!==",y=u.includes(c);u.length===1?y&&!S?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Pe(p,e),type:c}}):!y&&S?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Pe(p,e),type:Array.from(u)[0]}}):!y&&!S?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Pe(p,e),actualType:Ve(u),conditionType:c}}):y&&S&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Pe(p,e),actualType:Ve(u),conditionType:c}}):!y&&!S?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Pe(p,e),actualType:Ve(u),conditionType:c}}):!y&&S&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Pe(p,e),type:Ve(u)}})}return{BinaryExpression:o}}})};function Ve(e){return Array.from(new Set(e)).join(" | ")||"never"}function Pe(e,t){let r=e.argument;return r.type===Ee.AST_NODE_TYPES.Identifier?r.name:t.sourceCode.getText(r)}function Or(e,t){return t.has(e)}var He=require("@typescript-eslint/utils");var Pr=He.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-call-with-explicit-generics",Fr=H({functions:K(V())}),Nr=Pr({name:on,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:[Fr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:s}=n;s.type===He.AST_NODE_TYPES.Identifier&&r.has(s.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),lt={name:on,rule:Nr};var Ce=require("@typescript-eslint/utils"),Dr=Ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="no-call-with-inferred-generics",jr=Dr({name:an,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 r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:s}=n;if(s.type!==Ce.AST_NODE_TYPES.Identifier)return;let a=r.get(s.name);if(!a)return;let{minGenerics:o=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(o||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:o||0}}),!(i&&!l)&&n.typeArguments?.params?.some(c=>!i&&c.type===Ce.AST_NODE_TYPES.TSAnyKeyword||l&&c.type===Ce.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===Ce.AST_NODE_TYPES.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),pt={name:an,rule:jr};var pn=require("@typescript-eslint/utils"),Mr=pn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cn="no-commented-out-code",Lr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],B={returnStatement:/^\s*return\s+/,stringAssignment:/\w=("|'|`)/,objectPropertyWithQuotes:/\w+:\s*('|"|`)/,computedPropertyAssignment:/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,kebabCaseProperty:/\w+-\w+:/,snakeCaseProperty:/\w+_\w+:/,ternaryOperator:/\?\s+\w/,colonWithWord:/:\s+\w/,quotedString:/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,numberWithComma:/^\s*\d+[,}]/,arrayWithComma:/^\s*\[[^\]]*\][,}]/,objectWithComma:/^\s*\{[^}]*\}[,}]/,methodCall:/\.\w+\(/,arrayAccess:/\[\w+\]/,quotedPropertyKey:/^\s*(['"`]).+?\1\s*:/,jsxSelfClosing:/^<[A-Z]\w*(\s|>|\/)/,jsxElement:/^<[a-z]+(\s|>|\/)/,jsxOpeningTag:/<[A-Z]\w*(\s.*)?>/,jsxClosingTag:/<\/[A-Z]\w*>/,htmlOpeningTag:/<[a-z]+(\s.*)?>/,htmlClosingTag:/<\/[a-z]+>/,colonDescriptiveComment:/^[a-zA-Z]+(\s+[a-zA-Z]+)*:\s+[a-zA-Z]+\s+[a-zA-Z][^{=,'"]*$/,jsdocComment:/^\s*[*\s]*$/},_r=[") {","return;",B.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",B.stringAssignment,");",B.objectPropertyWithQuotes,B.computedPropertyAssignment,B.kebabCaseProperty,B.snakeCaseProperty,"&&","||","()",B.ternaryOperator,B.colonWithWord,B.quotedString,B.numberWithComma,B.arrayWithComma,B.objectWithComma,B.methodCall,B.arrayAccess,"?.(","??","=>",B.quotedPropertyKey],$r=["/>","</",B.jsxSelfClosing,B.jsxElement,B.jsxOpeningTag,B.jsxClosingTag,B.htmlOpeningTag,B.htmlClosingTag],ln=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Ur=Mr({name:cn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,s){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||B.jsdocComment.test(n))return!1;for(let o of ln)if(a.startsWith(o))return!1;if(n.includes("https://")||a.includes(":")&&B.colonDescriptiveComment.test(a.trim()))return!1;if(s==="Block"){for(let o of $r)if(typeof o=="string"){if(n.includes(o))return{wrongPattern:o}}else if(o.test(n))return{wrongPattern:`regex(${o.toString()})`};return!1}for(let o of Lr)if(a.startsWith(o))return{wrongPattern:o};for(let o of _r)if(typeof o=="string"){if(n.includes(o))return{wrongPattern:o}}else if(o.test(n))return{wrongPattern:`regex(${o.toString()})`};return!1}function r(n,s){let a=n,o=a.trim();if(o.startsWith("`")&&(o.endsWith("`,")||o.endsWith("`;")||o.endsWith("`")))return a;if(s==="Block"&&a.includes("```")){let p=a.split(/```[\s\S]*?```/g);p.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=p.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(p=>/[a-zA-Z0-9]/.test(p))?i.join(""):a}return{Program(){let s=e.sourceCode.getAllComments();for(let a of s){let o=r(a.value,a.type),i=t(o,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:ln.join(", ")}})}}}}}),ct={name:cn,rule:Ur};var ze=require("@typescript-eslint/utils"),Wr=ze.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),un="no-default-export",Vr=Wr({name:un,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 r of t.specifiers)r.exported.type===ze.TSESTree.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ut={name:un,rule:Vr};var fn=require("@typescript-eslint/utils"),Hr=fn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-leaked-text-in-jsx",zr=[",",";","[","]","(",")"],Yr=Hr({name:mn,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 r=t.value.trim();if(!r)return;let n="";zr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),ft={name:mn,rule:Yr};var be=require("@typescript-eslint/utils"),Jr=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yn="no-non-camel-case-functions",Br=/^(\$?[a-z][a-zA-Z0-9]*)$/;function dn(e){if(e.typeName.type!==be.AST_NODE_TYPES.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===be.AST_NODE_TYPES.Identifier&&t.name==="JSX"&&r.name==="Element"}var qr=Jr({name:yn,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&&!Br.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===be.AST_NODE_TYPES.TSTypeReference?dn(r):r.type===be.AST_NODE_TYPES.TSUnionType&&r.types.some(s=>s.type===be.AST_NODE_TYPES.TSTypeReference&&dn(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),mt={name:yn,rule:qr};var U=require("@typescript-eslint/utils");var dt=require("@typescript-eslint/utils");function Fe(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Fe(e.parent,t,r===1/0?r:r-1)}function*yt(e){yield e,e.parent&&(yield*yt(e.parent))}function gt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function gn(e,t,r){let s=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===dt.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===dt.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return s?s.references.filter(a=>!a.init):[]}var Xr=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sn="no-optional-root-props",Gr=Xr({name:Sn,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(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let o=a.references[0];if(!o)return!1;for(let i of yt(o.identifier)){if("returnType"in i||i.type===U.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===U.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===U.TSESTree.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===U.TSESTree.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let c=Fe(l.parent.parent,U.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let u=Ye(c,e.sourceCode);return u?!(u.parent.type===U.TSESTree.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===U.TSESTree.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===U.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===U.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let p=Fe(l,U.TSESTree.AST_NODE_TYPES.VariableDeclaration);return p?!!Ye(p,e.sourceCode):!1}if(l.type===U.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Ye(l,e.sourceCode)}return!1}function r(n){n.key.type!==U.TSESTree.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:s=>{let a=Fe(n,U.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let o=e.sourceCode.getText(a);return s.replaceText(a,o.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===U.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Je(n)||!t(n)))for(let s of n.typeAnnotation.members)s.type===U.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSInterfaceDeclaration(n){if(!(Je(n)||!t(n)))for(let s of n.body.body)s.type===U.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSTypeReference(n){if(n.typeName.type!==U.TSESTree.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let s=n.typeArguments.params[0];if(s.type!==U.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=Fe(n.parent,U.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let o=Ye(a,e.sourceCode);if(!(!o||o.parent.type===U.TSESTree.AST_NODE_TYPES.CallExpression&&o.parent.callee.type===U.TSESTree.AST_NODE_TYPES.Identifier&&o.parent.callee.name==="memo"))for(let l of s.members)l.type===U.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Je(e){return e?e.parent?.type===U.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===U.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ye(e,t){if(Je(e))return;let r;if(e.type===U.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===U.TSESTree.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===U.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let s=n.variables.find(o=>o.identifiers.includes(r));if(!s)return;let a=s.references.filter(o=>o.identifier!==r);if(!(a.length!==1||!a[0])&&!Je(a[0].identifier.parent.parent))return a[0].identifier}var St={name:Sn,rule:Gr};var Tn=require("@typescript-eslint/utils"),Be=ve(require("path"));var Kr=Tn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hn="no-relative-imports",Zr=H({find:V(),replacement:V()}),Qr=H({aliases:K(Zr),rootDir:_(V()),allowNotFoundAliases:_(ke()),_dev_simulateFileName:_(V())}),ei=Kr({name:hn,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:[Qr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(o){return o.startsWith(".")||o.startsWith("..")}function s(o,i){let l=Be.default.dirname(i);return Be.default.resolve(l,o)}function a(o){let i=t.rootDir??process.cwd(),l=Be.default.relative(i,o);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let u=l.replace(c,p);return{alias:p,newPath:u}}return null}return{ImportDeclaration(o){let i=o.source.value;if(!n(i))return;let l=s(i,r),p=a(l);!p&&t.allowNotFoundAliases||e.report({node:o,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(o.source,`'${p.newPath}'`):void 0})}}}}),Tt={name:hn,rule:ei};var Le=require("@typescript-eslint/utils"),Ie=ve(require("zod/v4"));var ti=Ie.object({alternativeMsgs:Ie.object({inArrayFind:Ie.string().optional(),inArrayFilter:Ie.string().optional()}).optional(),__dev_simulateFileName:Ie.string().optional()});function ni(e){return e.typeAnnotation.type!==Le.AST_NODE_TYPES.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function ri(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ii(e){let t=e.parent;for(;t;){if(t.type===Le.AST_NODE_TYPES.CallExpression&&t.callee.type===Le.AST_NODE_TYPES.MemberExpression&&t.callee.property.type===Le.AST_NODE_TYPES.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var ht=G({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[Oe(ti)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(ri(r))return{};function n(s){if(!ni(s))return;let a=ii(s),o=[];if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let l=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:s,messageId:l,data:{message:i}});return}}e.report({node:s,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});var we=require("@typescript-eslint/utils");var si="no-unnecessary-async-on-jsx-props";function oi(e){if(e.body.type!==we.AST_NODE_TYPES.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==we.AST_NODE_TYPES.ExpressionStatement?!1:r.expression.type===we.AST_NODE_TYPES.AwaitExpression}var Et=G({name:si,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(r){oi(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let s=e.sourceCode,a=[],o=s.getFirstToken(r,l=>l.value==="async");if(o){let l=s.getTokenAfter(o);l?a.push(n.replaceTextRange([o.range[0],l.range[0]],"")):a.push(n.remove(o))}function i(l){if(l.type===we.AST_NODE_TYPES.AwaitExpression){let p=s.getFirstToken(l);if(p&&p.value==="await"){let c=s.getTokenAfter(p);c?a.push(n.replaceTextRange([p.range[0],c.range[0]],"")):a.push(n.remove(p))}}if(l.type===we.AST_NODE_TYPES.BlockStatement)for(let p of l.body)i(p);else l.type===we.AST_NODE_TYPES.ExpressionStatement&&i(l.expression)}return i(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});var Se=require("@typescript-eslint/utils");var bt=ve(require("typescript")),ai=Se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),En="no-unnecessary-casting",li=H({additionalCastFunctions:_(K(H({name:V(),expectedType:zt(["string","number"])})))}),xt={name:En,rule:ai({name:En,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:[li],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],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(c,u){switch(c.type){case Se.AST_NODE_TYPES.Literal:return u==="number"?typeof c.value=="number":typeof c.value=="string";case Se.AST_NODE_TYPES.TemplateLiteral:return u==="string";case Se.AST_NODE_TYPES.UnaryExpression:return u==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function i(c,u){return u==="number"?!!(c.flags&bt.TypeFlags.NumberLike):!!(c.flags&bt.TypeFlags.StringLike)}function l(c,u){return S=>S.replaceText(c,e.sourceCode.getText(u))}function p(c){if(!a||c.arguments.length!==1)return;let u=c.arguments[0];if(!u||u.type===Se.AST_NODE_TYPES.SpreadElement)return;let{callee:S}=c;if(S.type!==Se.AST_NODE_TYPES.Identifier)return;let y=S.name,E=n.find(v=>v.name===y);if(!E)return;if(o(u,E.expectedType)||i(a.getTypeAtLocation(s.esTreeNodeToTSNodeMap.get(u)),E.expectedType)){let v,C;y==="Number"?v="unnecessaryNumberCasting":y==="String"?v="unnecessaryStringCasting":(v="unnecessaryCustomCasting",C={name:E.name,type:E.expectedType}),e.report({node:c,messageId:v,...C?{data:C}:{},fix:l(c,u)})}}return{CallExpression:p}}})};var _e=require("@typescript-eslint/utils"),ae=ve(require("zod/v4"));var pi=ae.object({methods:ae.union([ae.array(ae.string()),ae.literal("array")])}),Ct=G({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[ae.toJSONSchema(pi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function s(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===_e.AST_NODE_TYPES.MemberExpression){let p=l.property;if(p.type===_e.AST_NODE_TYPES.Identifier)return p.name}return null}function o(i,l){if(i.type!==_e.AST_NODE_TYPES.Identifier||!i.typeAnnotation)return;let p=l.parent;if(p.type===_e.AST_NODE_TYPES.CallExpression){let c=a(p);c&&s(c)&&p.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(S){return S.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)o(l,i)},FunctionExpression(i){for(let l of i.params)o(l,i)}}}});var se=require("@typescript-eslint/utils");var It=G({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===se.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==se.AST_NODE_TYPES.ObjectExpression||t.id.type===se.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===se.AST_NODE_TYPES.ExportNamedDeclaration)return;let r=new Map;for(let o of t.init.properties)o.type===se.AST_NODE_TYPES.Property&&o.key.type===se.AST_NODE_TYPES.Identifier&&r.set(o.key.name,o);if(r.size===0||t.id.type!==se.AST_NODE_TYPES.Identifier)return;let n=ci(t,e.sourceCode);if(n.length===0)return;let s=t.init.properties.some(o=>o.type!==se.AST_NODE_TYPES.Property?!1:o.value.type===se.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let o of n){if(o.identifier.parent.type!==se.AST_NODE_TYPES.MemberExpression)return;let i=o.identifier.parent;if(i.object!==o.identifier)return;if(i.computed)if(i.property.type===se.AST_NODE_TYPES.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==se.AST_NODE_TYPES.Identifier)return;a.add(i.property.name)}if(i.parent.type===se.AST_NODE_TYPES.CallExpression&&s)return}for(let[o,i]of r)a.has(o)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:o}})}}}});function ci(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}var W=require("@typescript-eslint/utils");var ui=H({selectors:K(H({name:V(),selectorProp:_(V()),selectorArgPos:_(fe()),returnProp:_(V())}))}),fi=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bn="no-unused-selected-values",wt={name:bn,rule:fi({name:bn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[ui]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.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=di(a);if(!o)return;let i=n.get(o);if(!i)return;let l=mi(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let p=yi(l);if(!p)return;let c=xn(p.properties,void 0);if(!c)return;if(s.id.type===W.AST_NODE_TYPES.ObjectPattern){let y=xn(s.id.properties,i.returnProp);if(!y)return;for(let[E,x]of c)y.has(E)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:E}});return}if(s.id.type!==W.AST_NODE_TYPES.Identifier||i.returnProp)return;let u=gi(s,e.sourceCode);if(u.length===0)return;let S=new Set;for(let y of u){if(y.identifier.parent.type!==W.AST_NODE_TYPES.MemberExpression)return;let E=y.identifier.parent.property;if(E.type!==W.AST_NODE_TYPES.Identifier)return;S.add(E.name)}for(let[y,E]of c)S.has(y)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:y}})}}}})};function mi(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===W.AST_NODE_TYPES.ArrowFunctionExpression||n.type===W.AST_NODE_TYPES.FunctionExpression)return n;if(r&&n.type===W.AST_NODE_TYPES.ObjectExpression){let s=n.properties.find(o=>o.type===W.AST_NODE_TYPES.Property&&o.key.type===W.AST_NODE_TYPES.Identifier&&o.key.name===r);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 di(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 yi(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(r=>r.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 xn(e,t){let r=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;r=s.value.properties}let n=new Map;for(let s of r){if(s.type!==W.AST_NODE_TYPES.Property||s.key.type!==W.AST_NODE_TYPES.Identifier)return null;n.set(s.key.name,s)}return n.size>0?n:null}function gi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}var z=require("@typescript-eslint/utils");var Rt=G({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===z.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,s=!1;return{CallExpression(a){if(s)return;if(!n){let i=Si(a);i&&(n=i);return}let o=Ti(a,e.sourceCode);if(o){s=!0;for(let i of o)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function Si(e){if(!(e.callee.type===z.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==z.AST_NODE_TYPES.ObjectExpression)return null;let n=gt(r.properties,a=>a.type!==z.AST_NODE_TYPES.Property||a.key.type!==z.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===z.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===z.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===z.AST_NODE_TYPES.FunctionExpression?hi(a.value):null);if(!n)return null;let s=new Map;for(let a of n.properties)a.type===z.AST_NODE_TYPES.Property&&a.key.type===z.AST_NODE_TYPES.Identifier&&s.set(a.key.name,a);return s}function Ti(e,t){if(!(e.callee.type===z.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==z.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==z.AST_NODE_TYPES.ObjectPattern||!gt(e.parent.id.properties,o=>o.type===z.AST_NODE_TYPES.Property&&o.key.type===z.AST_NODE_TYPES.Identifier&&o.key.name==="formFields"&&o))return null;let s=gn(e.parent,"formFields",t),a=new Set;for(let{identifier:o}of s){if(o.type!==z.AST_NODE_TYPES.Identifier||o.parent.type===z.AST_NODE_TYPES.Property&&o.parent.parent.type===z.AST_NODE_TYPES.ObjectExpression&&o.parent.parent.parent.type===z.AST_NODE_TYPES.ReturnStatement||o.parent.type===z.AST_NODE_TYPES.ReturnStatement)return null;if(o.parent.type===z.AST_NODE_TYPES.MemberExpression){if(o.parent.object.type!==z.AST_NODE_TYPES.Identifier||o.parent.property.type!==z.AST_NODE_TYPES.Identifier)return null;a.add(o.parent.property.name)}}return a}function hi(e){if(e.body.type===z.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===z.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===z.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==z.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var $=require("@typescript-eslint/utils");var Ei=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Cn(e){let t=[];for(let r of e.members)r.type===$.AST_NODE_TYPES.TSPropertySignature&&r.key.type===$.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function In(e,...t){for(let r of t)e.set(...r);return e}var bi=H({forceCheckOnFCPropTypesWithName:_(K(V()))}),wn="no-unused-type-props-in-args",At=null,xi=Ei({name:wn,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:[bi],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!At&&(At=r.map(i=>new RegExp(i)));function n(i,l,p,c,u=!0){let S=p.name,y=e.sourceCode.getScope(l).references.find(v=>v.identifier.name===S)?.resolved,E=i&&At?.some(v=>v.test(S));if(!y||!E&&y.references.filter(v=>v.isTypeReference).length>1)return;let x=y?.defs[0]?.node;if(!(u&&x?.parent?.type===$.AST_NODE_TYPES.ExportNamedDeclaration)){if(x?.type===$.AST_NODE_TYPES.TSTypeAliasDeclaration){s(i,l,c,x.typeAnnotation,!0);return}if(x?.type===$.AST_NODE_TYPES.TSInterfaceDeclaration){s(i,l,c,x.body,!0);return}}}function s(i,l,p,c,u){if(c.type===$.AST_NODE_TYPES.TSInterfaceBody){for(let S of c.body)S.type===$.AST_NODE_TYPES.TSPropertySignature&&S.key.type===$.AST_NODE_TYPES.Identifier&&p.set(S.key.name,S);return}if(c.type===$.AST_NODE_TYPES.TSTypeLiteral){In(p,...Cn(c));return}if(c.type===$.AST_NODE_TYPES.TSIntersectionType){for(let S of c.types)s(i,l,p,S,!0);return}u||c.type===$.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===$.AST_NODE_TYPES.Identifier&&n(i,l,c.typeName,p)}function a(i,l,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let u=new Map;if(s(i,l,u,c.typeAnnotation.typeAnnotation,!1),u.size===0)continue;o(c,u)}else c.type===$.AST_NODE_TYPES.AssignmentPattern&&c.left.type===$.AST_NODE_TYPES.ObjectPattern&&a(i,l,[c.left])}function o(i,l){let p=[];if(i.properties.at(-1)?.type===$.AST_NODE_TYPES.RestElement)return;for(let y of i.properties)y.type===$.AST_NODE_TYPES.Property&&y.key.type===$.AST_NODE_TYPES.Identifier&&p.push(y.key.name);let u=[],S=[];for(let[y,E]of l)p.includes(y)||(S.push(y),u.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,E]of u.entries())e.report({...E,fix:y===u.length-1?x=>{let v=i.properties.at(-1),C=S.join(", ");return v?v?.type===$.AST_NODE_TYPES.RestElement?null:x.insertTextAfter(v,`, ${C}`):x.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${C}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let p=new Map,c=l.id.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===$.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===$.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===$.AST_NODE_TYPES.Identifier)n(!0,i,c.typeName,p,!1);else if(c.type===$.AST_NODE_TYPES.TSTypeLiteral)In(p,...Cn(c));else if(c.type===$.AST_NODE_TYPES.TSIntersectionType)for(let u of c.types)u.type===$.AST_NODE_TYPES.TSTypeReference&&u.typeName.type===$.AST_NODE_TYPES.Identifier?n(!0,i,u.typeName,p,!1):s(!0,i,p,u,!0);if(p.size!==0&&l.init?.type===$.AST_NODE_TYPES.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===$.AST_NODE_TYPES.ObjectPattern&&o(u,p)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),vt={name:wn,rule:xi};var le=require("@typescript-eslint/utils");var kt=G({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function r(n){return n.callee.type===le.AST_NODE_TYPES.Identifier?t.has(n.callee.name):n.callee.type===le.AST_NODE_TYPES.MemberExpression&&n.callee.object.type===le.AST_NODE_TYPES.Identifier&&n.callee.property.type===le.AST_NODE_TYPES.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let s of n.specifiers)s.type===le.AST_NODE_TYPES.ImportSpecifier&&s.imported.type===le.AST_NODE_TYPES.Identifier&&s.imported.name==="useRef"&&t.add(s.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===le.AST_NODE_TYPES.CallExpression&&r(n.init)&&n.id.type===le.AST_NODE_TYPES.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let o=!1;for(let i of a.references){let p=i.identifier.parent;if(p!==n&&!(p.type===le.AST_NODE_TYPES.JSXExpressionContainer&&p.parent.type===le.AST_NODE_TYPES.JSXAttribute&&p.parent.name.type===le.AST_NODE_TYPES.JSXIdentifier&&p.parent.name.name==="ref")){o=!0;break}}o||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});var Ne=require("@typescript-eslint/utils"),Ci=Ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),An="prefer-named-functions",Rn=new Map,Ii=Ci({name:An,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 r=null;if(t.ignoreRegex){let n=Rn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),Rn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Ne.AST_NODE_TYPES.ArrowFunctionExpression&&n.id.type===Ne.AST_NODE_TYPES.Identifier){let s=n.id.name;if(n.id.typeAnnotation||r&&r.test(s)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Ne.AST_NODE_TYPES.BlockStatement)return;let a=n.parent,o=n.init.params,i=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(a,`${l.async?"async ":""}function ${s}(${o.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),Ot={name:An,rule:Ii};var N=require("@typescript-eslint/utils");var wi=H({disallowedFunctions:K(H({name:V(),allowUsingWithArgs:_(ke()),hookAlternative:_(V()),message:_(V()),allowUseInside:_(K(V()))}))});function qe(e){return/^use[A-Z]/.test(e)}function vn(e){return/^[A-Z]/.test(e)}function Ri(e){return e.type===N.AST_NODE_TYPES.Identifier?qe(e.name):e.type===N.AST_NODE_TYPES.MemberExpression&&e.property.type===N.AST_NODE_TYPES.Identifier?qe(e.property.name):!1}function kn(e,t){return e.type===N.AST_NODE_TYPES.Identifier?e.name===t:e.type===N.AST_NODE_TYPES.MemberExpression&&e.object.type===N.AST_NODE_TYPES.Identifier&&e.property.type===N.AST_NODE_TYPES.Identifier?e.object.name==="React"&&e.property.name===t:!1}function On(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&kn(e.parent.callee,"forwardRef"))}function Pn(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&kn(e.parent.callee,"memo"))}function Pt(e){if(e.type===N.AST_NODE_TYPES.FunctionDeclaration||e.type===N.AST_NODE_TYPES.FunctionExpression&&e.id)return e.id||void 0;if(e.type===N.AST_NODE_TYPES.FunctionExpression||e.type===N.AST_NODE_TYPES.ArrowFunctionExpression){if(e.parent.type===N.AST_NODE_TYPES.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===N.AST_NODE_TYPES.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===N.AST_NODE_TYPES.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===N.AST_NODE_TYPES.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Ai(e){let t=e.parent,r=!1;for(;t;){if(t.type===N.AST_NODE_TYPES.FunctionDeclaration||t.type===N.AST_NODE_TYPES.FunctionExpression||t.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let n=Pt(t);if(n&&n.type===N.AST_NODE_TYPES.Identifier){if(vn(n.name)||qe(n.name))return!r;r=!0}else{if(On(t)||Pn(t))return!r;if(t.parent.type===N.AST_NODE_TYPES.CallExpression){let s=t.parent;Ri(s.callee)||(r=!0)}else t.parent.type===N.AST_NODE_TYPES.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Fn(e){return e.callee.type===N.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===N.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===N.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function vi(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===N.AST_NODE_TYPES.FunctionDeclaration||r.type===N.AST_NODE_TYPES.FunctionExpression||r.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let n=Pt(r);if(n&&n.type===N.AST_NODE_TYPES.Identifier&&t.includes(n.name))return!0}else if(r.type===N.AST_NODE_TYPES.CallExpression){let n=Fn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function ki(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===N.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function Oi(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===N.AST_NODE_TYPES.FunctionDeclaration||n.type===N.AST_NODE_TYPES.FunctionExpression||n.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let s=Pt(n);if(s&&s.type===N.AST_NODE_TYPES.Identifier){if(vn(s.name)||qe(s.name)){r=!0;break}}else if(On(n)||Pn(n)){r=!0;break}}n=n.parent}return r?t.length===0?Ai(e):!vi(e,t):!1}var Ft=G({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{{message}}."},schema:[wi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(s=>[s.name,s]));return{CallExpression(s){let a=Fn(s);if(!a)return;let o=n.get(a);if(!o||o.allowUsingWithArgs&&ki(s))return;let i=o.allowUseInside||[];Oi(s,i)&&e.report({node:s,messageId:"preferHookAlternative",data:{message:o.message?` ${o.message}`:` use ${o.hookAlternative} instead`},suggest:o.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${o.hookAlternative}`,hookAlternative:o.hookAlternative},fix:l=>{let p=o.hookAlternative;return s.callee.type===N.AST_NODE_TYPES.Identifier?l.replaceText(s.callee,p):s.callee.type===N.AST_NODE_TYPES.MemberExpression&&s.callee.property.type===N.AST_NODE_TYPES.Identifier?l.replaceText(s.callee.property,p):null}}]:[]})}}}});var J=require("@typescript-eslint/utils");var Pi=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dn="prefer-single-line-if",Fi=H({maxLineLength:_(fe()),maxNonSimpleConditionLength:_(fe())}),Ni=Pi({name:Dn,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:[Fi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==J.AST_NODE_TYPES.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(a.type===J.AST_NODE_TYPES.ReturnStatement){if(!Mn(a))return}else if(!(a.type===J.AST_NODE_TYPES.ContinueStatement||a.type===J.AST_NODE_TYPES.BreakStatement))return;if(n.test.type===J.AST_NODE_TYPES.LogicalExpression||n.test.type===J.AST_NODE_TYPES.ConditionalExpression)return;let o;if(t.maxNonSimpleConditionLength){let u=Nn(n.test);if(!u&&n.test.type===J.AST_NODE_TYPES.UnaryExpression&&n.test.operator==="!"){let S=n.test.argument;Nn(S)&&(u=!0)}if(u&&(o=r.getText(n.test),o.length>t.maxNonSimpleConditionLength))return}o||(o=r.getText(n.test));let i=r.getText(a);if(o.includes(`
|
|
16
|
-
`))return;let l=r.getTokenAfter(n);if(l&&l.type===J.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let u=r.getTokenAfter(l);if(u&&u.type===J.AST_TOKEN_TYPES.Keyword&&(u.value==="else"||u.value==="catch"))return}let p=Di(r,n),c=`if (${o}) ${i}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:u=>u.replaceText(n,c)})}}}});function Nn(e){return e.type===J.AST_NODE_TYPES.CallExpression||e.type===J.AST_NODE_TYPES.BinaryExpression||e.type===J.AST_NODE_TYPES.MemberExpression&&jn(e)}function jn(e){return e.object.type===J.AST_NODE_TYPES.MemberExpression?jn(e.object):e.object.type!==J.AST_NODE_TYPES.Identifier}function Di(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Mn(e){if(!e.argument)return!0;let t=e.argument;return t.type===J.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===J.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===J.AST_NODE_TYPES.Literal||t.type===J.AST_NODE_TYPES.Identifier||t.type===J.AST_NODE_TYPES.TemplateLiteral||t.type===J.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===J.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===J.AST_NODE_TYPES.UnaryExpression?Mn(t):!1}var Nt={name:Dn,rule:Ni};var re=require("@typescript-eslint/utils");var ji=re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ln="react-compiler-migration",Mi=H({disallowHooks:_(K(H({name:V(),replacement:V()}))),disallowMethods:_(K(H({name:V(),replacement:_(V()),requireTrueProp:_(V())})))}),Li=/eslint +react-compiler\/react-compiler: +\["error/;function _i(e){return e.type===re.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===re.AST_NODE_TYPES.MemberExpression&&e.property.type===re.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var $i=ji({name:Ln,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 r=!1;for(let n of e.sourceCode.getAllComments())if(Li.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let s=null,a=null;if(n.callee.type===re.AST_NODE_TYPES.Identifier?(s=n.callee.name,a=n.callee):n.callee.type===re.AST_NODE_TYPES.MemberExpression&&n.callee.property.type===re.AST_NODE_TYPES.Identifier&&(s=n.callee.property.name,a=n.callee.property),s){let o=t.disallowHooks.find(i=>i.name===s);o&&a&&e.report({node:n,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&&_i(n.callee)){for(let s of n.arguments)if(s.type===re.AST_NODE_TYPES.ObjectExpression){for(let a of s.properties)if(a.type===re.AST_NODE_TYPES.Property&&a.key.type===re.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,p=!1;for(let c of s.properties)if(c.type===re.AST_NODE_TYPES.Property&&c.key.type===re.AST_NODE_TYPES.Identifier&&c.key.name===l&&c.value.type===re.AST_NODE_TYPES.Literal&&c.value.value===!0){p=!0;break}if(!p){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)}]})}}}}}}:{}}}),Dt={name:Ln,rule:$i};var Xe=require("@typescript-eslint/utils"),Ui=Xe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_n="require-description",Wi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Vi=/^eslint-disable-(next-)?line$/u,Hi=Ui({name:_n,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 r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let a=zi(s);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Ji(s.loc),messageId:"missingDescription"}))}}}}}),$n={name:_n,rule:Hi};function zi(e){let{text:t,description:r}=Yi(e.value);if(!t)return null;let n=Wi.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let a=Vi.test(s);if(e.type===Xe.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let o=t.slice(n.index+s.length);return{kind:s,value:o.trim(),description:r}}function Yi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Ji(e){return{start:{line:e.start.line,column:-1},end:e.end}}var Z=require("@typescript-eslint/utils"),xe=require("zod/v4");var Bi=xe.z.object({varsToCheck:xe.z.array(xe.z.object({selector:xe.z.string().optional(),fromFnCall:xe.z.string().optional(),prop:xe.z.string(),errorMsg:xe.z.string().optional()}))}),jt=G({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'Property "{{prop}}" from variable "{{varName}}" is never read. {{customMsg}}'},schema:[Oe(Bi)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map,n={};for(let s of t.varsToCheck)s.selector&&(n[s.selector]=a=>{a.type===Z.AST_NODE_TYPES.VariableDeclarator&&a.id.type===Z.AST_NODE_TYPES.Identifier&&r.set(a.id.name,{prop:s.prop,errorMsg:s.errorMsg,node:a.id})});for(let s of t.varsToCheck)if(s.fromFnCall){let a=s.fromFnCall;if(a.startsWith("*.")){let i=`VariableDeclarator > CallExpression > MemberExpression[property.name="${a.slice(2)}"]`;n[i]=l=>{if(l.type!==Z.AST_NODE_TYPES.MemberExpression)return;let c=l.parent.parent;c.id.type===Z.AST_NODE_TYPES.Identifier&&r.set(c.id.name,{prop:s.prop,errorMsg:s.errorMsg,node:c.id})}}else if(a.includes(".")){let[o,i]=a.split("."),l=`VariableDeclarator > CallExpression > MemberExpression[object.name="${o}"][property.name="${i}"]`;n[l]=p=>{if(p.type!==Z.AST_NODE_TYPES.MemberExpression)return;let u=p.parent.parent;u.id.type===Z.AST_NODE_TYPES.Identifier&&r.set(u.id.name,{prop:s.prop,errorMsg:s.errorMsg,node:u.id})}}else{let o=`VariableDeclarator > CallExpression > Identifier[name="${a}"]`;n[o]=i=>{if(i.type!==Z.AST_NODE_TYPES.Identifier)return;let p=i.parent.parent;p.id.type===Z.AST_NODE_TYPES.Identifier&&r.set(p.id.name,{prop:s.prop,errorMsg:s.errorMsg,node:p.id})}}}return{...n,"Program:exit"(){for(let[s,{prop:a,errorMsg:o,node:i}]of r){let p=e.sourceCode.getScope(i).set.get(s);if(p){let c=!1;for(let u of p.references){let S=u.identifier,y=S.parent;if(!(y.type===Z.AST_NODE_TYPES.VariableDeclarator&&y.id===S)){if(y.type===Z.AST_NODE_TYPES.MemberExpression&&y.object===S&&y.property.type===Z.AST_NODE_TYPES.Identifier&&y.property.name===a){c=!0;break}if(y.type===Z.AST_NODE_TYPES.VariableDeclarator&&y.init===S&&y.id.type===Z.AST_NODE_TYPES.ObjectPattern){for(let E of y.id.properties)if(E.type===Z.AST_NODE_TYPES.Property&&E.key.type===Z.AST_NODE_TYPES.Identifier&&E.key.name===a){c=!0;break}if(c)break}if(!(y.type===Z.AST_NODE_TYPES.MemberExpression&&y.object===S&&y.property.type===Z.AST_NODE_TYPES.Identifier&&y.property.name!==a)){c=!0;break}}}c||e.report({node:i,messageId:"propNotRead",data:{prop:a,varName:s,customMsg:o||""}})}}}}}});function Vn(e){return/^use[A-Z0-9]/.test(e)}function Ge(e){return e.type==="Identifier"?Vn(e.name):e.type==="MemberExpression"&&!e.computed&&Ge(e.property)?e.object.type==="Identifier":!1}function Hn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function zn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Yn(e){return!!(e.parent&&e.parent.callee&&zn(e.parent.callee,"forwardRef"))}function Jn(e){return!!(e.parent&&e.parent.callee&&zn(e.parent.callee,"memo"))}function Mt(e){for(;e;){let t=qn(e);if(t&&(Hn(t)||Ge(t))||Yn(e)||Jn(e))return!0;e=e.parent}return!1}function Un(e){return!1}function Lt(e){return!1}var qi=/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(qi.test(l.value))return{CallExpression(p){let c=null;p.callee.name==="useMemo"?c="useMemo":p.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:p,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,s=[],a=[],o=new WeakSet;function i(l){for(let p of l.references){let c=p.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&Un(c.init.callee))for(let u of p.resolved.references)u!==p&&o.add(u.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(l,p){let c=s.pop();if(c.size===0)return;let u=new Set;function S(T,m){let{cache:g}=S,R=g.get(T.id),w=new Set(m);if(w.has(T.id)){let b=[...w],F=b.slice(b.indexOf(T.id)+1);for(let Y of F)u.add(Y);return BigInt("0")}if(w.add(T.id),R!==void 0)return R;if(l.thrownSegments.includes(T))R=BigInt("0");else if(T.prevSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let b of T.prevSegments)R+=S(b,w)}return T.reachable&&R===BigInt("0")?g.delete(T.id):g.set(T.id,R),R}function y(T,m){let{cache:g}=y,R=g.get(T.id),w=new Set(m);if(w.has(T.id)){let b=Array.from(w),F=b.slice(b.indexOf(T.id)+1);for(let Y of F)u.add(Y);return BigInt("0")}if(w.add(T.id),R!==void 0)return R;if(l.thrownSegments.includes(T))R=BigInt("0");else if(T.nextSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let b of T.nextSegments)R+=y(b,w)}return g.set(T.id,R),R}function E(T){let{cache:m}=E,g=m.get(T.id);if(g===null)return 1/0;if(g!==void 0)return g;if(m.set(T.id,null),T.prevSegments.length===0)g=1;else{g=1/0;for(let R of T.prevSegments){let w=E(R);w<g&&(g=w)}g+=1}return m.set(T.id,g),g}S.cache=new Map,y.cache=new Map,E.cache=new Map;let x=y(l.initialSegment),v=qn(p),C=Mt(p),M=v?Hn(v)||Ge(v):Yn(p)||Jn(p),P=1/0;for(let T of l.finalSegments){if(!T.reachable)continue;let m=E(T);m<P&&(P=m)}for(let[T,m]of c){if(!T.reachable)continue;let g=T.nextSegments.length===0?P<=E(T):P<E(T),R=S(T)*y(T),w=u.has(T.id);for(let b of m)if(w&&!Lt(b)&&e.report({node:b,message:`React Hook "${t(b)}" 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.`}),M){if(p.async&&e.report({node:b,message:`React Hook "${t(b)}" cannot be called in an async function.`}),!w&&R!==x&&!Lt(b)){let Y=`React Hook "${t(b)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(g?" Did you accidentally call a React Hook after an early return?":"");e.report({node:b,message:Y})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let F=`React Hook "${t(b)}" 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:b,message:F})}else if(v){let F=`React Hook "${t(b)}" is called in function "${t(v)}" 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:b,message:F})}else if(p.type==="Program"){let F=`React Hook "${t(b)}" 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:b,message:F})}else if(C&&!Lt(b)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let Y=p.parent;if(Y.parent.type==="VariableDeclarator"&&Vn(Y.parent.id.name))return}let F=`React Hook "${t(b)}" 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:b,message:F})}}},CallExpression(l){if(Ge(l.callee)){let p=Wn(s),c=Wn(a),u=p.get(c);u||(u=[],p.set(c,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Un(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==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===n&&(n=null)},FunctionDeclaration(l){Mt(l)&&i(r(l))},ArrowFunctionExpression(l){Mt(l)&&i(r(l))}}}};function qn(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 Wn(e){return e[e.length-1]}var _t=require("@typescript-eslint/utils");function Xi(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function Gi(e){let t=e.parent;return t?.type===_t.AST_NODE_TYPES.NewExpression&&t.callee.type===_t.AST_NODE_TYPES.Identifier&&t.callee.name==="RegExp"}var $t=G({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function t(r){Xi(r)||Gi(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});var Xn={[vt.name]:vt.rule,[ct.name]:ct.rule,[pt.name]:pt.rule,"rules-of-hooks":Bn,"exhaustive-deps":en,"require-description":$n.rule,[ut.name]:ut.rule,[mt.name]:mt.rule,[Ot.name]:Ot.rule,[tt.name]:tt.rule,[lt.name]:lt.rule,[Tt.name]:Tt.rule,[Nt.name]:Nt.rule,[St.name]:St.rule,[ft.name]:ft.rule,[rt.name]:rt.rule,[Dt.name]:Dt.rule,[et.name]:et.rule,[at.name]:at.rule,[xt.name]:xt.rule,[Ct.name]:Ct.rule,[wt.name]:wt.rule,[Rt.name]:Rt.rule,[It.name]:It.rule,[Ft.name]:Ft.rule,[Et.name]:Et.rule,[ht.name]:ht.rule,[$t.name]:$t.rule,[kt.name]:kt.rule,[jt.name]:jt.rule};var Ki={rules:Xn};0&&(module.exports={extendedLintPlugin});
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let S=a.acquire(x),R=new Set,A=null;{let f=S.upper;for(;f&&(R.add(f),f.type!=="function");)f=f.upper;if(!f)return;A=f}let I=Array.isArray;function F(f){if(!I(f.defs))return!1;let g=f.defs[0];if(g==null||g.node.type!=="VariableDeclarator")return!1;let w=g.node.init;if(w==null)return!1;for(;w.type==="TSAsExpression";)w=w.expression;let v=g.node.parent;if(v==null&&(ot(A.block,g.node.id),v=g.node.parent,v==null))return!1;if(v.kind==="const"&&w.type==="Literal"&&(typeof w.value=="string"||typeof w.value=="number"||w.value===null))return!0;if(w.type!=="CallExpression")return!1;let O=w.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let k=g.node.id,{name:D}=O;if(D==="useRef"&&k.type==="Identifier")return!0;if(wn(O)&&k.type==="Identifier"){for(let j of f.references)j!==k&&y.add(j.identifier);return!0}else if(D==="useState"||D==="useReducer"){if(k.type==="ArrayPattern"&&k.elements.length===2&&I(f.identifiers)){if(k.elements[1]===f.identifiers[0]){if(D==="useState"){let j=f.references,oe=0;for(let ge=0;ge<j.length;ge++){if(j[ge].isWrite()&&oe++,oe>1)return!1;p.set(j[ge].identifier,k.elements[0])}}return!0}else if(k.elements[0]===f.identifiers[0]){if(D==="useState"){let j=f.references;for(let oe=0;oe<j.length;oe++)c.add(j[oe].identifier)}return!1}}}else if(D==="useTransition"&&k.type==="ArrayPattern"&&k.elements.length===2&&Array.isArray(f.identifiers)&&k.elements[1]===f.identifiers[0])return!0;return!1}function q(f){if(!I(f.defs))return!1;let g=f.defs[0];if(g==null||g.node==null||g.node.id==null)return!1;let w=g.node,v=A.childScopes,O=null,k;for(k=0;k<v.length;k++){let D=v[k],j=D.block;if(w.type==="FunctionDeclaration"&&j===w||w.type==="VariableDeclarator"&&j.parent===w){O=D;break}}if(O==null)return!1;for(k=0;k<O.through.length;k++){let D=O.through[k];if(D.resolved!=null&&R.has(D.resolved.scope)&&!X(D.resolved))return!1}return!0}let X=E(F,u),re=E(q,d),ee=new Map;function Ae(f){let g=f.from,w=!1;for(;g.block!==x;)g.type==="function"&&(w=g.block.parent!=null&&g.block.parent.type==="ReturnStatement"),g=g.upper;return w}let ie=new Map,De=new Map;de(S);function de(f){for(let g of f.references){if(!g.resolved||!R.has(g.resolved.scope))continue;let w=ot(x,g.identifier),v=tr(w),O=Se(v,De);if(m&&v.type==="Identifier"&&(v.parent.type==="MemberExpression"||v.parent.type==="OptionalMemberExpression")&&!v.parent.computed&&v.parent.property.type==="Identifier"&&v.parent.property.name==="current"&&Ae(g)&&ee.set(O,{reference:g,dependencyNode:v}),v.parent.type==="TSTypeQuery"||v.parent.type==="TSTypeReference")continue;let k=g.resolved.defs[0];if(k!=null&&!(k.node!=null&&k.node.init===x.parent)&&k.type!=="TypeParameter")if(ie.has(O))ie.get(O).references.push(g);else{let D=g.resolved,j=X(D)||re(D);ie.set(O,{isStable:j,references:[g]})}}for(let g of f.childScopes)de(g)}ee.forEach(({reference:f,dependencyNode:g},w)=>{let v=f.resolved.references,O=!1;for(let k=0;k<v.length;k++){let{identifier:D}=v[k],{parent:j}=D;if(j!=null&&j.type==="MemberExpression"&&!j.computed&&j.property.type==="Identifier"&&j.property.name==="current"&&j.parent.type==="AssignmentExpression"&&j.parent.left===j){O=!0;break}}O||s({node:g.parent.property,message:`The ref value '${w}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${w}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ue=new Set;function ye(f,g){ue.has(g)||(ue.add(g),s({node:f,message:`Assignments to the '${g}' variable from inside React Hook ${n(P)} 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(P)}.`}))}let Re=new Set;if(ie.forEach(({isStable:f,references:g},w)=>{f&&Re.add(w),g.forEach(v=>{v.writeExpr&&ye(v.writeExpr,w)})}),ue.size>0)return;if(!L){let f=null;if(ie.forEach(({isStable:g,references:w},v)=>{f||w.forEach(O=>{if(f)return;let k=O.identifier;if(!p.has(k))return;let j=O.from;for(;j.type!=="function";)j=j.upper;j.block===x&&(f=v)})}),f){let{suggestedDependencies:g}=it({dependencies:ie,declaredDependencies:[],stableDependencies:Re,externalDependencies:new Set,isEffect:!0});s({node:P,message:`React Hook ${b} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+g.join(", ")+`] as a second argument to the ${b} Hook.`,suggest:[{desc:`Add dependencies array: [${g.join(", ")}]`,fix(w){return w.insertTextAfter(x,`, [${g.join(", ")}]`)}}]})}return}let je=[],Me=new Set;L.type!=="ArrayExpression"?s({node:L,message:`React Hook ${n(P)} 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.`}):L.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){s({node:f,message:`React Hook ${n(P)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}y.has(f)&&s({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(f)}\``,fix(O){return O.removeRange(f.range)}}]});let g;try{g=Se(f,De)}catch(O){if(/Unsupported node type/.test(O.message)){f.type==="Literal"?ie.has(f.value)?s({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):s({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:f,message:`React Hook ${n(P)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let w=f;for(;w.type==="MemberExpression"||w.type==="OptionalMemberExpression"||w.type==="ChainExpression";)w=w.object||w.expression.object;let v=!A.through.some(O=>O.identifier===w);je.push({key:g,node:f}),v||Me.add(g)});let{suggestedDependencies:Xr,unnecessaryDependencies:$e,missingDependencies:he,duplicateDependencies:Ut}=it({dependencies:ie,declaredDependencies:je,stableDependencies:Re,externalDependencies:Me,isEffect:m}),Ue=Xr;if(Ut.size+he.size+$e.size===0){if(t)return;bn({declaredDependencies:je,declaredDependenciesNode:L,componentScope:A,scope:S}).forEach(({construction:g,isUsedOutsideOfHook:w,depType:v})=>{let O=v==="function"?"useCallback":"useMemo",k=v==="function"?"definition":"initialization",D=`wrap the ${k} of '${g.name.name}' in its own ${O}() Hook.`,j=w?`To fix this, ${D}`:`Move it inside the ${b} callback. Alternatively, ${D}`,oe=v==="conditional"||v==="logical expression"?"could make":"makes",ge=`The '${g.name.name}' ${v} ${oe} the dependencies of ${b} Hook (at line ${L.loc.start.line}) change on every render. ${j}`,Wt;w&&g.type==="Variable"&&v==="function"&&(Wt=[{desc:`Wrap the ${k} of '${g.name.name}' in its own ${O}() Hook.`,fix(Vt){let[Kr,Zr]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Vt.insertTextBefore(g.node.init,Kr),Vt.insertTextAfter(g.node.init,Zr)]}}]),s({node:g.node,message:ge,suggest:Wt})});return}!m&&he.size>0&&(Ue=it({dependencies:ie,declaredDependencies:[],stableDependencies:Re,externalDependencies:Me,isEffect:m}).suggestedDependencies);function Gr(){if(je.length===0)return!0;let f=je.map(w=>w.key),g=f.slice().sort();return f.join(",")===g.join(",")}Gr()&&Ue.sort();function Ke(f){let g=f.split("."),w="";for(let v=0;v<g.length;v++){if(v!==0){let O=g.slice(0,v+1).join("."),k=De.get(O)===!0;w+=k?"?.":"."}w+=g[v]}return w}function Ze(f,g,w,v){return f.size===0?null:(f.size>1?"":g+" ")+w+" "+(f.size>1?"dependencies":"dependency")+": "+Cn(Array.from(f).sort().map(O=>"'"+Ke(O)+"'"))+`. Either ${v} ${f.size>1?"them":"it"} or remove the dependency array.`}let pe="";if($e.size>0){let f=null;if(Array.from($e.keys()).forEach(g=>{f===null&&g.endsWith(".current")&&(f=g)}),f!==null)pe=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Me.size>0){let g=Array.from(Me)[0];S.set.has(g)||(pe=` Outer scope values like '${g}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!pe&&he.has("props")){let f=ie.get("props");if(f==null)return;let g=f.references;if(!Array.isArray(g))return;let w=!0;for(let v=0;v<g.length;v++){let O=g[v],k=ot(A.block,O.identifier);if(!k){w=!1;break}let D=k.parent;if(D==null){w=!1;break}if(D.type!=="MemberExpression"&&D.type!=="OptionalMemberExpression"){w=!1;break}}w&&(pe=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${b} call and refer to those specific props inside ${n(P)}.`)}if(!pe&&he.size>0){let f=null;he.forEach(g=>{if(f)return;let w=A.set.get(g),v=ie.get(g);if(v.references[0].resolved!==w)return;let O=w.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let k=!1,D;for(let j=0;j<v.references.length;j++)if(D=v.references[j].identifier,D!=null&&D.parent!=null&&(D.parent.type==="CallExpression"||D.parent.type==="OptionalCallExpression")&&D.parent.callee===D){k=!0;break}k&&(f=g)}),f!==null&&(pe=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!pe&&he.size>0){let f=null;if(he.forEach(g=>{if(f!==null)return;let v=ie.get(g).references,O,k;for(let D=0;D<v.length;D++){for(O=v[D].identifier,k=O.parent;k!=null&&k!==A.block;){if(k.type==="CallExpression"){let j=p.get(k.callee);if(j!=null){if(j.name===g)f={missingDep:g,setter:k.callee.name,form:"updater"};else if(c.has(O))f={missingDep:g,setter:k.callee.name,form:"reducer"};else{let oe=v[D].resolved;if(oe!=null){let ge=oe.defs[0];ge!=null&&ge.type==="Parameter"&&(f={missingDep:g,setter:k.callee.name,form:"inlineReducer"})}}break}}k=k.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":pe=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":pe=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":pe=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:L,message:`React Hook ${n(P)} has `+(Ze(he,"a","missing","include")||Ze($e,"an","unnecessary","exclude")||Ze(Ut,"a","duplicate","omit"))+pe,suggest:[{desc:`Update the dependencies array to be: [${Ue.map(Ke).join(", ")}]`,fix(f){return f.replaceText(L,`[${Ue.map(Ke).join(", ")}]`)}}]})}function T(x){let L=xn(x.callee,i);if(L===-1)return;let P=x.arguments[L],b=x.callee,m=rr(b).name,S=x.arguments[L+1],R=/Effect($|[^a-z])/g.test(m);if(!P){s({node:b,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!R)){if(!S&&!R){(m==="useMemo"||m==="useCallback")&&s({node:b,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(P.type){case"FunctionExpression":case"ArrowFunctionExpression":h(P,S,b,m,R);return;case"Identifier":if(!S||S.elements&&S.elements.some(F=>F&&F.type==="Identifier"&&F.name===P.name))return;let A=r(x).set.get(P.name);if(A==null||A.defs==null)return;let I=A.defs[0];if(!I||!I.node||I.type!=="Variable"&&I.type!=="FunctionName")break;switch(I.node.type){case"FunctionDeclaration":h(I.node,S,b,m,R);return;case"VariableDeclarator":let F=I.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":h(F,S,b,m,R);return}break}break;default:s({node:b,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:b,message:`React Hook ${m} has a missing dependency: '${P.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${P.name}]`,fix(A){return A.replaceText(S,`[${P.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let x of e.sourceCode.getAllComments())if(En.test(x.value))return t=!0,{CallExpression:L=>T(L,!0)}}return{CallExpression:x=>T(x)}}};function it({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:o}){let l=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((h,T)=>{let x=s(l,T);x.isUsed=!0,a(l,T,L=>{L.isSubtreeUsed=!0})}),t.forEach(({key:h})=>{let T=s(l,h);T.isSatisfiedRecursively=!0}),n.forEach(h=>{let T=s(l,h);T.isSatisfiedRecursively=!0});function s(h,T){let x=T.split("."),L=h;for(let P of x){let b=L.children.get(P);b||(b=i(),L.children.set(P,b)),L=b}return L}function a(h,T,x){let L=T.split("."),P=h;for(let b of L){let m=P.children.get(b);if(!m)return;x(m),P=m}}let p=new Set,c=new Set;u(l,p,c,h=>h);function u(h,T,x,L){h.children.forEach((P,b)=>{let m=L(b);if(P.isSatisfiedRecursively){P.isSubtreeUsed&&x.add(m);return}if(P.isUsed){T.add(m);return}u(P,T,x,S=>m+"."+S)})}let d=[],y=new Set,E=new Set;return t.forEach(({key:h})=>{c.has(h)?d.indexOf(h)===-1?d.push(h):E.add(h):y.add(h)}),p.forEach(h=>{d.push(h)}),{suggestedDependencies:d,unnecessaryDependencies:y,duplicateDependencies:E,missingDependencies:p}}function Ee(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return Ee(e.consequent)!=null||Ee(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Ee(e.left)!=null||Ee(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Ee(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Ee(e.expression);case"TSAsExpression":return Ee(e.expression)}return null}function bn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let o=e.map(({key:i})=>{let s=n.variables.find(p=>p.name===i);if(s==null)return null;let a=s.defs[0];if(a==null)return null;if(a.type==="Variable"&&a.node.type==="VariableDeclarator"&&a.node.id.type==="Identifier"&&a.node.init!=null){let p=Ee(a.node.init);if(p!=null)return[s,p]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[s,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function l(i){let s=!1;for(let a=0;a<i.references.length;a++){let p=i.references[a];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==r&&c!=null;)c=c.upper;if(c!==r&&!nr(t,p.identifier))return!0}return!1}return o.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:l(i)}))}function tr(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)?tr(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function st(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function Se(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=Se(e.object,t),r=Se(e.property,null),o=`${n}.${r}`;return st(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=Se(e.object,t),r=Se(e.property,null),o=`${n}.${r}`;return st(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=Se(n.object,t),o=Se(n.property,null),l=`${r}.${o}`;return st(n,t,l),l}else throw new Error(`Unsupported node type: ${e.type}`)}function rr(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function xn(e,t){let n=rr(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=Se(n,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(r)?0:-1}else return-1}}function ot(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),In(r,t))return r;if(nr(r,t))for(let[o,l]of Object.entries(r))o!=="parent"&&(Qt(l)?(l.parent=r,n.push(l)):Array.isArray(l)&&l.forEach(i=>{Qt(i)&&(i.parent=r,n.push(i))}))}return null}function Cn(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 Qt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function In(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 nr(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function wn(e){return!1}var be=require("@typescript-eslint/utils");var te=ve(require("typescript")),An=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ir="improved-no-unnecessary-condition",Rn=H({}),vn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],kn=new Set(vn),at={name:ir,rule:An({name:ir,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:[Rn]},defaultOptions:[{}],create(e){let t=be.ESLintUtils.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(s){return s.type===be.AST_NODE_TYPES.UnaryExpression&&s.operator==="typeof"}function o(s){return s.flags&te.default.TypeFlags.Any||s.flags&te.default.TypeFlags.Unknown?null:s.flags&te.default.TypeFlags.StringLike?["string"]:s.flags&te.default.TypeFlags.NumberLike?["number"]:s.flags&te.default.TypeFlags.BigIntLike?["bigint"]:s.flags&te.default.TypeFlags.BooleanLike?["boolean"]:s.flags&te.default.TypeFlags.ESSymbolLike?["symbol"]:s.flags&te.default.TypeFlags.Undefined||s.flags&te.default.TypeFlags.Void?["undefined"]:s.flags&te.default.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&te.default.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&te.default.TypeFlags.NonPrimitive?["object"]:s.flags&te.default.TypeFlags.Never?["never"]:null}function l(s){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(s),p=n.getTypeAtLocation(a.expression);if(p.flags&te.default.TypeFlags.Any||p.flags&te.default.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let d of p.types){let y=o(d);if(y)c.push(...y);else return null}return c}let u=o(p);return u?(c.push(...u),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(r(s.left)?(p=s.left,c=s.right.type===be.AST_NODE_TYPES.Literal&&typeof s.right.value=="string"?s.right.value:null):r(s.right)&&(p=s.right,c=s.left.type===be.AST_NODE_TYPES.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!On(c,kn))return;let u=l(p);if(!u)return;let d=s.operator==="!==",y=u.includes(c);u.length===1?y&&!d?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Pe(p,e),type:c}}):!y&&d?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Pe(p,e),type:Array.from(u)[0]}}):!y&&!d?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Pe(p,e),actualType:Ve(u),conditionType:c}}):y&&d&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Pe(p,e),actualType:Ve(u),conditionType:c}}):!y&&!d?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Pe(p,e),actualType:Ve(u),conditionType:c}}):!y&&d&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Pe(p,e),type:Ve(u)}})}return{BinaryExpression:i}}})};function Ve(e){return Array.from(new Set(e)).join(" | ")||"never"}function Pe(e,t){let n=e.argument;return n.type===be.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function On(e,t){return t.has(e)}var ze=require("@typescript-eslint/utils");var Pn=ze.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sr="no-call-with-explicit-generics",Fn=H({functions:Z(z())}),Nn=Pn({name:sr,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:[Fn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:o}=r;o.type===ze.AST_NODE_TYPES.Identifier&&n.has(o.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),lt={name:sr,rule:Nn};var Ce=require("@typescript-eslint/utils"),Dn=Ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),or="no-call-with-inferred-generics",jn=Dn({name:or,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:o}=r;if(o.type!==Ce.AST_NODE_TYPES.Identifier)return;let l=n.get(o.name);if(!l)return;let{minGenerics:i=1,allowAny:s,disallowTypes:a=t.disallowTypes}=l;(r.typeArguments?.params.length||0)<(i||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(s&&!a)&&r.typeArguments?.params?.some(c=>!s&&c.type===Ce.AST_NODE_TYPES.TSAnyKeyword||a&&c.type===Ce.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===Ce.AST_NODE_TYPES.Identifier&&a.includes(c.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),pt={name:or,rule:jn};var lr=require("@typescript-eslint/utils"),Mn=lr.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pr="no-commented-out-code",Ln=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],B={returnStatement:/^\s*return\s+/,stringAssignment:/\w=("|'|`)/,objectPropertyWithQuotes:/\w+:\s*('|"|`)/,computedPropertyAssignment:/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,kebabCaseProperty:/\w+-\w+:/,snakeCaseProperty:/\w+_\w+:/,ternaryOperator:/\?\s+\w/,colonWithWord:/:\s+\w/,quotedString:/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,numberWithComma:/^\s*\d+[,}]/,arrayWithComma:/^\s*\[[^\]]*\][,}]/,objectWithComma:/^\s*\{[^}]*\}[,}]/,methodCall:/\.\w+\(/,arrayAccess:/\[\w+\]/,quotedPropertyKey:/^\s*(['"`]).+?\1\s*:/,jsxSelfClosing:/^<[A-Z]\w*(\s|>|\/)/,jsxElement:/^<[a-z]+(\s|>|\/)/,jsxOpeningTag:/<[A-Z]\w*(\s.*)?>/,jsxClosingTag:/<\/[A-Z]\w*>/,htmlOpeningTag:/<[a-z]+(\s.*)?>/,htmlClosingTag:/<\/[a-z]+>/,colonDescriptiveComment:/^[a-zA-Z]+(\s+[a-zA-Z]+)*:\s+[a-zA-Z]+\s+[a-zA-Z][^{=,'"]*$/,jsdocComment:/^\s*[*\s]*$/},_n=[") {","return;",B.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",B.stringAssignment,");",B.objectPropertyWithQuotes,B.computedPropertyAssignment,B.kebabCaseProperty,B.snakeCaseProperty,"&&","||","()",B.ternaryOperator,B.colonWithWord,B.quotedString,B.numberWithComma,B.arrayWithComma,B.objectWithComma,B.methodCall,B.arrayAccess,"?.(","??","=>",B.quotedPropertyKey],$n=["/>","</",B.jsxSelfClosing,B.jsxElement,B.jsxOpeningTag,B.jsxClosingTag,B.htmlOpeningTag,B.htmlClosingTag],ar=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Un=Mn({name:pr,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(r,o){if(r.startsWith("/"))return!1;let l=r.trimStart();if(r.startsWith("*")||l.startsWith("eslint-disable")||r.includes("@deprecated")||r.includes("@example")||r.includes("@param")||r.includes("@returns")||r.includes("@throws")||r.includes("typescript-eslint")||r.includes("@ts-")||r.includes("prettier-ignore")||B.jsdocComment.test(r))return!1;for(let i of ar)if(l.startsWith(i))return!1;if(r.includes("https://")||l.includes(":")&&B.colonDescriptiveComment.test(l.trim()))return!1;if(o==="Block"){for(let i of $n)if(typeof i=="string"){if(r.includes(i))return{wrongPattern:i}}else if(i.test(r))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Ln)if(l.startsWith(i))return{wrongPattern:i};for(let i of _n)if(typeof i=="string"){if(r.includes(i))return{wrongPattern:i}}else if(i.test(r))return{wrongPattern:`regex(${i.toString()})`};return!1}function n(r,o){let l=r,i=l.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return l;if(o==="Block"&&l.includes("```")){let p=l.split(/```[\s\S]*?```/g);p.some(u=>/[a-zA-Z0-9]/.test(u))&&(l=p.join(""))}if(!l.includes("`"))return l;let s=l.split(/`[^`]*`/g);return s.some(p=>/[a-zA-Z0-9]/.test(p))?s.join(""):l}return{Program(){let o=e.sourceCode.getAllComments();for(let l of o){let i=n(l.value,l.type),s=t(i,l.type);s&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:ar.join(", ")}})}}}}}),ct={name:pr,rule:Un};var He=require("@typescript-eslint/utils"),Wn=He.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cr="no-default-export",Vn=Wn({name:cr,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===He.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ut={name:cr,rule:Vn};var ur=require("@typescript-eslint/utils"),zn=ur.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fr="no-leaked-text-in-jsx",Hn=[",",";","[","]","(",")"],Yn=zn({name:fr,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="";Hn.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),ft={name:fr,rule:Yn};var xe=require("@typescript-eslint/utils"),qn=xe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dr="no-non-camel-case-functions",Jn=/^(\$?[a-z][a-zA-Z0-9]*)$/;function mr(e){if(e.typeName.type!==xe.AST_NODE_TYPES.TSQualifiedName)return!1;let{left:t,right:n}=e.typeName;return t.type===xe.AST_NODE_TYPES.Identifier&&t.name==="JSX"&&n.name==="Element"}var Bn=qn({name:dr,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&&!Jn.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===xe.AST_NODE_TYPES.TSTypeReference?mr(n):n.type===xe.AST_NODE_TYPES.TSUnionType&&n.types.some(o=>o.type===xe.AST_NODE_TYPES.TSTypeReference&&mr(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),mt={name:dr,rule:Bn};var W=require("@typescript-eslint/utils");var dt=require("@typescript-eslint/utils");function Fe(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:Fe(e.parent,t,n===1/0?n:n-1)}function*yt(e){yield e,e.parent&&(yield*yt(e.parent))}function gt(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function yr(e,t,n){let o=n.getDeclaredVariables(e).find(l=>l.name===t||l.identifiers[0]?.parent.type===dt.AST_NODE_TYPES.Property&&l.identifiers[0]?.parent.key.type===dt.AST_NODE_TYPES.Identifier&&l.identifiers[0]?.parent.key.name===t);return o?o.references.filter(l=>!l.init):[]}var Xn=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gr="no-optional-root-props",Gn=Xn({name:gr,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let l=e.sourceCode.getDeclaredVariables(r)[0];if(!l||l.references.length!==1)return!1;let i=l.references[0];if(!i)return!1;for(let s of yt(i.identifier)){if("returnType"in s||s.type===W.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let a=s.parent;if(!a)return!1;if(a.type===W.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&a.parent.type===W.TSESTree.AST_NODE_TYPES.TSTypeReference&&a.parent.typeName.type===W.TSESTree.AST_NODE_TYPES.Identifier&&a.parent.typeName.name==="FC"){let c=Fe(a.parent.parent,W.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let u=Ye(c,e.sourceCode);return u?!(u.parent.type===W.TSESTree.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===W.TSESTree.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(s.type===W.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(a.type===W.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let p=Fe(a,W.TSESTree.AST_NODE_TYPES.VariableDeclaration);return p?!!Ye(p,e.sourceCode):!1}if(a.type===W.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Ye(a,e.sourceCode)}return!1}function n(r){r.key.type!==W.TSESTree.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:o=>{let l=Fe(r,W.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!l)return null;let i=e.sourceCode.getText(l);return o.replaceText(l,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===W.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(qe(r)||!t(r)))for(let o of r.typeAnnotation.members)o.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSInterfaceDeclaration(r){if(!(qe(r)||!t(r)))for(let o of r.body.body)o.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSTypeReference(r){if(r.typeName.type!==W.TSESTree.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let o=r.typeArguments.params[0];if(o.type!==W.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let l=Fe(r.parent,W.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!l)return;let i=Ye(l,e.sourceCode);if(!(!i||i.parent.type===W.TSESTree.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===W.TSESTree.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let a of o.members)a.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(a)}}}});function qe(e){return e?e.parent?.type===W.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===W.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ye(e,t){if(qe(e))return;let n;if(e.type===W.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===W.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===W.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let o=r.variables.find(i=>i.identifiers.includes(n));if(!o)return;let l=o.references.filter(i=>i.identifier!==n);if(!(l.length!==1||!l[0])&&!qe(l[0].identifier.parent.parent))return l[0].identifier}var St={name:gr,rule:Gn};var Sr=require("@typescript-eslint/utils"),Je=ve(require("path"));var Kn=Sr.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tr="no-relative-imports",Zn=H({find:z(),replacement:z()}),Qn=H({aliases:Z(Zn),rootDir:$(z()),allowNotFoundAliases:$(ke()),_dev_simulateFileName:$(z())}),ei=Kn({name:Tr,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:[Qn]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(i){return i.startsWith(".")||i.startsWith("..")}function o(i,s){let a=Je.default.dirname(s);return Je.default.resolve(a,i)}function l(i){let s=t.rootDir??process.cwd(),a=Je.default.relative(s,i);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:p,replacement:c}of t.aliases)if(a.startsWith(c)){let u=a.replace(c,p);return{alias:p,newPath:u}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!r(s))return;let a=o(s,n),p=l(a);!p&&t.allowNotFoundAliases||e.report({node:i,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(i.source,`'${p.newPath}'`):void 0})}}}}),Tt={name:Tr,rule:ei};var Le=require("@typescript-eslint/utils"),Ie=ve(require("zod/v4"));var ti=Ie.object({alternativeMsgs:Ie.object({inArrayFind:Ie.string().optional(),inArrayFilter:Ie.string().optional()}).optional(),__dev_simulateFileName:Ie.string().optional()});function ri(e){return e.typeAnnotation.type!==Le.AST_NODE_TYPES.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function ni(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ii(e){let t=e.parent;for(;t;){if(t.type===Le.AST_NODE_TYPES.CallExpression&&t.callee.type===Le.AST_NODE_TYPES.MemberExpression&&t.callee.property.type===Le.AST_NODE_TYPES.Identifier){let n=t.callee.property.name;if(n==="filter"||n==="find")return{method:n}}t=t.parent}return null}var ht=K({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[Oe(ti)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let n=t.__dev_simulateFileName??e.filename;if(ni(n))return{};function r(o){if(!ri(o))return;let l=ii(o),i=[];if(t.alternativeMsgs&&l){let s=l.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(s){let a=l.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:a,data:{message:s}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":r,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":r,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":r}}});var we=require("@typescript-eslint/utils");var si="no-unnecessary-async-on-jsx-props";function oi(e){if(e.body.type!==we.AST_NODE_TYPES.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let n=t[0];return!n||n.type!==we.AST_NODE_TYPES.ExpressionStatement?!1:n.expression.type===we.AST_NODE_TYPES.AwaitExpression}var Et=K({name:si,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(n){oi(n)&&e.report({node:n,messageId:"unnecessaryAsyncInJsxProp",fix(r){let o=e.sourceCode,l=[],i=o.getFirstToken(n,a=>a.value==="async");if(i){let a=o.getTokenAfter(i);a?l.push(r.replaceTextRange([i.range[0],a.range[0]],"")):l.push(r.remove(i))}function s(a){if(a.type===we.AST_NODE_TYPES.AwaitExpression){let p=o.getFirstToken(a);if(p&&p.value==="await"){let c=o.getTokenAfter(p);c?l.push(r.replaceTextRange([p.range[0],c.range[0]],"")):l.push(r.remove(p))}}if(a.type===we.AST_NODE_TYPES.BlockStatement)for(let p of a.body)s(p);else a.type===we.AST_NODE_TYPES.ExpressionStatement&&s(a.expression)}return s(n.body),l}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});var Te=require("@typescript-eslint/utils");var bt=ve(require("typescript")),ai=Te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hr="no-unnecessary-casting",li=H({additionalCastFunctions:$(Z(H({name:z(),expectedType:Ht(["string","number"])})))}),xt={name:hr,rule:ai({name:hr,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:[li],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],o=Te.ESLintUtils.getParserServices(e,!0),l=o.program?.getTypeChecker();if(!l||!o.program)throw new Error("TypeScript services or program not available");function i(c,u){switch(c.type){case Te.AST_NODE_TYPES.Literal:return u==="number"?typeof c.value=="number":typeof c.value=="string";case Te.AST_NODE_TYPES.TemplateLiteral:return u==="string";case Te.AST_NODE_TYPES.UnaryExpression:return u==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function s(c,u){return u==="number"?!!(c.flags&bt.TypeFlags.NumberLike):!!(c.flags&bt.TypeFlags.StringLike)}function a(c,u){return d=>d.replaceText(c,e.sourceCode.getText(u))}function p(c){if(!l||c.arguments.length!==1)return;let u=c.arguments[0];if(!u||u.type===Te.AST_NODE_TYPES.SpreadElement)return;let{callee:d}=c;if(d.type!==Te.AST_NODE_TYPES.Identifier)return;let y=d.name,E=r.find(T=>T.name===y);if(!E)return;if(i(u,E.expectedType)||s(l.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),E.expectedType)){let T,x;y==="Number"?T="unnecessaryNumberCasting":y==="String"?T="unnecessaryStringCasting":(T="unnecessaryCustomCasting",x={name:E.name,type:E.expectedType}),e.report({node:c,messageId:T,...x?{data:x}:{},fix:a(c,u)})}}return{CallExpression:p}}})};var _e=require("@typescript-eslint/utils"),ae=ve(require("zod/v4"));var pi=ae.object({methods:ae.union([ae.array(ae.string()),ae.literal("array")])}),Ct=K({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[ae.toJSONSchema(pi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let n=t.methods,r=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(s){return Array.isArray(n)?n.includes(s):r.has(s)}function l(s){let{callee:a}=s;if(a.type===_e.AST_NODE_TYPES.MemberExpression){let p=a.property;if(p.type===_e.AST_NODE_TYPES.Identifier)return p.name}return null}function i(s,a){if(s.type!==_e.AST_NODE_TYPES.Identifier||!s.typeAnnotation)return;let p=a.parent;if(p.type===_e.AST_NODE_TYPES.CallExpression){let c=l(p);c&&o(c)&&p.arguments.indexOf(a)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(d){return d.remove(s.typeAnnotation)}})}}return{ArrowFunctionExpression(s){for(let a of s.params)i(a,s)},FunctionExpression(s){for(let a of s.params)i(a,s)}}}});var se=require("@typescript-eslint/utils");var It=K({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===se.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==se.AST_NODE_TYPES.ObjectExpression||t.id.type===se.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===se.AST_NODE_TYPES.ExportNamedDeclaration)return;let n=new Map;for(let i of t.init.properties)i.type===se.AST_NODE_TYPES.Property&&i.key.type===se.AST_NODE_TYPES.Identifier&&n.set(i.key.name,i);if(n.size===0||t.id.type!==se.AST_NODE_TYPES.Identifier)return;let r=ci(t,e.sourceCode);if(r.length===0)return;let o=t.init.properties.some(i=>i.type!==se.AST_NODE_TYPES.Property?!1:i.value.type===se.AST_NODE_TYPES.FunctionExpression),l=new Set;for(let i of r){if(i.identifier.parent.type!==se.AST_NODE_TYPES.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===se.AST_NODE_TYPES.Literal&&typeof s.property.value=="string")l.add(s.property.value);else return;else{if(s.property.type!==se.AST_NODE_TYPES.Identifier)return;l.add(s.property.name)}if(s.parent.type===se.AST_NODE_TYPES.CallExpression&&o)return}for(let[i,s]of n)l.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function ci(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}var V=require("@typescript-eslint/utils");var ui=H({selectors:Z(H({name:z(),selectorProp:$(z()),selectorArgPos:$(fe()),returnProp:$(z())}))}),fi=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Er="no-unused-selected-values",wt={name:Er,rule:fi({name:Er,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[ui]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.map(o=>[o.name,o]));return{VariableDeclarator(o){let l=null;if(o.init?.type===V.AST_NODE_TYPES.CallExpression&&(l=o.init),!l)return;let i=di(l);if(!i)return;let s=r.get(i);if(!s)return;let a=mi(l,s.selectorArgPos??0,s.selectorProp);if(!a)return;let p=yi(a);if(!p)return;let c=br(p.properties,void 0);if(!c)return;if(o.id.type===V.AST_NODE_TYPES.ObjectPattern){let y=br(o.id.properties,s.returnProp);if(!y)return;for(let[E,h]of c)y.has(E)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:E}});return}if(o.id.type!==V.AST_NODE_TYPES.Identifier||s.returnProp)return;let u=gi(o,e.sourceCode);if(u.length===0)return;let d=new Set;for(let y of u){if(y.identifier.parent.type!==V.AST_NODE_TYPES.MemberExpression)return;let E=y.identifier.parent.property;if(E.type!==V.AST_NODE_TYPES.Identifier)return;d.add(E.name)}for(let[y,E]of c)d.has(y)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:y}})}}}})};function mi(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 o=r.properties.find(i=>i.type===V.AST_NODE_TYPES.Property&&i.key.type===V.AST_NODE_TYPES.Identifier&&i.key.name===n);if(o?.type!==V.AST_NODE_TYPES.Property)return null;let l=o.value;if(l.type===V.AST_NODE_TYPES.ArrowFunctionExpression||l.type===V.AST_NODE_TYPES.FunctionExpression)return l}return null}function di(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 yi(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 br(e,t){let n=e;if(t){let o=e.find(l=>l.type===V.AST_NODE_TYPES.Property&&l.key.type===V.AST_NODE_TYPES.Identifier&&l.key.name===t);if(o?.type!==V.AST_NODE_TYPES.Property||o.value.type!==V.AST_NODE_TYPES.ObjectPattern)return null;n=o.value.properties}let r=new Map;for(let o of n){if(o.type!==V.AST_NODE_TYPES.Property||o.key.type!==V.AST_NODE_TYPES.Identifier)return null;r.set(o.key.name,o)}return r.size>0?r:null}function gi(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}var Y=require("@typescript-eslint/utils");var At=K({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(l=>l.type===Y.AST_NODE_TYPES.ImportDeclaration&&l.source.value==="t-state-form"))return{};let r=null,o=!1;return{CallExpression(l){if(o)return;if(!r){let s=Si(l);s&&(r=s);return}let i=Ti(l,e.sourceCode);if(i){o=!0;for(let s of i)r.delete(s);if(r.size!==0)for(let[s,a]of r)e.report({node:a,messageId:"unusedField",data:{name:s}})}}}}});function Si(e){if(!(e.callee.type===Y.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==Y.AST_NODE_TYPES.ObjectExpression)return null;let r=gt(n.properties,l=>l.type!==Y.AST_NODE_TYPES.Property||l.key.type!==Y.AST_NODE_TYPES.Identifier||l.key.name!=="initialConfig"?null:l.value.type===Y.AST_NODE_TYPES.ObjectExpression?l.value:l.value.type===Y.AST_NODE_TYPES.ArrowFunctionExpression||l.value.type===Y.AST_NODE_TYPES.FunctionExpression?hi(l.value):null);if(!r)return null;let o=new Map;for(let l of r.properties)l.type===Y.AST_NODE_TYPES.Property&&l.key.type===Y.AST_NODE_TYPES.Identifier&&o.set(l.key.name,l);return o}function Ti(e,t){if(!(e.callee.type===Y.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==Y.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==Y.AST_NODE_TYPES.ObjectPattern||!gt(e.parent.id.properties,i=>i.type===Y.AST_NODE_TYPES.Property&&i.key.type===Y.AST_NODE_TYPES.Identifier&&i.key.name==="formFields"&&i))return null;let o=yr(e.parent,"formFields",t),l=new Set;for(let{identifier:i}of o){if(i.type!==Y.AST_NODE_TYPES.Identifier||i.parent.type===Y.AST_NODE_TYPES.Property&&i.parent.parent.type===Y.AST_NODE_TYPES.ObjectExpression&&i.parent.parent.parent.type===Y.AST_NODE_TYPES.ReturnStatement||i.parent.type===Y.AST_NODE_TYPES.ReturnStatement)return null;if(i.parent.type===Y.AST_NODE_TYPES.MemberExpression){if(i.parent.object.type!==Y.AST_NODE_TYPES.Identifier||i.parent.property.type!==Y.AST_NODE_TYPES.Identifier)return null;l.add(i.parent.property.name)}}return l}function hi(e){if(e.body.type===Y.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===Y.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===Y.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==Y.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var U=require("@typescript-eslint/utils");var Ei=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function xr(e){let t=[];for(let n of e.members)n.type===U.AST_NODE_TYPES.TSPropertySignature&&n.key.type===U.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function Cr(e,...t){for(let n of t)e.set(...n);return e}var bi=H({forceCheckOnFCPropTypesWithName:$(Z(z()))}),Ir="no-unused-type-props-in-args",Rt=null,xi=Ei({name:Ir,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:[bi],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Rt&&(Rt=n.map(s=>new RegExp(s)));function r(s,a,p,c,u=!0){let d=p.name,y=e.sourceCode.getScope(a).references.find(T=>T.identifier.name===d)?.resolved,E=s&&Rt?.some(T=>T.test(d));if(!y||!E&&y.references.filter(T=>T.isTypeReference).length>1)return;let h=y?.defs[0]?.node;if(!(u&&h?.parent?.type===U.AST_NODE_TYPES.ExportNamedDeclaration)){if(h?.type===U.AST_NODE_TYPES.TSTypeAliasDeclaration){o(s,a,c,h.typeAnnotation,!0);return}if(h?.type===U.AST_NODE_TYPES.TSInterfaceDeclaration){o(s,a,c,h.body,!0);return}}}function o(s,a,p,c,u){if(c.type===U.AST_NODE_TYPES.TSInterfaceBody){for(let d of c.body)d.type===U.AST_NODE_TYPES.TSPropertySignature&&d.key.type===U.AST_NODE_TYPES.Identifier&&p.set(d.key.name,d);return}if(c.type===U.AST_NODE_TYPES.TSTypeLiteral){Cr(p,...xr(c));return}if(c.type===U.AST_NODE_TYPES.TSIntersectionType){for(let d of c.types)o(s,a,p,d,!0);return}u||c.type===U.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===U.AST_NODE_TYPES.Identifier&&r(s,a,c.typeName,p)}function l(s,a,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let u=new Map;if(o(s,a,u,c.typeAnnotation.typeAnnotation,!1),u.size===0)continue;i(c,u)}else c.type===U.AST_NODE_TYPES.AssignmentPattern&&c.left.type===U.AST_NODE_TYPES.ObjectPattern&&l(s,a,[c.left])}function i(s,a){let p=[];if(s.properties.at(-1)?.type===U.AST_NODE_TYPES.RestElement)return;for(let y of s.properties)y.type===U.AST_NODE_TYPES.Property&&y.key.type===U.AST_NODE_TYPES.Identifier&&p.push(y.key.name);let u=[],d=[];for(let[y,E]of a)p.includes(y)||(d.push(y),u.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,E]of u.entries())e.report({...E,fix:y===u.length-1?h=>{let T=s.properties.at(-1),x=d.join(", ");return T?T?.type===U.AST_NODE_TYPES.RestElement?null:h.insertTextAfter(T,`, ${x}`):h.insertTextBeforeRange([s.range[0]+1,s.range[1]],`${x}`)}:void 0})}return{VariableDeclaration(s){let a=s.declarations[0];if(!a)return;let p=new Map,c=a.id.type===U.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===U.AST_NODE_TYPES.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===U.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===U.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===U.AST_NODE_TYPES.Identifier)r(!0,s,c.typeName,p,!1);else if(c.type===U.AST_NODE_TYPES.TSTypeLiteral)Cr(p,...xr(c));else if(c.type===U.AST_NODE_TYPES.TSIntersectionType)for(let u of c.types)u.type===U.AST_NODE_TYPES.TSTypeReference&&u.typeName.type===U.AST_NODE_TYPES.Identifier?r(!0,s,u.typeName,p,!1):o(!0,s,p,u,!0);if(p.size!==0&&a.init?.type===U.AST_NODE_TYPES.ArrowFunctionExpression){let u=a.init.params[0];if(!u){e.report({node:a.init,messageId:"missingComponentParam"});return}u.type===U.AST_NODE_TYPES.ObjectPattern&&i(u,p)}}},FunctionDeclaration:function(s){l(!1,s,s.params)},ArrowFunctionExpression(s){l(!1,s,s.params)}}}}),vt={name:Ir,rule:xi};var le=require("@typescript-eslint/utils");var kt=K({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function n(r){return r.callee.type===le.AST_NODE_TYPES.Identifier?t.has(r.callee.name):r.callee.type===le.AST_NODE_TYPES.MemberExpression&&r.callee.object.type===le.AST_NODE_TYPES.Identifier&&r.callee.property.type===le.AST_NODE_TYPES.Identifier?r.callee.property.name==="useRef":!1}return{ImportDeclaration(r){if(r.source.value==="react")for(let o of r.specifiers)o.type===le.AST_NODE_TYPES.ImportSpecifier&&o.imported.type===le.AST_NODE_TYPES.Identifier&&o.imported.name==="useRef"&&t.add(o.local.name)},VariableDeclarator(r){if(r.init&&r.init.type===le.AST_NODE_TYPES.CallExpression&&n(r.init)&&r.id.type===le.AST_NODE_TYPES.Identifier){let l=e.sourceCode.getScope(r).set.get(r.id.name);if(l){let i=!1;for(let s of l.references){let p=s.identifier.parent;if(p!==r&&!(p.type===le.AST_NODE_TYPES.JSXExpressionContainer&&p.parent.type===le.AST_NODE_TYPES.JSXAttribute&&p.parent.name.type===le.AST_NODE_TYPES.JSXIdentifier&&p.parent.name.name==="ref")){i=!0;break}}i||e.report({node:r.id,messageId:"refNotRead",data:{name:r.id.name}})}}}}}});var Ne=require("@typescript-eslint/utils"),Ci=Ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ar="prefer-named-functions",wr=new Map,Ii=Ci({name:Ar,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=wr.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),wr.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===Ne.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===Ne.AST_NODE_TYPES.Identifier){let o=r.id.name;if(r.id.typeAnnotation||n&&n.test(o)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==Ne.AST_NODE_TYPES.BlockStatement)return;let l=r.parent,i=r.init.params,s=r.init.body,a=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(l,`${a.async?"async ":""}function ${o}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),Ot={name:Ar,rule:Ii};var N=require("@typescript-eslint/utils");var wi=H({disallowedFunctions:Z(H({name:z(),allowUsingWithArgs:$(ke()),hookAlternative:$(z()),message:$(z()),allowUseInside:$(Z(z()))}))});function Be(e){return/^use[A-Z]/.test(e)}function Rr(e){return/^[A-Z]/.test(e)}function Ai(e){return e.type===N.AST_NODE_TYPES.Identifier?Be(e.name):e.type===N.AST_NODE_TYPES.MemberExpression&&e.property.type===N.AST_NODE_TYPES.Identifier?Be(e.property.name):!1}function vr(e,t){return e.type===N.AST_NODE_TYPES.Identifier?e.name===t:e.type===N.AST_NODE_TYPES.MemberExpression&&e.object.type===N.AST_NODE_TYPES.Identifier&&e.property.type===N.AST_NODE_TYPES.Identifier?e.object.name==="React"&&e.property.name===t:!1}function kr(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&vr(e.parent.callee,"forwardRef"))}function Or(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&vr(e.parent.callee,"memo"))}function Pt(e){if(e.type===N.AST_NODE_TYPES.FunctionDeclaration||e.type===N.AST_NODE_TYPES.FunctionExpression&&e.id)return e.id||void 0;if(e.type===N.AST_NODE_TYPES.FunctionExpression||e.type===N.AST_NODE_TYPES.ArrowFunctionExpression){if(e.parent.type===N.AST_NODE_TYPES.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===N.AST_NODE_TYPES.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===N.AST_NODE_TYPES.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===N.AST_NODE_TYPES.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Ri(e){let t=e.parent,n=!1;for(;t;){if(t.type===N.AST_NODE_TYPES.FunctionDeclaration||t.type===N.AST_NODE_TYPES.FunctionExpression||t.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let r=Pt(t);if(r&&r.type===N.AST_NODE_TYPES.Identifier){if(Rr(r.name)||Be(r.name))return!n;n=!0}else{if(kr(t)||Or(t))return!n;if(t.parent.type===N.AST_NODE_TYPES.CallExpression){let o=t.parent;Ai(o.callee)||(n=!0)}else t.parent.type===N.AST_NODE_TYPES.JSXExpressionContainer||(n=!0)}}t=t.parent}return!1}function Pr(e){return e.callee.type===N.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===N.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===N.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function vi(e,t){if(!t.length)return!1;let n=e.parent;for(;n;){if(n.type===N.AST_NODE_TYPES.FunctionDeclaration||n.type===N.AST_NODE_TYPES.FunctionExpression||n.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let r=Pt(n);if(r&&r.type===N.AST_NODE_TYPES.Identifier&&t.includes(r.name))return!0}else if(n.type===N.AST_NODE_TYPES.CallExpression){let r=Pr(n);if(r&&t.includes(r))return!0}n=n.parent}return!1}function ki(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===N.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function Oi(e,t){let n=!1,r=e.parent;for(;r;){if(r.type===N.AST_NODE_TYPES.FunctionDeclaration||r.type===N.AST_NODE_TYPES.FunctionExpression||r.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let o=Pt(r);if(o&&o.type===N.AST_NODE_TYPES.Identifier){if(Rr(o.name)||Be(o.name)){n=!0;break}}else if(kr(r)||Or(r)){n=!0;break}}r=r.parent}return n?t.length===0?Ri(e):!vi(e,t):!1}var Ft=K({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{{message}}."},schema:[wi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:n}=t,r=new Map(n.map(o=>[o.name,o]));return{CallExpression(o){let l=Pr(o);if(!l)return;let i=r.get(l);if(!i||i.allowUsingWithArgs&&ki(o))return;let s=i.allowUseInside||[];Oi(o,s)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:a=>{let p=i.hookAlternative;return o.callee.type===N.AST_NODE_TYPES.Identifier?a.replaceText(o.callee,p):o.callee.type===N.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===N.AST_NODE_TYPES.Identifier?a.replaceText(o.callee.property,p):null}}]:[]})}}}});var J=require("@typescript-eslint/utils");var Pi=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nr="prefer-single-line-if",Fi=H({maxLineLength:$(fe()),maxNonSimpleConditionLength:$(fe())}),Ni=Pi({name:Nr,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:[Fi]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==J.AST_NODE_TYPES.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let l=r.consequent.body[0];if(l.type===J.AST_NODE_TYPES.ReturnStatement){if(!jr(l))return}else if(!(l.type===J.AST_NODE_TYPES.ContinueStatement||l.type===J.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===J.AST_NODE_TYPES.LogicalExpression||r.test.type===J.AST_NODE_TYPES.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let u=Fr(r.test);if(!u&&r.test.type===J.AST_NODE_TYPES.UnaryExpression&&r.test.operator==="!"){let d=r.test.argument;Fr(d)&&(u=!0)}if(u&&(i=n.getText(r.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=n.getText(r.test));let s=n.getText(l);if(i.includes(`
|
|
16
|
+
`))return;let a=n.getTokenAfter(r);if(a&&a.type===J.AST_TOKEN_TYPES.Punctuator&&a.value==="}"){let u=n.getTokenAfter(a);if(u&&u.type===J.AST_TOKEN_TYPES.Keyword&&(u.value==="else"||u.value==="catch"))return}let p=Di(n,r),c=`if (${i}) ${s}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:u=>u.replaceText(r,c)})}}}});function Fr(e){return e.type===J.AST_NODE_TYPES.CallExpression||e.type===J.AST_NODE_TYPES.BinaryExpression||e.type===J.AST_NODE_TYPES.MemberExpression&&Dr(e)}function Dr(e){return e.object.type===J.AST_NODE_TYPES.MemberExpression?Dr(e.object):e.object.type!==J.AST_NODE_TYPES.Identifier}function Di(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function jr(e){if(!e.argument)return!0;let t=e.argument;return t.type===J.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===J.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===J.AST_NODE_TYPES.Literal||t.type===J.AST_NODE_TYPES.Identifier||t.type===J.AST_NODE_TYPES.TemplateLiteral||t.type===J.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===J.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===J.AST_NODE_TYPES.UnaryExpression?jr(t):!1}var Nt={name:Nr,rule:Ni};var ne=require("@typescript-eslint/utils");var ji=ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Mr="react-compiler-migration",Mi=H({disallowHooks:$(Z(H({name:z(),replacement:z()}))),disallowMethods:$(Z(H({name:z(),replacement:$(z()),requireTrueProp:$(z())})))}),Li=/eslint +react-compiler\/react-compiler: +\["error/;function _i(e){return e.type===ne.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===ne.AST_NODE_TYPES.MemberExpression&&e.property.type===ne.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var $i=ji({name:Mr,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(Li.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let o=null,l=null;if(r.callee.type===ne.AST_NODE_TYPES.Identifier?(o=r.callee.name,l=r.callee):r.callee.type===ne.AST_NODE_TYPES.MemberExpression&&r.callee.property.type===ne.AST_NODE_TYPES.Identifier&&(o=r.callee.property.name,l=r.callee.property),o){let i=t.disallowHooks.find(s=>s.name===o);i&&l&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(l,i.replacement)}]})}}if(t.disallowMethods?.length&&_i(r.callee)){for(let o of r.arguments)if(o.type===ne.AST_NODE_TYPES.ObjectExpression){for(let l of o.properties)if(l.type===ne.AST_NODE_TYPES.Property&&l.key.type===ne.AST_NODE_TYPES.Identifier){let i=l.key.name,s=t.disallowMethods.find(a=>a.name===i);if(s){if(s.requireTrueProp){let a=s.requireTrueProp,p=!1;for(let c of o.properties)if(c.type===ne.AST_NODE_TYPES.Property&&c.key.type===ne.AST_NODE_TYPES.Identifier&&c.key.name===a&&c.value.type===ne.AST_NODE_TYPES.Literal&&c.value.value===!0){p=!0;break}if(!p){e.report({node:l,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:a}});continue}}s.replacement&&e.report({node:l,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:a=>a.replaceText(l.key,s.replacement)}]})}}}}}}:{}}}),Dt={name:Mr,rule:$i};var Xe=require("@typescript-eslint/utils"),Ui=Xe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lr="require-description",Wi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Vi=/^eslint-disable-(next-)?line$/u,zi=Ui({name:Lr,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let o of n.getAllComments()){let l=Hi(o);l!=null&&(r.has(l.kind)||l.description||e.report({loc:qi(o.loc),messageId:"missingDescription"}))}}}}}),_r={name:Lr,rule:zi};function Hi(e){let{text:t,description:n}=Yi(e.value);if(!t)return null;let r=Wi.exec(t);if(!r)return null;let o=r[1];if(!o)return null;let l=Vi.test(o);if(e.type===Xe.TSESTree.AST_TOKEN_TYPES.Line&&!l||l&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(r.index+o.length);return{kind:o,value:i.trim(),description:n}}function Yi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function qi(e){return{start:{line:e.start.line,column:-1},end:e.end}}var M=require("@typescript-eslint/utils"),me=require("zod/v4");var Ji=me.z.object({varsToCheck:me.z.array(me.z.object({selector:me.z.string().optional(),fromFnCall:me.z.string().optional(),prop:me.z.string().or(me.z.array(me.z.string())),errorMsg:me.z.string().optional()}))}),jt=K({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[Oe(Ji)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let n=new Map,r=(i,s,a,p)=>{let c=new Set;for(let d of i.properties)d.type===M.AST_NODE_TYPES.Property&&d.key.type===M.AST_NODE_TYPES.Identifier&&c.add(d.key.name);let u=s.filter(d=>!c.has(d));if(u.length>0)if(u.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:u[0],fnName:p,customMsg:a||""}});else{let d=u.map(y=>`"${y}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:d,fnName:p,customMsg:a||""}})}},o=i=>{if(i.init?.type===M.AST_NODE_TYPES.CallExpression){if(i.init.callee.type===M.AST_NODE_TYPES.Identifier)return i.init.callee.name;if(i.init.callee.type===M.AST_NODE_TYPES.MemberExpression&&i.init.callee.property.type===M.AST_NODE_TYPES.Identifier)return i.init.callee.object.type===M.AST_NODE_TYPES.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"},l={};for(let i of t.varsToCheck)i.selector&&(l[i.selector]=s=>{if(s.type===M.AST_NODE_TYPES.VariableDeclarator&&s.id.type===M.AST_NODE_TYPES.Identifier&&n.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:o(s)}),s.type===M.AST_NODE_TYPES.VariableDeclarator&&s.id.type===M.AST_NODE_TYPES.ObjectPattern){let a=Array.isArray(i.prop)?i.prop:[i.prop];r(s.id,a,i.errorMsg,o(s))}});for(let i of t.varsToCheck)if(i.fromFnCall){let s=i.fromFnCall;if(s.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${s.slice(2)}"]`;l[p]=c=>{if(c.type!==M.AST_NODE_TYPES.MemberExpression||c.parent.type!==M.AST_NODE_TYPES.CallExpression)return;let u=c.parent;if(u.parent.type!==M.AST_NODE_TYPES.VariableDeclarator)return;let d=u.parent;if(d.id.type===M.AST_NODE_TYPES.Identifier)n.set(d.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:d.id,fnName:i.fromFnCall||"unknown function"});else if(d.id.type===M.AST_NODE_TYPES.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];r(d.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[a,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${a}"][property.name="${p}"]`;l[c]=u=>{if(u.type!==M.AST_NODE_TYPES.MemberExpression||u.parent.type!==M.AST_NODE_TYPES.CallExpression)return;let d=u.parent;if(d.parent.type!==M.AST_NODE_TYPES.VariableDeclarator)return;let y=d.parent;if(y.id.type===M.AST_NODE_TYPES.Identifier)n.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===M.AST_NODE_TYPES.ObjectPattern){let E=Array.isArray(i.prop)?i.prop:[i.prop];r(y.id,E,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let a=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;l[a]=p=>{if(p.type!==M.AST_NODE_TYPES.Identifier||p.parent.type!==M.AST_NODE_TYPES.CallExpression)return;let c=p.parent;if(c.parent.type!==M.AST_NODE_TYPES.VariableDeclarator)return;let u=c.parent;if(u.id.type===M.AST_NODE_TYPES.Identifier)n.set(u.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:u.id,fnName:i.fromFnCall||"unknown function"});else if(u.id.type===M.AST_NODE_TYPES.ObjectPattern){let d=Array.isArray(i.prop)?i.prop:[i.prop];r(u.id,d,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...l,"Program:exit"(){for(let[i,{props:s,errorMsg:a,node:p,fnName:c}]of n){let d=e.sourceCode.getScope(p).set.get(i);if(d){let y=new Set(s);for(let E of d.references){let h=E.identifier,T=h.parent;if(!(T.type===M.AST_NODE_TYPES.VariableDeclarator&&T.id===h)){if(T.type===M.AST_NODE_TYPES.MemberExpression&&T.object===h&&T.property.type===M.AST_NODE_TYPES.Identifier&&y.has(T.property.name)){if(y.delete(T.property.name),y.size===0)break;continue}if(T.type===M.AST_NODE_TYPES.VariableDeclarator&&T.init===h&&T.id.type===M.AST_NODE_TYPES.ObjectPattern){for(let x of T.id.properties)x.type===M.AST_NODE_TYPES.Property&&x.key.type===M.AST_NODE_TYPES.Identifier&&y.has(x.key.name)&&y.delete(x.key.name);if(y.size===0)break;continue}if(!(T.type===M.AST_NODE_TYPES.MemberExpression&&T.object===h&&T.property.type===M.AST_NODE_TYPES.Identifier&&!s.includes(T.property.name))){y.clear();break}}}if(y.size>0){let E=Array.from(y);if(E.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:E[0],fnName:c,customMsg:a||""}});else{let h=E.map(T=>`"${T}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:h,fnName:c,customMsg:a||""}})}}}}}}}});function Wr(e){return/^use[A-Z0-9]/.test(e)}function Ge(e){return e.type==="Identifier"?Wr(e.name):e.type==="MemberExpression"&&!e.computed&&Ge(e.property)?e.object.type==="Identifier":!1}function Vr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function zr(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Hr(e){return!!(e.parent&&e.parent.callee&&zr(e.parent.callee,"forwardRef"))}function Yr(e){return!!(e.parent&&e.parent.callee&&zr(e.parent.callee,"memo"))}function Mt(e){for(;e;){let t=Jr(e);if(t&&(Vr(t)||Ge(t))||Hr(e)||Yr(e))return!0;e=e.parent}return!1}function $r(e){return!1}function Lt(e){return!1}var Bi=/eslint +react-compiler\/react-compiler: +\["error/,qr={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let a of e.sourceCode.getAllComments())if(Bi.test(a.value))return{CallExpression(p){let c=null;p.callee.name==="useMemo"?c="useMemo":p.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:p,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),r=null,o=[],l=[],i=new WeakSet;function s(a){for(let p of a.references){let c=p.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&$r(c.init.callee))for(let u of p.resolved.references)u!==p&&i.add(u.identifier)}}return{onCodePathSegmentStart:a=>l.push(a),onCodePathSegmentEnd:()=>l.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(a,p){let c=o.pop();if(c.size===0)return;let u=new Set;function d(b,m){let{cache:S}=d,R=S.get(b.id),A=new Set(m);if(A.has(b.id)){let I=[...A],F=I.slice(I.indexOf(b.id)+1);for(let q of F)u.add(q);return BigInt("0")}if(A.add(b.id),R!==void 0)return R;if(a.thrownSegments.includes(b))R=BigInt("0");else if(b.prevSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let I of b.prevSegments)R+=d(I,A)}return b.reachable&&R===BigInt("0")?S.delete(b.id):S.set(b.id,R),R}function y(b,m){let{cache:S}=y,R=S.get(b.id),A=new Set(m);if(A.has(b.id)){let I=Array.from(A),F=I.slice(I.indexOf(b.id)+1);for(let q of F)u.add(q);return BigInt("0")}if(A.add(b.id),R!==void 0)return R;if(a.thrownSegments.includes(b))R=BigInt("0");else if(b.nextSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let I of b.nextSegments)R+=y(I,A)}return S.set(b.id,R),R}function E(b){let{cache:m}=E,S=m.get(b.id);if(S===null)return 1/0;if(S!==void 0)return S;if(m.set(b.id,null),b.prevSegments.length===0)S=1;else{S=1/0;for(let R of b.prevSegments){let A=E(R);A<S&&(S=A)}S+=1}return m.set(b.id,S),S}d.cache=new Map,y.cache=new Map,E.cache=new Map;let h=y(a.initialSegment),T=Jr(p),x=Mt(p),L=T?Vr(T)||Ge(T):Hr(p)||Yr(p),P=1/0;for(let b of a.finalSegments){if(!b.reachable)continue;let m=E(b);m<P&&(P=m)}for(let[b,m]of c){if(!b.reachable)continue;let S=b.nextSegments.length===0?P<=E(b):P<E(b),R=d(b)*y(b),A=u.has(b.id);for(let I of m)if(A&&!Lt(I)&&e.report({node:I,message:`React Hook "${t(I)}" 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.`}),L){if(p.async&&e.report({node:I,message:`React Hook "${t(I)}" cannot be called in an async function.`}),!A&&R!==h&&!Lt(I)){let q=`React Hook "${t(I)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(S?" Did you accidentally call a React Hook after an early return?":"");e.report({node:I,message:q})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let F=`React Hook "${t(I)}" 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:I,message:F})}else if(T){let F=`React Hook "${t(I)}" is called in function "${t(T)}" 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:I,message:F})}else if(p.type==="Program"){let F=`React Hook "${t(I)}" 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:I,message:F})}else if(x&&!Lt(I)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let q=p.parent;if(q.parent.type==="VariableDeclarator"&&Wr(q.parent.id.name))return}let F=`React Hook "${t(I)}" 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:I,message:F})}}},CallExpression(a){if(Ge(a.callee)){let p=Ur(o),c=Ur(l),u=p.get(c);u||(u=[],p.set(c,u)),u.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||$r(a.callee))&&a.arguments.length>0&&(r=a)},Identifier(a){r==null&&i.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===r&&(r=null)},FunctionDeclaration(a){Mt(a)&&s(n(a))},ArrowFunctionExpression(a){Mt(a)&&s(n(a))}}}};function Jr(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 Ur(e){return e[e.length-1]}var _t=require("@typescript-eslint/utils");function Xi(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function Gi(e){let t=e.parent;return t?.type===_t.AST_NODE_TYPES.NewExpression&&t.callee.type===_t.AST_NODE_TYPES.Identifier&&t.callee.name==="RegExp"}var $t=K({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function t(n){Xi(n)||Gi(n)||e.report({node:n,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});var Br={[vt.name]:vt.rule,[ct.name]:ct.rule,[pt.name]:pt.rule,"rules-of-hooks":qr,"exhaustive-deps":er,"require-description":_r.rule,[ut.name]:ut.rule,[mt.name]:mt.rule,[Ot.name]:Ot.rule,[tt.name]:tt.rule,[lt.name]:lt.rule,[Tt.name]:Tt.rule,[Nt.name]:Nt.rule,[St.name]:St.rule,[ft.name]:ft.rule,[nt.name]:nt.rule,[Dt.name]:Dt.rule,[et.name]:et.rule,[at.name]:at.rule,[xt.name]:xt.rule,[Ct.name]:Ct.rule,[wt.name]:wt.rule,[At.name]:At.rule,[It.name]:It.rule,[Ft.name]:Ft.rule,[Et.name]:Et.rule,[ht.name]:ht.rule,[$t.name]:$t.rule,[kt.name]:kt.rule,[jt.name]:jt.rule};var Ki={rules:Br};0&&(module.exports={extendedLintPlugin});
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{AST_NODE_TYPES as K,ESLintUtils as qn}from"@typescript-eslint/utils";var Je=Symbol.for("optional");function L(e){return{...e,[Je]:!0}}function Mt(e,t){return{enum:e,...t}}function Ce(e){return{...e,type:"boolean"}}function U(e){return{...e,type:"string"}}function fe(e){return{...e,type:"number"}}function G(e,t){return{...t,type:"array",items:e}}function W(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let n,s=[];for(n in e)e[n][Je]?e[n][Je]=void 0:s.push(n);s.length>0&&(r.required=s)}return r}var Xn=qn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="react-compiler-extra",Gn=W({runOnlyWithEnableCompilerDirective:L(Ce())}),Kn=/eslint +react-compiler\/react-compiler: +\["error/;function Zn(e){return e.type===K.Identifier?e.name.startsWith("use"):e.type===K.MemberExpression&&e.property.type===K.Identifier?e.property.name.startsWith("use"):!1}var Qn=/\bthis[.[]/;function Lt(e){return Qn.test(e)}var er=Xn({name:_t,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[Gn]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(Kn.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let o of a.properties)if(o.type===K.Property&&o.method&&o.value.type===K.FunctionExpression){let i=e.sourceCode,l=i.getText(o.key),p=o.value,c=i.getText(p.body);if(Lt(c))e.report({node:o,messageId:"thisKeywordInMethod"});else{let u=p.params.map(y=>i.getText(y)).join(", "),S="";p.generator?S=`${l}: function* (${u}) ${c}`:S=`${l}: (${u}) => ${c}`,e.report({node:o,messageId:"objectMethodIsNotSupported",fix:y=>y.replaceText(o,S)})}}}function s(a){for(let o of a.properties)if(o.type===K.Property&&o.value.type===K.ObjectExpression){for(let i of o.value.properties)if(i.type===K.Property&&i.method&&i.value.type===K.FunctionExpression){let p=e.sourceCode.getText(i.value.body);Lt(p)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Zn(a.callee))for(let o of a.arguments){if(o.type===K.ObjectExpression&&(n(o),s(o)),o.type===K.ArrowFunctionExpression&&(o.body.type===K.ObjectExpression&&(n(o.body),s(o.body)),o.body.type===K.BlockStatement))for(let i of o.body.body)i.type===K.ReturnStatement&&i.argument?.type===K.ObjectExpression&&(n(i.argument),s(i.argument));if(o.type===K.FunctionExpression)for(let i of o.body.body)i.type===K.ReturnStatement&&i.argument?.type===K.ObjectExpression&&(n(i.argument),s(i.argument))}}}}}),Be={name:_t,rule:er};import{AST_NODE_TYPES as ee}from"@typescript-eslint/utils";import{z as E}from"zod/v4";import{ESLintUtils as tr}from"@typescript-eslint/utils";import*as $t from"zod/v4";function q(e){let r=tr.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function Ie(e){return $t.toJSONSchema(e)}var nr=E.object({disallow:E.array(E.object({selector:E.string(),message:E.string(),replace:E.optional(E.union([E.string(),E.object({regex:E.string(),with:E.string()})])),replaceType:E.optional(E.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:E.optional(E.array(E.object({fn:E.string(),withArgs:E.optional(E.array(E.object({atIndex:E.number(),value:E.union([E.string(),E.number(),E.boolean()])}))),message:E.string(),replaceWith:E.optional(E.string()),ignoreRegex:E.optional(E.string())}))),__dev_simulateFileName:E.optional(E.string()),mustMatchSyntax:E.optional(E.array(E.object({includeRegex:E.string(),mustCallFn:E.optional(E.array(E.object({anyCall:E.array(E.object({fn:E.string(),withArgs:E.array(E.object({atIndex:E.number(),literal:E.union([E.string(),E.number(),E.boolean()])}))})),message:E.optional(E.string())}))),mustMatchSelector:E.optional(E.array(E.object({selector:E.string(),message:E.string()}))),mustHaveExport:E.optional(E.array(E.object({name:E.string(),type:E.enum(["function","variable","any"]).default("any"),message:E.string()})))})))}),qe=q({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Ie(nr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:s,disallow:a,disallowFnCalls:o}=t,i=s??e.filename,l=[],p=new Map,c=new Set,u=new Map,S=new Set,y=new Map;function h(m){for(let g of m.specifiers)g.type===ee.ImportSpecifier&&g.imported.type===ee.Identifier&&g.imported.name!==g.local.name&&y.set(g.local.name,g.imported.name)}function x(m){if(m.declaration){if(m.declaration.type===ee.FunctionDeclaration&&m.declaration.id){let g=m.declaration.id.name;for(let R of Array.from(S)){let[w,b]=R.split(":");w===g&&(b==="function"||b==="any")&&S.delete(R)}}else if(m.declaration.type===ee.VariableDeclaration){for(let g of m.declaration.declarations)if(g.id.type===ee.Identifier){let R=g.id.name;for(let w of Array.from(S)){let[b,F]=w.split(":");b===R&&(F==="variable"||F==="any")&&S.delete(w)}}}}for(let g of m.specifiers)if(g.exported.type===ee.Identifier){let R=g.exported.name;for(let w of Array.from(S)){let[b,F]=w.split(":");b===R&&F==="any"&&S.delete(w)}}}function v(m){m.id.type===ee.Identifier&&m.init?.type===ee.Identifier&&y.set(m.id.name,m.init.name)}function C(m){return y.get(m)??m}function M(m,g){return C(m)===g||m===g}for(let{includeRegex:m,mustCallFn:g,mustMatchSelector:R,mustHaveExport:w}of n??[]){let b=rr(i,new RegExp(m));if(!b)continue;let F=z=>{let B=z;for(let{name:te,value:Q}of b)B=B.replaceAll(te,Q);return B};for(let{anyCall:z,message:B}of g??[]){let te=`Expected file to call the function: ${z.map(({fn:Q})=>Q).join(" or ")}`;c.add(te),l.push(Q=>{let{callee:be}=Q;if(be.type===ee.Identifier){for(let{fn:re,withArgs:ve}of z)if(be.name===re){c.delete(te);for(let me of ve){let ue=Q.arguments[me.atIndex],de=typeof me.literal=="string"?F(me.literal):me.literal;if(!ue){e.report({node:Q,messageId:"default",data:{message:`Missing argument with value "${de}" at index ${me.atIndex}${B?`: ${F(B)}`:""}`}});continue}if(ue.type!==ee.Literal){e.report({node:ue,messageId:"default",data:{message:`Argument at position ${me.atIndex} should the literal "${de}"${B?`: ${F(B)}`:""}`}});continue}ue.value!==de&&e.report({node:ue,messageId:"default",data:{message:`Argument should have the value "${de}"${B?`: ${F(B)}`:""}`},fix:xe=>xe.replaceText(ue,typeof de=="string"?`'${de}'`:String(de))})}break}}})}for(let{selector:z,message:B}of R??[])u.set(z,F(B)),p.set(F(z),()=>{u.delete(z)});for(let{name:z,type:B,message:te}of w??[]){let Q=F(z),be=F(te);S.add(`${Q}:${B}:${be}`)}}for(let{fn:m,withArgs:g,message:R,replaceWith:w,ignoreRegex:b}of o??[])b&&new RegExp(b).test(i)||l.push(F=>{let{callee:z}=F;if(z.type!==ee.Identifier||!M(z.name,m))return;if(g)for(let te of g){let Q=F.arguments[te.atIndex];if(!Q){e.report({node:F,messageId:"default",data:{message:`Missing argument with value "${te.value}" at index ${te.atIndex}: ${R}`}});return}if(Q.type!==ee.Literal||Q.value!==te.value)return}let B=te=>w?te.replaceText(F,w):null;e.report({node:F,messageId:"default",data:{message:R},suggest:w?[{messageId:"default",data:{message:`Replace with "${w}"`},fix:B}]:void 0})});function P(m,g){let R=r[m];R?r[m]=w=>{R(w),g(w)}:r[m]=g}for(let{selector:m,message:g,replace:R,replaceType:w="suggestion"}of a??[]){if(m==="CallExpression"){l.push(b=>{T(R,b,g,w)});continue}r[m]=b=>{T(R,b,g,w)}}if(p.size>0)for(let[m,g]of p)P(m,g);return l.length>0&&(r.CallExpression=m=>{if(m.type===ee.CallExpression)for(let g of l)g(m)}),r.ImportDeclaration=m=>{m.type===ee.ImportDeclaration&&h(m)},r.ExportNamedDeclaration=m=>{m.type===ee.ExportNamedDeclaration&&x(m)},r.VariableDeclarator=m=>{m.type===ee.VariableDeclarator&&v(m)},r["Program:exit"]=m=>{for(let g of c)e.report({node:m,messageId:"default",data:{message:g}});for(let[,g]of u)e.report({node:m,messageId:"default",data:{message:g}});for(let g of S){let[R,w,b]=g.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${R}" of type ${w}: ${b}`}})}},r;function T(m,g,R,w){let b=F=>{if(!m)return null;if(typeof m=="string")return F.replaceText(g,m);{let z=new RegExp(m.regex),B=e.sourceCode.getText(g);return F.replaceText(g,B.replace(z,m.with))}};e.report({node:g,messageId:"default",data:{message:R},fix:m&&w==="autofix"?b:void 0,suggest:m&&w==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:b}]:void 0})}}});function rr(e,t){let r=[],n=t.exec(e);if(!n)return null;let[s,...a]=n;r.push({name:"$0_lowercase",value:s.toLowerCase()}),r.push({name:"$0_capitalize",value:Ut(s)}),r.push({name:"$0_uncapitalize",value:Wt(s)}),r.push({name:"$0",value:s});for(let o=0;o<a.length;o++){let i=`$${o+1}`,l=a[o];r.push({name:`${i}_lowercase`,value:l.toLowerCase()}),r.push({name:`${i}_capitalize`,value:Ut(l)}),r.push({name:`${i}_uncapitalize`,value:Wt(l)}),r.push({name:i,value:l})}return r}function Ut(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Wt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as _,AST_TOKEN_TYPES as Vt,ESLintUtils as ir}from"@typescript-eslint/utils";var sr=ir.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="collapse-simple-objs-in-one-line",or=W({maxLineLength:L(fe()),maxProperties:L(fe()),nestedObjMaxLineLength:L(fe()),nestedObjMaxProperties:L(fe()),ignoreTypesWithSuffix:L(G(U()))}),ar=sr({name:zt,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:[or]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],s=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,o=t.nestedObjMaxProperties??3;function i(p){if(p.type===_.ObjectExpression){let c=p.parent.type===_.Property,u=c?o:s,S=p.properties.length;if(S>u)return!1;if(S===1){let h=p.properties[0];return h.type===_.Property&&h.value.type===_.ObjectExpression||h.type===_.Property&&h.value.type===_.ArrayExpression&&!h.value.elements.every(v=>v&&Xe(v))?!1:{text:r.getText(h),isNested:c,propsSize:S}}let y=[];for(let h of p.properties){if(h.type===_.Property&&!Xe(h.value))return!1;y.push(r.getText(h))}return{text:y.join(", "),isNested:c,propsSize:S}}else{let c=p.parent.parent?.type===_.TSPropertySignature,u=c?o:s,S=p.members.length;if(S>u)return!1;if(n.length>0&&p.parent.type===_.TSTypeAliasDeclaration){let h=p.parent.id.name;if(n.some(x=>h.endsWith(x)))return!1}if(S===1){let h=p.members[0];return h.type===_.TSPropertySignature&&h.typeAnnotation?.typeAnnotation.type===_.TSTypeLiteral?!1:{text:r.getText(h),isNested:c,propsSize:1}}if(p.parent.type===_.TSIntersectionType||p.parent.type===_.TSUnionType&&p.parent.types[0]!==p)return!1;let y=[];for(let h of p.members){if(h.type!==_.TSPropertySignature)return!1;let x=h.typeAnnotation?.typeAnnotation;if(!x||x.type===_.TSTypeLiteral||!Ht(x))return!1;if(x.type===_.TSTypeReference&&x.typeArguments){if(x.typeArguments.params.length>1)return!1;let C=x.typeArguments.params[0];if(!Ht(C))return!1}let v=r.getText(h).trim();(v.endsWith(";")||v.endsWith(","))&&(v=v.slice(0,-1)),y.push(v)}return{text:y.join("; "),isNested:c,propsSize:S}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==_.JSXExpressionContainer){let x=0,v=!1,C=r.getTokenAfter(p,{filter:P=>P.type!==Vt.Punctuator||v?!0:P.value===","?(x++,!1):P.value===";"?(x++,v=!0,!1):P.value===")"||P.value==="}"?(x++,!1):!0});if(x>4)return;let M=C?.type===Vt.Template&&C.value.startsWith(`}
|
|
2
|
-
`);if(
|
|
3
|
-
`)||
|
|
4
|
-
`,
|
|
1
|
+
import{AST_NODE_TYPES as Z,ESLintUtils as Jr}from"@typescript-eslint/utils";var qe=Symbol.for("optional");function _(e){return{...e,[qe]:!0}}function Mt(e,t){return{enum:e,...t}}function Ce(e){return{...e,type:"boolean"}}function W(e){return{...e,type:"string"}}function fe(e){return{...e,type:"number"}}function K(e,t){return{...t,type:"array",items:e}}function V(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,o=[];for(r in e)e[r][qe]?e[r][qe]=void 0:o.push(r);o.length>0&&(n.required=o)}return n}var Br=Jr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="react-compiler-extra",Xr=V({runOnlyWithEnableCompilerDirective:_(Ce())}),Gr=/eslint +react-compiler\/react-compiler: +\["error/;function Kr(e){return e.type===Z.Identifier?e.name.startsWith("use"):e.type===Z.MemberExpression&&e.property.type===Z.Identifier?e.property.name.startsWith("use"):!1}var Zr=/\bthis[.[]/;function Lt(e){return Zr.test(e)}var Qr=Br({name:_t,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:[Xr]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let l of e.sourceCode.getAllComments())if(Gr.test(l.value)){n=!0;break}if(!n)return{}}function r(l){for(let i of l.properties)if(i.type===Z.Property&&i.method&&i.value.type===Z.FunctionExpression){let s=e.sourceCode,a=s.getText(i.key),p=i.value,c=s.getText(p.body);if(Lt(c))e.report({node:i,messageId:"thisKeywordInMethod"});else{let u=p.params.map(y=>s.getText(y)).join(", "),d="";p.generator?d=`${a}: function* (${u}) ${c}`:d=`${a}: (${u}) => ${c}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:y=>y.replaceText(i,d)})}}}function o(l){for(let i of l.properties)if(i.type===Z.Property&&i.value.type===Z.ObjectExpression){for(let s of i.value.properties)if(s.type===Z.Property&&s.method&&s.value.type===Z.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Lt(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(l){if(Kr(l.callee))for(let i of l.arguments){if(i.type===Z.ObjectExpression&&(r(i),o(i)),i.type===Z.ArrowFunctionExpression&&(i.body.type===Z.ObjectExpression&&(r(i.body),o(i.body)),i.body.type===Z.BlockStatement))for(let s of i.body.body)s.type===Z.ReturnStatement&&s.argument?.type===Z.ObjectExpression&&(r(s.argument),o(s.argument));if(i.type===Z.FunctionExpression)for(let s of i.body.body)s.type===Z.ReturnStatement&&s.argument?.type===Z.ObjectExpression&&(r(s.argument),o(s.argument))}}}}}),Je={name:_t,rule:Qr};import{AST_NODE_TYPES as ee}from"@typescript-eslint/utils";import{z as C}from"zod/v4";import{ESLintUtils as en}from"@typescript-eslint/utils";import*as $t from"zod/v4";function X(e){let n=en.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}function Ie(e){return $t.toJSONSchema(e)}var tn=C.object({disallow:C.array(C.object({selector:C.string(),message:C.string(),replace:C.optional(C.union([C.string(),C.object({regex:C.string(),with:C.string()})])),replaceType:C.optional(C.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:C.optional(C.array(C.object({fn:C.string(),withArgs:C.optional(C.array(C.object({atIndex:C.number(),value:C.union([C.string(),C.number(),C.boolean()])}))),message:C.string(),replaceWith:C.optional(C.string()),ignoreRegex:C.optional(C.string())}))),__dev_simulateFileName:C.optional(C.string()),mustMatchSyntax:C.optional(C.array(C.object({includeRegex:C.string(),mustCallFn:C.optional(C.array(C.object({anyCall:C.array(C.object({fn:C.string(),withArgs:C.array(C.object({atIndex:C.number(),literal:C.union([C.string(),C.number(),C.boolean()])}))})),message:C.optional(C.string())}))),mustMatchSelector:C.optional(C.array(C.object({selector:C.string(),message:C.string()}))),mustHaveExport:C.optional(C.array(C.object({name:C.string(),type:C.enum(["function","variable","any"]).default("any"),message:C.string()})))})))}),Be=X({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Ie(tn)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:o,disallow:l,disallowFnCalls:i}=t,s=o??e.filename,a=[],p=new Map,c=new Set,u=new Map,d=new Set,y=new Map;function E(m){for(let S of m.specifiers)S.type===ee.ImportSpecifier&&S.imported.type===ee.Identifier&&S.imported.name!==S.local.name&&y.set(S.local.name,S.imported.name)}function h(m){if(m.declaration){if(m.declaration.type===ee.FunctionDeclaration&&m.declaration.id){let S=m.declaration.id.name;for(let R of Array.from(d)){let[A,I]=R.split(":");A===S&&(I==="function"||I==="any")&&d.delete(R)}}else if(m.declaration.type===ee.VariableDeclaration){for(let S of m.declaration.declarations)if(S.id.type===ee.Identifier){let R=S.id.name;for(let A of Array.from(d)){let[I,F]=A.split(":");I===R&&(F==="variable"||F==="any")&&d.delete(A)}}}}for(let S of m.specifiers)if(S.exported.type===ee.Identifier){let R=S.exported.name;for(let A of Array.from(d)){let[I,F]=A.split(":");I===R&&F==="any"&&d.delete(A)}}}function T(m){m.id.type===ee.Identifier&&m.init?.type===ee.Identifier&&y.set(m.id.name,m.init.name)}function x(m){return y.get(m)??m}function M(m,S){return x(m)===S||m===S}for(let{includeRegex:m,mustCallFn:S,mustMatchSelector:R,mustHaveExport:A}of r??[]){let I=rn(s,new RegExp(m));if(!I)continue;let F=Y=>{let B=Y;for(let{name:te,value:Q}of I)B=B.replaceAll(te,Q);return B};for(let{anyCall:Y,message:B}of S??[]){let te=`Expected file to call the function: ${Y.map(({fn:Q})=>Q).join(" or ")}`;c.add(te),a.push(Q=>{let{callee:be}=Q;if(be.type===ee.Identifier){for(let{fn:ne,withArgs:ve}of Y)if(be.name===ne){c.delete(te);for(let me of ve){let ue=Q.arguments[me.atIndex],de=typeof me.literal=="string"?F(me.literal):me.literal;if(!ue){e.report({node:Q,messageId:"default",data:{message:`Missing argument with value "${de}" at index ${me.atIndex}${B?`: ${F(B)}`:""}`}});continue}if(ue.type!==ee.Literal){e.report({node:ue,messageId:"default",data:{message:`Argument at position ${me.atIndex} should the literal "${de}"${B?`: ${F(B)}`:""}`}});continue}ue.value!==de&&e.report({node:ue,messageId:"default",data:{message:`Argument should have the value "${de}"${B?`: ${F(B)}`:""}`},fix:xe=>xe.replaceText(ue,typeof de=="string"?`'${de}'`:String(de))})}break}}})}for(let{selector:Y,message:B}of R??[])u.set(Y,F(B)),p.set(F(Y),()=>{u.delete(Y)});for(let{name:Y,type:B,message:te}of A??[]){let Q=F(Y),be=F(te);d.add(`${Q}:${B}:${be}`)}}for(let{fn:m,withArgs:S,message:R,replaceWith:A,ignoreRegex:I}of i??[])I&&new RegExp(I).test(s)||a.push(F=>{let{callee:Y}=F;if(Y.type!==ee.Identifier||!M(Y.name,m))return;if(S)for(let te of S){let Q=F.arguments[te.atIndex];if(!Q){e.report({node:F,messageId:"default",data:{message:`Missing argument with value "${te.value}" at index ${te.atIndex}: ${R}`}});return}if(Q.type!==ee.Literal||Q.value!==te.value)return}let B=te=>A?te.replaceText(F,A):null;e.report({node:F,messageId:"default",data:{message:R},suggest:A?[{messageId:"default",data:{message:`Replace with "${A}"`},fix:B}]:void 0})});function P(m,S){let R=n[m];R?n[m]=A=>{R(A),S(A)}:n[m]=S}for(let{selector:m,message:S,replace:R,replaceType:A="suggestion"}of l??[]){if(m==="CallExpression"){a.push(I=>{b(R,I,S,A)});continue}n[m]=I=>{b(R,I,S,A)}}if(p.size>0)for(let[m,S]of p)P(m,S);return a.length>0&&(n.CallExpression=m=>{if(m.type===ee.CallExpression)for(let S of a)S(m)}),n.ImportDeclaration=m=>{m.type===ee.ImportDeclaration&&E(m)},n.ExportNamedDeclaration=m=>{m.type===ee.ExportNamedDeclaration&&h(m)},n.VariableDeclarator=m=>{m.type===ee.VariableDeclarator&&T(m)},n["Program:exit"]=m=>{for(let S of c)e.report({node:m,messageId:"default",data:{message:S}});for(let[,S]of u)e.report({node:m,messageId:"default",data:{message:S}});for(let S of d){let[R,A,I]=S.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${R}" of type ${A}: ${I}`}})}},n;function b(m,S,R,A){let I=F=>{if(!m)return null;if(typeof m=="string")return F.replaceText(S,m);{let Y=new RegExp(m.regex),B=e.sourceCode.getText(S);return F.replaceText(S,B.replace(Y,m.with))}};e.report({node:S,messageId:"default",data:{message:R},fix:m&&A==="autofix"?I:void 0,suggest:m&&A==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:I}]:void 0})}}});function rn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[o,...l]=r;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:Ut(o)}),n.push({name:"$0_uncapitalize",value:Wt(o)}),n.push({name:"$0",value:o});for(let i=0;i<l.length;i++){let s=`$${i+1}`,a=l[i];n.push({name:`${s}_lowercase`,value:a.toLowerCase()}),n.push({name:`${s}_capitalize`,value:Ut(a)}),n.push({name:`${s}_uncapitalize`,value:Wt(a)}),n.push({name:s,value:a})}return n}function Ut(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Wt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as $,AST_TOKEN_TYPES as Vt,ESLintUtils as nn}from"@typescript-eslint/utils";var sn=nn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="collapse-simple-objs-in-one-line",on=V({maxLineLength:_(fe()),maxProperties:_(fe()),nestedObjMaxLineLength:_(fe()),nestedObjMaxProperties:_(fe()),ignoreTypesWithSuffix:_(K(W()))}),an=sn({name:Ht,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:[on]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,l=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function s(p){if(p.type===$.ObjectExpression){let c=p.parent.type===$.Property,u=c?i:o,d=p.properties.length;if(d>u)return!1;if(d===1){let E=p.properties[0];return E.type===$.Property&&E.value.type===$.ObjectExpression||E.type===$.Property&&E.value.type===$.ArrayExpression&&!E.value.elements.every(T=>T&&Xe(T))?!1:{text:n.getText(E),isNested:c,propsSize:d}}let y=[];for(let E of p.properties){if(E.type===$.Property&&!Xe(E.value))return!1;y.push(n.getText(E))}return{text:y.join(", "),isNested:c,propsSize:d}}else{let c=p.parent.parent?.type===$.TSPropertySignature,u=c?i:o,d=p.members.length;if(d>u)return!1;if(r.length>0&&p.parent.type===$.TSTypeAliasDeclaration){let E=p.parent.id.name;if(r.some(h=>E.endsWith(h)))return!1}if(d===1){let E=p.members[0];return E.type===$.TSPropertySignature&&E.typeAnnotation?.typeAnnotation.type===$.TSTypeLiteral?!1:{text:n.getText(E),isNested:c,propsSize:1}}if(p.parent.type===$.TSIntersectionType||p.parent.type===$.TSUnionType&&p.parent.types[0]!==p)return!1;let y=[];for(let E of p.members){if(E.type!==$.TSPropertySignature)return!1;let h=E.typeAnnotation?.typeAnnotation;if(!h||h.type===$.TSTypeLiteral||!zt(h))return!1;if(h.type===$.TSTypeReference&&h.typeArguments){if(h.typeArguments.params.length>1)return!1;let x=h.typeArguments.params[0];if(!zt(x))return!1}let T=n.getText(E).trim();(T.endsWith(";")||T.endsWith(","))&&(T=T.slice(0,-1)),y.push(T)}return{text:y.join("; "),isNested:c,propsSize:d}}}function a(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==$.JSXExpressionContainer){let h=0,T=!1,x=n.getTokenAfter(p,{filter:P=>P.type!==Vt.Punctuator||T?!0:P.value===","?(h++,!1):P.value===";"?(h++,T=!0,!1):P.value===")"||P.value==="}"?(h++,!1):!0});if(h>4)return;let M=x?.type===Vt.Template&&x.value.startsWith(`}
|
|
2
|
+
`);if(x?.loc.start.line===p.loc.end.line&&!M)return}let c=s(p);if(!c)return;let u=c.text;if(u.includes(`
|
|
3
|
+
`)||n.getCommentsInside(p).length>0)return;u.endsWith(";")&&(u=u.slice(0,-1));let d=`{ ${u} }`,y=pn(n,p),E=c.isNested&&c.propsSize>2?l:t.maxLineLength;E&&d.length+y.length+ln(p,n)>E||e.report({node:p,messageId:"singleLineProp",fix:h=>h.replaceText(p,d)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function zt(e){return e.type===$.TSLiteralType||e.type===$.TSTypeReference||e.type===$.TSNumberKeyword||e.type===$.TSStringKeyword||e.type===$.TSBooleanKeyword||e.type===$.TSNullKeyword||e.type===$.TSUndefinedKeyword}function Xe(e,t){return!!(e.type===$.Literal||e.type===$.Identifier||e.type===$.TemplateLiteral||e.type===$.TaggedTemplateExpression||!t&&e.type===$.ArrayExpression&&e.elements.every(n=>n&&Xe(n,!0)))}function ln(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
|
|
4
|
+
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function pn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ge={name:Ht,rule:an};var cn=/eslint +react-compiler\/react-compiler: +\["error/,qt={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"?x=>n(x):x=>e.sourceCode.getText(x),r=typeof e.getScope=="function"?()=>r():x=>e.sourceCode.getScope(x),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,l=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:l};function s(x){l&&Array.isArray(x.suggest)&&x.suggest.length>0&&(x.fix=x.suggest[0].fix),e.report(x)}let a=e.getSourceCode().scopeManager,p=new WeakMap,c=new WeakSet,u=new WeakMap,d=new WeakMap,y=new WeakSet;function E(x,M){return function(P){if(M.has(P))return M.get(P);let b=x(P);return M.set(P,b),b}}function h(x,M,P,b,m){m&&x.async&&s({node:x,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
5
5
|
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
async function fetchData() {
|
|
@@ -12,5 +12,5 @@ useEffect(() => {
|
|
|
12
12
|
fetchData();
|
|
13
13
|
}, [someId]); // Or [] if effect doesn't need props or state
|
|
14
14
|
|
|
15
|
-
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let g=l.acquire(C),R=new Set,w=null;{let f=g.upper;for(;f&&(R.add(f),f.type!=="function");)f=f.upper;if(!f)return;w=f}let b=Array.isArray;function F(f){if(!b(f.defs))return!1;let d=f.defs[0];if(d==null||d.node.type!=="VariableDeclarator")return!1;let I=d.node.init;if(I==null)return!1;for(;I.type==="TSAsExpression";)I=I.expression;let A=d.node.parent;if(A==null&&(Qe(w.block,d.node.id),A=d.node.parent,A==null))return!1;if(A.kind==="const"&&I.type==="Literal"&&(typeof I.value=="string"||typeof I.value=="number"||I.value===null))return!0;if(I.type!=="CallExpression")return!1;let O=I.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let k=d.node.id,{name:N}=O;if(N==="useRef"&&k.type==="Identifier")return!0;if(yr(O)&&k.type==="Identifier"){for(let j of f.references)j!==k&&y.add(j.identifier);return!0}else if(N==="useState"||N==="useReducer"){if(k.type==="ArrayPattern"&&k.elements.length===2&&b(f.identifiers)){if(k.elements[1]===f.identifiers[0]){if(N==="useState"){let j=f.references,se=0;for(let ye=0;ye<j.length;ye++){if(j[ye].isWrite()&&se++,se>1)return!1;p.set(j[ye].identifier,k.elements[0])}}return!0}else if(k.elements[0]===f.identifiers[0]){if(N==="useState"){let j=f.references;for(let se=0;se<j.length;se++)c.add(j[se].identifier)}return!1}}}else if(N==="useTransition"&&k.type==="ArrayPattern"&&k.elements.length===2&&Array.isArray(f.identifiers)&&k.elements[1]===f.identifiers[0])return!0;return!1}function z(f){if(!b(f.defs))return!1;let d=f.defs[0];if(d==null||d.node==null||d.node.id==null)return!1;let I=d.node,A=w.childScopes,O=null,k;for(k=0;k<A.length;k++){let N=A[k],j=N.block;if(I.type==="FunctionDeclaration"&&j===I||I.type==="VariableDeclarator"&&j.parent===I){O=N;break}}if(O==null)return!1;for(k=0;k<O.through.length;k++){let N=O.through[k];if(N.resolved!=null&&R.has(N.resolved.scope)&&!B(N.resolved))return!1}return!0}let B=h(F,u),te=h(z,S),Q=new Map;function be(f){let d=f.from,I=!1;for(;d.block!==C;)d.type==="function"&&(I=d.block.parent!=null&&d.block.parent.type==="ReturnStatement"),d=d.upper;return I}let re=new Map,ve=new Map;me(g);function me(f){for(let d of f.references){if(!d.resolved||!R.has(d.resolved.scope))continue;let I=Qe(C,d.identifier),A=Bt(I),O=ge(A,ve);if(m&&A.type==="Identifier"&&(A.parent.type==="MemberExpression"||A.parent.type==="OptionalMemberExpression")&&!A.parent.computed&&A.parent.property.type==="Identifier"&&A.parent.property.name==="current"&&be(d)&&Q.set(O,{reference:d,dependencyNode:A}),A.parent.type==="TSTypeQuery"||A.parent.type==="TSTypeReference")continue;let k=d.resolved.defs[0];if(k!=null&&!(k.node!=null&&k.node.init===C.parent)&&k.type!=="TypeParameter")if(re.has(O))re.get(O).references.push(d);else{let N=d.resolved,j=B(N)||te(N);re.set(O,{isStable:j,references:[d]})}}for(let d of f.childScopes)me(d)}Q.forEach(({reference:f,dependencyNode:d},I)=>{let A=f.resolved.references,O=!1;for(let k=0;k<A.length;k++){let{identifier:N}=A[k],{parent:j}=N;if(j!=null&&j.type==="MemberExpression"&&!j.computed&&j.property.type==="Identifier"&&j.property.name==="current"&&j.parent.type==="AssignmentExpression"&&j.parent.left===j){O=!0;break}}O||i({node:d.parent.property,message:`The ref value '${I}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${I}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ue=new Set;function de(f,d){ue.has(d)||(ue.add(d),i({node:f,message:`Assignments to the '${d}' variable from inside React Hook ${r(P)} 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 ${r(P)}.`}))}let xe=new Set;if(re.forEach(({isStable:f,references:d},I)=>{f&&xe.add(I),d.forEach(A=>{A.writeExpr&&de(A.writeExpr,I)})}),ue.size>0)return;if(!M){let f=null;if(re.forEach(({isStable:d,references:I},A)=>{f||I.forEach(O=>{if(f)return;let k=O.identifier;if(!p.has(k))return;let j=O.from;for(;j.type!=="function";)j=j.upper;j.block===C&&(f=A)})}),f){let{suggestedDependencies:d}=Ke({dependencies:re,declaredDependencies:[],stableDependencies:xe,externalDependencies:new Set,isEffect:!0});i({node:P,message:`React Hook ${T} contains a call to '${f}'. 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 ${T} Hook.`,suggest:[{desc:`Add dependencies array: [${d.join(", ")}]`,fix(I){return I.insertTextAfter(C,`, [${d.join(", ")}]`)}}]})}return}let ke=[],Oe=new Set;M.type!=="ArrayExpression"?i({node:M,message:`React Hook ${r(P)} 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.`}):M.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(P)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}y.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(O){return O.removeRange(f.range)}}]});let d;try{d=ge(f,ve)}catch(O){if(/Unsupported node type/.test(O.message)){f.type==="Literal"?re.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(P)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let I=f;for(;I.type==="MemberExpression"||I.type==="OptionalMemberExpression"||I.type==="ChainExpression";)I=I.object||I.expression.object;let A=!w.through.some(O=>O.identifier===I);ke.push({key:d,node:f}),A||Oe.add(d)});let{suggestedDependencies:zn,unnecessaryDependencies:Ne,missingDependencies:Se,duplicateDependencies:Nt}=Ke({dependencies:re,declaredDependencies:ke,stableDependencies:xe,externalDependencies:Oe,isEffect:m}),De=zn;if(Nt.size+Se.size+Ne.size===0){if(t)return;ur({declaredDependencies:ke,declaredDependenciesNode:M,componentScope:w,scope:g}).forEach(({construction:d,isUsedOutsideOfHook:I,depType:A})=>{let O=A==="function"?"useCallback":"useMemo",k=A==="function"?"definition":"initialization",N=`wrap the ${k} of '${d.name.name}' in its own ${O}() Hook.`,j=I?`To fix this, ${N}`:`Move it inside the ${T} callback. Alternatively, ${N}`,se=A==="conditional"||A==="logical expression"?"could make":"makes",ye=`The '${d.name.name}' ${A} ${se} the dependencies of ${T} Hook (at line ${M.loc.start.line}) change on every render. ${j}`,Dt;I&&d.type==="Variable"&&A==="function"&&(Dt=[{desc:`Wrap the ${k} of '${d.name.name}' in its own ${O}() Hook.`,fix(jt){let[Jn,Bn]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[jt.insertTextBefore(d.node.init,Jn),jt.insertTextAfter(d.node.init,Bn)]}}]),i({node:d.node,message:ye,suggest:Dt})});return}!m&&Se.size>0&&(De=Ke({dependencies:re,declaredDependencies:[],stableDependencies:xe,externalDependencies:Oe,isEffect:m}).suggestedDependencies);function Yn(){if(ke.length===0)return!0;let f=ke.map(I=>I.key),d=f.slice().sort();return f.join(",")===d.join(",")}Yn()&&De.sort();function ze(f){let d=f.split("."),I="";for(let A=0;A<d.length;A++){if(A!==0){let O=d.slice(0,A+1).join("."),k=ve.get(O)===!0;I+=k?"?.":"."}I+=d[A]}return I}function Ye(f,d,I,A){return f.size===0?null:(f.size>1?"":d+" ")+I+" "+(f.size>1?"dependencies":"dependency")+": "+mr(Array.from(f).sort().map(O=>"'"+ze(O)+"'"))+`. Either ${A} ${f.size>1?"them":"it"} or remove the dependency array.`}let le="";if(Ne.size>0){let f=null;if(Array.from(Ne.keys()).forEach(d=>{f===null&&d.endsWith(".current")&&(f=d)}),f!==null)le=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Oe.size>0){let d=Array.from(Oe)[0];g.set.has(d)||(le=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!le&&Se.has("props")){let f=re.get("props");if(f==null)return;let d=f.references;if(!Array.isArray(d))return;let I=!0;for(let A=0;A<d.length;A++){let O=d[A],k=Qe(w.block,O.identifier);if(!k){I=!1;break}let N=k.parent;if(N==null){I=!1;break}if(N.type!=="MemberExpression"&&N.type!=="OptionalMemberExpression"){I=!1;break}}I&&(le=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${T} call and refer to those specific props inside ${r(P)}.`)}if(!le&&Se.size>0){let f=null;Se.forEach(d=>{if(f)return;let I=w.set.get(d),A=re.get(d);if(A.references[0].resolved!==I)return;let O=I.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let k=!1,N;for(let j=0;j<A.references.length;j++)if(N=A.references[j].identifier,N!=null&&N.parent!=null&&(N.parent.type==="CallExpression"||N.parent.type==="OptionalCallExpression")&&N.parent.callee===N){k=!0;break}k&&(f=d)}),f!==null&&(le=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!le&&Se.size>0){let f=null;if(Se.forEach(d=>{if(f!==null)return;let A=re.get(d).references,O,k;for(let N=0;N<A.length;N++){for(O=A[N].identifier,k=O.parent;k!=null&&k!==w.block;){if(k.type==="CallExpression"){let j=p.get(k.callee);if(j!=null){if(j.name===d)f={missingDep:d,setter:k.callee.name,form:"updater"};else if(c.has(O))f={missingDep:d,setter:k.callee.name,form:"reducer"};else{let se=A[N].resolved;if(se!=null){let ye=se.defs[0];ye!=null&&ye.type==="Parameter"&&(f={missingDep:d,setter:k.callee.name,form:"inlineReducer"})}}break}}k=k.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":le=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":le=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":le=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:M,message:`React Hook ${r(P)} has `+(Ye(Se,"a","missing","include")||Ye(Ne,"an","unnecessary","exclude")||Ye(Nt,"a","duplicate","omit"))+le,suggest:[{desc:`Update the dependencies array to be: [${De.map(ze).join(", ")}]`,fix(f){return f.replaceText(M,`[${De.map(ze).join(", ")}]`)}}]})}function v(C){let M=fr(C.callee,o);if(M===-1)return;let P=C.arguments[M],T=C.callee,m=qt(T).name,g=C.arguments[M+1],R=/Effect($|[^a-z])/g.test(m);if(!P){i({node:T,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!R)){if(!g&&!R){(m==="useMemo"||m==="useCallback")&&i({node:T,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(P.type){case"FunctionExpression":case"ArrowFunctionExpression":x(P,g,T,m,R);return;case"Identifier":if(!g||g.elements&&g.elements.some(F=>F&&F.type==="Identifier"&&F.name===P.name))return;let w=n(C).set.get(P.name);if(w==null||w.defs==null)return;let b=w.defs[0];if(!b||!b.node||b.type!=="Variable"&&b.type!=="FunctionName")break;switch(b.node.type){case"FunctionDeclaration":x(b.node,g,T,m,R);return;case"VariableDeclarator":let F=b.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":x(F,g,T,m,R);return}break}break;default:i({node:T,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:T,message:`React Hook ${m} has a missing dependency: '${P.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${P.name}]`,fix(w){return w.replaceText(g,`[${P.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let C of e.sourceCode.getAllComments())if(cr.test(C.value))return t=!0,{CallExpression:M=>v(M,!0)}}return{CallExpression:C=>v(C)}}};function Ke({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:s}){let a=o();function o(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((x,v)=>{let C=i(a,v);C.isUsed=!0,l(a,v,M=>{M.isSubtreeUsed=!0})}),t.forEach(({key:x})=>{let v=i(a,x);v.isSatisfiedRecursively=!0}),r.forEach(x=>{let v=i(a,x);v.isSatisfiedRecursively=!0});function i(x,v){let C=v.split("."),M=x;for(let P of C){let T=M.children.get(P);T||(T=o(),M.children.set(P,T)),M=T}return M}function l(x,v,C){let M=v.split("."),P=x;for(let T of M){let m=P.children.get(T);if(!m)return;C(m),P=m}}let p=new Set,c=new Set;u(a,p,c,x=>x);function u(x,v,C,M){x.children.forEach((P,T)=>{let m=M(T);if(P.isSatisfiedRecursively){P.isSubtreeUsed&&C.add(m);return}if(P.isUsed){v.add(m);return}u(P,v,C,g=>m+"."+g)})}let S=[],y=new Set,h=new Set;return t.forEach(({key:x})=>{c.has(x)?S.indexOf(x)===-1?S.push(x):h.add(x):y.add(x)}),p.forEach(x=>{S.push(x)}),{suggestedDependencies:S,unnecessaryDependencies:y,duplicateDependencies:h,missingDependencies:p}}function Te(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return Te(e.consequent)!=null||Te(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Te(e.left)!=null||Te(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Te(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Te(e.expression);case"TSAsExpression":return Te(e.expression)}return null}function ur({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let s=e.map(({key:o})=>{let i=r.variables.find(p=>p.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 p=Te(l.node.init);if(p!=null)return[i,p]}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 p=o.references[l];if(p.writeExpr){if(i)return!0;i=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!Xt(t,p.identifier))return!0}return!1}return s.map(([o,i])=>({construction:o.defs[0],depType:i,isUsedOutsideOfHook:a(o)}))}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 Ze(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function ge(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=ge(e.object,t),n=ge(e.property,null),s=`${r}.${n}`;return Ze(e,t,s),s}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=ge(e.object,t),n=ge(e.property,null),s=`${r}.${n}`;return Ze(e,t,s),s}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=ge(r.object,t),s=ge(r.property,null),a=`${n}.${s}`;return Ze(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function qt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function fr(e,t){let r=qt(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let n;try{n=ge(r,null)}catch(s){if(/Unsupported node type/.test(s.message))return 0;throw s}return t.additionalHooks.test(n)?0:-1}else return-1}}function Qe(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),dr(n,t))return n;if(Xt(n,t))for(let[s,a]of Object.entries(n))s!=="parent"&&(Yt(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(o=>{Yt(o)&&(o.parent=n,r.push(o))}))}return null}function mr(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function Yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function dr(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 Xt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function yr(e){return!1}import{AST_NODE_TYPES as Me,ESLintUtils as Kt}from"@typescript-eslint/utils";import ne from"typescript";var gr=Kt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="improved-no-unnecessary-condition",Sr=W({}),Tr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],hr=new Set(Tr),et={name:Gt,rule:gr({name:Gt,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:[Sr]},defaultOptions:[{}],create(e){let t=Kt.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===Me.UnaryExpression&&i.operator==="typeof"}function s(i){return i.flags&ne.TypeFlags.Any||i.flags&ne.TypeFlags.Unknown?null:i.flags&ne.TypeFlags.StringLike?["string"]:i.flags&ne.TypeFlags.NumberLike?["number"]:i.flags&ne.TypeFlags.BigIntLike?["bigint"]:i.flags&ne.TypeFlags.BooleanLike?["boolean"]:i.flags&ne.TypeFlags.ESSymbolLike?["symbol"]:i.flags&ne.TypeFlags.Undefined||i.flags&ne.TypeFlags.Void?["undefined"]:i.flags&ne.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&ne.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&ne.TypeFlags.NonPrimitive?["object"]:i.flags&ne.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),p=r.getTypeAtLocation(l.expression);if(p.flags&ne.TypeFlags.Any||p.flags&ne.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let S of p.types){let y=s(S);if(y)c.push(...y);else return null}return c}let u=s(p);return u?(c.push(...u),c):null}function o(i){if(!(i.operator==="==="||i.operator==="!=="))return;let p=null,c=null;if(n(i.left)?(p=i.left,c=i.right.type===Me.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(p=i.right,c=i.left.type===Me.Literal&&typeof i.left.value=="string"?i.left.value:null),!p||!c||!Er(c,hr))return;let u=a(p);if(!u)return;let S=i.operator==="!==",y=u.includes(c);u.length===1?y&&!S?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:we(p,e),type:c}}):!y&&S?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:we(p,e),type:Array.from(u)[0]}}):!y&&!S?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:we(p,e),actualType:je(u),conditionType:c}}):y&&S&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:we(p,e),actualType:je(u),conditionType:c}}):!y&&!S?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:we(p,e),actualType:je(u),conditionType:c}}):!y&&S&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:we(p,e),type:je(u)}})}return{BinaryExpression:o}}})};function je(e){return Array.from(new Set(e)).join(" | ")||"never"}function we(e,t){let r=e.argument;return r.type===Me.Identifier?r.name:t.sourceCode.getText(r)}function Er(e,t){return t.has(e)}import{AST_NODE_TYPES as br,ESLintUtils as xr}from"@typescript-eslint/utils";var Cr=xr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-call-with-explicit-generics",Ir=W({functions:G(U())}),wr=Cr({name:Zt,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:[Ir]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:s}=n;s.type===br.Identifier&&r.has(s.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:s.name}})}}}}),tt={name:Zt,rule:wr};import{AST_NODE_TYPES as Le,ESLintUtils as Rr}from"@typescript-eslint/utils";var Ar=Rr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="no-call-with-inferred-generics",vr=Ar({name:Qt,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 r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:s}=n;if(s.type!==Le.Identifier)return;let a=r.get(s.name);if(!a)return;let{minGenerics:o=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(o||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:s.name,minGenerics:o||0}}),!(i&&!l)&&n.typeArguments?.params?.some(c=>!i&&c.type===Le.TSAnyKeyword||l&&c.type===Le.TSTypeReference&&c.typeName.type===Le.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:s.name}})}}}}),nt={name:Qt,rule:vr};import{ESLintUtils as kr}from"@typescript-eslint/utils";var Or=kr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-commented-out-code",Pr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],J={returnStatement:/^\s*return\s+/,stringAssignment:/\w=("|'|`)/,objectPropertyWithQuotes:/\w+:\s*('|"|`)/,computedPropertyAssignment:/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,kebabCaseProperty:/\w+-\w+:/,snakeCaseProperty:/\w+_\w+:/,ternaryOperator:/\?\s+\w/,colonWithWord:/:\s+\w/,quotedString:/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,numberWithComma:/^\s*\d+[,}]/,arrayWithComma:/^\s*\[[^\]]*\][,}]/,objectWithComma:/^\s*\{[^}]*\}[,}]/,methodCall:/\.\w+\(/,arrayAccess:/\[\w+\]/,quotedPropertyKey:/^\s*(['"`]).+?\1\s*:/,jsxSelfClosing:/^<[A-Z]\w*(\s|>|\/)/,jsxElement:/^<[a-z]+(\s|>|\/)/,jsxOpeningTag:/<[A-Z]\w*(\s.*)?>/,jsxClosingTag:/<\/[A-Z]\w*>/,htmlOpeningTag:/<[a-z]+(\s.*)?>/,htmlClosingTag:/<\/[a-z]+>/,colonDescriptiveComment:/^[a-zA-Z]+(\s+[a-zA-Z]+)*:\s+[a-zA-Z]+\s+[a-zA-Z][^{=,'"]*$/,jsdocComment:/^\s*[*\s]*$/},Fr=[") {","return;",J.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",J.stringAssignment,");",J.objectPropertyWithQuotes,J.computedPropertyAssignment,J.kebabCaseProperty,J.snakeCaseProperty,"&&","||","()",J.ternaryOperator,J.colonWithWord,J.quotedString,J.numberWithComma,J.arrayWithComma,J.objectWithComma,J.methodCall,J.arrayAccess,"?.(","??","=>",J.quotedPropertyKey],Nr=["/>","</",J.jsxSelfClosing,J.jsxElement,J.jsxOpeningTag,J.jsxClosingTag,J.htmlOpeningTag,J.htmlClosingTag],en=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Dr=Or({name:tn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,s){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||J.jsdocComment.test(n))return!1;for(let o of en)if(a.startsWith(o))return!1;if(n.includes("https://")||a.includes(":")&&J.colonDescriptiveComment.test(a.trim()))return!1;if(s==="Block"){for(let o of Nr)if(typeof o=="string"){if(n.includes(o))return{wrongPattern:o}}else if(o.test(n))return{wrongPattern:`regex(${o.toString()})`};return!1}for(let o of Pr)if(a.startsWith(o))return{wrongPattern:o};for(let o of Fr)if(typeof o=="string"){if(n.includes(o))return{wrongPattern:o}}else if(o.test(n))return{wrongPattern:`regex(${o.toString()})`};return!1}function r(n,s){let a=n,o=a.trim();if(o.startsWith("`")&&(o.endsWith("`,")||o.endsWith("`;")||o.endsWith("`")))return a;if(s==="Block"&&a.includes("```")){let p=a.split(/```[\s\S]*?```/g);p.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=p.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(p=>/[a-zA-Z0-9]/.test(p))?i.join(""):a}return{Program(){let s=e.sourceCode.getAllComments();for(let a of s){let o=r(a.value,a.type),i=t(o,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:en.join(", ")}})}}}}}),rt={name:tn,rule:Dr};import{ESLintUtils as jr,TSESTree as Mr}from"@typescript-eslint/utils";var Lr=jr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nn="no-default-export",_r=Lr({name:nn,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 r of t.specifiers)r.exported.type===Mr.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),it={name:nn,rule:_r};import{ESLintUtils as $r}from"@typescript-eslint/utils";var Ur=$r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rn="no-leaked-text-in-jsx",Wr=[",",";","[","]","(",")"],Vr=Ur({name:rn,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 r=t.value.trim();if(!r)return;let n="";Wr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),st={name:rn,rule:Vr};import{AST_NODE_TYPES as Pe,ESLintUtils as Hr}from"@typescript-eslint/utils";var zr=Hr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-non-camel-case-functions",Yr=/^(\$?[a-z][a-zA-Z0-9]*)$/;function sn(e){if(e.typeName.type!==Pe.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Pe.Identifier&&t.name==="JSX"&&r.name==="Element"}var Jr=zr({name:on,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&&!Yr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Pe.TSTypeReference?sn(r):r.type===Pe.TSUnionType&&r.types.some(s=>s.type===Pe.TSTypeReference&&sn(s))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ot={name:on,rule:Jr};import{ESLintUtils as Br,TSESTree as V}from"@typescript-eslint/utils";import{AST_NODE_TYPES as an}from"@typescript-eslint/utils";function Re(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Re(e.parent,t,r===1/0?r:r-1)}function*at(e){yield e,e.parent&&(yield*at(e.parent))}function lt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function ln(e,t,r){let s=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===an.Property&&a.identifiers[0]?.parent.key.type===an.Identifier&&a.identifiers[0]?.parent.key.name===t);return s?s.references.filter(a=>!a.init):[]}var qr=Br.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-optional-root-props",Xr=qr({name:pn,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(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let o=a.references[0];if(!o)return!1;for(let i of at(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 c=Re(l.parent.parent,V.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let u=_e(c,e.sourceCode);return u?!(u.parent.type===V.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===V.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===V.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===V.AST_NODE_TYPES.ArrowFunctionExpression){let p=Re(l,V.AST_NODE_TYPES.VariableDeclaration);return p?!!_e(p,e.sourceCode):!1}if(l.type===V.AST_NODE_TYPES.FunctionDeclaration)return!!_e(l,e.sourceCode)}return!1}function r(n){n.key.type!==V.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:s=>{let a=Re(n,V.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let o=e.sourceCode.getText(a);return s.replaceText(a,o.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===V.AST_NODE_TYPES.TSTypeLiteral&&!($e(n)||!t(n)))for(let s of n.typeAnnotation.members)s.type===V.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSInterfaceDeclaration(n){if(!($e(n)||!t(n)))for(let s of n.body.body)s.type===V.AST_NODE_TYPES.TSPropertySignature&&r(s)},TSTypeReference(n){if(n.typeName.type!==V.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let s=n.typeArguments.params[0];if(s.type!==V.AST_NODE_TYPES.TSTypeLiteral)return;let a=Re(n.parent,V.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let o=_e(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&&r(l)}}}});function $e(e){return e?e.parent?.type===V.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===V.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function _e(e,t){if($e(e))return;let r;if(e.type===V.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===V.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===V.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let s=n.variables.find(o=>o.identifiers.includes(r));if(!s)return;let a=s.references.filter(o=>o.identifier!==r);if(!(a.length!==1||!a[0])&&!$e(a[0].identifier.parent.parent))return a[0].identifier}var pt={name:pn,rule:Xr};import{ESLintUtils as Gr}from"@typescript-eslint/utils";import ct from"node:path";var Kr=Gr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cn="no-relative-imports",Zr=W({find:U(),replacement:U()}),Qr=W({aliases:G(Zr),rootDir:L(U()),allowNotFoundAliases:L(Ce()),_dev_simulateFileName:L(U())}),ei=Kr({name:cn,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:[Qr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(o){return o.startsWith(".")||o.startsWith("..")}function s(o,i){let l=ct.dirname(i);return ct.resolve(l,o)}function a(o){let i=t.rootDir??process.cwd(),l=ct.relative(i,o);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let u=l.replace(c,p);return{alias:p,newPath:u}}return null}return{ImportDeclaration(o){let i=o.source.value;if(!n(i))return;let l=s(i,r),p=a(l);!p&&t.allowNotFoundAliases||e.report({node:o,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(o.source,`'${p.newPath}'`):void 0})}}}}),ut={name:cn,rule:ei};import{AST_NODE_TYPES as Ue}from"@typescript-eslint/utils";import*as he from"zod/v4";var ti=he.object({alternativeMsgs:he.object({inArrayFind:he.string().optional(),inArrayFilter:he.string().optional()}).optional(),__dev_simulateFileName:he.string().optional()});function ni(e){return e.typeAnnotation.type!==Ue.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function ri(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ii(e){let t=e.parent;for(;t;){if(t.type===Ue.CallExpression&&t.callee.type===Ue.MemberExpression&&t.callee.property.type===Ue.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var ft=q({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[Ie(ti)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(ri(r))return{};function n(s){if(!ni(s))return;let a=ii(s),o=[];if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let l=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:s,messageId:l,data:{message:i}});return}}e.report({node:s,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as Ae}from"@typescript-eslint/utils";var si="no-unnecessary-async-on-jsx-props";function oi(e){if(e.body.type!==Ae.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==Ae.ExpressionStatement?!1:r.expression.type===Ae.AwaitExpression}var mt=q({name:si,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(r){oi(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let s=e.sourceCode,a=[],o=s.getFirstToken(r,l=>l.value==="async");if(o){let l=s.getTokenAfter(o);l?a.push(n.replaceTextRange([o.range[0],l.range[0]],"")):a.push(n.remove(o))}function i(l){if(l.type===Ae.AwaitExpression){let p=s.getFirstToken(l);if(p&&p.value==="await"){let c=s.getTokenAfter(p);c?a.push(n.replaceTextRange([p.range[0],c.range[0]],"")):a.push(n.remove(p))}}if(l.type===Ae.BlockStatement)for(let p of l.body)i(p);else l.type===Ae.ExpressionStatement&&i(l.expression)}return i(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as Fe,ESLintUtils as fn}from"@typescript-eslint/utils";import*as dt from"typescript";var ai=fn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),un="no-unnecessary-casting",li=W({additionalCastFunctions:L(G(W({name:U(),expectedType:Mt(["string","number"])})))}),yt={name:un,rule:ai({name:un,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:[li],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],s=fn.getParserServices(e,!0),a=s.program?.getTypeChecker();if(!a||!s.program)throw new Error("TypeScript services or program not available");function o(c,u){switch(c.type){case Fe.Literal:return u==="number"?typeof c.value=="number":typeof c.value=="string";case Fe.TemplateLiteral:return u==="string";case Fe.UnaryExpression:return u==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function i(c,u){return u==="number"?!!(c.flags&dt.TypeFlags.NumberLike):!!(c.flags&dt.TypeFlags.StringLike)}function l(c,u){return S=>S.replaceText(c,e.sourceCode.getText(u))}function p(c){if(!a||c.arguments.length!==1)return;let u=c.arguments[0];if(!u||u.type===Fe.SpreadElement)return;let{callee:S}=c;if(S.type!==Fe.Identifier)return;let y=S.name,h=n.find(v=>v.name===y);if(!h)return;if(o(u,h.expectedType)||i(a.getTypeAtLocation(s.esTreeNodeToTSNodeMap.get(u)),h.expectedType)){let v,C;y==="Number"?v="unnecessaryNumberCasting":y==="String"?v="unnecessaryStringCasting":(v="unnecessaryCustomCasting",C={name:h.name,type:h.expectedType}),e.report({node:c,messageId:v,...C?{data:C}:{},fix:l(c,u)})}}return{CallExpression:p}}})};import{AST_NODE_TYPES as We}from"@typescript-eslint/utils";import*as oe from"zod/v4";var pi=oe.object({methods:oe.union([oe.array(oe.string()),oe.literal("array")])}),gt=q({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[oe.toJSONSchema(pi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function s(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===We.MemberExpression){let p=l.property;if(p.type===We.Identifier)return p.name}return null}function o(i,l){if(i.type!==We.Identifier||!i.typeAnnotation)return;let p=l.parent;if(p.type===We.CallExpression){let c=a(p);c&&s(c)&&p.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(S){return S.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)o(l,i)},FunctionExpression(i){for(let l of i.params)o(l,i)}}}});import{AST_NODE_TYPES as ie}from"@typescript-eslint/utils";var St=q({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===ie.ObjectPattern||!t.init||t.init.type!==ie.ObjectExpression||t.id.type===ie.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ie.ExportNamedDeclaration)return;let r=new Map;for(let o of t.init.properties)o.type===ie.Property&&o.key.type===ie.Identifier&&r.set(o.key.name,o);if(r.size===0||t.id.type!==ie.Identifier)return;let n=ci(t,e.sourceCode);if(n.length===0)return;let s=t.init.properties.some(o=>o.type!==ie.Property?!1:o.value.type===ie.FunctionExpression),a=new Set;for(let o of n){if(o.identifier.parent.type!==ie.MemberExpression)return;let i=o.identifier.parent;if(i.object!==o.identifier)return;if(i.computed)if(i.property.type===ie.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==ie.Identifier)return;a.add(i.property.name)}if(i.parent.type===ie.CallExpression&&s)return}for(let[o,i]of r)a.has(o)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:o}})}}}});function ci(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as Y,ESLintUtils as ui}from"@typescript-eslint/utils";var fi=W({selectors:G(W({name:U(),selectorProp:L(U()),selectorArgPos:L(fe()),returnProp:L(U())}))}),mi=ui.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-unused-selected-values",Tt={name:mn,rule:mi({name:mn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[fi]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(s=>[s.name,s]));return{VariableDeclarator(s){let a=null;if(s.init?.type===Y.CallExpression&&(a=s.init),!a)return;let o=yi(a);if(!o)return;let i=n.get(o);if(!i)return;let l=di(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let p=gi(l);if(!p)return;let c=dn(p.properties,void 0);if(!c)return;if(s.id.type===Y.ObjectPattern){let y=dn(s.id.properties,i.returnProp);if(!y)return;for(let[h,x]of c)y.has(h)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:h}});return}if(s.id.type!==Y.Identifier||i.returnProp)return;let u=Si(s,e.sourceCode);if(u.length===0)return;let S=new Set;for(let y of u){if(y.identifier.parent.type!==Y.MemberExpression)return;let h=y.identifier.parent.property;if(h.type!==Y.Identifier)return;S.add(h.name)}for(let[y,h]of c)S.has(y)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:y}})}}}})};function di(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===Y.ArrowFunctionExpression||n.type===Y.FunctionExpression)return n;if(r&&n.type===Y.ObjectExpression){let s=n.properties.find(o=>o.type===Y.Property&&o.key.type===Y.Identifier&&o.key.name===r);if(s?.type!==Y.Property)return null;let a=s.value;if(a.type===Y.ArrowFunctionExpression||a.type===Y.FunctionExpression)return a}return null}function yi(e){return e.callee.type===Y.Identifier?e.callee.name:e.callee.type===Y.MemberExpression&&e.callee.property.type===Y.Identifier?e.callee.property.name:null}function gi(e){if(e.body.type===Y.ObjectExpression)return e.body;if(e.body.type===Y.BlockStatement){let t=e.body.body.filter(r=>r.type===Y.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==Y.ObjectExpression?null:t[0].argument}return null}function dn(e,t){let r=e;if(t){let s=e.find(a=>a.type===Y.Property&&a.key.type===Y.Identifier&&a.key.name===t);if(s?.type!==Y.Property||s.value.type!==Y.ObjectPattern)return null;r=s.value.properties}let n=new Map;for(let s of r){if(s.type!==Y.Property||s.key.type!==Y.Identifier)return null;n.set(s.key.name,s)}return n.size>0?n:null}function Si(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(s=>s.identifier!==e.id):[]}import{AST_NODE_TYPES as H}from"@typescript-eslint/utils";var ht=q({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.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,s=!1;return{CallExpression(a){if(s)return;if(!n){let i=Ti(a);i&&(n=i);return}let o=hi(a,e.sourceCode);if(o){s=!0;for(let i of o)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function Ti(e){if(!(e.callee.type===H.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==H.ObjectExpression)return null;let n=lt(r.properties,a=>a.type!==H.Property||a.key.type!==H.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.ObjectExpression?a.value:a.value.type===H.ArrowFunctionExpression||a.value.type===H.FunctionExpression?Ei(a.value):null);if(!n)return null;let s=new Map;for(let a of n.properties)a.type===H.Property&&a.key.type===H.Identifier&&s.set(a.key.name,a);return s}function hi(e,t){if(!(e.callee.type===H.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.VariableDeclarator||e.parent.id.type!==H.ObjectPattern||!lt(e.parent.id.properties,o=>o.type===H.Property&&o.key.type===H.Identifier&&o.key.name==="formFields"&&o))return null;let s=ln(e.parent,"formFields",t),a=new Set;for(let{identifier:o}of s){if(o.type!==H.Identifier||o.parent.type===H.Property&&o.parent.parent.type===H.ObjectExpression&&o.parent.parent.parent.type===H.ReturnStatement||o.parent.type===H.ReturnStatement)return null;if(o.parent.type===H.MemberExpression){if(o.parent.object.type!==H.Identifier||o.parent.property.type!==H.Identifier)return null;a.add(o.parent.property.name)}}return a}function Ei(e){if(e.body.type===H.ObjectExpression)return e.body;if(e.body.type===H.BlockStatement){let t=e.body.body.filter(r=>r.type===H.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as $,ESLintUtils as bi}from"@typescript-eslint/utils";var xi=bi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function yn(e){let t=[];for(let r of e.members)r.type===$.TSPropertySignature&&r.key.type===$.Identifier&&t.push([r.key.name,r]);return t}function gn(e,...t){for(let r of t)e.set(...r);return e}var Ci=W({forceCheckOnFCPropTypesWithName:L(G(U()))}),Sn="no-unused-type-props-in-args",Et=null,Ii=xi({name:Sn,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:[Ci],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!Et&&(Et=r.map(i=>new RegExp(i)));function n(i,l,p,c,u=!0){let S=p.name,y=e.sourceCode.getScope(l).references.find(v=>v.identifier.name===S)?.resolved,h=i&&Et?.some(v=>v.test(S));if(!y||!h&&y.references.filter(v=>v.isTypeReference).length>1)return;let x=y?.defs[0]?.node;if(!(u&&x?.parent?.type===$.ExportNamedDeclaration)){if(x?.type===$.TSTypeAliasDeclaration){s(i,l,c,x.typeAnnotation,!0);return}if(x?.type===$.TSInterfaceDeclaration){s(i,l,c,x.body,!0);return}}}function s(i,l,p,c,u){if(c.type===$.TSInterfaceBody){for(let S of c.body)S.type===$.TSPropertySignature&&S.key.type===$.Identifier&&p.set(S.key.name,S);return}if(c.type===$.TSTypeLiteral){gn(p,...yn(c));return}if(c.type===$.TSIntersectionType){for(let S of c.types)s(i,l,p,S,!0);return}u||c.type===$.TSTypeReference&&c.typeName.type===$.Identifier&&n(i,l,c.typeName,p)}function a(i,l,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let u=new Map;if(s(i,l,u,c.typeAnnotation.typeAnnotation,!1),u.size===0)continue;o(c,u)}else c.type===$.AssignmentPattern&&c.left.type===$.ObjectPattern&&a(i,l,[c.left])}function o(i,l){let p=[];if(i.properties.at(-1)?.type===$.RestElement)return;for(let y of i.properties)y.type===$.Property&&y.key.type===$.Identifier&&p.push(y.key.name);let u=[],S=[];for(let[y,h]of l)p.includes(y)||(S.push(y),u.push({node:h,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,h]of u.entries())e.report({...h,fix:y===u.length-1?x=>{let v=i.properties.at(-1),C=S.join(", ");return v?v?.type===$.RestElement?null:x.insertTextAfter(v,`, ${C}`):x.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${C}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let p=new Map,c=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(c){if(c.type===$.TSTypeReference&&c.typeName.type===$.Identifier)n(!0,i,c.typeName,p,!1);else if(c.type===$.TSTypeLiteral)gn(p,...yn(c));else if(c.type===$.TSIntersectionType)for(let u of c.types)u.type===$.TSTypeReference&&u.typeName.type===$.Identifier?n(!0,i,u.typeName,p,!1):s(!0,i,p,u,!0);if(p.size!==0&&l.init?.type===$.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===$.ObjectPattern&&o(u,p)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),bt={name:Sn,rule:Ii};import{AST_NODE_TYPES as ce}from"@typescript-eslint/utils";var xt=q({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function r(n){return n.callee.type===ce.Identifier?t.has(n.callee.name):n.callee.type===ce.MemberExpression&&n.callee.object.type===ce.Identifier&&n.callee.property.type===ce.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let s of n.specifiers)s.type===ce.ImportSpecifier&&s.imported.type===ce.Identifier&&s.imported.name==="useRef"&&t.add(s.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===ce.CallExpression&&r(n.init)&&n.id.type===ce.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let o=!1;for(let i of a.references){let p=i.identifier.parent;if(p!==n&&!(p.type===ce.JSXExpressionContainer&&p.parent.type===ce.JSXAttribute&&p.parent.name.type===ce.JSXIdentifier&&p.parent.name.name==="ref")){o=!0;break}}o||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});import{AST_NODE_TYPES as Ct,ESLintUtils as wi}from"@typescript-eslint/utils";var Ri=wi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hn="prefer-named-functions",Tn=new Map,Ai=Ri({name:hn,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 r=null;if(t.ignoreRegex){let n=Tn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),Tn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Ct.ArrowFunctionExpression&&n.id.type===Ct.Identifier){let s=n.id.name;if(n.id.typeAnnotation||r&&r.test(s)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Ct.BlockStatement)return;let a=n.parent,o=n.init.params,i=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:s,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(a,`${l.async?"async ":""}function ${s}(${o.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),It={name:hn,rule:Ai};import{AST_NODE_TYPES as D}from"@typescript-eslint/utils";var vi=W({disallowedFunctions:G(W({name:U(),allowUsingWithArgs:L(Ce()),hookAlternative:L(U()),message:L(U()),allowUseInside:L(G(U()))}))});function Ve(e){return/^use[A-Z]/.test(e)}function En(e){return/^[A-Z]/.test(e)}function ki(e){return e.type===D.Identifier?Ve(e.name):e.type===D.MemberExpression&&e.property.type===D.Identifier?Ve(e.property.name):!1}function bn(e,t){return e.type===D.Identifier?e.name===t:e.type===D.MemberExpression&&e.object.type===D.Identifier&&e.property.type===D.Identifier?e.object.name==="React"&&e.property.name===t:!1}function xn(e){return!!(e.parent&&e.parent.type===D.CallExpression&&bn(e.parent.callee,"forwardRef"))}function Cn(e){return!!(e.parent&&e.parent.type===D.CallExpression&&bn(e.parent.callee,"memo"))}function wt(e){if(e.type===D.FunctionDeclaration||e.type===D.FunctionExpression&&e.id)return e.id||void 0;if(e.type===D.FunctionExpression||e.type===D.ArrowFunctionExpression){if(e.parent.type===D.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===D.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===D.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===D.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Oi(e){let t=e.parent,r=!1;for(;t;){if(t.type===D.FunctionDeclaration||t.type===D.FunctionExpression||t.type===D.ArrowFunctionExpression){let n=wt(t);if(n&&n.type===D.Identifier){if(En(n.name)||Ve(n.name))return!r;r=!0}else{if(xn(t)||Cn(t))return!r;if(t.parent.type===D.CallExpression){let s=t.parent;ki(s.callee)||(r=!0)}else t.parent.type===D.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function In(e){return e.callee.type===D.Identifier?e.callee.name:e.callee.type===D.MemberExpression&&e.callee.property.type===D.Identifier?e.callee.property.name:null}function Pi(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===D.FunctionDeclaration||r.type===D.FunctionExpression||r.type===D.ArrowFunctionExpression){let n=wt(r);if(n&&n.type===D.Identifier&&t.includes(n.name))return!0}else if(r.type===D.CallExpression){let n=In(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Fi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===D.Identifier&&t.name==="undefined")}function Ni(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===D.FunctionDeclaration||n.type===D.FunctionExpression||n.type===D.ArrowFunctionExpression){let s=wt(n);if(s&&s.type===D.Identifier){if(En(s.name)||Ve(s.name)){r=!0;break}}else if(xn(n)||Cn(n)){r=!0;break}}n=n.parent}return r?t.length===0?Oi(e):!Pi(e,t):!1}var Rt=q({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{{message}}."},schema:[vi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(s=>[s.name,s]));return{CallExpression(s){let a=In(s);if(!a)return;let o=n.get(a);if(!o||o.allowUsingWithArgs&&Fi(s))return;let i=o.allowUseInside||[];Ni(s,i)&&e.report({node:s,messageId:"preferHookAlternative",data:{message:o.message?` ${o.message}`:` use ${o.hookAlternative} instead`},suggest:o.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${o.hookAlternative}`,hookAlternative:o.hookAlternative},fix:l=>{let p=o.hookAlternative;return s.callee.type===D.Identifier?l.replaceText(s.callee,p):s.callee.type===D.MemberExpression&&s.callee.property.type===D.Identifier?l.replaceText(s.callee.property,p):null}}]:[]})}}}});import{AST_NODE_TYPES as X,AST_TOKEN_TYPES as wn,ESLintUtils as Di}from"@typescript-eslint/utils";var ji=Di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),An="prefer-single-line-if",Mi=W({maxLineLength:L(fe()),maxNonSimpleConditionLength:L(fe())}),Li=ji({name:An,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:[Mi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==X.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(a.type===X.ReturnStatement){if(!kn(a))return}else if(!(a.type===X.ContinueStatement||a.type===X.BreakStatement))return;if(n.test.type===X.LogicalExpression||n.test.type===X.ConditionalExpression)return;let o;if(t.maxNonSimpleConditionLength){let u=Rn(n.test);if(!u&&n.test.type===X.UnaryExpression&&n.test.operator==="!"){let S=n.test.argument;Rn(S)&&(u=!0)}if(u&&(o=r.getText(n.test),o.length>t.maxNonSimpleConditionLength))return}o||(o=r.getText(n.test));let i=r.getText(a);if(o.includes(`
|
|
16
|
-
`))return;let l=r.getTokenAfter(n);if(l&&l.type===wn.Punctuator&&l.value==="}"){let u=r.getTokenAfter(l);if(u&&u.type===wn.Keyword&&(u.value==="else"||u.value==="catch"))return}let p=_i(r,n),c=`if (${o}) ${i}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:u=>u.replaceText(n,c)})}}}});function Rn(e){return e.type===X.CallExpression||e.type===X.BinaryExpression||e.type===X.MemberExpression&&vn(e)}function vn(e){return e.object.type===X.MemberExpression?vn(e.object):e.object.type!==X.Identifier}function _i(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function kn(e){if(!e.argument)return!0;let t=e.argument;return t.type===X.ArrayExpression&&t.elements.length===0||t.type===X.ObjectExpression&&t.properties.length===0||t.type===X.Literal||t.type===X.Identifier||t.type===X.TemplateLiteral||t.type===X.TaggedTemplateExpression?!0:t.type===X.CallExpression?t.arguments.length===0:t.type===X.UnaryExpression?kn(t):!1}var At={name:An,rule:Li};import{AST_NODE_TYPES as ae,ESLintUtils as $i}from"@typescript-eslint/utils";var Ui=$i.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),On="react-compiler-migration",Wi=W({disallowHooks:L(G(W({name:U(),replacement:U()}))),disallowMethods:L(G(W({name:U(),replacement:L(U()),requireTrueProp:L(U())})))}),Vi=/eslint +react-compiler\/react-compiler: +\["error/;function Hi(e){return e.type===ae.Identifier?e.name.startsWith("use"):e.type===ae.MemberExpression&&e.property.type===ae.Identifier?e.property.name.startsWith("use"):!1}var zi=Ui({name:On,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[Wi]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Vi.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let s=null,a=null;if(n.callee.type===ae.Identifier?(s=n.callee.name,a=n.callee):n.callee.type===ae.MemberExpression&&n.callee.property.type===ae.Identifier&&(s=n.callee.property.name,a=n.callee.property),s){let o=t.disallowHooks.find(i=>i.name===s);o&&a&&e.report({node:n,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&&Hi(n.callee)){for(let s of n.arguments)if(s.type===ae.ObjectExpression){for(let a of s.properties)if(a.type===ae.Property&&a.key.type===ae.Identifier){let o=a.key.name,i=t.disallowMethods.find(l=>l.name===o);if(i){if(i.requireTrueProp){let l=i.requireTrueProp,p=!1;for(let c of s.properties)if(c.type===ae.Property&&c.key.type===ae.Identifier&&c.key.name===l&&c.value.type===ae.Literal&&c.value.value===!0){p=!0;break}if(!p){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)}]})}}}}}}:{}}}),vt={name:On,rule:zi};import{ESLintUtils as Yi,TSESTree as Ji}from"@typescript-eslint/utils";var Bi=Yi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pn="require-description",qi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Xi=/^eslint-disable-(next-)?line$/u,Gi=Bi({name:Pn,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 r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let a=Ki(s);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Qi(s.loc),messageId:"missingDescription"}))}}}}}),Fn={name:Pn,rule:Gi};function Ki(e){let{text:t,description:r}=Zi(e.value);if(!t)return null;let n=qi.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let a=Xi.test(s);if(e.type===Ji.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let o=t.slice(n.index+s.length);return{kind:s,value:o.trim(),description:r}}function Zi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Qi(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as Z}from"@typescript-eslint/utils";import{z as Ee}from"zod/v4";var es=Ee.object({varsToCheck:Ee.array(Ee.object({selector:Ee.string().optional(),fromFnCall:Ee.string().optional(),prop:Ee.string(),errorMsg:Ee.string().optional()}))}),kt=q({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'Property "{{prop}}" from variable "{{varName}}" is never read. {{customMsg}}'},schema:[Ie(es)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map,n={};for(let s of t.varsToCheck)s.selector&&(n[s.selector]=a=>{a.type===Z.VariableDeclarator&&a.id.type===Z.Identifier&&r.set(a.id.name,{prop:s.prop,errorMsg:s.errorMsg,node:a.id})});for(let s of t.varsToCheck)if(s.fromFnCall){let a=s.fromFnCall;if(a.startsWith("*.")){let i=`VariableDeclarator > CallExpression > MemberExpression[property.name="${a.slice(2)}"]`;n[i]=l=>{if(l.type!==Z.MemberExpression)return;let c=l.parent.parent;c.id.type===Z.Identifier&&r.set(c.id.name,{prop:s.prop,errorMsg:s.errorMsg,node:c.id})}}else if(a.includes(".")){let[o,i]=a.split("."),l=`VariableDeclarator > CallExpression > MemberExpression[object.name="${o}"][property.name="${i}"]`;n[l]=p=>{if(p.type!==Z.MemberExpression)return;let u=p.parent.parent;u.id.type===Z.Identifier&&r.set(u.id.name,{prop:s.prop,errorMsg:s.errorMsg,node:u.id})}}else{let o=`VariableDeclarator > CallExpression > Identifier[name="${a}"]`;n[o]=i=>{if(i.type!==Z.Identifier)return;let p=i.parent.parent;p.id.type===Z.Identifier&&r.set(p.id.name,{prop:s.prop,errorMsg:s.errorMsg,node:p.id})}}}return{...n,"Program:exit"(){for(let[s,{prop:a,errorMsg:o,node:i}]of r){let p=e.sourceCode.getScope(i).set.get(s);if(p){let c=!1;for(let u of p.references){let S=u.identifier,y=S.parent;if(!(y.type===Z.VariableDeclarator&&y.id===S)){if(y.type===Z.MemberExpression&&y.object===S&&y.property.type===Z.Identifier&&y.property.name===a){c=!0;break}if(y.type===Z.VariableDeclarator&&y.init===S&&y.id.type===Z.ObjectPattern){for(let h of y.id.properties)if(h.type===Z.Property&&h.key.type===Z.Identifier&&h.key.name===a){c=!0;break}if(c)break}if(!(y.type===Z.MemberExpression&&y.object===S&&y.property.type===Z.Identifier&&y.property.name!==a)){c=!0;break}}}c||e.report({node:i,messageId:"propNotRead",data:{prop:a,varName:s,customMsg:o||""}})}}}}}});function jn(e){return/^use[A-Z0-9]/.test(e)}function He(e){return e.type==="Identifier"?jn(e.name):e.type==="MemberExpression"&&!e.computed&&He(e.property)?e.object.type==="Identifier":!1}function Mn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Ln(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function _n(e){return!!(e.parent&&e.parent.callee&&Ln(e.parent.callee,"forwardRef"))}function $n(e){return!!(e.parent&&e.parent.callee&&Ln(e.parent.callee,"memo"))}function Ot(e){for(;e;){let t=Wn(e);if(t&&(Mn(t)||He(t))||_n(e)||$n(e))return!0;e=e.parent}return!1}function Nn(e){return!1}function Pt(e){return!1}var ts=/eslint +react-compiler\/react-compiler: +\["error/,Un={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(ts.test(l.value))return{CallExpression(p){let c=null;p.callee.name==="useMemo"?c="useMemo":p.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:p,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,s=[],a=[],o=new WeakSet;function i(l){for(let p of l.references){let c=p.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&Nn(c.init.callee))for(let u of p.resolved.references)u!==p&&o.add(u.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>s.push(new Map),onCodePathEnd(l,p){let c=s.pop();if(c.size===0)return;let u=new Set;function S(T,m){let{cache:g}=S,R=g.get(T.id),w=new Set(m);if(w.has(T.id)){let b=[...w],F=b.slice(b.indexOf(T.id)+1);for(let z of F)u.add(z);return BigInt("0")}if(w.add(T.id),R!==void 0)return R;if(l.thrownSegments.includes(T))R=BigInt("0");else if(T.prevSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let b of T.prevSegments)R+=S(b,w)}return T.reachable&&R===BigInt("0")?g.delete(T.id):g.set(T.id,R),R}function y(T,m){let{cache:g}=y,R=g.get(T.id),w=new Set(m);if(w.has(T.id)){let b=Array.from(w),F=b.slice(b.indexOf(T.id)+1);for(let z of F)u.add(z);return BigInt("0")}if(w.add(T.id),R!==void 0)return R;if(l.thrownSegments.includes(T))R=BigInt("0");else if(T.nextSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let b of T.nextSegments)R+=y(b,w)}return g.set(T.id,R),R}function h(T){let{cache:m}=h,g=m.get(T.id);if(g===null)return 1/0;if(g!==void 0)return g;if(m.set(T.id,null),T.prevSegments.length===0)g=1;else{g=1/0;for(let R of T.prevSegments){let w=h(R);w<g&&(g=w)}g+=1}return m.set(T.id,g),g}S.cache=new Map,y.cache=new Map,h.cache=new Map;let x=y(l.initialSegment),v=Wn(p),C=Ot(p),M=v?Mn(v)||He(v):_n(p)||$n(p),P=1/0;for(let T of l.finalSegments){if(!T.reachable)continue;let m=h(T);m<P&&(P=m)}for(let[T,m]of c){if(!T.reachable)continue;let g=T.nextSegments.length===0?P<=h(T):P<h(T),R=S(T)*y(T),w=u.has(T.id);for(let b of m)if(w&&!Pt(b)&&e.report({node:b,message:`React Hook "${t(b)}" 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.`}),M){if(p.async&&e.report({node:b,message:`React Hook "${t(b)}" cannot be called in an async function.`}),!w&&R!==x&&!Pt(b)){let z=`React Hook "${t(b)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(g?" Did you accidentally call a React Hook after an early return?":"");e.report({node:b,message:z})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let F=`React Hook "${t(b)}" 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:b,message:F})}else if(v){let F=`React Hook "${t(b)}" is called in function "${t(v)}" 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:b,message:F})}else if(p.type==="Program"){let F=`React Hook "${t(b)}" 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:b,message:F})}else if(C&&!Pt(b)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let z=p.parent;if(z.parent.type==="VariableDeclarator"&&jn(z.parent.id.name))return}let F=`React Hook "${t(b)}" 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:b,message:F})}}},CallExpression(l){if(He(l.callee)){let p=Dn(s),c=Dn(a),u=p.get(c);u||(u=[],p.set(c,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Nn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==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===n&&(n=null)},FunctionDeclaration(l){Ot(l)&&i(r(l))},ArrowFunctionExpression(l){Ot(l)&&i(r(l))}}}};function Wn(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 Dn(e){return e[e.length-1]}import{AST_NODE_TYPES as Vn}from"@typescript-eslint/utils";function ns(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function rs(e){let t=e.parent;return t?.type===Vn.NewExpression&&t.callee.type===Vn.Identifier&&t.callee.name==="RegExp"}var Ft=q({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function t(r){ns(r)||rs(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});var Hn={[bt.name]:bt.rule,[rt.name]:rt.rule,[nt.name]:nt.rule,"rules-of-hooks":Un,"exhaustive-deps":Jt,"require-description":Fn.rule,[it.name]:it.rule,[ot.name]:ot.rule,[It.name]:It.rule,[qe.name]:qe.rule,[tt.name]:tt.rule,[ut.name]:ut.rule,[At.name]:At.rule,[pt.name]:pt.rule,[st.name]:st.rule,[Ge.name]:Ge.rule,[vt.name]:vt.rule,[Be.name]:Be.rule,[et.name]:et.rule,[yt.name]:yt.rule,[gt.name]:gt.rule,[Tt.name]:Tt.rule,[ht.name]:ht.rule,[St.name]:St.rule,[Rt.name]:Rt.rule,[mt.name]:mt.rule,[ft.name]:ft.rule,[Ft.name]:Ft.rule,[xt.name]:xt.rule,[kt.name]:kt.rule};var $a={rules:Hn};export{$a as extendedLintPlugin};
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let S=a.acquire(x),R=new Set,A=null;{let f=S.upper;for(;f&&(R.add(f),f.type!=="function");)f=f.upper;if(!f)return;A=f}let I=Array.isArray;function F(f){if(!I(f.defs))return!1;let g=f.defs[0];if(g==null||g.node.type!=="VariableDeclarator")return!1;let w=g.node.init;if(w==null)return!1;for(;w.type==="TSAsExpression";)w=w.expression;let v=g.node.parent;if(v==null&&(Qe(A.block,g.node.id),v=g.node.parent,v==null))return!1;if(v.kind==="const"&&w.type==="Literal"&&(typeof w.value=="string"||typeof w.value=="number"||w.value===null))return!0;if(w.type!=="CallExpression")return!1;let O=w.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let k=g.node.id,{name:N}=O;if(N==="useRef"&&k.type==="Identifier")return!0;if(yn(O)&&k.type==="Identifier"){for(let j of f.references)j!==k&&y.add(j.identifier);return!0}else if(N==="useState"||N==="useReducer"){if(k.type==="ArrayPattern"&&k.elements.length===2&&I(f.identifiers)){if(k.elements[1]===f.identifiers[0]){if(N==="useState"){let j=f.references,se=0;for(let ye=0;ye<j.length;ye++){if(j[ye].isWrite()&&se++,se>1)return!1;p.set(j[ye].identifier,k.elements[0])}}return!0}else if(k.elements[0]===f.identifiers[0]){if(N==="useState"){let j=f.references;for(let se=0;se<j.length;se++)c.add(j[se].identifier)}return!1}}}else if(N==="useTransition"&&k.type==="ArrayPattern"&&k.elements.length===2&&Array.isArray(f.identifiers)&&k.elements[1]===f.identifiers[0])return!0;return!1}function Y(f){if(!I(f.defs))return!1;let g=f.defs[0];if(g==null||g.node==null||g.node.id==null)return!1;let w=g.node,v=A.childScopes,O=null,k;for(k=0;k<v.length;k++){let N=v[k],j=N.block;if(w.type==="FunctionDeclaration"&&j===w||w.type==="VariableDeclarator"&&j.parent===w){O=N;break}}if(O==null)return!1;for(k=0;k<O.through.length;k++){let N=O.through[k];if(N.resolved!=null&&R.has(N.resolved.scope)&&!B(N.resolved))return!1}return!0}let B=E(F,u),te=E(Y,d),Q=new Map;function be(f){let g=f.from,w=!1;for(;g.block!==x;)g.type==="function"&&(w=g.block.parent!=null&&g.block.parent.type==="ReturnStatement"),g=g.upper;return w}let ne=new Map,ve=new Map;me(S);function me(f){for(let g of f.references){if(!g.resolved||!R.has(g.resolved.scope))continue;let w=Qe(x,g.identifier),v=Jt(w),O=ge(v,ve);if(m&&v.type==="Identifier"&&(v.parent.type==="MemberExpression"||v.parent.type==="OptionalMemberExpression")&&!v.parent.computed&&v.parent.property.type==="Identifier"&&v.parent.property.name==="current"&&be(g)&&Q.set(O,{reference:g,dependencyNode:v}),v.parent.type==="TSTypeQuery"||v.parent.type==="TSTypeReference")continue;let k=g.resolved.defs[0];if(k!=null&&!(k.node!=null&&k.node.init===x.parent)&&k.type!=="TypeParameter")if(ne.has(O))ne.get(O).references.push(g);else{let N=g.resolved,j=B(N)||te(N);ne.set(O,{isStable:j,references:[g]})}}for(let g of f.childScopes)me(g)}Q.forEach(({reference:f,dependencyNode:g},w)=>{let v=f.resolved.references,O=!1;for(let k=0;k<v.length;k++){let{identifier:N}=v[k],{parent:j}=N;if(j!=null&&j.type==="MemberExpression"&&!j.computed&&j.property.type==="Identifier"&&j.property.name==="current"&&j.parent.type==="AssignmentExpression"&&j.parent.left===j){O=!0;break}}O||s({node:g.parent.property,message:`The ref value '${w}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${w}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ue=new Set;function de(f,g){ue.has(g)||(ue.add(g),s({node:f,message:`Assignments to the '${g}' variable from inside React Hook ${n(P)} 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(P)}.`}))}let xe=new Set;if(ne.forEach(({isStable:f,references:g},w)=>{f&&xe.add(w),g.forEach(v=>{v.writeExpr&&de(v.writeExpr,w)})}),ue.size>0)return;if(!M){let f=null;if(ne.forEach(({isStable:g,references:w},v)=>{f||w.forEach(O=>{if(f)return;let k=O.identifier;if(!p.has(k))return;let j=O.from;for(;j.type!=="function";)j=j.upper;j.block===x&&(f=v)})}),f){let{suggestedDependencies:g}=Ke({dependencies:ne,declaredDependencies:[],stableDependencies:xe,externalDependencies:new Set,isEffect:!0});s({node:P,message:`React Hook ${b} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+g.join(", ")+`] as a second argument to the ${b} Hook.`,suggest:[{desc:`Add dependencies array: [${g.join(", ")}]`,fix(w){return w.insertTextAfter(x,`, [${g.join(", ")}]`)}}]})}return}let ke=[],Oe=new Set;M.type!=="ArrayExpression"?s({node:M,message:`React Hook ${n(P)} 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.`}):M.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){s({node:f,message:`React Hook ${n(P)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}y.has(f)&&s({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(f)}\``,fix(O){return O.removeRange(f.range)}}]});let g;try{g=ge(f,ve)}catch(O){if(/Unsupported node type/.test(O.message)){f.type==="Literal"?ne.has(f.value)?s({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):s({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:f,message:`React Hook ${n(P)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let w=f;for(;w.type==="MemberExpression"||w.type==="OptionalMemberExpression"||w.type==="ChainExpression";)w=w.object||w.expression.object;let v=!A.through.some(O=>O.identifier===w);ke.push({key:g,node:f}),v||Oe.add(g)});let{suggestedDependencies:zr,unnecessaryDependencies:Ne,missingDependencies:Te,duplicateDependencies:Nt}=Ke({dependencies:ne,declaredDependencies:ke,stableDependencies:xe,externalDependencies:Oe,isEffect:m}),De=zr;if(Nt.size+Te.size+Ne.size===0){if(t)return;un({declaredDependencies:ke,declaredDependenciesNode:M,componentScope:A,scope:S}).forEach(({construction:g,isUsedOutsideOfHook:w,depType:v})=>{let O=v==="function"?"useCallback":"useMemo",k=v==="function"?"definition":"initialization",N=`wrap the ${k} of '${g.name.name}' in its own ${O}() Hook.`,j=w?`To fix this, ${N}`:`Move it inside the ${b} callback. Alternatively, ${N}`,se=v==="conditional"||v==="logical expression"?"could make":"makes",ye=`The '${g.name.name}' ${v} ${se} the dependencies of ${b} Hook (at line ${M.loc.start.line}) change on every render. ${j}`,Dt;w&&g.type==="Variable"&&v==="function"&&(Dt=[{desc:`Wrap the ${k} of '${g.name.name}' in its own ${O}() Hook.`,fix(jt){let[Yr,qr]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[jt.insertTextBefore(g.node.init,Yr),jt.insertTextAfter(g.node.init,qr)]}}]),s({node:g.node,message:ye,suggest:Dt})});return}!m&&Te.size>0&&(De=Ke({dependencies:ne,declaredDependencies:[],stableDependencies:xe,externalDependencies:Oe,isEffect:m}).suggestedDependencies);function Hr(){if(ke.length===0)return!0;let f=ke.map(w=>w.key),g=f.slice().sort();return f.join(",")===g.join(",")}Hr()&&De.sort();function He(f){let g=f.split("."),w="";for(let v=0;v<g.length;v++){if(v!==0){let O=g.slice(0,v+1).join("."),k=ve.get(O)===!0;w+=k?"?.":"."}w+=g[v]}return w}function Ye(f,g,w,v){return f.size===0?null:(f.size>1?"":g+" ")+w+" "+(f.size>1?"dependencies":"dependency")+": "+mn(Array.from(f).sort().map(O=>"'"+He(O)+"'"))+`. Either ${v} ${f.size>1?"them":"it"} or remove the dependency array.`}let le="";if(Ne.size>0){let f=null;if(Array.from(Ne.keys()).forEach(g=>{f===null&&g.endsWith(".current")&&(f=g)}),f!==null)le=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Oe.size>0){let g=Array.from(Oe)[0];S.set.has(g)||(le=` Outer scope values like '${g}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!le&&Te.has("props")){let f=ne.get("props");if(f==null)return;let g=f.references;if(!Array.isArray(g))return;let w=!0;for(let v=0;v<g.length;v++){let O=g[v],k=Qe(A.block,O.identifier);if(!k){w=!1;break}let N=k.parent;if(N==null){w=!1;break}if(N.type!=="MemberExpression"&&N.type!=="OptionalMemberExpression"){w=!1;break}}w&&(le=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${b} call and refer to those specific props inside ${n(P)}.`)}if(!le&&Te.size>0){let f=null;Te.forEach(g=>{if(f)return;let w=A.set.get(g),v=ne.get(g);if(v.references[0].resolved!==w)return;let O=w.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let k=!1,N;for(let j=0;j<v.references.length;j++)if(N=v.references[j].identifier,N!=null&&N.parent!=null&&(N.parent.type==="CallExpression"||N.parent.type==="OptionalCallExpression")&&N.parent.callee===N){k=!0;break}k&&(f=g)}),f!==null&&(le=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!le&&Te.size>0){let f=null;if(Te.forEach(g=>{if(f!==null)return;let v=ne.get(g).references,O,k;for(let N=0;N<v.length;N++){for(O=v[N].identifier,k=O.parent;k!=null&&k!==A.block;){if(k.type==="CallExpression"){let j=p.get(k.callee);if(j!=null){if(j.name===g)f={missingDep:g,setter:k.callee.name,form:"updater"};else if(c.has(O))f={missingDep:g,setter:k.callee.name,form:"reducer"};else{let se=v[N].resolved;if(se!=null){let ye=se.defs[0];ye!=null&&ye.type==="Parameter"&&(f={missingDep:g,setter:k.callee.name,form:"inlineReducer"})}}break}}k=k.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":le=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":le=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":le=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:M,message:`React Hook ${n(P)} has `+(Ye(Te,"a","missing","include")||Ye(Ne,"an","unnecessary","exclude")||Ye(Nt,"a","duplicate","omit"))+le,suggest:[{desc:`Update the dependencies array to be: [${De.map(He).join(", ")}]`,fix(f){return f.replaceText(M,`[${De.map(He).join(", ")}]`)}}]})}function T(x){let M=fn(x.callee,i);if(M===-1)return;let P=x.arguments[M],b=x.callee,m=Bt(b).name,S=x.arguments[M+1],R=/Effect($|[^a-z])/g.test(m);if(!P){s({node:b,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!R)){if(!S&&!R){(m==="useMemo"||m==="useCallback")&&s({node:b,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(P.type){case"FunctionExpression":case"ArrowFunctionExpression":h(P,S,b,m,R);return;case"Identifier":if(!S||S.elements&&S.elements.some(F=>F&&F.type==="Identifier"&&F.name===P.name))return;let A=r(x).set.get(P.name);if(A==null||A.defs==null)return;let I=A.defs[0];if(!I||!I.node||I.type!=="Variable"&&I.type!=="FunctionName")break;switch(I.node.type){case"FunctionDeclaration":h(I.node,S,b,m,R);return;case"VariableDeclarator":let F=I.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":h(F,S,b,m,R);return}break}break;default:s({node:b,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:b,message:`React Hook ${m} has a missing dependency: '${P.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${P.name}]`,fix(A){return A.replaceText(S,`[${P.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let x of e.sourceCode.getAllComments())if(cn.test(x.value))return t=!0,{CallExpression:M=>T(M,!0)}}return{CallExpression:x=>T(x)}}};function Ke({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:o}){let l=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((h,T)=>{let x=s(l,T);x.isUsed=!0,a(l,T,M=>{M.isSubtreeUsed=!0})}),t.forEach(({key:h})=>{let T=s(l,h);T.isSatisfiedRecursively=!0}),n.forEach(h=>{let T=s(l,h);T.isSatisfiedRecursively=!0});function s(h,T){let x=T.split("."),M=h;for(let P of x){let b=M.children.get(P);b||(b=i(),M.children.set(P,b)),M=b}return M}function a(h,T,x){let M=T.split("."),P=h;for(let b of M){let m=P.children.get(b);if(!m)return;x(m),P=m}}let p=new Set,c=new Set;u(l,p,c,h=>h);function u(h,T,x,M){h.children.forEach((P,b)=>{let m=M(b);if(P.isSatisfiedRecursively){P.isSubtreeUsed&&x.add(m);return}if(P.isUsed){T.add(m);return}u(P,T,x,S=>m+"."+S)})}let d=[],y=new Set,E=new Set;return t.forEach(({key:h})=>{c.has(h)?d.indexOf(h)===-1?d.push(h):E.add(h):y.add(h)}),p.forEach(h=>{d.push(h)}),{suggestedDependencies:d,unnecessaryDependencies:y,duplicateDependencies:E,missingDependencies:p}}function he(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 he(e.consequent)!=null||he(e.alternate)!=null?"conditional":null;case"LogicalExpression":return he(e.left)!=null||he(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return he(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return he(e.expression);case"TSAsExpression":return he(e.expression)}return null}function un({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let o=e.map(({key:i})=>{let s=n.variables.find(p=>p.name===i);if(s==null)return null;let a=s.defs[0];if(a==null)return null;if(a.type==="Variable"&&a.node.type==="VariableDeclarator"&&a.node.id.type==="Identifier"&&a.node.init!=null){let p=he(a.node.init);if(p!=null)return[s,p]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[s,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function l(i){let s=!1;for(let a=0;a<i.references.length;a++){let p=i.references[a];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==r&&c!=null;)c=c.upper;if(c!==r&&!Xt(t,p.identifier))return!0}return!1}return o.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:l(i)}))}function Jt(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)?Jt(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 ge(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=ge(e.object,t),r=ge(e.property,null),o=`${n}.${r}`;return Ze(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=ge(e.object,t),r=ge(e.property,null),o=`${n}.${r}`;return Ze(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=ge(n.object,t),o=ge(n.property,null),l=`${r}.${o}`;return Ze(n,t,l),l}else throw new Error(`Unsupported node type: ${e.type}`)}function Bt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function fn(e,t){let n=Bt(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=ge(n,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(r)?0:-1}else return-1}}function Qe(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),dn(r,t))return r;if(Xt(r,t))for(let[o,l]of Object.entries(r))o!=="parent"&&(Yt(l)?(l.parent=r,n.push(l)):Array.isArray(l)&&l.forEach(i=>{Yt(i)&&(i.parent=r,n.push(i))}))}return null}function mn(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function dn(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 Xt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function yn(e){return!1}import{AST_NODE_TYPES as Me,ESLintUtils as Kt}from"@typescript-eslint/utils";import re from"typescript";var gn=Kt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="improved-no-unnecessary-condition",Sn=V({}),Tn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],hn=new Set(Tn),et={name:Gt,rule:gn({name:Gt,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:[Sn]},defaultOptions:[{}],create(e){let t=Kt.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(s){return s.type===Me.UnaryExpression&&s.operator==="typeof"}function o(s){return s.flags&re.TypeFlags.Any||s.flags&re.TypeFlags.Unknown?null:s.flags&re.TypeFlags.StringLike?["string"]:s.flags&re.TypeFlags.NumberLike?["number"]:s.flags&re.TypeFlags.BigIntLike?["bigint"]:s.flags&re.TypeFlags.BooleanLike?["boolean"]:s.flags&re.TypeFlags.ESSymbolLike?["symbol"]:s.flags&re.TypeFlags.Undefined||s.flags&re.TypeFlags.Void?["undefined"]:s.flags&re.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&re.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&re.TypeFlags.NonPrimitive?["object"]:s.flags&re.TypeFlags.Never?["never"]:null}function l(s){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(s),p=n.getTypeAtLocation(a.expression);if(p.flags&re.TypeFlags.Any||p.flags&re.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let d of p.types){let y=o(d);if(y)c.push(...y);else return null}return c}let u=o(p);return u?(c.push(...u),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(r(s.left)?(p=s.left,c=s.right.type===Me.Literal&&typeof s.right.value=="string"?s.right.value:null):r(s.right)&&(p=s.right,c=s.left.type===Me.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!En(c,hn))return;let u=l(p);if(!u)return;let d=s.operator==="!==",y=u.includes(c);u.length===1?y&&!d?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:we(p,e),type:c}}):!y&&d?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:we(p,e),type:Array.from(u)[0]}}):!y&&!d?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:we(p,e),actualType:je(u),conditionType:c}}):y&&d&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:we(p,e),actualType:je(u),conditionType:c}}):!y&&!d?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:we(p,e),actualType:je(u),conditionType:c}}):!y&&d&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:we(p,e),type:je(u)}})}return{BinaryExpression:i}}})};function je(e){return Array.from(new Set(e)).join(" | ")||"never"}function we(e,t){let n=e.argument;return n.type===Me.Identifier?n.name:t.sourceCode.getText(n)}function En(e,t){return t.has(e)}import{AST_NODE_TYPES as bn,ESLintUtils as xn}from"@typescript-eslint/utils";var Cn=xn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-call-with-explicit-generics",In=V({functions:K(W())}),wn=Cn({name:Zt,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[In]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:o}=r;o.type===bn.Identifier&&n.has(o.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),tt={name:Zt,rule:wn};import{AST_NODE_TYPES as Le,ESLintUtils as An}from"@typescript-eslint/utils";var Rn=An.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="no-call-with-inferred-generics",vn=Rn({name:Qt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:o}=r;if(o.type!==Le.Identifier)return;let l=n.get(o.name);if(!l)return;let{minGenerics:i=1,allowAny:s,disallowTypes:a=t.disallowTypes}=l;(r.typeArguments?.params.length||0)<(i||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(s&&!a)&&r.typeArguments?.params?.some(c=>!s&&c.type===Le.TSAnyKeyword||a&&c.type===Le.TSTypeReference&&c.typeName.type===Le.Identifier&&a.includes(c.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),rt={name:Qt,rule:vn};import{ESLintUtils as kn}from"@typescript-eslint/utils";var On=kn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tr="no-commented-out-code",Pn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],J={returnStatement:/^\s*return\s+/,stringAssignment:/\w=("|'|`)/,objectPropertyWithQuotes:/\w+:\s*('|"|`)/,computedPropertyAssignment:/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,kebabCaseProperty:/\w+-\w+:/,snakeCaseProperty:/\w+_\w+:/,ternaryOperator:/\?\s+\w/,colonWithWord:/:\s+\w/,quotedString:/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,numberWithComma:/^\s*\d+[,}]/,arrayWithComma:/^\s*\[[^\]]*\][,}]/,objectWithComma:/^\s*\{[^}]*\}[,}]/,methodCall:/\.\w+\(/,arrayAccess:/\[\w+\]/,quotedPropertyKey:/^\s*(['"`]).+?\1\s*:/,jsxSelfClosing:/^<[A-Z]\w*(\s|>|\/)/,jsxElement:/^<[a-z]+(\s|>|\/)/,jsxOpeningTag:/<[A-Z]\w*(\s.*)?>/,jsxClosingTag:/<\/[A-Z]\w*>/,htmlOpeningTag:/<[a-z]+(\s.*)?>/,htmlClosingTag:/<\/[a-z]+>/,colonDescriptiveComment:/^[a-zA-Z]+(\s+[a-zA-Z]+)*:\s+[a-zA-Z]+\s+[a-zA-Z][^{=,'"]*$/,jsdocComment:/^\s*[*\s]*$/},Fn=[") {","return;",J.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",J.stringAssignment,");",J.objectPropertyWithQuotes,J.computedPropertyAssignment,J.kebabCaseProperty,J.snakeCaseProperty,"&&","||","()",J.ternaryOperator,J.colonWithWord,J.quotedString,J.numberWithComma,J.arrayWithComma,J.objectWithComma,J.methodCall,J.arrayAccess,"?.(","??","=>",J.quotedPropertyKey],Nn=["/>","</",J.jsxSelfClosing,J.jsxElement,J.jsxOpeningTag,J.jsxClosingTag,J.htmlOpeningTag,J.htmlClosingTag],er=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Dn=On({name:tr,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(r,o){if(r.startsWith("/"))return!1;let l=r.trimStart();if(r.startsWith("*")||l.startsWith("eslint-disable")||r.includes("@deprecated")||r.includes("@example")||r.includes("@param")||r.includes("@returns")||r.includes("@throws")||r.includes("typescript-eslint")||r.includes("@ts-")||r.includes("prettier-ignore")||J.jsdocComment.test(r))return!1;for(let i of er)if(l.startsWith(i))return!1;if(r.includes("https://")||l.includes(":")&&J.colonDescriptiveComment.test(l.trim()))return!1;if(o==="Block"){for(let i of Nn)if(typeof i=="string"){if(r.includes(i))return{wrongPattern:i}}else if(i.test(r))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Pn)if(l.startsWith(i))return{wrongPattern:i};for(let i of Fn)if(typeof i=="string"){if(r.includes(i))return{wrongPattern:i}}else if(i.test(r))return{wrongPattern:`regex(${i.toString()})`};return!1}function n(r,o){let l=r,i=l.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return l;if(o==="Block"&&l.includes("```")){let p=l.split(/```[\s\S]*?```/g);p.some(u=>/[a-zA-Z0-9]/.test(u))&&(l=p.join(""))}if(!l.includes("`"))return l;let s=l.split(/`[^`]*`/g);return s.some(p=>/[a-zA-Z0-9]/.test(p))?s.join(""):l}return{Program(){let o=e.sourceCode.getAllComments();for(let l of o){let i=n(l.value,l.type),s=t(i,l.type);s&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:er.join(", ")}})}}}}}),nt={name:tr,rule:Dn};import{ESLintUtils as jn,TSESTree as Mn}from"@typescript-eslint/utils";var Ln=jn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rr="no-default-export",_n=Ln({name:rr,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===Mn.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),it={name:rr,rule:_n};import{ESLintUtils as $n}from"@typescript-eslint/utils";var Un=$n.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nr="no-leaked-text-in-jsx",Wn=[",",";","[","]","(",")"],Vn=Un({name:nr,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="";Wn.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),st={name:nr,rule:Vn};import{AST_NODE_TYPES as Pe,ESLintUtils as zn}from"@typescript-eslint/utils";var Hn=zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sr="no-non-camel-case-functions",Yn=/^(\$?[a-z][a-zA-Z0-9]*)$/;function ir(e){if(e.typeName.type!==Pe.TSQualifiedName)return!1;let{left:t,right:n}=e.typeName;return t.type===Pe.Identifier&&t.name==="JSX"&&n.name==="Element"}var qn=Hn({name:sr,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Yn.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===Pe.TSTypeReference?ir(n):n.type===Pe.TSUnionType&&n.types.some(o=>o.type===Pe.TSTypeReference&&ir(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ot={name:sr,rule:qn};import{ESLintUtils as Jn,TSESTree as z}from"@typescript-eslint/utils";import{AST_NODE_TYPES as or}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*at(e){yield e,e.parent&&(yield*at(e.parent))}function lt(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function ar(e,t,n){let o=n.getDeclaredVariables(e).find(l=>l.name===t||l.identifiers[0]?.parent.type===or.Property&&l.identifiers[0]?.parent.key.type===or.Identifier&&l.identifiers[0]?.parent.key.name===t);return o?o.references.filter(l=>!l.init):[]}var Bn=Jn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lr="no-optional-root-props",Xn=Bn({name:lr,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let l=e.sourceCode.getDeclaredVariables(r)[0];if(!l||l.references.length!==1)return!1;let i=l.references[0];if(!i)return!1;for(let s of at(i.identifier)){if("returnType"in s||s.type===z.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let a=s.parent;if(!a)return!1;if(a.type===z.AST_NODE_TYPES.TSTypeParameterInstantiation&&a.parent.type===z.AST_NODE_TYPES.TSTypeReference&&a.parent.typeName.type===z.AST_NODE_TYPES.Identifier&&a.parent.typeName.name==="FC"){let c=Ae(a.parent.parent,z.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let u=_e(c,e.sourceCode);return u?!(u.parent.type===z.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===z.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(s.type===z.AST_NODE_TYPES.AssignmentPattern)return!1;if(a.type===z.AST_NODE_TYPES.ArrowFunctionExpression){let p=Ae(a,z.AST_NODE_TYPES.VariableDeclaration);return p?!!_e(p,e.sourceCode):!1}if(a.type===z.AST_NODE_TYPES.FunctionDeclaration)return!!_e(a,e.sourceCode)}return!1}function n(r){r.key.type!==z.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:o=>{let l=Ae(r,z.AST_NODE_TYPES.TSPropertySignature);if(!l)return null;let i=e.sourceCode.getText(l);return o.replaceText(l,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===z.AST_NODE_TYPES.TSTypeLiteral&&!($e(r)||!t(r)))for(let o of r.typeAnnotation.members)o.type===z.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSInterfaceDeclaration(r){if(!($e(r)||!t(r)))for(let o of r.body.body)o.type===z.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSTypeReference(r){if(r.typeName.type!==z.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let o=r.typeArguments.params[0];if(o.type!==z.AST_NODE_TYPES.TSTypeLiteral)return;let l=Ae(r.parent,z.AST_NODE_TYPES.VariableDeclaration,4);if(!l)return;let i=_e(l,e.sourceCode);if(!(!i||i.parent.type===z.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===z.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let a of o.members)a.type===z.AST_NODE_TYPES.TSPropertySignature&&n(a)}}}});function $e(e){return e?e.parent?.type===z.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===z.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function _e(e,t){if($e(e))return;let n;if(e.type===z.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===z.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===z.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let o=r.variables.find(i=>i.identifiers.includes(n));if(!o)return;let l=o.references.filter(i=>i.identifier!==n);if(!(l.length!==1||!l[0])&&!$e(l[0].identifier.parent.parent))return l[0].identifier}var pt={name:lr,rule:Xn};import{ESLintUtils as Gn}from"@typescript-eslint/utils";import ct from"node:path";var Kn=Gn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pr="no-relative-imports",Zn=V({find:W(),replacement:W()}),Qn=V({aliases:K(Zn),rootDir:_(W()),allowNotFoundAliases:_(Ce()),_dev_simulateFileName:_(W())}),ei=Kn({name:pr,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:[Qn]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(i){return i.startsWith(".")||i.startsWith("..")}function o(i,s){let a=ct.dirname(s);return ct.resolve(a,i)}function l(i){let s=t.rootDir??process.cwd(),a=ct.relative(s,i);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:p,replacement:c}of t.aliases)if(a.startsWith(c)){let u=a.replace(c,p);return{alias:p,newPath:u}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!r(s))return;let a=o(s,n),p=l(a);!p&&t.allowNotFoundAliases||e.report({node:i,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(i.source,`'${p.newPath}'`):void 0})}}}}),ut={name:pr,rule:ei};import{AST_NODE_TYPES as Ue}from"@typescript-eslint/utils";import*as Ee from"zod/v4";var ti=Ee.object({alternativeMsgs:Ee.object({inArrayFind:Ee.string().optional(),inArrayFilter:Ee.string().optional()}).optional(),__dev_simulateFileName:Ee.string().optional()});function ri(e){return e.typeAnnotation.type!==Ue.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function ni(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ii(e){let t=e.parent;for(;t;){if(t.type===Ue.CallExpression&&t.callee.type===Ue.MemberExpression&&t.callee.property.type===Ue.Identifier){let n=t.callee.property.name;if(n==="filter"||n==="find")return{method:n}}t=t.parent}return null}var ft=X({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[Ie(ti)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let n=t.__dev_simulateFileName??e.filename;if(ni(n))return{};function r(o){if(!ri(o))return;let l=ii(o),i=[];if(t.alternativeMsgs&&l){let s=l.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(s){let a=l.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:a,data:{message:s}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":r,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":r,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":r}}});import{AST_NODE_TYPES as Re}from"@typescript-eslint/utils";var si="no-unnecessary-async-on-jsx-props";function oi(e){if(e.body.type!==Re.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let n=t[0];return!n||n.type!==Re.ExpressionStatement?!1:n.expression.type===Re.AwaitExpression}var mt=X({name:si,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(n){oi(n)&&e.report({node:n,messageId:"unnecessaryAsyncInJsxProp",fix(r){let o=e.sourceCode,l=[],i=o.getFirstToken(n,a=>a.value==="async");if(i){let a=o.getTokenAfter(i);a?l.push(r.replaceTextRange([i.range[0],a.range[0]],"")):l.push(r.remove(i))}function s(a){if(a.type===Re.AwaitExpression){let p=o.getFirstToken(a);if(p&&p.value==="await"){let c=o.getTokenAfter(p);c?l.push(r.replaceTextRange([p.range[0],c.range[0]],"")):l.push(r.remove(p))}}if(a.type===Re.BlockStatement)for(let p of a.body)s(p);else a.type===Re.ExpressionStatement&&s(a.expression)}return s(n.body),l}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as Fe,ESLintUtils as ur}from"@typescript-eslint/utils";import*as dt from"typescript";var ai=ur.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cr="no-unnecessary-casting",li=V({additionalCastFunctions:_(K(V({name:W(),expectedType:Mt(["string","number"])})))}),yt={name:cr,rule:ai({name:cr,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:[li],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],o=ur.getParserServices(e,!0),l=o.program?.getTypeChecker();if(!l||!o.program)throw new Error("TypeScript services or program not available");function i(c,u){switch(c.type){case Fe.Literal:return u==="number"?typeof c.value=="number":typeof c.value=="string";case Fe.TemplateLiteral:return u==="string";case Fe.UnaryExpression:return u==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function s(c,u){return u==="number"?!!(c.flags&dt.TypeFlags.NumberLike):!!(c.flags&dt.TypeFlags.StringLike)}function a(c,u){return d=>d.replaceText(c,e.sourceCode.getText(u))}function p(c){if(!l||c.arguments.length!==1)return;let u=c.arguments[0];if(!u||u.type===Fe.SpreadElement)return;let{callee:d}=c;if(d.type!==Fe.Identifier)return;let y=d.name,E=r.find(T=>T.name===y);if(!E)return;if(i(u,E.expectedType)||s(l.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),E.expectedType)){let T,x;y==="Number"?T="unnecessaryNumberCasting":y==="String"?T="unnecessaryStringCasting":(T="unnecessaryCustomCasting",x={name:E.name,type:E.expectedType}),e.report({node:c,messageId:T,...x?{data:x}:{},fix:a(c,u)})}}return{CallExpression:p}}})};import{AST_NODE_TYPES as We}from"@typescript-eslint/utils";import*as oe from"zod/v4";var pi=oe.object({methods:oe.union([oe.array(oe.string()),oe.literal("array")])}),gt=X({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[oe.toJSONSchema(pi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let n=t.methods,r=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(s){return Array.isArray(n)?n.includes(s):r.has(s)}function l(s){let{callee:a}=s;if(a.type===We.MemberExpression){let p=a.property;if(p.type===We.Identifier)return p.name}return null}function i(s,a){if(s.type!==We.Identifier||!s.typeAnnotation)return;let p=a.parent;if(p.type===We.CallExpression){let c=l(p);c&&o(c)&&p.arguments.indexOf(a)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(d){return d.remove(s.typeAnnotation)}})}}return{ArrowFunctionExpression(s){for(let a of s.params)i(a,s)},FunctionExpression(s){for(let a of s.params)i(a,s)}}}});import{AST_NODE_TYPES as ie}from"@typescript-eslint/utils";var St=X({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===ie.ObjectPattern||!t.init||t.init.type!==ie.ObjectExpression||t.id.type===ie.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ie.ExportNamedDeclaration)return;let n=new Map;for(let i of t.init.properties)i.type===ie.Property&&i.key.type===ie.Identifier&&n.set(i.key.name,i);if(n.size===0||t.id.type!==ie.Identifier)return;let r=ci(t,e.sourceCode);if(r.length===0)return;let o=t.init.properties.some(i=>i.type!==ie.Property?!1:i.value.type===ie.FunctionExpression),l=new Set;for(let i of r){if(i.identifier.parent.type!==ie.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===ie.Literal&&typeof s.property.value=="string")l.add(s.property.value);else return;else{if(s.property.type!==ie.Identifier)return;l.add(s.property.name)}if(s.parent.type===ie.CallExpression&&o)return}for(let[i,s]of n)l.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function ci(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as q,ESLintUtils as ui}from"@typescript-eslint/utils";var fi=V({selectors:K(V({name:W(),selectorProp:_(W()),selectorArgPos:_(fe()),returnProp:_(W())}))}),mi=ui.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fr="no-unused-selected-values",Tt={name:fr,rule:mi({name:fr,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[fi]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.map(o=>[o.name,o]));return{VariableDeclarator(o){let l=null;if(o.init?.type===q.CallExpression&&(l=o.init),!l)return;let i=yi(l);if(!i)return;let s=r.get(i);if(!s)return;let a=di(l,s.selectorArgPos??0,s.selectorProp);if(!a)return;let p=gi(a);if(!p)return;let c=mr(p.properties,void 0);if(!c)return;if(o.id.type===q.ObjectPattern){let y=mr(o.id.properties,s.returnProp);if(!y)return;for(let[E,h]of c)y.has(E)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:E}});return}if(o.id.type!==q.Identifier||s.returnProp)return;let u=Si(o,e.sourceCode);if(u.length===0)return;let d=new Set;for(let y of u){if(y.identifier.parent.type!==q.MemberExpression)return;let E=y.identifier.parent.property;if(E.type!==q.Identifier)return;d.add(E.name)}for(let[y,E]of c)d.has(y)||e.report({node:E,messageId:"unusedSelectedValue",data:{name:y}})}}}})};function di(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===q.ArrowFunctionExpression||r.type===q.FunctionExpression)return r;if(n&&r.type===q.ObjectExpression){let o=r.properties.find(i=>i.type===q.Property&&i.key.type===q.Identifier&&i.key.name===n);if(o?.type!==q.Property)return null;let l=o.value;if(l.type===q.ArrowFunctionExpression||l.type===q.FunctionExpression)return l}return null}function yi(e){return e.callee.type===q.Identifier?e.callee.name:e.callee.type===q.MemberExpression&&e.callee.property.type===q.Identifier?e.callee.property.name:null}function gi(e){if(e.body.type===q.ObjectExpression)return e.body;if(e.body.type===q.BlockStatement){let t=e.body.body.filter(n=>n.type===q.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==q.ObjectExpression?null:t[0].argument}return null}function mr(e,t){let n=e;if(t){let o=e.find(l=>l.type===q.Property&&l.key.type===q.Identifier&&l.key.name===t);if(o?.type!==q.Property||o.value.type!==q.ObjectPattern)return null;n=o.value.properties}let r=new Map;for(let o of n){if(o.type!==q.Property||o.key.type!==q.Identifier)return null;r.set(o.key.name,o)}return r.size>0?r:null}function Si(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as H}from"@typescript-eslint/utils";var ht=X({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(l=>l.type===H.ImportDeclaration&&l.source.value==="t-state-form"))return{};let r=null,o=!1;return{CallExpression(l){if(o)return;if(!r){let s=Ti(l);s&&(r=s);return}let i=hi(l,e.sourceCode);if(i){o=!0;for(let s of i)r.delete(s);if(r.size!==0)for(let[s,a]of r)e.report({node:a,messageId:"unusedField",data:{name:s}})}}}}});function Ti(e){if(!(e.callee.type===H.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==H.ObjectExpression)return null;let r=lt(n.properties,l=>l.type!==H.Property||l.key.type!==H.Identifier||l.key.name!=="initialConfig"?null:l.value.type===H.ObjectExpression?l.value:l.value.type===H.ArrowFunctionExpression||l.value.type===H.FunctionExpression?Ei(l.value):null);if(!r)return null;let o=new Map;for(let l of r.properties)l.type===H.Property&&l.key.type===H.Identifier&&o.set(l.key.name,l);return o}function hi(e,t){if(!(e.callee.type===H.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.VariableDeclarator||e.parent.id.type!==H.ObjectPattern||!lt(e.parent.id.properties,i=>i.type===H.Property&&i.key.type===H.Identifier&&i.key.name==="formFields"&&i))return null;let o=ar(e.parent,"formFields",t),l=new Set;for(let{identifier:i}of o){if(i.type!==H.Identifier||i.parent.type===H.Property&&i.parent.parent.type===H.ObjectExpression&&i.parent.parent.parent.type===H.ReturnStatement||i.parent.type===H.ReturnStatement)return null;if(i.parent.type===H.MemberExpression){if(i.parent.object.type!==H.Identifier||i.parent.property.type!==H.Identifier)return null;l.add(i.parent.property.name)}}return l}function Ei(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}import{AST_NODE_TYPES as U,ESLintUtils as bi}from"@typescript-eslint/utils";var xi=bi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function dr(e){let t=[];for(let n of e.members)n.type===U.TSPropertySignature&&n.key.type===U.Identifier&&t.push([n.key.name,n]);return t}function yr(e,...t){for(let n of t)e.set(...n);return e}var Ci=V({forceCheckOnFCPropTypesWithName:_(K(W()))}),gr="no-unused-type-props-in-args",Et=null,Ii=xi({name:gr,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:[Ci],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Et&&(Et=n.map(s=>new RegExp(s)));function r(s,a,p,c,u=!0){let d=p.name,y=e.sourceCode.getScope(a).references.find(T=>T.identifier.name===d)?.resolved,E=s&&Et?.some(T=>T.test(d));if(!y||!E&&y.references.filter(T=>T.isTypeReference).length>1)return;let h=y?.defs[0]?.node;if(!(u&&h?.parent?.type===U.ExportNamedDeclaration)){if(h?.type===U.TSTypeAliasDeclaration){o(s,a,c,h.typeAnnotation,!0);return}if(h?.type===U.TSInterfaceDeclaration){o(s,a,c,h.body,!0);return}}}function o(s,a,p,c,u){if(c.type===U.TSInterfaceBody){for(let d of c.body)d.type===U.TSPropertySignature&&d.key.type===U.Identifier&&p.set(d.key.name,d);return}if(c.type===U.TSTypeLiteral){yr(p,...dr(c));return}if(c.type===U.TSIntersectionType){for(let d of c.types)o(s,a,p,d,!0);return}u||c.type===U.TSTypeReference&&c.typeName.type===U.Identifier&&r(s,a,c.typeName,p)}function l(s,a,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let u=new Map;if(o(s,a,u,c.typeAnnotation.typeAnnotation,!1),u.size===0)continue;i(c,u)}else c.type===U.AssignmentPattern&&c.left.type===U.ObjectPattern&&l(s,a,[c.left])}function i(s,a){let p=[];if(s.properties.at(-1)?.type===U.RestElement)return;for(let y of s.properties)y.type===U.Property&&y.key.type===U.Identifier&&p.push(y.key.name);let u=[],d=[];for(let[y,E]of a)p.includes(y)||(d.push(y),u.push({node:E,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,E]of u.entries())e.report({...E,fix:y===u.length-1?h=>{let T=s.properties.at(-1),x=d.join(", ");return T?T?.type===U.RestElement?null:h.insertTextAfter(T,`, ${x}`):h.insertTextBeforeRange([s.range[0]+1,s.range[1]],`${x}`)}:void 0})}return{VariableDeclaration(s){let a=s.declarations[0];if(!a)return;let p=new Map,c=a.id.type===U.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===U.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===U.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===U.TSTypeReference&&c.typeName.type===U.Identifier)r(!0,s,c.typeName,p,!1);else if(c.type===U.TSTypeLiteral)yr(p,...dr(c));else if(c.type===U.TSIntersectionType)for(let u of c.types)u.type===U.TSTypeReference&&u.typeName.type===U.Identifier?r(!0,s,u.typeName,p,!1):o(!0,s,p,u,!0);if(p.size!==0&&a.init?.type===U.ArrowFunctionExpression){let u=a.init.params[0];if(!u){e.report({node:a.init,messageId:"missingComponentParam"});return}u.type===U.ObjectPattern&&i(u,p)}}},FunctionDeclaration:function(s){l(!1,s,s.params)},ArrowFunctionExpression(s){l(!1,s,s.params)}}}}),bt={name:gr,rule:Ii};import{AST_NODE_TYPES as ce}from"@typescript-eslint/utils";var xt=X({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function n(r){return r.callee.type===ce.Identifier?t.has(r.callee.name):r.callee.type===ce.MemberExpression&&r.callee.object.type===ce.Identifier&&r.callee.property.type===ce.Identifier?r.callee.property.name==="useRef":!1}return{ImportDeclaration(r){if(r.source.value==="react")for(let o of r.specifiers)o.type===ce.ImportSpecifier&&o.imported.type===ce.Identifier&&o.imported.name==="useRef"&&t.add(o.local.name)},VariableDeclarator(r){if(r.init&&r.init.type===ce.CallExpression&&n(r.init)&&r.id.type===ce.Identifier){let l=e.sourceCode.getScope(r).set.get(r.id.name);if(l){let i=!1;for(let s of l.references){let p=s.identifier.parent;if(p!==r&&!(p.type===ce.JSXExpressionContainer&&p.parent.type===ce.JSXAttribute&&p.parent.name.type===ce.JSXIdentifier&&p.parent.name.name==="ref")){i=!0;break}}i||e.report({node:r.id,messageId:"refNotRead",data:{name:r.id.name}})}}}}}});import{AST_NODE_TYPES as Ct,ESLintUtils as wi}from"@typescript-eslint/utils";var Ai=wi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tr="prefer-named-functions",Sr=new Map,Ri=Ai({name:Tr,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=Sr.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),Sr.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===Ct.ArrowFunctionExpression&&r.id.type===Ct.Identifier){let o=r.id.name;if(r.id.typeAnnotation||n&&n.test(o)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==Ct.BlockStatement)return;let l=r.parent,i=r.init.params,s=r.init.body,a=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(l,`${a.async?"async ":""}function ${o}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),It={name:Tr,rule:Ri};import{AST_NODE_TYPES as D}from"@typescript-eslint/utils";var vi=V({disallowedFunctions:K(V({name:W(),allowUsingWithArgs:_(Ce()),hookAlternative:_(W()),message:_(W()),allowUseInside:_(K(W()))}))});function Ve(e){return/^use[A-Z]/.test(e)}function hr(e){return/^[A-Z]/.test(e)}function ki(e){return e.type===D.Identifier?Ve(e.name):e.type===D.MemberExpression&&e.property.type===D.Identifier?Ve(e.property.name):!1}function Er(e,t){return e.type===D.Identifier?e.name===t:e.type===D.MemberExpression&&e.object.type===D.Identifier&&e.property.type===D.Identifier?e.object.name==="React"&&e.property.name===t:!1}function br(e){return!!(e.parent&&e.parent.type===D.CallExpression&&Er(e.parent.callee,"forwardRef"))}function xr(e){return!!(e.parent&&e.parent.type===D.CallExpression&&Er(e.parent.callee,"memo"))}function wt(e){if(e.type===D.FunctionDeclaration||e.type===D.FunctionExpression&&e.id)return e.id||void 0;if(e.type===D.FunctionExpression||e.type===D.ArrowFunctionExpression){if(e.parent.type===D.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===D.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===D.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===D.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Oi(e){let t=e.parent,n=!1;for(;t;){if(t.type===D.FunctionDeclaration||t.type===D.FunctionExpression||t.type===D.ArrowFunctionExpression){let r=wt(t);if(r&&r.type===D.Identifier){if(hr(r.name)||Ve(r.name))return!n;n=!0}else{if(br(t)||xr(t))return!n;if(t.parent.type===D.CallExpression){let o=t.parent;ki(o.callee)||(n=!0)}else t.parent.type===D.JSXExpressionContainer||(n=!0)}}t=t.parent}return!1}function Cr(e){return e.callee.type===D.Identifier?e.callee.name:e.callee.type===D.MemberExpression&&e.callee.property.type===D.Identifier?e.callee.property.name:null}function Pi(e,t){if(!t.length)return!1;let n=e.parent;for(;n;){if(n.type===D.FunctionDeclaration||n.type===D.FunctionExpression||n.type===D.ArrowFunctionExpression){let r=wt(n);if(r&&r.type===D.Identifier&&t.includes(r.name))return!0}else if(n.type===D.CallExpression){let r=Cr(n);if(r&&t.includes(r))return!0}n=n.parent}return!1}function Fi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===D.Identifier&&t.name==="undefined")}function Ni(e,t){let n=!1,r=e.parent;for(;r;){if(r.type===D.FunctionDeclaration||r.type===D.FunctionExpression||r.type===D.ArrowFunctionExpression){let o=wt(r);if(o&&o.type===D.Identifier){if(hr(o.name)||Ve(o.name)){n=!0;break}}else if(br(r)||xr(r)){n=!0;break}}r=r.parent}return n?t.length===0?Oi(e):!Pi(e,t):!1}var At=X({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{{message}}."},schema:[vi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:n}=t,r=new Map(n.map(o=>[o.name,o]));return{CallExpression(o){let l=Cr(o);if(!l)return;let i=r.get(l);if(!i||i.allowUsingWithArgs&&Fi(o))return;let s=i.allowUseInside||[];Ni(o,s)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:a=>{let p=i.hookAlternative;return o.callee.type===D.Identifier?a.replaceText(o.callee,p):o.callee.type===D.MemberExpression&&o.callee.property.type===D.Identifier?a.replaceText(o.callee.property,p):null}}]:[]})}}}});import{AST_NODE_TYPES as G,AST_TOKEN_TYPES as Ir,ESLintUtils as Di}from"@typescript-eslint/utils";var ji=Di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ar="prefer-single-line-if",Mi=V({maxLineLength:_(fe()),maxNonSimpleConditionLength:_(fe())}),Li=ji({name:Ar,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:[Mi]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==G.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let l=r.consequent.body[0];if(l.type===G.ReturnStatement){if(!vr(l))return}else if(!(l.type===G.ContinueStatement||l.type===G.BreakStatement))return;if(r.test.type===G.LogicalExpression||r.test.type===G.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let u=wr(r.test);if(!u&&r.test.type===G.UnaryExpression&&r.test.operator==="!"){let d=r.test.argument;wr(d)&&(u=!0)}if(u&&(i=n.getText(r.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=n.getText(r.test));let s=n.getText(l);if(i.includes(`
|
|
16
|
+
`))return;let a=n.getTokenAfter(r);if(a&&a.type===Ir.Punctuator&&a.value==="}"){let u=n.getTokenAfter(a);if(u&&u.type===Ir.Keyword&&(u.value==="else"||u.value==="catch"))return}let p=_i(n,r),c=`if (${i}) ${s}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:u=>u.replaceText(r,c)})}}}});function wr(e){return e.type===G.CallExpression||e.type===G.BinaryExpression||e.type===G.MemberExpression&&Rr(e)}function Rr(e){return e.object.type===G.MemberExpression?Rr(e.object):e.object.type!==G.Identifier}function _i(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function vr(e){if(!e.argument)return!0;let t=e.argument;return t.type===G.ArrayExpression&&t.elements.length===0||t.type===G.ObjectExpression&&t.properties.length===0||t.type===G.Literal||t.type===G.Identifier||t.type===G.TemplateLiteral||t.type===G.TaggedTemplateExpression?!0:t.type===G.CallExpression?t.arguments.length===0:t.type===G.UnaryExpression?vr(t):!1}var Rt={name:Ar,rule:Li};import{AST_NODE_TYPES as ae,ESLintUtils as $i}from"@typescript-eslint/utils";var Ui=$i.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kr="react-compiler-migration",Wi=V({disallowHooks:_(K(V({name:W(),replacement:W()}))),disallowMethods:_(K(V({name:W(),replacement:_(W()),requireTrueProp:_(W())})))}),Vi=/eslint +react-compiler\/react-compiler: +\["error/;function zi(e){return e.type===ae.Identifier?e.name.startsWith("use"):e.type===ae.MemberExpression&&e.property.type===ae.Identifier?e.property.name.startsWith("use"):!1}var Hi=Ui({name:kr,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:[Wi]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(Vi.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let o=null,l=null;if(r.callee.type===ae.Identifier?(o=r.callee.name,l=r.callee):r.callee.type===ae.MemberExpression&&r.callee.property.type===ae.Identifier&&(o=r.callee.property.name,l=r.callee.property),o){let i=t.disallowHooks.find(s=>s.name===o);i&&l&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(l,i.replacement)}]})}}if(t.disallowMethods?.length&&zi(r.callee)){for(let o of r.arguments)if(o.type===ae.ObjectExpression){for(let l of o.properties)if(l.type===ae.Property&&l.key.type===ae.Identifier){let i=l.key.name,s=t.disallowMethods.find(a=>a.name===i);if(s){if(s.requireTrueProp){let a=s.requireTrueProp,p=!1;for(let c of o.properties)if(c.type===ae.Property&&c.key.type===ae.Identifier&&c.key.name===a&&c.value.type===ae.Literal&&c.value.value===!0){p=!0;break}if(!p){e.report({node:l,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:a}});continue}}s.replacement&&e.report({node:l,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:a=>a.replaceText(l.key,s.replacement)}]})}}}}}}:{}}}),vt={name:kr,rule:Hi};import{ESLintUtils as Yi,TSESTree as qi}from"@typescript-eslint/utils";var Ji=Yi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Or="require-description",Bi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Xi=/^eslint-disable-(next-)?line$/u,Gi=Ji({name:Or,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let o of n.getAllComments()){let l=Ki(o);l!=null&&(r.has(l.kind)||l.description||e.report({loc:Qi(o.loc),messageId:"missingDescription"}))}}}}}),Pr={name:Or,rule:Gi};function Ki(e){let{text:t,description:n}=Zi(e.value);if(!t)return null;let r=Bi.exec(t);if(!r)return null;let o=r[1];if(!o)return null;let l=Xi.test(o);if(e.type===qi.AST_TOKEN_TYPES.Line&&!l||l&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(r.index+o.length);return{kind:o,value:i.trim(),description:n}}function Zi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Qi(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";import{z as Se}from"zod/v4";var es=Se.object({varsToCheck:Se.array(Se.object({selector:Se.string().optional(),fromFnCall:Se.string().optional(),prop:Se.string().or(Se.array(Se.string())),errorMsg:Se.string().optional()}))}),kt=X({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[Ie(es)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let n=new Map,r=(i,s,a,p)=>{let c=new Set;for(let d of i.properties)d.type===L.Property&&d.key.type===L.Identifier&&c.add(d.key.name);let u=s.filter(d=>!c.has(d));if(u.length>0)if(u.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:u[0],fnName:p,customMsg:a||""}});else{let d=u.map(y=>`"${y}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:d,fnName:p,customMsg:a||""}})}},o=i=>{if(i.init?.type===L.CallExpression){if(i.init.callee.type===L.Identifier)return i.init.callee.name;if(i.init.callee.type===L.MemberExpression&&i.init.callee.property.type===L.Identifier)return i.init.callee.object.type===L.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"},l={};for(let i of t.varsToCheck)i.selector&&(l[i.selector]=s=>{if(s.type===L.VariableDeclarator&&s.id.type===L.Identifier&&n.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:o(s)}),s.type===L.VariableDeclarator&&s.id.type===L.ObjectPattern){let a=Array.isArray(i.prop)?i.prop:[i.prop];r(s.id,a,i.errorMsg,o(s))}});for(let i of t.varsToCheck)if(i.fromFnCall){let s=i.fromFnCall;if(s.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${s.slice(2)}"]`;l[p]=c=>{if(c.type!==L.MemberExpression||c.parent.type!==L.CallExpression)return;let u=c.parent;if(u.parent.type!==L.VariableDeclarator)return;let d=u.parent;if(d.id.type===L.Identifier)n.set(d.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:d.id,fnName:i.fromFnCall||"unknown function"});else if(d.id.type===L.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];r(d.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[a,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${a}"][property.name="${p}"]`;l[c]=u=>{if(u.type!==L.MemberExpression||u.parent.type!==L.CallExpression)return;let d=u.parent;if(d.parent.type!==L.VariableDeclarator)return;let y=d.parent;if(y.id.type===L.Identifier)n.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===L.ObjectPattern){let E=Array.isArray(i.prop)?i.prop:[i.prop];r(y.id,E,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let a=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;l[a]=p=>{if(p.type!==L.Identifier||p.parent.type!==L.CallExpression)return;let c=p.parent;if(c.parent.type!==L.VariableDeclarator)return;let u=c.parent;if(u.id.type===L.Identifier)n.set(u.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:u.id,fnName:i.fromFnCall||"unknown function"});else if(u.id.type===L.ObjectPattern){let d=Array.isArray(i.prop)?i.prop:[i.prop];r(u.id,d,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...l,"Program:exit"(){for(let[i,{props:s,errorMsg:a,node:p,fnName:c}]of n){let d=e.sourceCode.getScope(p).set.get(i);if(d){let y=new Set(s);for(let E of d.references){let h=E.identifier,T=h.parent;if(!(T.type===L.VariableDeclarator&&T.id===h)){if(T.type===L.MemberExpression&&T.object===h&&T.property.type===L.Identifier&&y.has(T.property.name)){if(y.delete(T.property.name),y.size===0)break;continue}if(T.type===L.VariableDeclarator&&T.init===h&&T.id.type===L.ObjectPattern){for(let x of T.id.properties)x.type===L.Property&&x.key.type===L.Identifier&&y.has(x.key.name)&&y.delete(x.key.name);if(y.size===0)break;continue}if(!(T.type===L.MemberExpression&&T.object===h&&T.property.type===L.Identifier&&!s.includes(T.property.name))){y.clear();break}}}if(y.size>0){let E=Array.from(y);if(E.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:E[0],fnName:c,customMsg:a||""}});else{let h=E.map(T=>`"${T}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:h,fnName:c,customMsg:a||""}})}}}}}}}});function Dr(e){return/^use[A-Z0-9]/.test(e)}function ze(e){return e.type==="Identifier"?Dr(e.name):e.type==="MemberExpression"&&!e.computed&&ze(e.property)?e.object.type==="Identifier":!1}function jr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Mr(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Lr(e){return!!(e.parent&&e.parent.callee&&Mr(e.parent.callee,"forwardRef"))}function _r(e){return!!(e.parent&&e.parent.callee&&Mr(e.parent.callee,"memo"))}function Ot(e){for(;e;){let t=Ur(e);if(t&&(jr(t)||ze(t))||Lr(e)||_r(e))return!0;e=e.parent}return!1}function Fr(e){return!1}function Pt(e){return!1}var ts=/eslint +react-compiler\/react-compiler: +\["error/,$r={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let a of e.sourceCode.getAllComments())if(ts.test(a.value))return{CallExpression(p){let c=null;p.callee.name==="useMemo"?c="useMemo":p.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:p,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),r=null,o=[],l=[],i=new WeakSet;function s(a){for(let p of a.references){let c=p.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&Fr(c.init.callee))for(let u of p.resolved.references)u!==p&&i.add(u.identifier)}}return{onCodePathSegmentStart:a=>l.push(a),onCodePathSegmentEnd:()=>l.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(a,p){let c=o.pop();if(c.size===0)return;let u=new Set;function d(b,m){let{cache:S}=d,R=S.get(b.id),A=new Set(m);if(A.has(b.id)){let I=[...A],F=I.slice(I.indexOf(b.id)+1);for(let Y of F)u.add(Y);return BigInt("0")}if(A.add(b.id),R!==void 0)return R;if(a.thrownSegments.includes(b))R=BigInt("0");else if(b.prevSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let I of b.prevSegments)R+=d(I,A)}return b.reachable&&R===BigInt("0")?S.delete(b.id):S.set(b.id,R),R}function y(b,m){let{cache:S}=y,R=S.get(b.id),A=new Set(m);if(A.has(b.id)){let I=Array.from(A),F=I.slice(I.indexOf(b.id)+1);for(let Y of F)u.add(Y);return BigInt("0")}if(A.add(b.id),R!==void 0)return R;if(a.thrownSegments.includes(b))R=BigInt("0");else if(b.nextSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let I of b.nextSegments)R+=y(I,A)}return S.set(b.id,R),R}function E(b){let{cache:m}=E,S=m.get(b.id);if(S===null)return 1/0;if(S!==void 0)return S;if(m.set(b.id,null),b.prevSegments.length===0)S=1;else{S=1/0;for(let R of b.prevSegments){let A=E(R);A<S&&(S=A)}S+=1}return m.set(b.id,S),S}d.cache=new Map,y.cache=new Map,E.cache=new Map;let h=y(a.initialSegment),T=Ur(p),x=Ot(p),M=T?jr(T)||ze(T):Lr(p)||_r(p),P=1/0;for(let b of a.finalSegments){if(!b.reachable)continue;let m=E(b);m<P&&(P=m)}for(let[b,m]of c){if(!b.reachable)continue;let S=b.nextSegments.length===0?P<=E(b):P<E(b),R=d(b)*y(b),A=u.has(b.id);for(let I of m)if(A&&!Pt(I)&&e.report({node:I,message:`React Hook "${t(I)}" 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.`}),M){if(p.async&&e.report({node:I,message:`React Hook "${t(I)}" cannot be called in an async function.`}),!A&&R!==h&&!Pt(I)){let Y=`React Hook "${t(I)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(S?" Did you accidentally call a React Hook after an early return?":"");e.report({node:I,message:Y})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let F=`React Hook "${t(I)}" 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:I,message:F})}else if(T){let F=`React Hook "${t(I)}" is called in function "${t(T)}" 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:I,message:F})}else if(p.type==="Program"){let F=`React Hook "${t(I)}" 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:I,message:F})}else if(x&&!Pt(I)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let Y=p.parent;if(Y.parent.type==="VariableDeclarator"&&Dr(Y.parent.id.name))return}let F=`React Hook "${t(I)}" 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:I,message:F})}}},CallExpression(a){if(ze(a.callee)){let p=Nr(o),c=Nr(l),u=p.get(c);u||(u=[],p.set(c,u)),u.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Fr(a.callee))&&a.arguments.length>0&&(r=a)},Identifier(a){r==null&&i.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===r&&(r=null)},FunctionDeclaration(a){Ot(a)&&s(n(a))},ArrowFunctionExpression(a){Ot(a)&&s(n(a))}}}};function Ur(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 Nr(e){return e[e.length-1]}import{AST_NODE_TYPES as Wr}from"@typescript-eslint/utils";function rs(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function ns(e){let t=e.parent;return t?.type===Wr.NewExpression&&t.callee.type===Wr.Identifier&&t.callee.name==="RegExp"}var Ft=X({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function t(n){rs(n)||ns(n)||e.report({node:n,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});var Vr={[bt.name]:bt.rule,[nt.name]:nt.rule,[rt.name]:rt.rule,"rules-of-hooks":$r,"exhaustive-deps":qt,"require-description":Pr.rule,[it.name]:it.rule,[ot.name]:ot.rule,[It.name]:It.rule,[Be.name]:Be.rule,[tt.name]:tt.rule,[ut.name]:ut.rule,[Rt.name]:Rt.rule,[pt.name]:pt.rule,[st.name]:st.rule,[Ge.name]:Ge.rule,[vt.name]:vt.rule,[Je.name]:Je.rule,[et.name]:et.rule,[yt.name]:yt.rule,[gt.name]:gt.rule,[Tt.name]:Tt.rule,[ht.name]:ht.rule,[St.name]:St.rule,[At.name]:At.rule,[mt.name]:mt.rule,[ft.name]:ft.rule,[Ft.name]:Ft.rule,[xt.name]:xt.rule,[kt.name]:kt.rule};var $a={rules:Vr};export{$a as extendedLintPlugin};
|