@ls-stack/extended-lint 0.54.0 → 0.56.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 +11 -6
- package/dist/extended-lint.mjs +11 -6
- package/package.json +11 -11
package/dist/extended-lint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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(
|
|
3
|
-
`)||
|
|
4
|
-
`,
|
|
1
|
+
"use strict";var rr=Object.create;var ze=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty;var lr=(e,t)=>{for(var r in t)ze(e,r,{get:t[r],enumerable:!0})},qt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sr(t))!ar.call(e,o)&&o!==r&&ze(e,o,{get:()=>t[o],enumerable:!(n=ir(t,o))||n.enumerable});return e};var ve=(e,t,r)=>(r=e!=null?rr(or(e)):{},qt(t||!e||!e.__esModule?ze(r,"default",{value:e,enumerable:!0}):r,e)),pr=e=>qt(ze({},"__esModule",{value:!0}),e);var ns={};lr(ns,{extendedLintPlugin:()=>ts});module.exports=pr(ns);var Z=require("@typescript-eslint/utils");var tt=Symbol.for("optional");function $(e){return{...e,[tt]:!0}}function Jt(e,t){return{enum:e,...t}}function Ne(e){return{...e,type:"boolean"}}function H(e){return{...e,type:"string"}}function ge(e){return{...e,type:"number"}}function te(e,t){return{...t,type:"array",items:e}}function Y(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let n,o=[];for(n in e)e[n][tt]?e[n][tt]=void 0:o.push(n);o.length>0&&(r.required=o)}return r}var cr=Z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xt="react-compiler-extra",ur=Y({runOnlyWithEnableCompilerDirective:$(Ne())}),fr=/eslint +react-compiler\/react-compiler: +\["error/;function mr(e){return e.type===Z.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===Z.AST_NODE_TYPES.MemberExpression&&e.property.type===Z.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var dr=/\bthis[.[]/;function Bt(e){return dr.test(e)}var yr=cr({name:Xt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[ur]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(fr.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let i of a.properties)if(i.type===Z.AST_NODE_TYPES.Property&&i.method&&i.value.type===Z.AST_NODE_TYPES.FunctionExpression){let s=e.sourceCode,l=s.getText(i.key),p=i.value,c=s.getText(p.body);if(Bt(c))e.report({node:i,messageId:"thisKeywordInMethod"});else{let f=p.params.map(T=>s.getText(T)).join(", "),y="";p.generator?y=`${l}: function* (${f}) ${c}`:y=`${l}: (${f}) => ${c}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(i,y)})}}}function o(a){for(let i of a.properties)if(i.type===Z.AST_NODE_TYPES.Property&&i.value.type===Z.AST_NODE_TYPES.ObjectExpression){for(let s of i.value.properties)if(s.type===Z.AST_NODE_TYPES.Property&&s.method&&s.value.type===Z.AST_NODE_TYPES.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Bt(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(mr(a.callee))for(let i of a.arguments){if(i.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(i),o(i)),i.type===Z.AST_NODE_TYPES.ArrowFunctionExpression&&(i.body.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(i.body),o(i.body)),i.body.type===Z.AST_NODE_TYPES.BlockStatement))for(let s of i.body.body)s.type===Z.AST_NODE_TYPES.ReturnStatement&&s.argument?.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(s.argument),o(s.argument));if(i.type===Z.AST_NODE_TYPES.FunctionExpression)for(let s of i.body.body)s.type===Z.AST_NODE_TYPES.ReturnStatement&&s.argument?.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(s.argument),o(s.argument))}}}}}),nt={name:Xt,rule:yr};var re=require("@typescript-eslint/utils"),w=require("zod/v4");var Gt=require("@typescript-eslint/utils"),Kt=ve(require("zod/v4"));function K(e){let r=Gt.ESLintUtils.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function Ce(e){return Kt.toJSONSchema(e)}var gr=w.z.object({disallow:w.z.array(w.z.object({selector:w.z.string(),message:w.z.string(),replace:w.z.optional(w.z.union([w.z.string(),w.z.object({regex:w.z.string(),with:w.z.string()})])),replaceType:w.z.optional(w.z.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:w.z.optional(w.z.array(w.z.object({fn:w.z.string(),withArgs:w.z.optional(w.z.array(w.z.object({atIndex:w.z.number(),value:w.z.union([w.z.string(),w.z.number(),w.z.boolean()])}))),message:w.z.string(),replaceWith:w.z.optional(w.z.string()),ignoreRegex:w.z.optional(w.z.string())}))),__dev_simulateFileName:w.z.optional(w.z.string()),mustMatchSyntax:w.z.optional(w.z.array(w.z.object({includeRegex:w.z.string(),mustCallFn:w.z.optional(w.z.array(w.z.object({anyCall:w.z.array(w.z.object({fn:w.z.string(),withArgs:w.z.array(w.z.object({atIndex:w.z.number(),literal:w.z.union([w.z.string(),w.z.number(),w.z.boolean()])}))})),message:w.z.optional(w.z.string())}))),mustMatchSelector:w.z.optional(w.z.array(w.z.object({selector:w.z.string(),message:w.z.string()}))),mustHaveExport:w.z.optional(w.z.array(w.z.object({name:w.z.string(),type:w.z.enum(["function","variable","any"]).default("any"),message:w.z.string()})))})))}),rt=K({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Ce(gr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:o,disallow:a,disallowFnCalls:i}=t,s=o??e.filename,l=[],p=new Map,c=new Set,f=new Map,y=new Set,T=new Map;function I(m){for(let S of m.specifiers)S.type===re.AST_NODE_TYPES.ImportSpecifier&&S.imported.type===re.AST_NODE_TYPES.Identifier&&S.imported.name!==S.local.name&&T.set(S.local.name,S.imported.name)}function x(m){if(m.declaration){if(m.declaration.type===re.AST_NODE_TYPES.FunctionDeclaration&&m.declaration.id){let S=m.declaration.id.name;for(let k of Array.from(y)){let[R,C]=k.split(":");R===S&&(C==="function"||C==="any")&&y.delete(k)}}else if(m.declaration.type===re.AST_NODE_TYPES.VariableDeclaration){for(let S of m.declaration.declarations)if(S.id.type===re.AST_NODE_TYPES.Identifier){let k=S.id.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&(N==="variable"||N==="any")&&y.delete(R)}}}}for(let S of m.specifiers)if(S.exported.type===re.AST_NODE_TYPES.Identifier){let k=S.exported.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&N==="any"&&y.delete(R)}}}function E(m){m.id.type===re.AST_NODE_TYPES.Identifier&&m.init?.type===re.AST_NODE_TYPES.Identifier&&T.set(m.id.name,m.init.name)}function u(m){return T.get(m)??m}function A(m,S){return u(m)===S||m===S}for(let{includeRegex:m,mustCallFn:S,mustMatchSelector:k,mustHaveExport:R}of n??[]){let C=Sr(s,new RegExp(m));if(!C)continue;let N=z=>{let B=z;for(let{name:ne,value:ee}of C)B=B.replaceAll(ne,ee);return B};for(let{anyCall:z,message:B}of S??[]){let ne=`Expected file to call the function: ${z.map(({fn:ee})=>ee).join(" or ")}`;c.add(ne),l.push(ee=>{let{callee:xe}=ee;if(xe.type===re.AST_NODE_TYPES.Identifier){for(let{fn:X,withArgs:ye}of z)if(xe.name===X){c.delete(ne);for(let fe of ye){let se=ee.arguments[fe.atIndex],Te=typeof fe.literal=="string"?N(fe.literal):fe.literal;if(!se){e.report({node:ee,messageId:"default",data:{message:`Missing argument with value "${Te}" at index ${fe.atIndex}${B?`: ${N(B)}`:""}`}});continue}if(se.type!==re.AST_NODE_TYPES.Literal){e.report({node:se,messageId:"default",data:{message:`Argument at position ${fe.atIndex} should the literal "${Te}"${B?`: ${N(B)}`:""}`}});continue}se.value!==Te&&e.report({node:se,messageId:"default",data:{message:`Argument should have the value "${Te}"${B?`: ${N(B)}`:""}`},fix:Fe=>Fe.replaceText(se,typeof Te=="string"?`'${Te}'`:String(Te))})}break}}})}for(let{selector:z,message:B}of k??[])f.set(z,N(B)),p.set(N(z),()=>{f.delete(z)});for(let{name:z,type:B,message:ne}of R??[]){let ee=N(z),xe=N(ne);y.add(`${ee}:${B}:${xe}`)}}for(let{fn:m,withArgs:S,message:k,replaceWith:R,ignoreRegex:C}of i??[])C&&new RegExp(C).test(s)||l.push(N=>{let{callee:z}=N;if(z.type!==re.AST_NODE_TYPES.Identifier||!A(z.name,m))return;if(S)for(let ne of S){let ee=N.arguments[ne.atIndex];if(!ee){e.report({node:N,messageId:"default",data:{message:`Missing argument with value "${ne.value}" at index ${ne.atIndex}: ${k}`}});return}if(ee.type!==re.AST_NODE_TYPES.Literal||ee.value!==ne.value)return}let B=ne=>R?ne.replaceText(N,R):null;e.report({node:N,messageId:"default",data:{message:k},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:B}]:void 0})});function b(m,S){let k=r[m];k?r[m]=R=>{k(R),S(R)}:r[m]=S}for(let{selector:m,message:S,replace:k,replaceType:R="suggestion"}of a??[]){if(m==="CallExpression"){l.push(C=>{g(k,C,S,R)});continue}r[m]=C=>{g(k,C,S,R)}}if(p.size>0)for(let[m,S]of p)b(m,S);return l.length>0&&(r.CallExpression=m=>{if(m.type===re.AST_NODE_TYPES.CallExpression)for(let S of l)S(m)}),r.ImportDeclaration=m=>{m.type===re.AST_NODE_TYPES.ImportDeclaration&&I(m)},r.ExportNamedDeclaration=m=>{m.type===re.AST_NODE_TYPES.ExportNamedDeclaration&&x(m)},r.VariableDeclarator=m=>{m.type===re.AST_NODE_TYPES.VariableDeclarator&&E(m)},r["Program:exit"]=m=>{for(let S of c)e.report({node:m,messageId:"default",data:{message:S}});for(let[,S]of f)e.report({node:m,messageId:"default",data:{message:S}});for(let S of y){let[k,R,C]=S.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${k}" of type ${R}: ${C}`}})}},r;function g(m,S,k,R){let C=N=>{if(!m)return null;if(typeof m=="string")return N.replaceText(S,m);{let z=new RegExp(m.regex),B=e.sourceCode.getText(S);return N.replaceText(S,B.replace(z,m.with))}};e.report({node:S,messageId:"default",data:{message:k},fix:m&&R==="autofix"?C:void 0,suggest:m&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:C}]:void 0})}}});function Sr(e,t){let r=[],n=t.exec(e);if(!n)return null;let[o,...a]=n;r.push({name:"$0_lowercase",value:o.toLowerCase()}),r.push({name:"$0_capitalize",value:Zt(o)}),r.push({name:"$0_uncapitalize",value:Qt(o)}),r.push({name:"$0",value:o});for(let i=0;i<a.length;i++){let s=`$${i+1}`,l=a[i];r.push({name:`${s}_lowercase`,value:l.toLowerCase()}),r.push({name:`${s}_capitalize`,value:Zt(l)}),r.push({name:`${s}_uncapitalize`,value:Qt(l)}),r.push({name:s,value:l})}return r}function Zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Qt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var _=require("@typescript-eslint/utils");var Tr=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="collapse-simple-objs-in-one-line",hr=Y({maxLineLength:$(ge()),maxProperties:$(ge()),nestedObjMaxLineLength:$(ge()),nestedObjMaxProperties:$(ge()),ignoreTypesWithSuffix:$(te(H()))}),Er=Tr({name:tn,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:[hr]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,a=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,f=c?i:o,y=p.properties.length;if(y>f)return!1;if(y===1){let I=p.properties[0];return I.type===_.AST_NODE_TYPES.Property&&I.value.type===_.AST_NODE_TYPES.ObjectExpression||I.type===_.AST_NODE_TYPES.Property&&I.value.type===_.AST_NODE_TYPES.ArrayExpression&&!I.value.elements.every(E=>E&&it(E))?!1:{text:r.getText(I),isNested:c,propsSize:y}}let T=[];for(let I of p.properties){if(I.type===_.AST_NODE_TYPES.Property&&!it(I.value))return!1;T.push(r.getText(I))}return{text:T.join(", "),isNested:c,propsSize:y}}else{let c=p.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,f=c?i:o,y=p.members.length;if(y>f)return!1;if(n.length>0&&p.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let I=p.parent.id.name;if(n.some(x=>I.endsWith(x)))return!1}if(y===1){let I=p.members[0];return I.type===_.AST_NODE_TYPES.TSPropertySignature&&I.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:r.getText(I),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 T=[];for(let I of p.members){if(I.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let x=I.typeAnnotation?.typeAnnotation;if(!x||x.type===_.AST_NODE_TYPES.TSTypeLiteral||!en(x))return!1;if(x.type===_.AST_NODE_TYPES.TSTypeReference&&x.typeArguments){if(x.typeArguments.params.length>1)return!1;let u=x.typeArguments.params[0];if(!en(u))return!1}let E=r.getText(I).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),T.push(E)}return{text:T.join("; "),isNested:c,propsSize:y}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer){let x=0,E=!1,u=r.getTokenAfter(p,{filter:b=>b.type!==_.AST_TOKEN_TYPES.Punctuator||E?!0:b.value===","?(x++,!1):b.value===";"?(x++,E=!0,!1):b.value===")"||b.value==="}"?(x++,!1):!0});if(x>4)return;let A=u?.type===_.AST_TOKEN_TYPES.Template&&u.value.startsWith(`}
|
|
2
|
+
`);if(u?.loc.start.line===p.loc.end.line&&!A)return}let c=s(p);if(!c)return;let f=c.text;if(f.includes(`
|
|
3
|
+
`)||r.getCommentsInside(p).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let y=`{ ${f} }`,T=xr(r,p),I=c.isNested&&c.propsSize>2?a:t.maxLineLength;I&&y.length+T.length+br(p,r)>I||e.report({node:p,messageId:"singleLineProp",fix:x=>x.replaceText(p,y)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function en(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 it(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(r=>r&&it(r,!0)))}function br(e,t){let r=t.getLastToken(e);if(!r)return 0;let n=t.text.indexOf(`
|
|
4
|
+
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function xr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var st={name:tn,rule:Er};var Ir=/eslint +react-compiler\/react-compiler: +\["error/,rn={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,r=typeof e.getSource=="function"?u=>r(u):u=>e.sourceCode.getText(u),n=typeof e.getScope=="function"?()=>n():u=>e.sourceCode.getScope(u),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,a=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function s(u){a&&Array.isArray(u.suggest)&&u.suggest.length>0&&(u.fix=u.suggest[0].fix),e.report(u)}let l=e.getSourceCode().scopeManager,p=new WeakMap,c=new WeakSet,f=new WeakMap,y=new WeakMap,T=new WeakSet;function I(u,A){return function(b){if(A.has(b))return A.get(b);let g=u(b);return A.set(b,g),g}}function x(u,A,b,g,m){m&&u.async&&s({node:u,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,10 @@ 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 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});
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let S=l.acquire(u),k=new Set,R=null;{let d=S.upper;for(;d&&(k.add(d),d.type!=="function");)d=d.upper;if(!d)return;R=d}let C=Array.isArray;function N(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node.type!=="VariableDeclarator")return!1;let v=h.node.init;if(v==null)return!1;for(;v.type==="TSAsExpression";)v=v.expression;let O=h.node.parent;if(O==null&&(lt(R.block,h.node.id),O=h.node.parent,O==null))return!1;if(O.kind==="const"&&v.type==="Literal"&&(typeof v.value=="string"||typeof v.value=="number"||v.value===null))return!0;if(v.type!=="CallExpression")return!1;let F=v.callee;if(F.type==="MemberExpression"&&F.object.name==="React"&&F.property!=null&&!F.computed&&(F=F.property),F.type!=="Identifier")return!1;let P=h.node.id,{name:M}=F;if(M==="useRef"&&P.type==="Identifier")return!0;if(vr(F)&&P.type==="Identifier"){for(let D of d.references)D!==P&&T.add(D.identifier);return!0}else if(M==="useState"||M==="useReducer"){if(P.type==="ArrayPattern"&&P.elements.length===2&&C(d.identifiers)){if(P.elements[1]===d.identifiers[0]){if(M==="useState"){let D=d.references,pe=0;for(let he=0;he<D.length;he++){if(D[he].isWrite()&&pe++,pe>1)return!1;p.set(D[he].identifier,P.elements[0])}}return!0}else if(P.elements[0]===d.identifiers[0]){if(M==="useState"){let D=d.references;for(let pe=0;pe<D.length;pe++)c.add(D[pe].identifier)}return!1}}}else if(M==="useTransition"&&P.type==="ArrayPattern"&&P.elements.length===2&&Array.isArray(d.identifiers)&&P.elements[1]===d.identifiers[0])return!0;return!1}function z(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node==null||h.node.id==null)return!1;let v=h.node,O=R.childScopes,F=null,P;for(P=0;P<O.length;P++){let M=O[P],D=M.block;if(v.type==="FunctionDeclaration"&&D===v||v.type==="VariableDeclarator"&&D.parent===v){F=M;break}}if(F==null)return!1;for(P=0;P<F.through.length;P++){let M=F.through[P];if(M.resolved!=null&&k.has(M.resolved.scope)&&!B(M.resolved))return!1}return!0}let B=I(N,f),ne=I(z,y),ee=new Map;function xe(d){let h=d.from,v=!1;for(;h.block!==u;)h.type==="function"&&(v=h.block.parent!=null&&h.block.parent.type==="ReturnStatement"),h=h.upper;return v}let X=new Map,ye=new Map;fe(S);function fe(d){for(let h of d.references){if(!h.resolved||!k.has(h.resolved.scope))continue;let v=lt(u,h.identifier),O=sn(v),F=Ee(O,ye);if(m&&O.type==="Identifier"&&(O.parent.type==="MemberExpression"||O.parent.type==="OptionalMemberExpression")&&!O.parent.computed&&O.parent.property.type==="Identifier"&&O.parent.property.name==="current"&&xe(h)&&ee.set(F,{reference:h,dependencyNode:O}),O.parent.type==="TSTypeQuery"||O.parent.type==="TSTypeReference")continue;let P=h.resolved.defs[0];if(P!=null&&!(P.node!=null&&P.node.init===u.parent)&&P.type!=="TypeParameter")if(X.has(F))X.get(F).references.push(h);else{let M=h.resolved,D=B(M)||ne(M);X.set(F,{isStable:D,references:[h]})}}for(let h of d.childScopes)fe(h)}ee.forEach(({reference:d,dependencyNode:h},v)=>{let O=d.resolved.references,F=!1;for(let P=0;P<O.length;P++){let{identifier:M}=O[P],{parent:D}=M;if(D!=null&&D.type==="MemberExpression"&&!D.computed&&D.property.type==="Identifier"&&D.property.name==="current"&&D.parent.type==="AssignmentExpression"&&D.parent.left===D){F=!0;break}}F||s({node:h.parent.property,message:`The ref value '${v}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${v}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let se=new Set;function Te(d,h){se.has(h)||(se.add(h),s({node:d,message:`Assignments to the '${h}' variable from inside React Hook ${r(b)} 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(b)}.`}))}let Fe=new Set;if(X.forEach(({isStable:d,references:h},v)=>{d&&Fe.add(v),h.forEach(O=>{O.writeExpr&&Te(O.writeExpr,v)})}),se.size>0)return;if(!A){let d=null;if(X.forEach(({isStable:h,references:v},O)=>{d||v.forEach(F=>{if(d)return;let P=F.identifier;if(!p.has(P))return;let D=F.from;for(;D.type!=="function";)D=D.upper;D.block===u&&(d=O)})}),d){let{suggestedDependencies:h}=ot({dependencies:X,declaredDependencies:[],stableDependencies:Fe,externalDependencies:new Set,isEffect:!0});s({node:b,message:`React Hook ${g} contains a call to '${d}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+h.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${h.join(", ")}]`,fix(v){return v.insertTextAfter(u,`, [${h.join(", ")}]`)}}]})}return}let Le=[],_e=new Set;A.type!=="ArrayExpression"?s({node:A,message:`React Hook ${r(b)} 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.`}):A.elements.forEach(d=>{if(d===null)return;if(d.type==="SpreadElement"){s({node:d,message:`React Hook ${r(b)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}T.has(d)&&s({node:d,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(d)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(d)}\``,fix(F){return F.removeRange(d.range)}}]});let h;try{h=Ee(d,ye)}catch(F){if(/Unsupported node type/.test(F.message)){d.type==="Literal"?X.has(d.value)?s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. Did you mean to include ${d.value} in the array instead?`}):s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:d,message:`React Hook ${r(b)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw F}let v=d;for(;v.type==="MemberExpression"||v.type==="OptionalMemberExpression"||v.type==="ChainExpression";)v=v.object||v.expression.object;let O=!R.through.some(F=>F.identifier===v);Le.push({key:h,node:d}),O||_e.add(h)});let{suggestedDependencies:Qn,unnecessaryDependencies:We,missingDependencies:Ie,duplicateDependencies:zt}=ot({dependencies:X,declaredDependencies:Le,stableDependencies:Fe,externalDependencies:_e,isEffect:m}),Ve=Qn;if(zt.size+Ie.size+We.size===0){if(t)return;Cr({declaredDependencies:Le,declaredDependenciesNode:A,componentScope:R,scope:S}).forEach(({construction:h,isUsedOutsideOfHook:v,depType:O})=>{let F=O==="function"?"useCallback":"useMemo",P=O==="function"?"definition":"initialization",M=`wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,D=v?`To fix this, ${M}`:`Move it inside the ${g} callback. Alternatively, ${M}`,pe=O==="conditional"||O==="logical expression"?"could make":"makes",he=`The '${h.name.name}' ${O} ${pe} the dependencies of ${g} Hook (at line ${A.loc.start.line}) change on every render. ${D}`,Ht;v&&h.type==="Variable"&&O==="function"&&(Ht=[{desc:`Wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,fix(Yt){let[tr,nr]=F==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Yt.insertTextBefore(h.node.init,tr),Yt.insertTextAfter(h.node.init,nr)]}}]),s({node:h.node,message:he,suggest:Ht})});return}!m&&Ie.size>0&&(Ve=ot({dependencies:X,declaredDependencies:[],stableDependencies:Fe,externalDependencies:_e,isEffect:m}).suggestedDependencies);function er(){if(Le.length===0)return!0;let d=Le.map(v=>v.key),h=d.slice().sort();return d.join(",")===h.join(",")}er()&&Ve.sort();function Qe(d){let h=d.split("."),v="";for(let O=0;O<h.length;O++){if(O!==0){let F=h.slice(0,O+1).join("."),P=ye.get(F)===!0;v+=P?"?.":"."}v+=h[O]}return v}function et(d,h,v,O){return d.size===0?null:(d.size>1?"":h+" ")+v+" "+(d.size>1?"dependencies":"dependency")+": "+Ar(Array.from(d).sort().map(F=>"'"+Qe(F)+"'"))+`. Either ${O} ${d.size>1?"them":"it"} or remove the dependency array.`}let me="";if(We.size>0){let d=null;if(Array.from(We.keys()).forEach(h=>{d===null&&h.endsWith(".current")&&(d=h)}),d!==null)me=` Mutable values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(_e.size>0){let h=Array.from(_e)[0];S.set.has(h)||(me=` Outer scope values like '${h}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!me&&Ie.has("props")){let d=X.get("props");if(d==null)return;let h=d.references;if(!Array.isArray(h))return;let v=!0;for(let O=0;O<h.length;O++){let F=h[O],P=lt(R.block,F.identifier);if(!P){v=!1;break}let M=P.parent;if(M==null){v=!1;break}if(M.type!=="MemberExpression"&&M.type!=="OptionalMemberExpression"){v=!1;break}}v&&(me=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${g} call and refer to those specific props inside ${r(b)}.`)}if(!me&&Ie.size>0){let d=null;Ie.forEach(h=>{if(d)return;let v=R.set.get(h),O=X.get(h);if(O.references[0].resolved!==v)return;let F=v.defs[0];if(F==null||F.name==null||F.type!=="Parameter")return;let P=!1,M;for(let D=0;D<O.references.length;D++)if(M=O.references[D].identifier,M!=null&&M.parent!=null&&(M.parent.type==="CallExpression"||M.parent.type==="OptionalCallExpression")&&M.parent.callee===M){P=!0;break}P&&(d=h)}),d!==null&&(me=` If '${d}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!me&&Ie.size>0){let d=null;if(Ie.forEach(h=>{if(d!==null)return;let O=X.get(h).references,F,P;for(let M=0;M<O.length;M++){for(F=O[M].identifier,P=F.parent;P!=null&&P!==R.block;){if(P.type==="CallExpression"){let D=p.get(P.callee);if(D!=null){if(D.name===h)d={missingDep:h,setter:P.callee.name,form:"updater"};else if(c.has(F))d={missingDep:h,setter:P.callee.name,form:"reducer"};else{let pe=O[M].resolved;if(pe!=null){let he=pe.defs[0];he!=null&&he.type==="Parameter"&&(d={missingDep:h,setter:P.callee.name,form:"inlineReducer"})}}break}}P=P.parent}if(d!==null)break}}),d!==null)switch(d.form){case"reducer":me=` You can also replace multiple useState variables with useReducer if '${d.setter}' needs the current value of '${d.missingDep}'.`;break;case"inlineReducer":me=` If '${d.setter}' needs the current value of '${d.missingDep}', you can also switch to useReducer instead of useState and read '${d.missingDep}' in the reducer.`;break;case"updater":me=` You can also do a functional update '${d.setter}(${d.missingDep.slice(0,1)} => ...)' if you only need '${d.missingDep}' in the '${d.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:A,message:`React Hook ${r(b)} has `+(et(Ie,"a","missing","include")||et(We,"an","unnecessary","exclude")||et(zt,"a","duplicate","omit"))+me,suggest:[{desc:`Update the dependencies array to be: [${Ve.map(Qe).join(", ")}]`,fix(d){return d.replaceText(A,`[${Ve.map(Qe).join(", ")}]`)}}]})}function E(u){let A=wr(u.callee,i);if(A===-1)return;let b=u.arguments[A],g=u.callee,m=on(g).name,S=u.arguments[A+1],k=/Effect($|[^a-z])/g.test(m);if(!b){s({node:g,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!S&&!k){(m==="useMemo"||m==="useCallback")&&s({node:g,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(b.type){case"FunctionExpression":case"ArrowFunctionExpression":x(b,S,g,m,k);return;case"Identifier":if(!S||S.elements&&S.elements.some(N=>N&&N.type==="Identifier"&&N.name===b.name))return;let R=n(u).set.get(b.name);if(R==null||R.defs==null)return;let C=R.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":x(C.node,S,g,m,k);return;case"VariableDeclarator":let N=C.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":x(N,S,g,m,k);return}break}break;default:s({node:g,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:g,message:`React Hook ${m} has a missing dependency: '${b.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${b.name}]`,fix(R){return R.replaceText(S,`[${b.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let u of e.sourceCode.getAllComments())if(Ir.test(u.value))return t=!0,{CallExpression:A=>E(A,!0)}}return{CallExpression:u=>E(u)}}};function ot({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((x,E)=>{let u=s(a,E);u.isUsed=!0,l(a,E,A=>{A.isSubtreeUsed=!0})}),t.forEach(({key:x})=>{let E=s(a,x);E.isSatisfiedRecursively=!0}),r.forEach(x=>{let E=s(a,x);E.isSatisfiedRecursively=!0});function s(x,E){let u=E.split("."),A=x;for(let b of u){let g=A.children.get(b);g||(g=i(),A.children.set(b,g)),A=g}return A}function l(x,E,u){let A=E.split("."),b=x;for(let g of A){let m=b.children.get(g);if(!m)return;u(m),b=m}}let p=new Set,c=new Set;f(a,p,c,x=>x);function f(x,E,u,A){x.children.forEach((b,g)=>{let m=A(g);if(b.isSatisfiedRecursively){b.isSubtreeUsed&&u.add(m);return}if(b.isUsed){E.add(m);return}f(b,E,u,S=>m+"."+S)})}let y=[],T=new Set,I=new Set;return t.forEach(({key:x})=>{c.has(x)?y.indexOf(x)===-1?y.push(x):I.add(x):T.add(x)}),p.forEach(x=>{y.push(x)}),{suggestedDependencies:y,unnecessaryDependencies:T,duplicateDependencies:I,missingDependencies:p}}function we(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 we(e.consequent)!=null||we(e.alternate)!=null?"conditional":null;case"LogicalExpression":return we(e.left)!=null||we(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return we(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return we(e.expression);case"TSAsExpression":return we(e.expression)}return null}function Cr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:i})=>{let s=r.variables.find(p=>p.name===i);if(s==null)return null;let l=s.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=we(l.node.init);if(p!=null)return[s,p]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[s,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function a(i){let s=!1;for(let l=0;l<i.references.length;l++){let p=i.references[l];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!an(t,p.identifier))return!0}return!1}return o.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:a(i)}))}function sn(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)?sn(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function at(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function Ee(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=Ee(e.object,t),n=Ee(e.property,null),o=`${r}.${n}`;return at(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Ee(e.object,t),n=Ee(e.property,null),o=`${r}.${n}`;return at(e,t,o),o}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=Ee(r.object,t),o=Ee(r.property,null),a=`${n}.${o}`;return at(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function on(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function wr(e,t){let r=on(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=Ee(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(n)?0:-1}else return-1}}function lt(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),Rr(n,t))return n;if(an(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(nn(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(i=>{nn(i)&&(i.parent=n,r.push(i))}))}return null}function Ar(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 nn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Rr(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 an(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function vr(e){return!1}var Ae=require("@typescript-eslint/utils");var ie=ve(require("typescript")),kr=Ae.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ln="improved-no-unnecessary-condition",Or=Y({}),Pr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Fr=new Set(Pr),pt={name:ln,rule:kr({name:ln,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:[Or]},defaultOptions:[{}],create(e){let t=Ae.ESLintUtils.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(s){return s.type===Ae.AST_NODE_TYPES.UnaryExpression&&s.operator==="typeof"}function o(s){return s.flags&ie.default.TypeFlags.Any||s.flags&ie.default.TypeFlags.Unknown?null:s.flags&ie.default.TypeFlags.StringLike?["string"]:s.flags&ie.default.TypeFlags.NumberLike?["number"]:s.flags&ie.default.TypeFlags.BigIntLike?["bigint"]:s.flags&ie.default.TypeFlags.BooleanLike?["boolean"]:s.flags&ie.default.TypeFlags.ESSymbolLike?["symbol"]:s.flags&ie.default.TypeFlags.Undefined||s.flags&ie.default.TypeFlags.Void?["undefined"]:s.flags&ie.default.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&ie.default.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&ie.default.TypeFlags.NonPrimitive?["object"]:s.flags&ie.default.TypeFlags.Never?["never"]:null}function a(s){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(s),p=r.getTypeAtLocation(l.expression);if(p.flags&ie.default.TypeFlags.Any||p.flags&ie.default.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let y of p.types){let T=o(y);if(T)c.push(...T);else return null}return c}let f=o(p);return f?(c.push(...f),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(n(s.left)?(p=s.left,c=s.right.type===Ae.AST_NODE_TYPES.Literal&&typeof s.right.value=="string"?s.right.value:null):n(s.right)&&(p=s.right,c=s.left.type===Ae.AST_NODE_TYPES.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!Nr(c,Fr))return;let f=a(p);if(!f)return;let y=s.operator==="!==",T=f.includes(c);f.length===1?T&&!y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:je(p,e),type:c}}):!T&&y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:je(p,e),type:Array.from(f)[0]}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:je(p,e),actualType:He(f),conditionType:c}}):T&&y&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:je(p,e),actualType:He(f),conditionType:c}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:je(p,e),actualType:He(f),conditionType:c}}):!T&&y&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:je(p,e),type:He(f)}})}return{BinaryExpression:i}}})};function He(e){return Array.from(new Set(e)).join(" | ")||"never"}function je(e,t){let r=e.argument;return r.type===Ae.AST_NODE_TYPES.Identifier?r.name:t.sourceCode.getText(r)}function Nr(e,t){return t.has(e)}var Ye=require("@typescript-eslint/utils");var jr=Ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-call-with-explicit-generics",Mr=Y({functions:te(H())}),Dr=jr({name:pn,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:[Mr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===Ye.AST_NODE_TYPES.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),ct={name:pn,rule:Dr};var ke=require("@typescript-eslint/utils"),Lr=ke.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cn="no-call-with-inferred-generics",_r=Lr({name:cn,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:o}=n;if(o.type!==ke.AST_NODE_TYPES.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:i=1,allowAny:s,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(s&&!l)&&n.typeArguments?.params?.some(c=>!s&&c.type===ke.AST_NODE_TYPES.TSAnyKeyword||l&&c.type===ke.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===ke.AST_NODE_TYPES.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),ut={name:cn,rule:_r};var fn=require("@typescript-eslint/utils"),$r=fn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-commented-out-code",Ur=["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:"],G={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]*$/},Wr=[") {","return;",G.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",G.stringAssignment,");",G.objectPropertyWithQuotes,G.computedPropertyAssignment,G.kebabCaseProperty,G.snakeCaseProperty,"&&","||","()",G.ternaryOperator,G.colonWithWord,G.quotedString,G.numberWithComma,G.arrayWithComma,G.objectWithComma,G.methodCall,G.arrayAccess,"?.(","??","=>",G.quotedPropertyKey],Vr=["/>","</",G.jsxSelfClosing,G.jsxElement,G.jsxOpeningTag,G.jsxClosingTag,G.htmlOpeningTag,G.htmlClosingTag],un=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],zr=$r({name:mn,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,o){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")||G.jsdocComment.test(n))return!1;for(let i of un)if(a.startsWith(i))return!1;if(n.includes("https://")||a.includes(":")&&G.colonDescriptiveComment.test(a.trim()))return!1;if(o==="Block"){for(let i of Vr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Ur)if(a.startsWith(i))return{wrongPattern:i};for(let i of Wr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,o){let a=n,i=a.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let p=a.split(/```[\s\S]*?```/g);p.some(f=>/[a-zA-Z0-9]/.test(f))&&(a=p.join(""))}if(!a.includes("`"))return a;let s=a.split(/`[^`]*`/g);return s.some(p=>/[a-zA-Z0-9]/.test(p))?s.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let i=r(a.value,a.type),s=t(i,a.type);s&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:un.join(", ")}})}}}}}),ft={name:mn,rule:zr};var qe=require("@typescript-eslint/utils"),Hr=qe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="no-default-export",Yr=Hr({name:dn,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===qe.TSESTree.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),mt={name:dn,rule:Yr};var yn=require("@typescript-eslint/utils"),qr=yn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn="no-leaked-text-in-jsx",Jr=[",",";","[","]","(",")"],Br=qr({name:gn,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="";Jr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),dt={name:gn,rule:Br};var Re=require("@typescript-eslint/utils"),Xr=Re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tn="no-non-camel-case-functions",Gr=/^(\$?[a-z][a-zA-Z0-9]*)$/;function Sn(e){if(e.typeName.type!==Re.AST_NODE_TYPES.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Re.AST_NODE_TYPES.Identifier&&t.name==="JSX"&&r.name==="Element"}var Kr=Xr({name:Tn,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Gr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Re.AST_NODE_TYPES.TSTypeReference?Sn(r):r.type===Re.AST_NODE_TYPES.TSUnionType&&r.types.some(o=>o.type===Re.AST_NODE_TYPES.TSTypeReference&&Sn(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),yt={name:Tn,rule:Kr};var W=require("@typescript-eslint/utils");var gt=require("@typescript-eslint/utils");function Me(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Me(e.parent,t,r===1/0?r:r-1)}function*St(e){yield e,e.parent&&(yield*St(e.parent))}function Tt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function hn(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===gt.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===gt.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Zr=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),En="no-optional-root-props",Qr=Zr({name:En,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 i=a.references[0];if(!i)return!1;for(let s of St(i.identifier)){if("returnType"in s||s.type===W.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=s.parent;if(!l)return!1;if(l.type===W.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===W.TSESTree.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===W.TSESTree.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let c=Me(l.parent.parent,W.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let f=Je(c,e.sourceCode);return f?!(f.parent.type===W.TSESTree.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===W.TSESTree.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(s.type===W.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===W.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let p=Me(l,W.TSESTree.AST_NODE_TYPES.VariableDeclaration);return p?!!Je(p,e.sourceCode):!1}if(l.type===W.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Je(l,e.sourceCode)}return!1}function r(n){n.key.type!==W.TSESTree.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Me(n,W.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let i=e.sourceCode.getText(a);return o.replaceText(a,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===W.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Be(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Be(n)||!t(n)))for(let o of n.body.body)o.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==W.TSESTree.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==W.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=Me(n.parent,W.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let i=Je(a,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 l of o.members)l.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Be(e){return e?e.parent?.type===W.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===W.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Je(e,t){if(Be(e))return;let r;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&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===W.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(i=>i.identifiers.includes(r));if(!o)return;let a=o.references.filter(i=>i.identifier!==r);if(!(a.length!==1||!a[0])&&!Be(a[0].identifier.parent.parent))return a[0].identifier}var ht={name:En,rule:Qr};var bn=require("@typescript-eslint/utils"),Xe=ve(require("path"));var ei=bn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xn="no-relative-imports",ti=Y({find:H(),replacement:H()}),ni=Y({aliases:te(ti),rootDir:$(H()),allowNotFoundAliases:$(Ne()),_dev_simulateFileName:$(H())}),ri=ei({name:xn,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:[ni]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function o(i,s){let l=Xe.default.dirname(s);return Xe.default.resolve(l,i)}function a(i){let s=t.rootDir??process.cwd(),l=Xe.default.relative(s,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let f=l.replace(c,p);return{alias:p,newPath:f}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!n(s))return;let l=o(s,r),p=a(l);!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})}}}}),Et={name:xn,rule:ri};var $e=require("@typescript-eslint/utils"),Oe=ve(require("zod/v4"));var ii=Oe.object({alternativeMsgs:Oe.object({inArrayFind:Oe.string().optional(),inArrayFilter:Oe.string().optional()}).optional(),__dev_simulateFileName:Oe.string().optional()});function si(e){return e.typeAnnotation.type!==$e.AST_NODE_TYPES.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function oi(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ai(e){let t=e.parent;for(;t;){if(t.type===$e.AST_NODE_TYPES.CallExpression&&t.callee.type===$e.AST_NODE_TYPES.MemberExpression&&t.callee.property.type===$e.AST_NODE_TYPES.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var bt=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:[Ce(ii)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(oi(r))return{};function n(o){if(!si(o))return;let a=ai(o),i=[];if(t.alternativeMsgs&&a){let s=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(s){let l=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:l,data:{message:s}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});var Pe=require("@typescript-eslint/utils");var li="no-unnecessary-async-on-jsx-props";function pi(e){if(e.body.type!==Pe.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!==Pe.AST_NODE_TYPES.ExpressionStatement?!1:r.expression.type===Pe.AST_NODE_TYPES.AwaitExpression}var xt=K({name:li,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){pi(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let o=e.sourceCode,a=[],i=o.getFirstToken(r,l=>l.value==="async");if(i){let l=o.getTokenAfter(i);l?a.push(n.replaceTextRange([i.range[0],l.range[0]],"")):a.push(n.remove(i))}function s(l){if(l.type===Pe.AST_NODE_TYPES.AwaitExpression){let p=o.getFirstToken(l);if(p&&p.value==="await"){let c=o.getTokenAfter(p);c?a.push(n.replaceTextRange([p.range[0],c.range[0]],"")):a.push(n.remove(p))}}if(l.type===Pe.AST_NODE_TYPES.BlockStatement)for(let p of l.body)s(p);else l.type===Pe.AST_NODE_TYPES.ExpressionStatement&&s(l.expression)}return s(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});var be=require("@typescript-eslint/utils");var It=ve(require("typescript")),ci=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),In="no-unnecessary-casting",ui=Y({additionalCastFunctions:$(te(Y({name:H(),expectedType:Jt(["string","number"])})))}),Ct={name:In,rule:ci({name:In,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:[ui],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=be.ESLintUtils.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function i(c,f){switch(c.type){case be.AST_NODE_TYPES.Literal:return f==="number"?typeof c.value=="number":typeof c.value=="string";case be.AST_NODE_TYPES.TemplateLiteral:return f==="string";case be.AST_NODE_TYPES.UnaryExpression:return f==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function s(c,f){return f==="number"?!!(c.flags&It.TypeFlags.NumberLike):!!(c.flags&It.TypeFlags.StringLike)}function l(c,f){return y=>y.replaceText(c,e.sourceCode.getText(f))}function p(c){if(!a||c.arguments.length!==1)return;let f=c.arguments[0];if(!f||f.type===be.AST_NODE_TYPES.SpreadElement)return;let{callee:y}=c;if(y.type!==be.AST_NODE_TYPES.Identifier)return;let T=y.name,I=n.find(E=>E.name===T);if(!I)return;if(i(f,I.expectedType)||s(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(f)),I.expectedType)){let E,u;T==="Number"?E="unnecessaryNumberCasting":T==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",u={name:I.name,type:I.expectedType}),e.report({node:c,messageId:E,...u?{data:u}:{},fix:l(c,f)})}}return{CallExpression:p}}})};var Ue=require("@typescript-eslint/utils"),ce=ve(require("zod/v4"));var fi=ce.object({methods:ce.union([ce.array(ce.string()),ce.literal("array")])}),wt=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:[ce.toJSONSchema(fi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(s){return Array.isArray(r)?r.includes(s):n.has(s)}function a(s){let{callee:l}=s;if(l.type===Ue.AST_NODE_TYPES.MemberExpression){let p=l.property;if(p.type===Ue.AST_NODE_TYPES.Identifier)return p.name}return null}function i(s,l){if(s.type!==Ue.AST_NODE_TYPES.Identifier||!s.typeAnnotation)return;let p=l.parent;if(p.type===Ue.AST_NODE_TYPES.CallExpression){let c=a(p);c&&o(c)&&p.arguments.indexOf(l)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(y){return y.remove(s.typeAnnotation)}})}}return{ArrowFunctionExpression(s){for(let l of s.params)i(l,s)},FunctionExpression(s){for(let l of s.params)i(l,s)}}}});var le=require("@typescript-eslint/utils");var At=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===le.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==le.AST_NODE_TYPES.ObjectExpression||t.id.type===le.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===le.AST_NODE_TYPES.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===le.AST_NODE_TYPES.Property&&i.key.type===le.AST_NODE_TYPES.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==le.AST_NODE_TYPES.Identifier)return;let n=mi(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(i=>i.type!==le.AST_NODE_TYPES.Property?!1:i.value.type===le.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let i of n){if(i.identifier.parent.type!==le.AST_NODE_TYPES.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===le.AST_NODE_TYPES.Literal&&typeof s.property.value=="string")a.add(s.property.value);else return;else{if(s.property.type!==le.AST_NODE_TYPES.Identifier)return;a.add(s.property.name)}if(s.parent.type===le.AST_NODE_TYPES.CallExpression&&o)return}for(let[i,s]of r)a.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function mi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var V=require("@typescript-eslint/utils");var di=Y({selectors:te(Y({name:H(),selectorProp:$(H()),selectorArgPos:$(ge()),returnProp:$(H())}))}),yi=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cn="no-unused-selected-values",Rt={name:Cn,rule:yi({name:Cn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[di]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===V.AST_NODE_TYPES.CallExpression&&(a=o.init),!a)return;let i=Si(a);if(!i)return;let s=n.get(i);if(!s)return;let l=gi(a,s.selectorArgPos??0,s.selectorProp);if(!l)return;let p=Ti(l);if(!p)return;let c=wn(p.properties,void 0);if(!c)return;if(o.id.type===V.AST_NODE_TYPES.ObjectPattern){let T=wn(o.id.properties,s.returnProp);if(!T)return;for(let[I,x]of c)T.has(I)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:I}});return}if(o.id.type!==V.AST_NODE_TYPES.Identifier||s.returnProp)return;let f=hi(o,e.sourceCode);if(f.length===0)return;let y=new Set;for(let T of f){if(T.identifier.parent.type!==V.AST_NODE_TYPES.MemberExpression)return;let I=T.identifier.parent.property;if(I.type!==V.AST_NODE_TYPES.Identifier)return;y.add(I.name)}for(let[T,I]of c)y.has(T)||e.report({node:I,messageId:"unusedSelectedValue",data:{name:T}})}}}})};function gi(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===V.AST_NODE_TYPES.ArrowFunctionExpression||n.type===V.AST_NODE_TYPES.FunctionExpression)return n;if(r&&n.type===V.AST_NODE_TYPES.ObjectExpression){let o=n.properties.find(i=>i.type===V.AST_NODE_TYPES.Property&&i.key.type===V.AST_NODE_TYPES.Identifier&&i.key.name===r);if(o?.type!==V.AST_NODE_TYPES.Property)return null;let a=o.value;if(a.type===V.AST_NODE_TYPES.ArrowFunctionExpression||a.type===V.AST_NODE_TYPES.FunctionExpression)return a}return null}function Si(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 Ti(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(r=>r.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 wn(e,t){let r=e;if(t){let o=e.find(a=>a.type===V.AST_NODE_TYPES.Property&&a.key.type===V.AST_NODE_TYPES.Identifier&&a.key.name===t);if(o?.type!==V.AST_NODE_TYPES.Property||o.value.type!==V.AST_NODE_TYPES.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==V.AST_NODE_TYPES.Property||o.key.type!==V.AST_NODE_TYPES.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function hi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var q=require("@typescript-eslint/utils");var vt=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(a=>a.type===q.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let s=Ei(a);s&&(n=s);return}let i=bi(a,e.sourceCode);if(i){o=!0;for(let s of i)n.delete(s);if(n.size!==0)for(let[s,l]of n)e.report({node:l,messageId:"unusedField",data:{name:s}})}}}}});function Ei(e){if(!(e.callee.type===q.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==q.AST_NODE_TYPES.ObjectExpression)return null;let n=Tt(r.properties,a=>a.type!==q.AST_NODE_TYPES.Property||a.key.type!==q.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===q.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===q.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===q.AST_NODE_TYPES.FunctionExpression?xi(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===q.AST_NODE_TYPES.Property&&a.key.type===q.AST_NODE_TYPES.Identifier&&o.set(a.key.name,a);return o}function bi(e,t){if(!(e.callee.type===q.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==q.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==q.AST_NODE_TYPES.ObjectPattern||!Tt(e.parent.id.properties,i=>i.type===q.AST_NODE_TYPES.Property&&i.key.type===q.AST_NODE_TYPES.Identifier&&i.key.name==="formFields"&&i))return null;let o=hn(e.parent,"formFields",t),a=new Set;for(let{identifier:i}of o){if(i.type!==q.AST_NODE_TYPES.Identifier||i.parent.type===q.AST_NODE_TYPES.Property&&i.parent.parent.type===q.AST_NODE_TYPES.ObjectExpression&&i.parent.parent.parent.type===q.AST_NODE_TYPES.ReturnStatement||i.parent.type===q.AST_NODE_TYPES.ReturnStatement)return null;if(i.parent.type===q.AST_NODE_TYPES.MemberExpression){if(i.parent.object.type!==q.AST_NODE_TYPES.Identifier||i.parent.property.type!==q.AST_NODE_TYPES.Identifier)return null;a.add(i.parent.property.name)}}return a}function xi(e){if(e.body.type===q.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===q.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===q.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==q.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var U=require("@typescript-eslint/utils");var Ii=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function An(e){let t=[];for(let r of e.members)r.type===U.AST_NODE_TYPES.TSPropertySignature&&r.key.type===U.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function Rn(e,...t){for(let r of t)e.set(...r);return e}var Ci=Y({forceCheckOnFCPropTypesWithName:$(te(H()))}),vn="no-unused-type-props-in-args",kt=null,wi=Ii({name:vn,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&&!kt&&(kt=r.map(s=>new RegExp(s)));function n(s,l,p,c,f=!0){let y=p.name,T=e.sourceCode.getScope(l).references.find(E=>E.identifier.name===y)?.resolved,I=s&&kt?.some(E=>E.test(y));if(!T||!I&&T.references.filter(E=>E.isTypeReference).length>1)return;let x=T?.defs[0]?.node;if(!(f&&x?.parent?.type===U.AST_NODE_TYPES.ExportNamedDeclaration)){if(x?.type===U.AST_NODE_TYPES.TSTypeAliasDeclaration){o(s,l,c,x.typeAnnotation,!0);return}if(x?.type===U.AST_NODE_TYPES.TSInterfaceDeclaration){o(s,l,c,x.body,!0);return}}}function o(s,l,p,c,f){if(c.type===U.AST_NODE_TYPES.TSInterfaceBody){for(let y of c.body)y.type===U.AST_NODE_TYPES.TSPropertySignature&&y.key.type===U.AST_NODE_TYPES.Identifier&&p.set(y.key.name,y);return}if(c.type===U.AST_NODE_TYPES.TSTypeLiteral){Rn(p,...An(c));return}if(c.type===U.AST_NODE_TYPES.TSIntersectionType){for(let y of c.types)o(s,l,p,y,!0);return}f||c.type===U.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===U.AST_NODE_TYPES.Identifier&&n(s,l,c.typeName,p)}function a(s,l,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let f=new Map;if(o(s,l,f,c.typeAnnotation.typeAnnotation,!1),f.size===0)continue;i(c,f)}else c.type===U.AST_NODE_TYPES.AssignmentPattern&&c.left.type===U.AST_NODE_TYPES.ObjectPattern&&a(s,l,[c.left])}function i(s,l){let p=[];if(s.properties.at(-1)?.type===U.AST_NODE_TYPES.RestElement)return;for(let T of s.properties)T.type===U.AST_NODE_TYPES.Property&&T.key.type===U.AST_NODE_TYPES.Identifier&&p.push(T.key.name);let f=[],y=[];for(let[T,I]of l)p.includes(T)||(y.push(T),f.push({node:I,messageId:"unusedObjectTypeProperty",data:{propertyName:T}}));for(let[T,I]of f.entries())e.report({...I,fix:T===f.length-1?x=>{let E=s.properties.at(-1),u=y.join(", ");return E?E?.type===U.AST_NODE_TYPES.RestElement?null:x.insertTextAfter(E,`, ${u}`):x.insertTextBeforeRange([s.range[0]+1,s.range[1]],`${u}`)}:void 0})}return{VariableDeclaration(s){let l=s.declarations[0];if(!l)return;let p=new Map,c=l.id.type===U.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===U.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===U.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===U.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===U.AST_NODE_TYPES.Identifier)n(!0,s,c.typeName,p,!1);else if(c.type===U.AST_NODE_TYPES.TSTypeLiteral)Rn(p,...An(c));else if(c.type===U.AST_NODE_TYPES.TSIntersectionType)for(let f of c.types)f.type===U.AST_NODE_TYPES.TSTypeReference&&f.typeName.type===U.AST_NODE_TYPES.Identifier?n(!0,s,f.typeName,p,!1):o(!0,s,p,f,!0);if(p.size!==0&&l.init?.type===U.AST_NODE_TYPES.ArrowFunctionExpression){let f=l.init.params[0];if(!f){e.report({node:l.init,messageId:"missingComponentParam"});return}f.type===U.AST_NODE_TYPES.ObjectPattern&&i(f,p)}}},FunctionDeclaration:function(s){a(!1,s,s.params)},ArrowFunctionExpression(s){a(!1,s,s.params)}}}}),Ot={name:vn,rule:wi};var ue=require("@typescript-eslint/utils");var Pt=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 r(n){return n.callee.type===ue.AST_NODE_TYPES.Identifier?t.has(n.callee.name):n.callee.type===ue.AST_NODE_TYPES.MemberExpression&&n.callee.object.type===ue.AST_NODE_TYPES.Identifier&&n.callee.property.type===ue.AST_NODE_TYPES.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let o of n.specifiers)o.type===ue.AST_NODE_TYPES.ImportSpecifier&&o.imported.type===ue.AST_NODE_TYPES.Identifier&&o.imported.name==="useRef"&&t.add(o.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===ue.AST_NODE_TYPES.CallExpression&&r(n.init)&&n.id.type===ue.AST_NODE_TYPES.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let i=!1;for(let s of a.references){let p=s.identifier.parent;if(p!==n&&!(p.type===ue.AST_NODE_TYPES.JSXExpressionContainer&&p.parent.type===ue.AST_NODE_TYPES.JSXAttribute&&p.parent.name.type===ue.AST_NODE_TYPES.JSXIdentifier&&p.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});var De=require("@typescript-eslint/utils"),Ai=De.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),On="prefer-named-functions",kn=new Map,Ri=Ai({name:On,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=kn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),kn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===De.AST_NODE_TYPES.ArrowFunctionExpression&&n.id.type===De.AST_NODE_TYPES.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==De.AST_NODE_TYPES.BlockStatement)return;let a=n.parent,i=n.init.params,s=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(a,`${l.async?"async ":""}function ${o}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),Ft={name:On,rule:Ri};var j=require("@typescript-eslint/utils");var vi=Y({disallowedFunctions:te(Y({name:H(),allowUsingWithArgs:$(Ne()),hookAlternative:$(H()),message:$(H()),allowUseInside:$(te(H()))}))});function Ge(e){return/^use[A-Z]/.test(e)}function Pn(e){return/^[A-Z]/.test(e)}function ki(e){return e.type===j.AST_NODE_TYPES.Identifier?Ge(e.name):e.type===j.AST_NODE_TYPES.MemberExpression&&e.property.type===j.AST_NODE_TYPES.Identifier?Ge(e.property.name):!1}function Fn(e,t){return e.type===j.AST_NODE_TYPES.Identifier?e.name===t:e.type===j.AST_NODE_TYPES.MemberExpression&&e.object.type===j.AST_NODE_TYPES.Identifier&&e.property.type===j.AST_NODE_TYPES.Identifier?e.object.name==="React"&&e.property.name===t:!1}function Nn(e){return!!(e.parent&&e.parent.type===j.AST_NODE_TYPES.CallExpression&&Fn(e.parent.callee,"forwardRef"))}function jn(e){return!!(e.parent&&e.parent.type===j.AST_NODE_TYPES.CallExpression&&Fn(e.parent.callee,"memo"))}function Nt(e){if(e.type===j.AST_NODE_TYPES.FunctionDeclaration||e.type===j.AST_NODE_TYPES.FunctionExpression&&e.id)return e.id||void 0;if(e.type===j.AST_NODE_TYPES.FunctionExpression||e.type===j.AST_NODE_TYPES.ArrowFunctionExpression){if(e.parent.type===j.AST_NODE_TYPES.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===j.AST_NODE_TYPES.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===j.AST_NODE_TYPES.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===j.AST_NODE_TYPES.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Oi(e){let t=e.parent,r=!1;for(;t;){if(t.type===j.AST_NODE_TYPES.FunctionDeclaration||t.type===j.AST_NODE_TYPES.FunctionExpression||t.type===j.AST_NODE_TYPES.ArrowFunctionExpression){let n=Nt(t);if(n&&n.type===j.AST_NODE_TYPES.Identifier){if(Pn(n.name)||Ge(n.name))return!r;r=!0}else{if(Nn(t)||jn(t))return!r;if(t.parent.type===j.AST_NODE_TYPES.CallExpression){let o=t.parent;ki(o.callee)||(r=!0)}else t.parent.type===j.AST_NODE_TYPES.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Mn(e){return e.callee.type===j.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===j.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===j.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Pi(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===j.AST_NODE_TYPES.FunctionDeclaration||r.type===j.AST_NODE_TYPES.FunctionExpression||r.type===j.AST_NODE_TYPES.ArrowFunctionExpression){let n=Nt(r);if(n&&n.type===j.AST_NODE_TYPES.Identifier&&t.includes(n.name))return!0}else if(r.type===j.AST_NODE_TYPES.CallExpression){let n=Mn(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===j.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function Ni(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===j.AST_NODE_TYPES.FunctionDeclaration||n.type===j.AST_NODE_TYPES.FunctionExpression||n.type===j.AST_NODE_TYPES.ArrowFunctionExpression){let o=Nt(n);if(o&&o.type===j.AST_NODE_TYPES.Identifier){if(Pn(o.name)||Ge(o.name)){r=!0;break}}else if(Nn(n)||jn(n)){r=!0;break}}n=n.parent}return r?t.length===0?Oi(e):!Pi(e,t):!1}var jt=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:[vi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=Mn(o);if(!a)return;let i=n.get(a);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:l=>{let p=i.hookAlternative;return o.callee.type===j.AST_NODE_TYPES.Identifier?l.replaceText(o.callee,p):o.callee.type===j.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===j.AST_NODE_TYPES.Identifier?l.replaceText(o.callee.property,p):null}}]:[]})}}}});var J=require("@typescript-eslint/utils");var ji=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ln="prefer-single-line-if",Mi=Y({maxLineLength:$(ge()),maxNonSimpleConditionLength:$(ge())}),Di=ji({name:Ln,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[Mi]},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(!$n(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 i;if(t.maxNonSimpleConditionLength){let f=Dn(n.test);if(!f&&n.test.type===J.AST_NODE_TYPES.UnaryExpression&&n.test.operator==="!"){let y=n.test.argument;Dn(y)&&(f=!0)}if(f&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let s=r.getText(a);if(i.includes(`
|
|
16
|
+
`))return;let l=r.getTokenAfter(n);if(l&&l.type===J.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let f=r.getTokenAfter(l);if(f&&f.type===J.AST_TOKEN_TYPES.Keyword&&(f.value==="else"||f.value==="catch"))return}let p=Li(r,n),c=`if (${i}) ${s}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:f=>f.replaceText(n,c)})}}}});function Dn(e){return e.type===J.AST_NODE_TYPES.CallExpression||e.type===J.AST_NODE_TYPES.BinaryExpression||e.type===J.AST_NODE_TYPES.MemberExpression&&_n(e)}function _n(e){return e.object.type===J.AST_NODE_TYPES.MemberExpression?_n(e.object):e.object.type!==J.AST_NODE_TYPES.Identifier}function Li(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function $n(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?$n(t):!1}var Mt={name:Ln,rule:Di};var oe=require("@typescript-eslint/utils");var _i=oe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Un="react-compiler-migration",$i=Y({disallowHooks:$(te(Y({name:H(),replacement:H()}))),disallowMethods:$(te(Y({name:H(),replacement:$(H()),requireTrueProp:$(H())})))}),Ui=/eslint +react-compiler\/react-compiler: +\["error/;function Wi(e){return e.type===oe.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===oe.AST_NODE_TYPES.MemberExpression&&e.property.type===oe.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Vi=_i({name:Un,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[$i]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Ui.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===oe.AST_NODE_TYPES.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===oe.AST_NODE_TYPES.MemberExpression&&n.callee.property.type===oe.AST_NODE_TYPES.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let i=t.disallowHooks.find(s=>s.name===o);i&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(a,i.replacement)}]})}}if(t.disallowMethods?.length&&Wi(n.callee)){for(let o of n.arguments)if(o.type===oe.AST_NODE_TYPES.ObjectExpression){for(let a of o.properties)if(a.type===oe.AST_NODE_TYPES.Property&&a.key.type===oe.AST_NODE_TYPES.Identifier){let i=a.key.name,s=t.disallowMethods.find(l=>l.name===i);if(s){if(s.requireTrueProp){let l=s.requireTrueProp,p=!1;for(let c of o.properties)if(c.type===oe.AST_NODE_TYPES.Property&&c.key.type===oe.AST_NODE_TYPES.Identifier&&c.key.name===l&&c.value.type===oe.AST_NODE_TYPES.Literal&&c.value.value===!0){p=!0;break}if(!p){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:l}});continue}}s.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:l=>l.replaceText(a.key,s.replacement)}]})}}}}}}:{}}}),Dt={name:Un,rule:Vi};var Ke=require("@typescript-eslint/utils"),zi=Ke.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wn="require-description",Hi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Yi=/^eslint-disable-(next-)?line$/u,qi=zi({name:Wn,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 o of r.getAllComments()){let a=Ji(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Xi(o.loc),messageId:"missingDescription"}))}}}}}),Vn={name:Wn,rule:qi};function Ji(e){let{text:t,description:r}=Bi(e.value);if(!t)return null;let n=Hi.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=Yi.test(o);if(e.type===Ke.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+o.length);return{kind:o,value:i.trim(),description:r}}function Bi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Xi(e){return{start:{line:e.start.line,column:-1},end:e.end}}var L=require("@typescript-eslint/utils"),Se=require("zod/v4");var Gi=Se.z.object({varsToCheck:Se.z.array(Se.z.object({selector:Se.z.string().optional(),fromFnCall:Se.z.string().optional(),prop:Se.z.string().or(Se.z.array(Se.z.string())),errorMsg:Se.z.string().optional()}))}),Lt=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:[Ce(Gi)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map,n=(i,s,l,p)=>{let c=new Set;for(let y of i.properties)y.type===L.AST_NODE_TYPES.Property&&y.key.type===L.AST_NODE_TYPES.Identifier&&c.add(y.key.name);let f=s.filter(y=>!c.has(y));if(f.length>0)if(f.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:f[0],fnName:p,customMsg:l||""}});else{let y=f.map(T=>`"${T}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:p,customMsg:l||""}})}},o=i=>{if(i.init?.type===L.AST_NODE_TYPES.CallExpression){if(i.init.callee.type===L.AST_NODE_TYPES.Identifier)return i.init.callee.name;if(i.init.callee.type===L.AST_NODE_TYPES.MemberExpression&&i.init.callee.property.type===L.AST_NODE_TYPES.Identifier)return i.init.callee.object.type===L.AST_NODE_TYPES.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"},a={};for(let i of t.varsToCheck)i.selector&&(a[i.selector]=s=>{if(s.type===L.AST_NODE_TYPES.VariableDeclarator&&s.id.type===L.AST_NODE_TYPES.Identifier&&r.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.AST_NODE_TYPES.VariableDeclarator&&s.id.type===L.AST_NODE_TYPES.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(s.id,l,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)}"]`;a[p]=c=>{if(c.type!==L.AST_NODE_TYPES.MemberExpression||c.parent.type!==L.AST_NODE_TYPES.CallExpression)return;let f=c.parent;if(f.parent.type!==L.AST_NODE_TYPES.VariableDeclarator)return;let y=f.parent;if(y.id.type===L.AST_NODE_TYPES.Identifier)r.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.AST_NODE_TYPES.ObjectPattern){let T=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,T,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[l,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;a[c]=f=>{if(f.type!==L.AST_NODE_TYPES.MemberExpression||f.parent.type!==L.AST_NODE_TYPES.CallExpression)return;let y=f.parent;if(y.parent.type!==L.AST_NODE_TYPES.VariableDeclarator)return;let T=y.parent;if(T.id.type===L.AST_NODE_TYPES.Identifier)r.set(T.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:T.id,fnName:i.fromFnCall||"unknown function"});else if(T.id.type===L.AST_NODE_TYPES.ObjectPattern){let I=Array.isArray(i.prop)?i.prop:[i.prop];n(T.id,I,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;a[l]=p=>{if(p.type!==L.AST_NODE_TYPES.Identifier||p.parent.type!==L.AST_NODE_TYPES.CallExpression)return;let c=p.parent;if(c.parent.type!==L.AST_NODE_TYPES.VariableDeclarator)return;let f=c.parent;if(f.id.type===L.AST_NODE_TYPES.Identifier)r.set(f.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:f.id,fnName:i.fromFnCall||"unknown function"});else if(f.id.type===L.AST_NODE_TYPES.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];n(f.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...a,"Program:exit"(){for(let[i,{props:s,errorMsg:l,node:p,fnName:c}]of r){let y=e.sourceCode.getScope(p).set.get(i);if(y){let T=new Set(s);for(let I of y.references){let x=I.identifier,E=x.parent;if(!(E.type===L.AST_NODE_TYPES.VariableDeclarator&&E.id===x)){if(E.type===L.AST_NODE_TYPES.MemberExpression&&E.object===x&&E.property.type===L.AST_NODE_TYPES.Identifier&&T.has(E.property.name)){if(T.delete(E.property.name),T.size===0)break;continue}if(E.type===L.AST_NODE_TYPES.VariableDeclarator&&E.init===x&&E.id.type===L.AST_NODE_TYPES.ObjectPattern){for(let u of E.id.properties)u.type===L.AST_NODE_TYPES.Property&&u.key.type===L.AST_NODE_TYPES.Identifier&&T.has(u.key.name)&&T.delete(u.key.name);if(T.size===0)break;continue}if(!(E.type===L.AST_NODE_TYPES.MemberExpression&&E.object===x&&E.property.type===L.AST_NODE_TYPES.Identifier&&!s.includes(E.property.name))){T.clear();break}}}if(T.size>0){let I=Array.from(T);if(I.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:I[0],fnName:c,customMsg:l||""}});else{let x=I.map(E=>`"${E}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:x,fnName:c,customMsg:l||""}})}}}}}}}});function Yn(e){return/^use[A-Z0-9]/.test(e)}function Ze(e){return e.type==="Identifier"?Yn(e.name):e.type==="MemberExpression"&&!e.computed&&Ze(e.property)?e.object.type==="Identifier":!1}function qn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Jn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Bn(e){return!!(e.parent&&e.parent.callee&&Jn(e.parent.callee,"forwardRef"))}function Xn(e){return!!(e.parent&&e.parent.callee&&Jn(e.parent.callee,"memo"))}function _t(e){for(;e;){let t=Kn(e);if(t&&(qn(t)||Ze(t))||Bn(e)||Xn(e))return!0;e=e.parent}return!1}function zn(e){return!1}function $t(e){return!1}var Ki=/eslint +react-compiler\/react-compiler: +\["error/,Gn={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(Ki.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,o=[],a=[],i=new WeakSet;function s(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&&zn(c.init.callee))for(let f of p.resolved.references)f!==p&&i.add(f.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,p){let c=o.pop();if(c.size===0)return;let f=new Set;function y(g,m){let{cache:S}=y,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=[...R],N=C.slice(C.indexOf(g.id)+1);for(let z of N)f.add(z);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.prevSegments)k+=y(C,R)}return g.reachable&&k===BigInt("0")?S.delete(g.id):S.set(g.id,k),k}function T(g,m){let{cache:S}=T,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=Array.from(R),N=C.slice(C.indexOf(g.id)+1);for(let z of N)f.add(z);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.nextSegments)k+=T(C,R)}return S.set(g.id,k),k}function I(g){let{cache:m}=I,S=m.get(g.id);if(S===null)return 1/0;if(S!==void 0)return S;if(m.set(g.id,null),g.prevSegments.length===0)S=1;else{S=1/0;for(let k of g.prevSegments){let R=I(k);R<S&&(S=R)}S+=1}return m.set(g.id,S),S}y.cache=new Map,T.cache=new Map,I.cache=new Map;let x=T(l.initialSegment),E=Kn(p),u=_t(p),A=E?qn(E)||Ze(E):Bn(p)||Xn(p),b=1/0;for(let g of l.finalSegments){if(!g.reachable)continue;let m=I(g);m<b&&(b=m)}for(let[g,m]of c){if(!g.reachable)continue;let S=g.nextSegments.length===0?b<=I(g):b<I(g),k=y(g)*T(g),R=f.has(g.id);for(let C of m)if(R&&!$t(C)&&e.report({node:C,message:`React Hook "${t(C)}" 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.`}),A){if(p.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!R&&k!==x&&!$t(C)){let z=`React Hook "${t(C)}" 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:C,message:z})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let N=`React Hook "${t(C)}" 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:C,message:N})}else if(E){let N=`React Hook "${t(C)}" is called in function "${t(E)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:C,message:N})}else if(p.type==="Program"){let N=`React Hook "${t(C)}" 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:C,message:N})}else if(u&&!$t(C)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let z=p.parent;if(z.parent.type==="VariableDeclarator"&&Yn(z.parent.id.name))return}let N=`React Hook "${t(C)}" 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:C,message:N})}}},CallExpression(l){if(Ze(l.callee)){let p=Hn(o),c=Hn(a),f=p.get(c);f||(f=[],p.set(c,f)),f.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||zn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.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){_t(l)&&s(r(l))},ArrowFunctionExpression(l){_t(l)&&s(r(l))}}}};function Kn(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 Hn(e){return e[e.length-1]}var Q=require("@typescript-eslint/utils"),ae=ve(require("zod/v4"));var Zi=ae.object({indent:ae.union([ae.string().regex(/^\s+$/),ae.number().int().min(1)]).optional(),tags:ae.array(ae.string()).optional(),functions:ae.array(ae.string()).optional(),comments:ae.array(ae.string()).optional()}),Ut=K({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[Ce(Zi)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:o=["outdent","dedent","gql","sql","html","styled"],indent:a}=e.options[0],i=r.map(u=>u.toLowerCase());function s(u){let A=u.split(/\r?\n/),b=A.filter(m=>m.trim()!=="");if(b.length===0)return u;let g=Number.POSITIVE_INFINITY;for(let m of b){let S=m.match(/^(\s*)/);S&&(g=Math.min(g,S[1]?.length??0))}return!isFinite(g)||g===0?u:A.map(m=>m.slice(g)).join(`
|
|
17
|
+
`)}function l(u,A,b){return u.split(/\r?\n/).map(m=>m.trim()===""?m:b.repeat(A)+m).join(`
|
|
18
|
+
`)}function p(u){if(u.type===Q.AST_NODE_TYPES.Identifier)return u.name;if(u.type===Q.AST_NODE_TYPES.MemberExpression){let A=u.object.type===Q.AST_NODE_TYPES.Identifier?u.object.name:null,b=u.property.type===Q.AST_NODE_TYPES.Identifier?u.property.name:null;return A&&b?`${A}.${b}`:b}return null}function c(u,A){if(!u)return!1;for(let b of A)if(b.includes(".")){let g=b.split(".");if(u.type===Q.AST_NODE_TYPES.MemberExpression&&u.object.type===Q.AST_NODE_TYPES.Identifier&&u.property.type===Q.AST_NODE_TYPES.Identifier&&u.object.name===g[0]&&u.property.name===g[1])return!0}else if(u.type===Q.AST_NODE_TYPES.Identifier&&u.name===b)return!0;return!1}function f(u,A){let b=u.parent;if(b.type!==Q.AST_NODE_TYPES.TaggedTemplateExpression)return!1;let g=p(b.tag);return g?A.includes(g):!1}function y(u,A){if(!u||u.type!==Q.AST_NODE_TYPES.CallExpression)return!1;let{method:b,argumentsLength:g,optionalCall:m=!0,optionalMember:S=!0}=A;return g!==void 0&&u.arguments.length!==g||!m&&u.optional||u.callee.type!==Q.AST_NODE_TYPES.MemberExpression||!S&&u.callee.optional||u.callee.property.type!==Q.AST_NODE_TYPES.Identifier?!1:u.callee.property.name===b}function T(u,A){if(!u||u.type!==Q.AST_NODE_TYPES.CallExpression)return!1;let{name:b,argumentsLength:g,optionalCall:m=!0}=A;return g!==void 0&&u.arguments.length!==g||!m&&u.optional||u.callee.type!==Q.AST_NODE_TYPES.Identifier?!1:u.callee.name===b}function I(u){return y(u.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&u.parent.type===Q.AST_NODE_TYPES.CallExpression&&u.parent.arguments[0]===u&&T(u.parent.callee.type===Q.AST_NODE_TYPES.MemberExpression?u.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function x(u){if(i.length>0){let A=t.getTokenBefore(u,{includeComments:!0});if(A?.type===Q.AST_TOKEN_TYPES.Block&&i.includes(A.value.trim().toLowerCase()))return!0}return!!(I(u)||o.length>0&&f(u,o)||n.length>0&&u.parent.type===Q.AST_NODE_TYPES.CallExpression&&u.parent.arguments.includes(u)&&c(u.parent.callee,n))}function E(u){let A=`__PLACEHOLDER__${Math.random()}`,b=u.quasis.map(X=>t.getText(X).slice(1,X.tail?-1:-2)).join(A),g=b.match(/\r?\n/);if(!g)return;let m=g[0],S=t.lines[t.getLocFromIndex(u.range[0]).line-1];if(!S)return;let R=S.match(/^(\s*)\S/)?.[1]??"",C;typeof a=="string"?C=a:typeof a=="number"?C=" ".repeat(a):C=R.startsWith(" ")?" ":" ";let z=s(b).replace(new RegExp(`^${m}|${m}[ ]*$`,"g"),""),B=m+l(z,1,R+C)+m+R,ne=b.includes(`\r
|
|
19
|
+
`)?`\r
|
|
20
|
+
`:`
|
|
21
|
+
`,ee=b.split(/\r?\n/),xe=ee.map((X,ye)=>ye!==ee.length-1&&X===C?"":X).join(ne);if(B!==xe)return{node:u,messageId:"improperlyIndented",fix:X=>B.split(A).map((ye,fe)=>{let se=u.quasis[fe];return se?X.replaceTextRange([se.range[0]+1,se.range[1]-(se.tail?1:2)],ye):[]}).flat()}}return{TemplateLiteral(u){if(!x(u))return;let A=E(u);if(A)return e.report(A)}}}});var Wt=require("@typescript-eslint/utils");function Qi(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function es(e){let t=e.parent;return t?.type===Wt.AST_NODE_TYPES.NewExpression&&t.callee.type===Wt.AST_NODE_TYPES.Identifier&&t.callee.name==="RegExp"}var Vt=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(r){Qi(r)||es(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});var Zn={[Ot.name]:Ot.rule,[ft.name]:ft.rule,[ut.name]:ut.rule,"rules-of-hooks":Gn,"exhaustive-deps":rn,"require-description":Vn.rule,[mt.name]:mt.rule,[yt.name]:yt.rule,[Ft.name]:Ft.rule,[rt.name]:rt.rule,[ct.name]:ct.rule,[Et.name]:Et.rule,[Mt.name]:Mt.rule,[ht.name]:ht.rule,[dt.name]:dt.rule,[st.name]:st.rule,[Dt.name]:Dt.rule,[nt.name]:nt.rule,[pt.name]:pt.rule,[Ct.name]:Ct.rule,[wt.name]:wt.rule,[Rt.name]:Rt.rule,[vt.name]:vt.rule,[At.name]:At.rule,[jt.name]:jt.rule,[xt.name]:xt.rule,[bt.name]:bt.rule,[Vt.name]:Vt.rule,[Pt.name]:Pt.rule,[Lt.name]:Lt.rule,[Ut.name]:Ut.rule};var ts={rules:Zn};0&&(module.exports={extendedLintPlugin});
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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(
|
|
3
|
-
`)||
|
|
4
|
-
`,
|
|
1
|
+
import{AST_NODE_TYPES as ee,ESLintUtils as Kn}from"@typescript-eslint/utils";var Be=Symbol.for("optional");function _(e){return{...e,[Be]:!0}}function $t(e,t){return{enum:e,...t}}function Re(e){return{...e,type:"boolean"}}function V(e){return{...e,type:"string"}}function ge(e){return{...e,type:"number"}}function Q(e,t){return{...t,type:"array",items:e}}function z(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let n,a=[];for(n in e)e[n][Be]?e[n][Be]=void 0:a.push(n);a.length>0&&(r.required=a)}return r}var Zn=Kn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="react-compiler-extra",Qn=z({runOnlyWithEnableCompilerDirective:_(Re())}),er=/eslint +react-compiler\/react-compiler: +\["error/;function tr(e){return e.type===ee.Identifier?e.name.startsWith("use"):e.type===ee.MemberExpression&&e.property.type===ee.Identifier?e.property.name.startsWith("use"):!1}var nr=/\bthis[.[]/;function Ut(e){return nr.test(e)}var rr=Zn({name:Wt,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:[Qn]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let o of e.sourceCode.getAllComments())if(er.test(o.value)){r=!0;break}if(!r)return{}}function n(o){for(let i of o.properties)if(i.type===ee.Property&&i.method&&i.value.type===ee.FunctionExpression){let s=e.sourceCode,l=s.getText(i.key),p=i.value,c=s.getText(p.body);if(Ut(c))e.report({node:i,messageId:"thisKeywordInMethod"});else{let f=p.params.map(T=>s.getText(T)).join(", "),y="";p.generator?y=`${l}: function* (${f}) ${c}`:y=`${l}: (${f}) => ${c}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(i,y)})}}}function a(o){for(let i of o.properties)if(i.type===ee.Property&&i.value.type===ee.ObjectExpression){for(let s of i.value.properties)if(s.type===ee.Property&&s.method&&s.value.type===ee.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Ut(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(o){if(tr(o.callee))for(let i of o.arguments){if(i.type===ee.ObjectExpression&&(n(i),a(i)),i.type===ee.ArrowFunctionExpression&&(i.body.type===ee.ObjectExpression&&(n(i.body),a(i.body)),i.body.type===ee.BlockStatement))for(let s of i.body.body)s.type===ee.ReturnStatement&&s.argument?.type===ee.ObjectExpression&&(n(s.argument),a(s.argument));if(i.type===ee.FunctionExpression)for(let s of i.body.body)s.type===ee.ReturnStatement&&s.argument?.type===ee.ObjectExpression&&(n(s.argument),a(s.argument))}}}}}),Xe={name:Wt,rule:rr};import{AST_NODE_TYPES as re}from"@typescript-eslint/utils";import{z as w}from"zod/v4";import{ESLintUtils as ir}from"@typescript-eslint/utils";import*as Vt from"zod/v4";function G(e){let r=ir.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function Ie(e){return Vt.toJSONSchema(e)}var sr=w.object({disallow:w.array(w.object({selector:w.string(),message:w.string(),replace:w.optional(w.union([w.string(),w.object({regex:w.string(),with:w.string()})])),replaceType:w.optional(w.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:w.optional(w.array(w.object({fn:w.string(),withArgs:w.optional(w.array(w.object({atIndex:w.number(),value:w.union([w.string(),w.number(),w.boolean()])}))),message:w.string(),replaceWith:w.optional(w.string()),ignoreRegex:w.optional(w.string())}))),__dev_simulateFileName:w.optional(w.string()),mustMatchSyntax:w.optional(w.array(w.object({includeRegex:w.string(),mustCallFn:w.optional(w.array(w.object({anyCall:w.array(w.object({fn:w.string(),withArgs:w.array(w.object({atIndex:w.number(),literal:w.union([w.string(),w.number(),w.boolean()])}))})),message:w.optional(w.string())}))),mustMatchSelector:w.optional(w.array(w.object({selector:w.string(),message:w.string()}))),mustHaveExport:w.optional(w.array(w.object({name:w.string(),type:w.enum(["function","variable","any"]).default("any"),message:w.string()})))})))}),Ge=G({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Ie(sr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:a,disallow:o,disallowFnCalls:i}=t,s=a??e.filename,l=[],p=new Map,c=new Set,f=new Map,y=new Set,T=new Map;function I(m){for(let S of m.specifiers)S.type===re.ImportSpecifier&&S.imported.type===re.Identifier&&S.imported.name!==S.local.name&&T.set(S.local.name,S.imported.name)}function x(m){if(m.declaration){if(m.declaration.type===re.FunctionDeclaration&&m.declaration.id){let S=m.declaration.id.name;for(let k of Array.from(y)){let[R,C]=k.split(":");R===S&&(C==="function"||C==="any")&&y.delete(k)}}else if(m.declaration.type===re.VariableDeclaration){for(let S of m.declaration.declarations)if(S.id.type===re.Identifier){let k=S.id.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&(N==="variable"||N==="any")&&y.delete(R)}}}}for(let S of m.specifiers)if(S.exported.type===re.Identifier){let k=S.exported.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&N==="any"&&y.delete(R)}}}function E(m){m.id.type===re.Identifier&&m.init?.type===re.Identifier&&T.set(m.id.name,m.init.name)}function u(m){return T.get(m)??m}function A(m,S){return u(m)===S||m===S}for(let{includeRegex:m,mustCallFn:S,mustMatchSelector:k,mustHaveExport:R}of n??[]){let C=or(s,new RegExp(m));if(!C)continue;let N=W=>{let J=W;for(let{name:te,value:Z}of C)J=J.replaceAll(te,Z);return J};for(let{anyCall:W,message:J}of S??[]){let te=`Expected file to call the function: ${W.map(({fn:Z})=>Z).join(" or ")}`;c.add(te),l.push(Z=>{let{callee:be}=Z;if(be.type===re.Identifier){for(let{fn:B,withArgs:ye}of W)if(be.name===B){c.delete(te);for(let ue of ye){let ie=Z.arguments[ue.atIndex],Se=typeof ue.literal=="string"?N(ue.literal):ue.literal;if(!ie){e.report({node:Z,messageId:"default",data:{message:`Missing argument with value "${Se}" at index ${ue.atIndex}${J?`: ${N(J)}`:""}`}});continue}if(ie.type!==re.Literal){e.report({node:ie,messageId:"default",data:{message:`Argument at position ${ue.atIndex} should the literal "${Se}"${J?`: ${N(J)}`:""}`}});continue}ie.value!==Se&&e.report({node:ie,messageId:"default",data:{message:`Argument should have the value "${Se}"${J?`: ${N(J)}`:""}`},fix:Ae=>Ae.replaceText(ie,typeof Se=="string"?`'${Se}'`:String(Se))})}break}}})}for(let{selector:W,message:J}of k??[])f.set(W,N(J)),p.set(N(W),()=>{f.delete(W)});for(let{name:W,type:J,message:te}of R??[]){let Z=N(W),be=N(te);y.add(`${Z}:${J}:${be}`)}}for(let{fn:m,withArgs:S,message:k,replaceWith:R,ignoreRegex:C}of i??[])C&&new RegExp(C).test(s)||l.push(N=>{let{callee:W}=N;if(W.type!==re.Identifier||!A(W.name,m))return;if(S)for(let te of S){let Z=N.arguments[te.atIndex];if(!Z){e.report({node:N,messageId:"default",data:{message:`Missing argument with value "${te.value}" at index ${te.atIndex}: ${k}`}});return}if(Z.type!==re.Literal||Z.value!==te.value)return}let J=te=>R?te.replaceText(N,R):null;e.report({node:N,messageId:"default",data:{message:k},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:J}]:void 0})});function b(m,S){let k=r[m];k?r[m]=R=>{k(R),S(R)}:r[m]=S}for(let{selector:m,message:S,replace:k,replaceType:R="suggestion"}of o??[]){if(m==="CallExpression"){l.push(C=>{g(k,C,S,R)});continue}r[m]=C=>{g(k,C,S,R)}}if(p.size>0)for(let[m,S]of p)b(m,S);return l.length>0&&(r.CallExpression=m=>{if(m.type===re.CallExpression)for(let S of l)S(m)}),r.ImportDeclaration=m=>{m.type===re.ImportDeclaration&&I(m)},r.ExportNamedDeclaration=m=>{m.type===re.ExportNamedDeclaration&&x(m)},r.VariableDeclarator=m=>{m.type===re.VariableDeclarator&&E(m)},r["Program:exit"]=m=>{for(let S of c)e.report({node:m,messageId:"default",data:{message:S}});for(let[,S]of f)e.report({node:m,messageId:"default",data:{message:S}});for(let S of y){let[k,R,C]=S.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${k}" of type ${R}: ${C}`}})}},r;function g(m,S,k,R){let C=N=>{if(!m)return null;if(typeof m=="string")return N.replaceText(S,m);{let W=new RegExp(m.regex),J=e.sourceCode.getText(S);return N.replaceText(S,J.replace(W,m.with))}};e.report({node:S,messageId:"default",data:{message:k},fix:m&&R==="autofix"?C:void 0,suggest:m&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:C}]:void 0})}}});function or(e,t){let r=[],n=t.exec(e);if(!n)return null;let[a,...o]=n;r.push({name:"$0_lowercase",value:a.toLowerCase()}),r.push({name:"$0_capitalize",value:zt(a)}),r.push({name:"$0_uncapitalize",value:Ht(a)}),r.push({name:"$0",value:a});for(let i=0;i<o.length;i++){let s=`$${i+1}`,l=o[i];r.push({name:`${s}_lowercase`,value:l.toLowerCase()}),r.push({name:`${s}_capitalize`,value:zt(l)}),r.push({name:`${s}_uncapitalize`,value:Ht(l)}),r.push({name:s,value:l})}return r}function zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ht(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as $,AST_TOKEN_TYPES as Yt,ESLintUtils as ar}from"@typescript-eslint/utils";var lr=ar.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="collapse-simple-objs-in-one-line",pr=z({maxLineLength:_(ge()),maxProperties:_(ge()),nestedObjMaxLineLength:_(ge()),nestedObjMaxProperties:_(ge()),ignoreTypesWithSuffix:_(Q(V()))}),cr=lr({name:Jt,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:[pr]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],a=t.maxProperties??2,o=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function s(p){if(p.type===$.ObjectExpression){let c=p.parent.type===$.Property,f=c?i:a,y=p.properties.length;if(y>f)return!1;if(y===1){let I=p.properties[0];return I.type===$.Property&&I.value.type===$.ObjectExpression||I.type===$.Property&&I.value.type===$.ArrayExpression&&!I.value.elements.every(E=>E&&Ke(E))?!1:{text:r.getText(I),isNested:c,propsSize:y}}let T=[];for(let I of p.properties){if(I.type===$.Property&&!Ke(I.value))return!1;T.push(r.getText(I))}return{text:T.join(", "),isNested:c,propsSize:y}}else{let c=p.parent.parent?.type===$.TSPropertySignature,f=c?i:a,y=p.members.length;if(y>f)return!1;if(n.length>0&&p.parent.type===$.TSTypeAliasDeclaration){let I=p.parent.id.name;if(n.some(x=>I.endsWith(x)))return!1}if(y===1){let I=p.members[0];return I.type===$.TSPropertySignature&&I.typeAnnotation?.typeAnnotation.type===$.TSTypeLiteral?!1:{text:r.getText(I),isNested:c,propsSize:1}}if(p.parent.type===$.TSIntersectionType||p.parent.type===$.TSUnionType&&p.parent.types[0]!==p)return!1;let T=[];for(let I of p.members){if(I.type!==$.TSPropertySignature)return!1;let x=I.typeAnnotation?.typeAnnotation;if(!x||x.type===$.TSTypeLiteral||!qt(x))return!1;if(x.type===$.TSTypeReference&&x.typeArguments){if(x.typeArguments.params.length>1)return!1;let u=x.typeArguments.params[0];if(!qt(u))return!1}let E=r.getText(I).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),T.push(E)}return{text:T.join("; "),isNested:c,propsSize:y}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==$.JSXExpressionContainer){let x=0,E=!1,u=r.getTokenAfter(p,{filter:b=>b.type!==Yt.Punctuator||E?!0:b.value===","?(x++,!1):b.value===";"?(x++,E=!0,!1):b.value===")"||b.value==="}"?(x++,!1):!0});if(x>4)return;let A=u?.type===Yt.Template&&u.value.startsWith(`}
|
|
2
|
+
`);if(u?.loc.start.line===p.loc.end.line&&!A)return}let c=s(p);if(!c)return;let f=c.text;if(f.includes(`
|
|
3
|
+
`)||r.getCommentsInside(p).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let y=`{ ${f} }`,T=fr(r,p),I=c.isNested&&c.propsSize>2?o:t.maxLineLength;I&&y.length+T.length+ur(p,r)>I||e.report({node:p,messageId:"singleLineProp",fix:x=>x.replaceText(p,y)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function qt(e){return e.type===$.TSLiteralType||e.type===$.TSTypeReference||e.type===$.TSNumberKeyword||e.type===$.TSStringKeyword||e.type===$.TSBooleanKeyword||e.type===$.TSNullKeyword||e.type===$.TSUndefinedKeyword}function Ke(e,t){return!!(e.type===$.Literal||e.type===$.Identifier||e.type===$.TemplateLiteral||e.type===$.TaggedTemplateExpression||!t&&e.type===$.ArrayExpression&&e.elements.every(r=>r&&Ke(r,!0)))}function ur(e,t){let r=t.getLastToken(e);if(!r)return 0;let n=t.text.indexOf(`
|
|
4
|
+
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function fr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ze={name:Jt,rule:cr};var mr=/eslint +react-compiler\/react-compiler: +\["error/,Xt={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,r=typeof e.getSource=="function"?u=>r(u):u=>e.sourceCode.getText(u),n=typeof e.getScope=="function"?()=>n():u=>e.sourceCode.getScope(u),a=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,o=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:a,enableDangerousAutofixThisMayCauseInfiniteLoops:o};function s(u){o&&Array.isArray(u.suggest)&&u.suggest.length>0&&(u.fix=u.suggest[0].fix),e.report(u)}let l=e.getSourceCode().scopeManager,p=new WeakMap,c=new WeakSet,f=new WeakMap,y=new WeakMap,T=new WeakSet;function I(u,A){return function(b){if(A.has(b))return A.get(b);let g=u(b);return A.set(b,g),g}}function x(u,A,b,g,m){m&&u.async&&s({node:u,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,10 @@ 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 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};
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let S=l.acquire(u),k=new Set,R=null;{let d=S.upper;for(;d&&(k.add(d),d.type!=="function");)d=d.upper;if(!d)return;R=d}let C=Array.isArray;function N(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node.type!=="VariableDeclarator")return!1;let v=h.node.init;if(v==null)return!1;for(;v.type==="TSAsExpression";)v=v.expression;let O=h.node.parent;if(O==null&&(tt(R.block,h.node.id),O=h.node.parent,O==null))return!1;if(O.kind==="const"&&v.type==="Literal"&&(typeof v.value=="string"||typeof v.value=="number"||v.value===null))return!0;if(v.type!=="CallExpression")return!1;let F=v.callee;if(F.type==="MemberExpression"&&F.object.name==="React"&&F.property!=null&&!F.computed&&(F=F.property),F.type!=="Identifier")return!1;let P=h.node.id,{name:j}=F;if(j==="useRef"&&P.type==="Identifier")return!0;if(Tr(F)&&P.type==="Identifier"){for(let D of d.references)D!==P&&T.add(D.identifier);return!0}else if(j==="useState"||j==="useReducer"){if(P.type==="ArrayPattern"&&P.elements.length===2&&C(d.identifiers)){if(P.elements[1]===d.identifiers[0]){if(j==="useState"){let D=d.references,le=0;for(let Te=0;Te<D.length;Te++){if(D[Te].isWrite()&&le++,le>1)return!1;p.set(D[Te].identifier,P.elements[0])}}return!0}else if(P.elements[0]===d.identifiers[0]){if(j==="useState"){let D=d.references;for(let le=0;le<D.length;le++)c.add(D[le].identifier)}return!1}}}else if(j==="useTransition"&&P.type==="ArrayPattern"&&P.elements.length===2&&Array.isArray(d.identifiers)&&P.elements[1]===d.identifiers[0])return!0;return!1}function W(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node==null||h.node.id==null)return!1;let v=h.node,O=R.childScopes,F=null,P;for(P=0;P<O.length;P++){let j=O[P],D=j.block;if(v.type==="FunctionDeclaration"&&D===v||v.type==="VariableDeclarator"&&D.parent===v){F=j;break}}if(F==null)return!1;for(P=0;P<F.through.length;P++){let j=F.through[P];if(j.resolved!=null&&k.has(j.resolved.scope)&&!J(j.resolved))return!1}return!0}let J=I(N,f),te=I(W,y),Z=new Map;function be(d){let h=d.from,v=!1;for(;h.block!==u;)h.type==="function"&&(v=h.block.parent!=null&&h.block.parent.type==="ReturnStatement"),h=h.upper;return v}let B=new Map,ye=new Map;ue(S);function ue(d){for(let h of d.references){if(!h.resolved||!k.has(h.resolved.scope))continue;let v=tt(u,h.identifier),O=Gt(v),F=he(O,ye);if(m&&O.type==="Identifier"&&(O.parent.type==="MemberExpression"||O.parent.type==="OptionalMemberExpression")&&!O.parent.computed&&O.parent.property.type==="Identifier"&&O.parent.property.name==="current"&&be(h)&&Z.set(F,{reference:h,dependencyNode:O}),O.parent.type==="TSTypeQuery"||O.parent.type==="TSTypeReference")continue;let P=h.resolved.defs[0];if(P!=null&&!(P.node!=null&&P.node.init===u.parent)&&P.type!=="TypeParameter")if(B.has(F))B.get(F).references.push(h);else{let j=h.resolved,D=J(j)||te(j);B.set(F,{isStable:D,references:[h]})}}for(let h of d.childScopes)ue(h)}Z.forEach(({reference:d,dependencyNode:h},v)=>{let O=d.resolved.references,F=!1;for(let P=0;P<O.length;P++){let{identifier:j}=O[P],{parent:D}=j;if(D!=null&&D.type==="MemberExpression"&&!D.computed&&D.property.type==="Identifier"&&D.property.name==="current"&&D.parent.type==="AssignmentExpression"&&D.parent.left===D){F=!0;break}}F||s({node:h.parent.property,message:`The ref value '${v}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${v}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ie=new Set;function Se(d,h){ie.has(h)||(ie.add(h),s({node:d,message:`Assignments to the '${h}' variable from inside React Hook ${r(b)} 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(b)}.`}))}let Ae=new Set;if(B.forEach(({isStable:d,references:h},v)=>{d&&Ae.add(v),h.forEach(O=>{O.writeExpr&&Se(O.writeExpr,v)})}),ie.size>0)return;if(!A){let d=null;if(B.forEach(({isStable:h,references:v},O)=>{d||v.forEach(F=>{if(d)return;let P=F.identifier;if(!p.has(P))return;let D=F.from;for(;D.type!=="function";)D=D.upper;D.block===u&&(d=O)})}),d){let{suggestedDependencies:h}=Qe({dependencies:B,declaredDependencies:[],stableDependencies:Ae,externalDependencies:new Set,isEffect:!0});s({node:b,message:`React Hook ${g} contains a call to '${d}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+h.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${h.join(", ")}]`,fix(v){return v.insertTextAfter(u,`, [${h.join(", ")}]`)}}]})}return}let Pe=[],Fe=new Set;A.type!=="ArrayExpression"?s({node:A,message:`React Hook ${r(b)} 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.`}):A.elements.forEach(d=>{if(d===null)return;if(d.type==="SpreadElement"){s({node:d,message:`React Hook ${r(b)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}T.has(d)&&s({node:d,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(d)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(d)}\``,fix(F){return F.removeRange(d.range)}}]});let h;try{h=he(d,ye)}catch(F){if(/Unsupported node type/.test(F.message)){d.type==="Literal"?B.has(d.value)?s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. Did you mean to include ${d.value} in the array instead?`}):s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:d,message:`React Hook ${r(b)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw F}let v=d;for(;v.type==="MemberExpression"||v.type==="OptionalMemberExpression"||v.type==="ChainExpression";)v=v.object||v.expression.object;let O=!R.through.some(F=>F.identifier===v);Pe.push({key:h,node:d}),O||Fe.add(h)});let{suggestedDependencies:Jn,unnecessaryDependencies:Me,missingDependencies:xe,duplicateDependencies:Dt}=Qe({dependencies:B,declaredDependencies:Pe,stableDependencies:Ae,externalDependencies:Fe,isEffect:m}),De=Jn;if(Dt.size+xe.size+Me.size===0){if(t)return;dr({declaredDependencies:Pe,declaredDependenciesNode:A,componentScope:R,scope:S}).forEach(({construction:h,isUsedOutsideOfHook:v,depType:O})=>{let F=O==="function"?"useCallback":"useMemo",P=O==="function"?"definition":"initialization",j=`wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,D=v?`To fix this, ${j}`:`Move it inside the ${g} callback. Alternatively, ${j}`,le=O==="conditional"||O==="logical expression"?"could make":"makes",Te=`The '${h.name.name}' ${O} ${le} the dependencies of ${g} Hook (at line ${A.loc.start.line}) change on every render. ${D}`,Lt;v&&h.type==="Variable"&&O==="function"&&(Lt=[{desc:`Wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,fix(_t){let[Xn,Gn]=F==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[_t.insertTextBefore(h.node.init,Xn),_t.insertTextAfter(h.node.init,Gn)]}}]),s({node:h.node,message:Te,suggest:Lt})});return}!m&&xe.size>0&&(De=Qe({dependencies:B,declaredDependencies:[],stableDependencies:Ae,externalDependencies:Fe,isEffect:m}).suggestedDependencies);function Bn(){if(Pe.length===0)return!0;let d=Pe.map(v=>v.key),h=d.slice().sort();return d.join(",")===h.join(",")}Bn()&&De.sort();function qe(d){let h=d.split("."),v="";for(let O=0;O<h.length;O++){if(O!==0){let F=h.slice(0,O+1).join("."),P=ye.get(F)===!0;v+=P?"?.":"."}v+=h[O]}return v}function Je(d,h,v,O){return d.size===0?null:(d.size>1?"":h+" ")+v+" "+(d.size>1?"dependencies":"dependency")+": "+gr(Array.from(d).sort().map(F=>"'"+qe(F)+"'"))+`. Either ${O} ${d.size>1?"them":"it"} or remove the dependency array.`}let fe="";if(Me.size>0){let d=null;if(Array.from(Me.keys()).forEach(h=>{d===null&&h.endsWith(".current")&&(d=h)}),d!==null)fe=` Mutable values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Fe.size>0){let h=Array.from(Fe)[0];S.set.has(h)||(fe=` Outer scope values like '${h}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!fe&&xe.has("props")){let d=B.get("props");if(d==null)return;let h=d.references;if(!Array.isArray(h))return;let v=!0;for(let O=0;O<h.length;O++){let F=h[O],P=tt(R.block,F.identifier);if(!P){v=!1;break}let j=P.parent;if(j==null){v=!1;break}if(j.type!=="MemberExpression"&&j.type!=="OptionalMemberExpression"){v=!1;break}}v&&(fe=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${g} call and refer to those specific props inside ${r(b)}.`)}if(!fe&&xe.size>0){let d=null;xe.forEach(h=>{if(d)return;let v=R.set.get(h),O=B.get(h);if(O.references[0].resolved!==v)return;let F=v.defs[0];if(F==null||F.name==null||F.type!=="Parameter")return;let P=!1,j;for(let D=0;D<O.references.length;D++)if(j=O.references[D].identifier,j!=null&&j.parent!=null&&(j.parent.type==="CallExpression"||j.parent.type==="OptionalCallExpression")&&j.parent.callee===j){P=!0;break}P&&(d=h)}),d!==null&&(fe=` If '${d}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!fe&&xe.size>0){let d=null;if(xe.forEach(h=>{if(d!==null)return;let O=B.get(h).references,F,P;for(let j=0;j<O.length;j++){for(F=O[j].identifier,P=F.parent;P!=null&&P!==R.block;){if(P.type==="CallExpression"){let D=p.get(P.callee);if(D!=null){if(D.name===h)d={missingDep:h,setter:P.callee.name,form:"updater"};else if(c.has(F))d={missingDep:h,setter:P.callee.name,form:"reducer"};else{let le=O[j].resolved;if(le!=null){let Te=le.defs[0];Te!=null&&Te.type==="Parameter"&&(d={missingDep:h,setter:P.callee.name,form:"inlineReducer"})}}break}}P=P.parent}if(d!==null)break}}),d!==null)switch(d.form){case"reducer":fe=` You can also replace multiple useState variables with useReducer if '${d.setter}' needs the current value of '${d.missingDep}'.`;break;case"inlineReducer":fe=` If '${d.setter}' needs the current value of '${d.missingDep}', you can also switch to useReducer instead of useState and read '${d.missingDep}' in the reducer.`;break;case"updater":fe=` You can also do a functional update '${d.setter}(${d.missingDep.slice(0,1)} => ...)' if you only need '${d.missingDep}' in the '${d.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:A,message:`React Hook ${r(b)} has `+(Je(xe,"a","missing","include")||Je(Me,"an","unnecessary","exclude")||Je(Dt,"a","duplicate","omit"))+fe,suggest:[{desc:`Update the dependencies array to be: [${De.map(qe).join(", ")}]`,fix(d){return d.replaceText(A,`[${De.map(qe).join(", ")}]`)}}]})}function E(u){let A=yr(u.callee,i);if(A===-1)return;let b=u.arguments[A],g=u.callee,m=Kt(g).name,S=u.arguments[A+1],k=/Effect($|[^a-z])/g.test(m);if(!b){s({node:g,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!S&&!k){(m==="useMemo"||m==="useCallback")&&s({node:g,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(b.type){case"FunctionExpression":case"ArrowFunctionExpression":x(b,S,g,m,k);return;case"Identifier":if(!S||S.elements&&S.elements.some(N=>N&&N.type==="Identifier"&&N.name===b.name))return;let R=n(u).set.get(b.name);if(R==null||R.defs==null)return;let C=R.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":x(C.node,S,g,m,k);return;case"VariableDeclarator":let N=C.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":x(N,S,g,m,k);return}break}break;default:s({node:g,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:g,message:`React Hook ${m} has a missing dependency: '${b.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${b.name}]`,fix(R){return R.replaceText(S,`[${b.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let u of e.sourceCode.getAllComments())if(mr.test(u.value))return t=!0,{CallExpression:A=>E(A,!0)}}return{CallExpression:u=>E(u)}}};function Qe({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:a}){let o=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((x,E)=>{let u=s(o,E);u.isUsed=!0,l(o,E,A=>{A.isSubtreeUsed=!0})}),t.forEach(({key:x})=>{let E=s(o,x);E.isSatisfiedRecursively=!0}),r.forEach(x=>{let E=s(o,x);E.isSatisfiedRecursively=!0});function s(x,E){let u=E.split("."),A=x;for(let b of u){let g=A.children.get(b);g||(g=i(),A.children.set(b,g)),A=g}return A}function l(x,E,u){let A=E.split("."),b=x;for(let g of A){let m=b.children.get(g);if(!m)return;u(m),b=m}}let p=new Set,c=new Set;f(o,p,c,x=>x);function f(x,E,u,A){x.children.forEach((b,g)=>{let m=A(g);if(b.isSatisfiedRecursively){b.isSubtreeUsed&&u.add(m);return}if(b.isUsed){E.add(m);return}f(b,E,u,S=>m+"."+S)})}let y=[],T=new Set,I=new Set;return t.forEach(({key:x})=>{c.has(x)?y.indexOf(x)===-1?y.push(x):I.add(x):T.add(x)}),p.forEach(x=>{y.push(x)}),{suggestedDependencies:y,unnecessaryDependencies:T,duplicateDependencies:I,missingDependencies:p}}function Ce(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 Ce(e.consequent)!=null||Ce(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Ce(e.left)!=null||Ce(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Ce(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Ce(e.expression);case"TSAsExpression":return Ce(e.expression)}return null}function dr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let a=e.map(({key:i})=>{let s=r.variables.find(p=>p.name===i);if(s==null)return null;let l=s.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=Ce(l.node.init);if(p!=null)return[s,p]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[s,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function o(i){let s=!1;for(let l=0;l<i.references.length;l++){let p=i.references[l];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!Zt(t,p.identifier))return!0}return!1}return a.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:o(i)}))}function Gt(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)?Gt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function et(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function he(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=he(e.object,t),n=he(e.property,null),a=`${r}.${n}`;return et(e,t,a),a}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=he(e.object,t),n=he(e.property,null),a=`${r}.${n}`;return et(e,t,a),a}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=he(r.object,t),a=he(r.property,null),o=`${n}.${a}`;return et(r,t,o),o}else throw new Error(`Unsupported node type: ${e.type}`)}function Kt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function yr(e,t){let r=Kt(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=he(r,null)}catch(a){if(/Unsupported node type/.test(a.message))return 0;throw a}return t.additionalHooks.test(n)?0:-1}else return-1}}function tt(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),Sr(n,t))return n;if(Zt(n,t))for(let[a,o]of Object.entries(n))a!=="parent"&&(Bt(o)?(o.parent=n,r.push(o)):Array.isArray(o)&&o.forEach(i=>{Bt(i)&&(i.parent=n,r.push(i))}))}return null}function gr(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 Bt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Sr(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 Zt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Tr(e){return!1}import{AST_NODE_TYPES as _e,ESLintUtils as en}from"@typescript-eslint/utils";import se from"typescript";var hr=en.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="improved-no-unnecessary-condition",Er=z({}),br=["string","number","bigint","boolean","symbol","undefined","object","function","never"],xr=new Set(br),nt={name:Qt,rule:hr({name:Qt,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:[Er]},defaultOptions:[{}],create(e){let t=en.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(s){return s.type===_e.UnaryExpression&&s.operator==="typeof"}function a(s){return s.flags&se.TypeFlags.Any||s.flags&se.TypeFlags.Unknown?null:s.flags&se.TypeFlags.StringLike?["string"]:s.flags&se.TypeFlags.NumberLike?["number"]:s.flags&se.TypeFlags.BigIntLike?["bigint"]:s.flags&se.TypeFlags.BooleanLike?["boolean"]:s.flags&se.TypeFlags.ESSymbolLike?["symbol"]:s.flags&se.TypeFlags.Undefined||s.flags&se.TypeFlags.Void?["undefined"]:s.flags&se.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&se.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&se.TypeFlags.NonPrimitive?["object"]:s.flags&se.TypeFlags.Never?["never"]:null}function o(s){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(s),p=r.getTypeAtLocation(l.expression);if(p.flags&se.TypeFlags.Any||p.flags&se.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let y of p.types){let T=a(y);if(T)c.push(...T);else return null}return c}let f=a(p);return f?(c.push(...f),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(n(s.left)?(p=s.left,c=s.right.type===_e.Literal&&typeof s.right.value=="string"?s.right.value:null):n(s.right)&&(p=s.right,c=s.left.type===_e.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!Ir(c,xr))return;let f=o(p);if(!f)return;let y=s.operator==="!==",T=f.includes(c);f.length===1?T&&!y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:ve(p,e),type:c}}):!T&&y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:ve(p,e),type:Array.from(f)[0]}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:ve(p,e),actualType:Le(f),conditionType:c}}):T&&y&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:ve(p,e),actualType:Le(f),conditionType:c}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:ve(p,e),actualType:Le(f),conditionType:c}}):!T&&y&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:ve(p,e),type:Le(f)}})}return{BinaryExpression:i}}})};function Le(e){return Array.from(new Set(e)).join(" | ")||"never"}function ve(e,t){let r=e.argument;return r.type===_e.Identifier?r.name:t.sourceCode.getText(r)}function Ir(e,t){return t.has(e)}import{AST_NODE_TYPES as Cr,ESLintUtils as wr}from"@typescript-eslint/utils";var Ar=wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-call-with-explicit-generics",Rr=z({functions:Q(V())}),vr=Ar({name:tn,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Rr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:a}=n;a.type===Cr.Identifier&&r.has(a.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:a.name}})}}}}),rt={name:tn,rule:vr};import{AST_NODE_TYPES as $e,ESLintUtils as kr}from"@typescript-eslint/utils";var Or=kr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nn="no-call-with-inferred-generics",Pr=Or({name:nn,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:a}=n;if(a.type!==$e.Identifier)return;let o=r.get(a.name);if(!o)return;let{minGenerics:i=1,allowAny:s,disallowTypes:l=t.disallowTypes}=o;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:a.name,minGenerics:i||0}}),!(s&&!l)&&n.typeArguments?.params?.some(c=>!s&&c.type===$e.TSAnyKeyword||l&&c.type===$e.TSTypeReference&&c.typeName.type===$e.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:a.name}})}}}}),it={name:nn,rule:Pr};import{ESLintUtils as Fr}from"@typescript-eslint/utils";var Nr=Fr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="no-commented-out-code",jr=["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:"],X={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]*$/},Mr=[") {","return;",X.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",X.stringAssignment,");",X.objectPropertyWithQuotes,X.computedPropertyAssignment,X.kebabCaseProperty,X.snakeCaseProperty,"&&","||","()",X.ternaryOperator,X.colonWithWord,X.quotedString,X.numberWithComma,X.arrayWithComma,X.objectWithComma,X.methodCall,X.arrayAccess,"?.(","??","=>",X.quotedPropertyKey],Dr=["/>","</",X.jsxSelfClosing,X.jsxElement,X.jsxOpeningTag,X.jsxClosingTag,X.htmlOpeningTag,X.htmlClosingTag],rn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Lr=Nr({name:sn,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,a){if(n.startsWith("/"))return!1;let o=n.trimStart();if(n.startsWith("*")||o.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")||X.jsdocComment.test(n))return!1;for(let i of rn)if(o.startsWith(i))return!1;if(n.includes("https://")||o.includes(":")&&X.colonDescriptiveComment.test(o.trim()))return!1;if(a==="Block"){for(let i of Dr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of jr)if(o.startsWith(i))return{wrongPattern:i};for(let i of Mr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,a){let o=n,i=o.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return o;if(a==="Block"&&o.includes("```")){let p=o.split(/```[\s\S]*?```/g);p.some(f=>/[a-zA-Z0-9]/.test(f))&&(o=p.join(""))}if(!o.includes("`"))return o;let s=o.split(/`[^`]*`/g);return s.some(p=>/[a-zA-Z0-9]/.test(p))?s.join(""):o}return{Program(){let a=e.sourceCode.getAllComments();for(let o of a){let i=r(o.value,o.type),s=t(i,o.type);s&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:rn.join(", ")}})}}}}}),st={name:sn,rule:Lr};import{ESLintUtils as _r,TSESTree as $r}from"@typescript-eslint/utils";var Ur=_r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-default-export",Wr=Ur({name:on,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===$r.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ot={name:on,rule:Wr};import{ESLintUtils as Vr}from"@typescript-eslint/utils";var zr=Vr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="no-leaked-text-in-jsx",Hr=[",",";","[","]","(",")"],Yr=zr({name:an,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="";Hr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),at={name:an,rule:Yr};import{AST_NODE_TYPES as Ne,ESLintUtils as qr}from"@typescript-eslint/utils";var Jr=qr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-non-camel-case-functions",Br=/^(\$?[a-z][a-zA-Z0-9]*)$/;function ln(e){if(e.typeName.type!==Ne.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Ne.Identifier&&t.name==="JSX"&&r.name==="Element"}var Xr=Jr({name:pn,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===Ne.TSTypeReference?ln(r):r.type===Ne.TSUnionType&&r.types.some(a=>a.type===Ne.TSTypeReference&&ln(a))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),lt={name:pn,rule:Xr};import{ESLintUtils as Gr,TSESTree as H}from"@typescript-eslint/utils";import{AST_NODE_TYPES as cn}from"@typescript-eslint/utils";function ke(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:ke(e.parent,t,r===1/0?r:r-1)}function*pt(e){yield e,e.parent&&(yield*pt(e.parent))}function ct(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function un(e,t,r){let a=r.getDeclaredVariables(e).find(o=>o.name===t||o.identifiers[0]?.parent.type===cn.Property&&o.identifiers[0]?.parent.key.type===cn.Identifier&&o.identifiers[0]?.parent.key.name===t);return a?a.references.filter(o=>!o.init):[]}var Kr=Gr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="no-optional-root-props",Zr=Kr({name:fn,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 o=e.sourceCode.getDeclaredVariables(n)[0];if(!o||o.references.length!==1)return!1;let i=o.references[0];if(!i)return!1;for(let s of pt(i.identifier)){if("returnType"in s||s.type===H.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=s.parent;if(!l)return!1;if(l.type===H.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===H.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===H.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let c=ke(l.parent.parent,H.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let f=Ue(c,e.sourceCode);return f?!(f.parent.type===H.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===H.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(s.type===H.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===H.AST_NODE_TYPES.ArrowFunctionExpression){let p=ke(l,H.AST_NODE_TYPES.VariableDeclaration);return p?!!Ue(p,e.sourceCode):!1}if(l.type===H.AST_NODE_TYPES.FunctionDeclaration)return!!Ue(l,e.sourceCode)}return!1}function r(n){n.key.type!==H.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:a=>{let o=ke(n,H.AST_NODE_TYPES.TSPropertySignature);if(!o)return null;let i=e.sourceCode.getText(o);return a.replaceText(o,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===H.AST_NODE_TYPES.TSTypeLiteral&&!(We(n)||!t(n)))for(let a of n.typeAnnotation.members)a.type===H.AST_NODE_TYPES.TSPropertySignature&&r(a)},TSInterfaceDeclaration(n){if(!(We(n)||!t(n)))for(let a of n.body.body)a.type===H.AST_NODE_TYPES.TSPropertySignature&&r(a)},TSTypeReference(n){if(n.typeName.type!==H.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let a=n.typeArguments.params[0];if(a.type!==H.AST_NODE_TYPES.TSTypeLiteral)return;let o=ke(n.parent,H.AST_NODE_TYPES.VariableDeclaration,4);if(!o)return;let i=Ue(o,e.sourceCode);if(!(!i||i.parent.type===H.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===H.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of a.members)l.type===H.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function We(e){return e?e.parent?.type===H.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===H.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ue(e,t){if(We(e))return;let r;if(e.type===H.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===H.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===H.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let a=n.variables.find(i=>i.identifiers.includes(r));if(!a)return;let o=a.references.filter(i=>i.identifier!==r);if(!(o.length!==1||!o[0])&&!We(o[0].identifier.parent.parent))return o[0].identifier}var ut={name:fn,rule:Zr};import{ESLintUtils as Qr}from"@typescript-eslint/utils";import ft from"node:path";var ei=Qr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-relative-imports",ti=z({find:V(),replacement:V()}),ni=z({aliases:Q(ti),rootDir:_(V()),allowNotFoundAliases:_(Re()),_dev_simulateFileName:_(V())}),ri=ei({name:mn,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:[ni]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function a(i,s){let l=ft.dirname(s);return ft.resolve(l,i)}function o(i){let s=t.rootDir??process.cwd(),l=ft.relative(s,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let f=l.replace(c,p);return{alias:p,newPath:f}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!n(s))return;let l=a(s,r),p=o(l);!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})}}}}),mt={name:mn,rule:ri};import{AST_NODE_TYPES as Ve}from"@typescript-eslint/utils";import*as we from"zod/v4";var ii=we.object({alternativeMsgs:we.object({inArrayFind:we.string().optional(),inArrayFilter:we.string().optional()}).optional(),__dev_simulateFileName:we.string().optional()});function si(e){return e.typeAnnotation.type!==Ve.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function oi(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ai(e){let t=e.parent;for(;t;){if(t.type===Ve.CallExpression&&t.callee.type===Ve.MemberExpression&&t.callee.property.type===Ve.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var dt=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:[Ie(ii)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(oi(r))return{};function n(a){if(!si(a))return;let o=ai(a),i=[];if(t.alternativeMsgs&&o){let s=o.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(s){let l=o.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:a,messageId:l,data:{message:s}});return}}e.report({node:a,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as Oe}from"@typescript-eslint/utils";var li="no-unnecessary-async-on-jsx-props";function pi(e){if(e.body.type!==Oe.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==Oe.ExpressionStatement?!1:r.expression.type===Oe.AwaitExpression}var yt=G({name:li,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){pi(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let a=e.sourceCode,o=[],i=a.getFirstToken(r,l=>l.value==="async");if(i){let l=a.getTokenAfter(i);l?o.push(n.replaceTextRange([i.range[0],l.range[0]],"")):o.push(n.remove(i))}function s(l){if(l.type===Oe.AwaitExpression){let p=a.getFirstToken(l);if(p&&p.value==="await"){let c=a.getTokenAfter(p);c?o.push(n.replaceTextRange([p.range[0],c.range[0]],"")):o.push(n.remove(p))}}if(l.type===Oe.BlockStatement)for(let p of l.body)s(p);else l.type===Oe.ExpressionStatement&&s(l.expression)}return s(r.body),o}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as je,ESLintUtils as yn}from"@typescript-eslint/utils";import*as gt from"typescript";var ci=yn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="no-unnecessary-casting",ui=z({additionalCastFunctions:_(Q(z({name:V(),expectedType:$t(["string","number"])})))}),St={name:dn,rule:ci({name:dn,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:[ui],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],a=yn.getParserServices(e,!0),o=a.program?.getTypeChecker();if(!o||!a.program)throw new Error("TypeScript services or program not available");function i(c,f){switch(c.type){case je.Literal:return f==="number"?typeof c.value=="number":typeof c.value=="string";case je.TemplateLiteral:return f==="string";case je.UnaryExpression:return f==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function s(c,f){return f==="number"?!!(c.flags>.TypeFlags.NumberLike):!!(c.flags>.TypeFlags.StringLike)}function l(c,f){return y=>y.replaceText(c,e.sourceCode.getText(f))}function p(c){if(!o||c.arguments.length!==1)return;let f=c.arguments[0];if(!f||f.type===je.SpreadElement)return;let{callee:y}=c;if(y.type!==je.Identifier)return;let T=y.name,I=n.find(E=>E.name===T);if(!I)return;if(i(f,I.expectedType)||s(o.getTypeAtLocation(a.esTreeNodeToTSNodeMap.get(f)),I.expectedType)){let E,u;T==="Number"?E="unnecessaryNumberCasting":T==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",u={name:I.name,type:I.expectedType}),e.report({node:c,messageId:E,...u?{data:u}:{},fix:l(c,f)})}}return{CallExpression:p}}})};import{AST_NODE_TYPES as ze}from"@typescript-eslint/utils";import*as pe from"zod/v4";var fi=pe.object({methods:pe.union([pe.array(pe.string()),pe.literal("array")])}),Tt=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:[pe.toJSONSchema(fi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function a(s){return Array.isArray(r)?r.includes(s):n.has(s)}function o(s){let{callee:l}=s;if(l.type===ze.MemberExpression){let p=l.property;if(p.type===ze.Identifier)return p.name}return null}function i(s,l){if(s.type!==ze.Identifier||!s.typeAnnotation)return;let p=l.parent;if(p.type===ze.CallExpression){let c=o(p);c&&a(c)&&p.arguments.indexOf(l)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(y){return y.remove(s.typeAnnotation)}})}}return{ArrowFunctionExpression(s){for(let l of s.params)i(l,s)},FunctionExpression(s){for(let l of s.params)i(l,s)}}}});import{AST_NODE_TYPES as ae}from"@typescript-eslint/utils";var ht=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===ae.ObjectPattern||!t.init||t.init.type!==ae.ObjectExpression||t.id.type===ae.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ae.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===ae.Property&&i.key.type===ae.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==ae.Identifier)return;let n=mi(t,e.sourceCode);if(n.length===0)return;let a=t.init.properties.some(i=>i.type!==ae.Property?!1:i.value.type===ae.FunctionExpression),o=new Set;for(let i of n){if(i.identifier.parent.type!==ae.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===ae.Literal&&typeof s.property.value=="string")o.add(s.property.value);else return;else{if(s.property.type!==ae.Identifier)return;o.add(s.property.name)}if(s.parent.type===ae.CallExpression&&a)return}for(let[i,s]of r)o.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function mi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(a=>a.identifier!==e.id):[]}import{AST_NODE_TYPES as q,ESLintUtils as di}from"@typescript-eslint/utils";var yi=z({selectors:Q(z({name:V(),selectorProp:_(V()),selectorArgPos:_(ge()),returnProp:_(V())}))}),gi=di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn="no-unused-selected-values",Et={name:gn,rule:gi({name:gn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[yi]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(a=>[a.name,a]));return{VariableDeclarator(a){let o=null;if(a.init?.type===q.CallExpression&&(o=a.init),!o)return;let i=Ti(o);if(!i)return;let s=n.get(i);if(!s)return;let l=Si(o,s.selectorArgPos??0,s.selectorProp);if(!l)return;let p=hi(l);if(!p)return;let c=Sn(p.properties,void 0);if(!c)return;if(a.id.type===q.ObjectPattern){let T=Sn(a.id.properties,s.returnProp);if(!T)return;for(let[I,x]of c)T.has(I)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:I}});return}if(a.id.type!==q.Identifier||s.returnProp)return;let f=Ei(a,e.sourceCode);if(f.length===0)return;let y=new Set;for(let T of f){if(T.identifier.parent.type!==q.MemberExpression)return;let I=T.identifier.parent.property;if(I.type!==q.Identifier)return;y.add(I.name)}for(let[T,I]of c)y.has(T)||e.report({node:I,messageId:"unusedSelectedValue",data:{name:T}})}}}})};function Si(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===q.ArrowFunctionExpression||n.type===q.FunctionExpression)return n;if(r&&n.type===q.ObjectExpression){let a=n.properties.find(i=>i.type===q.Property&&i.key.type===q.Identifier&&i.key.name===r);if(a?.type!==q.Property)return null;let o=a.value;if(o.type===q.ArrowFunctionExpression||o.type===q.FunctionExpression)return o}return null}function Ti(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 hi(e){if(e.body.type===q.ObjectExpression)return e.body;if(e.body.type===q.BlockStatement){let t=e.body.body.filter(r=>r.type===q.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==q.ObjectExpression?null:t[0].argument}return null}function Sn(e,t){let r=e;if(t){let a=e.find(o=>o.type===q.Property&&o.key.type===q.Identifier&&o.key.name===t);if(a?.type!==q.Property||a.value.type!==q.ObjectPattern)return null;r=a.value.properties}let n=new Map;for(let a of r){if(a.type!==q.Property||a.key.type!==q.Identifier)return null;n.set(a.key.name,a)}return n.size>0?n:null}function Ei(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(a=>a.identifier!==e.id):[]}import{AST_NODE_TYPES as Y}from"@typescript-eslint/utils";var bt=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(o=>o.type===Y.ImportDeclaration&&o.source.value==="t-state-form"))return{};let n=null,a=!1;return{CallExpression(o){if(a)return;if(!n){let s=bi(o);s&&(n=s);return}let i=xi(o,e.sourceCode);if(i){a=!0;for(let s of i)n.delete(s);if(n.size!==0)for(let[s,l]of n)e.report({node:l,messageId:"unusedField",data:{name:s}})}}}}});function bi(e){if(!(e.callee.type===Y.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==Y.ObjectExpression)return null;let n=ct(r.properties,o=>o.type!==Y.Property||o.key.type!==Y.Identifier||o.key.name!=="initialConfig"?null:o.value.type===Y.ObjectExpression?o.value:o.value.type===Y.ArrowFunctionExpression||o.value.type===Y.FunctionExpression?Ii(o.value):null);if(!n)return null;let a=new Map;for(let o of n.properties)o.type===Y.Property&&o.key.type===Y.Identifier&&a.set(o.key.name,o);return a}function xi(e,t){if(!(e.callee.type===Y.Identifier&&e.callee.name==="useFormState")||e.parent.type!==Y.VariableDeclarator||e.parent.id.type!==Y.ObjectPattern||!ct(e.parent.id.properties,i=>i.type===Y.Property&&i.key.type===Y.Identifier&&i.key.name==="formFields"&&i))return null;let a=un(e.parent,"formFields",t),o=new Set;for(let{identifier:i}of a){if(i.type!==Y.Identifier||i.parent.type===Y.Property&&i.parent.parent.type===Y.ObjectExpression&&i.parent.parent.parent.type===Y.ReturnStatement||i.parent.type===Y.ReturnStatement)return null;if(i.parent.type===Y.MemberExpression){if(i.parent.object.type!==Y.Identifier||i.parent.property.type!==Y.Identifier)return null;o.add(i.parent.property.name)}}return o}function Ii(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}import{AST_NODE_TYPES as U,ESLintUtils as Ci}from"@typescript-eslint/utils";var wi=Ci.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Tn(e){let t=[];for(let r of e.members)r.type===U.TSPropertySignature&&r.key.type===U.Identifier&&t.push([r.key.name,r]);return t}function hn(e,...t){for(let r of t)e.set(...r);return e}var Ai=z({forceCheckOnFCPropTypesWithName:_(Q(V()))}),En="no-unused-type-props-in-args",xt=null,Ri=wi({name:En,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:[Ai],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!xt&&(xt=r.map(s=>new RegExp(s)));function n(s,l,p,c,f=!0){let y=p.name,T=e.sourceCode.getScope(l).references.find(E=>E.identifier.name===y)?.resolved,I=s&&xt?.some(E=>E.test(y));if(!T||!I&&T.references.filter(E=>E.isTypeReference).length>1)return;let x=T?.defs[0]?.node;if(!(f&&x?.parent?.type===U.ExportNamedDeclaration)){if(x?.type===U.TSTypeAliasDeclaration){a(s,l,c,x.typeAnnotation,!0);return}if(x?.type===U.TSInterfaceDeclaration){a(s,l,c,x.body,!0);return}}}function a(s,l,p,c,f){if(c.type===U.TSInterfaceBody){for(let y of c.body)y.type===U.TSPropertySignature&&y.key.type===U.Identifier&&p.set(y.key.name,y);return}if(c.type===U.TSTypeLiteral){hn(p,...Tn(c));return}if(c.type===U.TSIntersectionType){for(let y of c.types)a(s,l,p,y,!0);return}f||c.type===U.TSTypeReference&&c.typeName.type===U.Identifier&&n(s,l,c.typeName,p)}function o(s,l,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let f=new Map;if(a(s,l,f,c.typeAnnotation.typeAnnotation,!1),f.size===0)continue;i(c,f)}else c.type===U.AssignmentPattern&&c.left.type===U.ObjectPattern&&o(s,l,[c.left])}function i(s,l){let p=[];if(s.properties.at(-1)?.type===U.RestElement)return;for(let T of s.properties)T.type===U.Property&&T.key.type===U.Identifier&&p.push(T.key.name);let f=[],y=[];for(let[T,I]of l)p.includes(T)||(y.push(T),f.push({node:I,messageId:"unusedObjectTypeProperty",data:{propertyName:T}}));for(let[T,I]of f.entries())e.report({...I,fix:T===f.length-1?x=>{let E=s.properties.at(-1),u=y.join(", ");return E?E?.type===U.RestElement?null:x.insertTextAfter(E,`, ${u}`):x.insertTextBeforeRange([s.range[0]+1,s.range[1]],`${u}`)}:void 0})}return{VariableDeclaration(s){let l=s.declarations[0];if(!l)return;let p=new Map,c=l.id.type===U.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===U.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===U.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===U.TSTypeReference&&c.typeName.type===U.Identifier)n(!0,s,c.typeName,p,!1);else if(c.type===U.TSTypeLiteral)hn(p,...Tn(c));else if(c.type===U.TSIntersectionType)for(let f of c.types)f.type===U.TSTypeReference&&f.typeName.type===U.Identifier?n(!0,s,f.typeName,p,!1):a(!0,s,p,f,!0);if(p.size!==0&&l.init?.type===U.ArrowFunctionExpression){let f=l.init.params[0];if(!f){e.report({node:l.init,messageId:"missingComponentParam"});return}f.type===U.ObjectPattern&&i(f,p)}}},FunctionDeclaration:function(s){o(!1,s,s.params)},ArrowFunctionExpression(s){o(!1,s,s.params)}}}}),It={name:En,rule:Ri};import{AST_NODE_TYPES as de}from"@typescript-eslint/utils";var Ct=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===de.Identifier?t.has(n.callee.name):n.callee.type===de.MemberExpression&&n.callee.object.type===de.Identifier&&n.callee.property.type===de.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let a of n.specifiers)a.type===de.ImportSpecifier&&a.imported.type===de.Identifier&&a.imported.name==="useRef"&&t.add(a.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===de.CallExpression&&r(n.init)&&n.id.type===de.Identifier){let o=e.sourceCode.getScope(n).set.get(n.id.name);if(o){let i=!1;for(let s of o.references){let p=s.identifier.parent;if(p!==n&&!(p.type===de.JSXExpressionContainer&&p.parent.type===de.JSXAttribute&&p.parent.name.type===de.JSXIdentifier&&p.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});import{AST_NODE_TYPES as wt,ESLintUtils as vi}from"@typescript-eslint/utils";var ki=vi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xn="prefer-named-functions",bn=new Map,Oi=ki({name:xn,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=bn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),bn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===wt.ArrowFunctionExpression&&n.id.type===wt.Identifier){let a=n.id.name;if(n.id.typeAnnotation||r&&r.test(a)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==wt.BlockStatement)return;let o=n.parent,i=n.init.params,s=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:a,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(o,`${l.async?"async ":""}function ${a}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),At={name:xn,rule:Oi};import{AST_NODE_TYPES as M}from"@typescript-eslint/utils";var Pi=z({disallowedFunctions:Q(z({name:V(),allowUsingWithArgs:_(Re()),hookAlternative:_(V()),message:_(V()),allowUseInside:_(Q(V()))}))});function He(e){return/^use[A-Z]/.test(e)}function In(e){return/^[A-Z]/.test(e)}function Fi(e){return e.type===M.Identifier?He(e.name):e.type===M.MemberExpression&&e.property.type===M.Identifier?He(e.property.name):!1}function Cn(e,t){return e.type===M.Identifier?e.name===t:e.type===M.MemberExpression&&e.object.type===M.Identifier&&e.property.type===M.Identifier?e.object.name==="React"&&e.property.name===t:!1}function wn(e){return!!(e.parent&&e.parent.type===M.CallExpression&&Cn(e.parent.callee,"forwardRef"))}function An(e){return!!(e.parent&&e.parent.type===M.CallExpression&&Cn(e.parent.callee,"memo"))}function Rt(e){if(e.type===M.FunctionDeclaration||e.type===M.FunctionExpression&&e.id)return e.id||void 0;if(e.type===M.FunctionExpression||e.type===M.ArrowFunctionExpression){if(e.parent.type===M.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===M.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===M.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===M.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Ni(e){let t=e.parent,r=!1;for(;t;){if(t.type===M.FunctionDeclaration||t.type===M.FunctionExpression||t.type===M.ArrowFunctionExpression){let n=Rt(t);if(n&&n.type===M.Identifier){if(In(n.name)||He(n.name))return!r;r=!0}else{if(wn(t)||An(t))return!r;if(t.parent.type===M.CallExpression){let a=t.parent;Fi(a.callee)||(r=!0)}else t.parent.type===M.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Rn(e){return e.callee.type===M.Identifier?e.callee.name:e.callee.type===M.MemberExpression&&e.callee.property.type===M.Identifier?e.callee.property.name:null}function ji(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===M.FunctionDeclaration||r.type===M.FunctionExpression||r.type===M.ArrowFunctionExpression){let n=Rt(r);if(n&&n.type===M.Identifier&&t.includes(n.name))return!0}else if(r.type===M.CallExpression){let n=Rn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Mi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===M.Identifier&&t.name==="undefined")}function Di(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===M.FunctionDeclaration||n.type===M.FunctionExpression||n.type===M.ArrowFunctionExpression){let a=Rt(n);if(a&&a.type===M.Identifier){if(In(a.name)||He(a.name)){r=!0;break}}else if(wn(n)||An(n)){r=!0;break}}n=n.parent}return r?t.length===0?Ni(e):!ji(e,t):!1}var vt=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:[Pi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(a=>[a.name,a]));return{CallExpression(a){let o=Rn(a);if(!o)return;let i=n.get(o);if(!i||i.allowUsingWithArgs&&Mi(a))return;let s=i.allowUseInside||[];Di(a,s)&&e.report({node:a,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:l=>{let p=i.hookAlternative;return a.callee.type===M.Identifier?l.replaceText(a.callee,p):a.callee.type===M.MemberExpression&&a.callee.property.type===M.Identifier?l.replaceText(a.callee.property,p):null}}]:[]})}}}});import{AST_NODE_TYPES as K,AST_TOKEN_TYPES as vn,ESLintUtils as Li}from"@typescript-eslint/utils";var _i=Li.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),On="prefer-single-line-if",$i=z({maxLineLength:_(ge()),maxNonSimpleConditionLength:_(ge())}),Ui=_i({name:On,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:[$i]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==K.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let o=n.consequent.body[0];if(o.type===K.ReturnStatement){if(!Fn(o))return}else if(!(o.type===K.ContinueStatement||o.type===K.BreakStatement))return;if(n.test.type===K.LogicalExpression||n.test.type===K.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let f=kn(n.test);if(!f&&n.test.type===K.UnaryExpression&&n.test.operator==="!"){let y=n.test.argument;kn(y)&&(f=!0)}if(f&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let s=r.getText(o);if(i.includes(`
|
|
16
|
+
`))return;let l=r.getTokenAfter(n);if(l&&l.type===vn.Punctuator&&l.value==="}"){let f=r.getTokenAfter(l);if(f&&f.type===vn.Keyword&&(f.value==="else"||f.value==="catch"))return}let p=Wi(r,n),c=`if (${i}) ${s}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:f=>f.replaceText(n,c)})}}}});function kn(e){return e.type===K.CallExpression||e.type===K.BinaryExpression||e.type===K.MemberExpression&&Pn(e)}function Pn(e){return e.object.type===K.MemberExpression?Pn(e.object):e.object.type!==K.Identifier}function Wi(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Fn(e){if(!e.argument)return!0;let t=e.argument;return t.type===K.ArrayExpression&&t.elements.length===0||t.type===K.ObjectExpression&&t.properties.length===0||t.type===K.Literal||t.type===K.Identifier||t.type===K.TemplateLiteral||t.type===K.TaggedTemplateExpression?!0:t.type===K.CallExpression?t.arguments.length===0:t.type===K.UnaryExpression?Fn(t):!1}var kt={name:On,rule:Ui};import{AST_NODE_TYPES as ce,ESLintUtils as Vi}from"@typescript-eslint/utils";var zi=Vi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nn="react-compiler-migration",Hi=z({disallowHooks:_(Q(z({name:V(),replacement:V()}))),disallowMethods:_(Q(z({name:V(),replacement:_(V()),requireTrueProp:_(V())})))}),Yi=/eslint +react-compiler\/react-compiler: +\["error/;function qi(e){return e.type===ce.Identifier?e.name.startsWith("use"):e.type===ce.MemberExpression&&e.property.type===ce.Identifier?e.property.name.startsWith("use"):!1}var Ji=zi({name:Nn,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:[Hi]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Yi.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let a=null,o=null;if(n.callee.type===ce.Identifier?(a=n.callee.name,o=n.callee):n.callee.type===ce.MemberExpression&&n.callee.property.type===ce.Identifier&&(a=n.callee.property.name,o=n.callee.property),a){let i=t.disallowHooks.find(s=>s.name===a);i&&o&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(o,i.replacement)}]})}}if(t.disallowMethods?.length&&qi(n.callee)){for(let a of n.arguments)if(a.type===ce.ObjectExpression){for(let o of a.properties)if(o.type===ce.Property&&o.key.type===ce.Identifier){let i=o.key.name,s=t.disallowMethods.find(l=>l.name===i);if(s){if(s.requireTrueProp){let l=s.requireTrueProp,p=!1;for(let c of a.properties)if(c.type===ce.Property&&c.key.type===ce.Identifier&&c.key.name===l&&c.value.type===ce.Literal&&c.value.value===!0){p=!0;break}if(!p){e.report({node:o,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:l}});continue}}s.replacement&&e.report({node:o,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:l=>l.replaceText(o.key,s.replacement)}]})}}}}}}:{}}}),Ot={name:Nn,rule:Ji};import{ESLintUtils as Bi,TSESTree as Xi}from"@typescript-eslint/utils";var Gi=Bi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jn="require-description",Ki=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Zi=/^eslint-disable-(next-)?line$/u,Qi=Gi({name:jn,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 a of r.getAllComments()){let o=es(a);o!=null&&(n.has(o.kind)||o.description||e.report({loc:ns(a.loc),messageId:"missingDescription"}))}}}}}),Mn={name:jn,rule:Qi};function es(e){let{text:t,description:r}=ts(e.value);if(!t)return null;let n=Ki.exec(t);if(!n)return null;let a=n[1];if(!a)return null;let o=Zi.test(a);if(e.type===Xi.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+a.length);return{kind:a,value:i.trim(),description:r}}function ts(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ns(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 Ee}from"zod/v4";var rs=Ee.object({varsToCheck:Ee.array(Ee.object({selector:Ee.string().optional(),fromFnCall:Ee.string().optional(),prop:Ee.string().or(Ee.array(Ee.string())),errorMsg:Ee.string().optional()}))}),Pt=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:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[Ie(rs)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map,n=(i,s,l,p)=>{let c=new Set;for(let y of i.properties)y.type===L.Property&&y.key.type===L.Identifier&&c.add(y.key.name);let f=s.filter(y=>!c.has(y));if(f.length>0)if(f.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:f[0],fnName:p,customMsg:l||""}});else{let y=f.map(T=>`"${T}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:p,customMsg:l||""}})}},a=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"},o={};for(let i of t.varsToCheck)i.selector&&(o[i.selector]=s=>{if(s.type===L.VariableDeclarator&&s.id.type===L.Identifier&&r.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:a(s)}),s.type===L.VariableDeclarator&&s.id.type===L.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(s.id,l,i.errorMsg,a(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)}"]`;o[p]=c=>{if(c.type!==L.MemberExpression||c.parent.type!==L.CallExpression)return;let f=c.parent;if(f.parent.type!==L.VariableDeclarator)return;let y=f.parent;if(y.id.type===L.Identifier)r.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 T=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,T,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[l,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;o[c]=f=>{if(f.type!==L.MemberExpression||f.parent.type!==L.CallExpression)return;let y=f.parent;if(y.parent.type!==L.VariableDeclarator)return;let T=y.parent;if(T.id.type===L.Identifier)r.set(T.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:T.id,fnName:i.fromFnCall||"unknown function"});else if(T.id.type===L.ObjectPattern){let I=Array.isArray(i.prop)?i.prop:[i.prop];n(T.id,I,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;o[l]=p=>{if(p.type!==L.Identifier||p.parent.type!==L.CallExpression)return;let c=p.parent;if(c.parent.type!==L.VariableDeclarator)return;let f=c.parent;if(f.id.type===L.Identifier)r.set(f.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:f.id,fnName:i.fromFnCall||"unknown function"});else if(f.id.type===L.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];n(f.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:s,errorMsg:l,node:p,fnName:c}]of r){let y=e.sourceCode.getScope(p).set.get(i);if(y){let T=new Set(s);for(let I of y.references){let x=I.identifier,E=x.parent;if(!(E.type===L.VariableDeclarator&&E.id===x)){if(E.type===L.MemberExpression&&E.object===x&&E.property.type===L.Identifier&&T.has(E.property.name)){if(T.delete(E.property.name),T.size===0)break;continue}if(E.type===L.VariableDeclarator&&E.init===x&&E.id.type===L.ObjectPattern){for(let u of E.id.properties)u.type===L.Property&&u.key.type===L.Identifier&&T.has(u.key.name)&&T.delete(u.key.name);if(T.size===0)break;continue}if(!(E.type===L.MemberExpression&&E.object===x&&E.property.type===L.Identifier&&!s.includes(E.property.name))){T.clear();break}}}if(T.size>0){let I=Array.from(T);if(I.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:I[0],fnName:c,customMsg:l||""}});else{let x=I.map(E=>`"${E}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:x,fnName:c,customMsg:l||""}})}}}}}}}});function _n(e){return/^use[A-Z0-9]/.test(e)}function Ye(e){return e.type==="Identifier"?_n(e.name):e.type==="MemberExpression"&&!e.computed&&Ye(e.property)?e.object.type==="Identifier":!1}function $n(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Un(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Wn(e){return!!(e.parent&&e.parent.callee&&Un(e.parent.callee,"forwardRef"))}function Vn(e){return!!(e.parent&&e.parent.callee&&Un(e.parent.callee,"memo"))}function Ft(e){for(;e;){let t=Hn(e);if(t&&($n(t)||Ye(t))||Wn(e)||Vn(e))return!0;e=e.parent}return!1}function Dn(e){return!1}function Nt(e){return!1}var is=/eslint +react-compiler\/react-compiler: +\["error/,zn={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(is.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,a=[],o=[],i=new WeakSet;function s(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&&Dn(c.init.callee))for(let f of p.resolved.references)f!==p&&i.add(f.identifier)}}return{onCodePathSegmentStart:l=>o.push(l),onCodePathSegmentEnd:()=>o.pop(),onCodePathStart:()=>a.push(new Map),onCodePathEnd(l,p){let c=a.pop();if(c.size===0)return;let f=new Set;function y(g,m){let{cache:S}=y,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=[...R],N=C.slice(C.indexOf(g.id)+1);for(let W of N)f.add(W);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.prevSegments)k+=y(C,R)}return g.reachable&&k===BigInt("0")?S.delete(g.id):S.set(g.id,k),k}function T(g,m){let{cache:S}=T,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=Array.from(R),N=C.slice(C.indexOf(g.id)+1);for(let W of N)f.add(W);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.nextSegments)k+=T(C,R)}return S.set(g.id,k),k}function I(g){let{cache:m}=I,S=m.get(g.id);if(S===null)return 1/0;if(S!==void 0)return S;if(m.set(g.id,null),g.prevSegments.length===0)S=1;else{S=1/0;for(let k of g.prevSegments){let R=I(k);R<S&&(S=R)}S+=1}return m.set(g.id,S),S}y.cache=new Map,T.cache=new Map,I.cache=new Map;let x=T(l.initialSegment),E=Hn(p),u=Ft(p),A=E?$n(E)||Ye(E):Wn(p)||Vn(p),b=1/0;for(let g of l.finalSegments){if(!g.reachable)continue;let m=I(g);m<b&&(b=m)}for(let[g,m]of c){if(!g.reachable)continue;let S=g.nextSegments.length===0?b<=I(g):b<I(g),k=y(g)*T(g),R=f.has(g.id);for(let C of m)if(R&&!Nt(C)&&e.report({node:C,message:`React Hook "${t(C)}" 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.`}),A){if(p.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!R&&k!==x&&!Nt(C)){let W=`React Hook "${t(C)}" 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:C,message:W})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let N=`React Hook "${t(C)}" 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:C,message:N})}else if(E){let N=`React Hook "${t(C)}" is called in function "${t(E)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:C,message:N})}else if(p.type==="Program"){let N=`React Hook "${t(C)}" 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:C,message:N})}else if(u&&!Nt(C)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let W=p.parent;if(W.parent.type==="VariableDeclarator"&&_n(W.parent.id.name))return}let N=`React Hook "${t(C)}" 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:C,message:N})}}},CallExpression(l){if(Ye(l.callee)){let p=Ln(a),c=Ln(o),f=p.get(c);f||(f=[],p.set(c,f)),f.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Dn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.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){Ft(l)&&s(r(l))},ArrowFunctionExpression(l){Ft(l)&&s(r(l))}}}};function Hn(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 Ln(e){return e[e.length-1]}import{AST_NODE_TYPES as ne,AST_TOKEN_TYPES as ss}from"@typescript-eslint/utils";import*as oe from"zod/v4";var os=oe.object({indent:oe.union([oe.string().regex(/^\s+$/),oe.number().int().min(1)]).optional(),tags:oe.array(oe.string()).optional(),functions:oe.array(oe.string()).optional(),comments:oe.array(oe.string()).optional()}),jt=G({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[Ie(os)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:a=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(u=>u.toLowerCase());function s(u){let A=u.split(/\r?\n/),b=A.filter(m=>m.trim()!=="");if(b.length===0)return u;let g=Number.POSITIVE_INFINITY;for(let m of b){let S=m.match(/^(\s*)/);S&&(g=Math.min(g,S[1]?.length??0))}return!isFinite(g)||g===0?u:A.map(m=>m.slice(g)).join(`
|
|
17
|
+
`)}function l(u,A,b){return u.split(/\r?\n/).map(m=>m.trim()===""?m:b.repeat(A)+m).join(`
|
|
18
|
+
`)}function p(u){if(u.type===ne.Identifier)return u.name;if(u.type===ne.MemberExpression){let A=u.object.type===ne.Identifier?u.object.name:null,b=u.property.type===ne.Identifier?u.property.name:null;return A&&b?`${A}.${b}`:b}return null}function c(u,A){if(!u)return!1;for(let b of A)if(b.includes(".")){let g=b.split(".");if(u.type===ne.MemberExpression&&u.object.type===ne.Identifier&&u.property.type===ne.Identifier&&u.object.name===g[0]&&u.property.name===g[1])return!0}else if(u.type===ne.Identifier&&u.name===b)return!0;return!1}function f(u,A){let b=u.parent;if(b.type!==ne.TaggedTemplateExpression)return!1;let g=p(b.tag);return g?A.includes(g):!1}function y(u,A){if(!u||u.type!==ne.CallExpression)return!1;let{method:b,argumentsLength:g,optionalCall:m=!0,optionalMember:S=!0}=A;return g!==void 0&&u.arguments.length!==g||!m&&u.optional||u.callee.type!==ne.MemberExpression||!S&&u.callee.optional||u.callee.property.type!==ne.Identifier?!1:u.callee.property.name===b}function T(u,A){if(!u||u.type!==ne.CallExpression)return!1;let{name:b,argumentsLength:g,optionalCall:m=!0}=A;return g!==void 0&&u.arguments.length!==g||!m&&u.optional||u.callee.type!==ne.Identifier?!1:u.callee.name===b}function I(u){return y(u.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&u.parent.type===ne.CallExpression&&u.parent.arguments[0]===u&&T(u.parent.callee.type===ne.MemberExpression?u.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function x(u){if(i.length>0){let A=t.getTokenBefore(u,{includeComments:!0});if(A?.type===ss.Block&&i.includes(A.value.trim().toLowerCase()))return!0}return!!(I(u)||a.length>0&&f(u,a)||n.length>0&&u.parent.type===ne.CallExpression&&u.parent.arguments.includes(u)&&c(u.parent.callee,n))}function E(u){let A=`__PLACEHOLDER__${Math.random()}`,b=u.quasis.map(B=>t.getText(B).slice(1,B.tail?-1:-2)).join(A),g=b.match(/\r?\n/);if(!g)return;let m=g[0],S=t.lines[t.getLocFromIndex(u.range[0]).line-1];if(!S)return;let R=S.match(/^(\s*)\S/)?.[1]??"",C;typeof o=="string"?C=o:typeof o=="number"?C=" ".repeat(o):C=R.startsWith(" ")?" ":" ";let W=s(b).replace(new RegExp(`^${m}|${m}[ ]*$`,"g"),""),J=m+l(W,1,R+C)+m+R,te=b.includes(`\r
|
|
19
|
+
`)?`\r
|
|
20
|
+
`:`
|
|
21
|
+
`,Z=b.split(/\r?\n/),be=Z.map((B,ye)=>ye!==Z.length-1&&B===C?"":B).join(te);if(J!==be)return{node:u,messageId:"improperlyIndented",fix:B=>J.split(A).map((ye,ue)=>{let ie=u.quasis[ue];return ie?B.replaceTextRange([ie.range[0]+1,ie.range[1]-(ie.tail?1:2)],ye):[]}).flat()}}return{TemplateLiteral(u){if(!x(u))return;let A=E(u);if(A)return e.report(A)}}}});import{AST_NODE_TYPES as Yn}from"@typescript-eslint/utils";function as(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function ls(e){let t=e.parent;return t?.type===Yn.NewExpression&&t.callee.type===Yn.Identifier&&t.callee.name==="RegExp"}var Mt=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){as(r)||ls(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});var qn={[It.name]:It.rule,[st.name]:st.rule,[it.name]:it.rule,"rules-of-hooks":zn,"exhaustive-deps":Xt,"require-description":Mn.rule,[ot.name]:ot.rule,[lt.name]:lt.rule,[At.name]:At.rule,[Ge.name]:Ge.rule,[rt.name]:rt.rule,[mt.name]:mt.rule,[kt.name]:kt.rule,[ut.name]:ut.rule,[at.name]:at.rule,[Ze.name]:Ze.rule,[Ot.name]:Ot.rule,[Xe.name]:Xe.rule,[nt.name]:nt.rule,[St.name]:St.rule,[Tt.name]:Tt.rule,[Et.name]:Et.rule,[bt.name]:bt.rule,[ht.name]:ht.rule,[vt.name]:vt.rule,[yt.name]:yt.rule,[dt.name]:dt.rule,[Mt.name]:Mt.rule,[Ct.name]:Ct.rule,[Pt.name]:Pt.rule,[jt.name]:jt.rule};var Ga={rules:qn};export{Ga as extendedLintPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ls-stack/extended-lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@ls-stack/eslint-cfg": "^0.1.3",
|
|
23
|
-
"@ls-stack/utils": "^
|
|
23
|
+
"@ls-stack/utils": "^3.25.0",
|
|
24
24
|
"@types/eslint": "^9.6.1",
|
|
25
|
-
"@types/node": "^
|
|
26
|
-
"@typescript-eslint/parser": "^8.
|
|
27
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
28
|
-
"@vitest/ui": "^3.
|
|
29
|
-
"eslint": "^9.
|
|
25
|
+
"@types/node": "^24.2.1",
|
|
26
|
+
"@typescript-eslint/parser": "^8.39.0",
|
|
27
|
+
"@typescript-eslint/rule-tester": "^8.39.0",
|
|
28
|
+
"@vitest/ui": "^3.2.4",
|
|
29
|
+
"eslint": "^9.33.0",
|
|
30
30
|
"tschema": "^3.2.0",
|
|
31
31
|
"tsm": "^2.3.0",
|
|
32
|
-
"tsup": "^8.
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"vite": "^
|
|
35
|
-
"vitest": "^3.
|
|
32
|
+
"tsup": "^8.5.0",
|
|
33
|
+
"typescript": "^5.9.2",
|
|
34
|
+
"vite": "^7.1.1",
|
|
35
|
+
"vitest": "^3.2.4"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@typescript-eslint/utils": "^8.22.0",
|