@ls-stack/extended-lint 0.47.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extended-lint.js +6 -6
- package/dist/extended-lint.mjs +6 -6
- package/package.json +1 -1
package/dist/extended-lint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var Wn=Object.create;var ve=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Yn=Object.getOwnPropertyNames;var zn=Object.getPrototypeOf,Bn=Object.prototype.hasOwnProperty;var Jn=(e,t)=>{for(var r in t)ve(e,r,{get:t[r],enumerable:!0})},Ft=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Yn(t))!Bn.call(e,o)&&o!==r&&ve(e,o,{get:()=>t[o],enumerable:!(n=Hn(t,o))||n.enumerable});return e};var Oe=(e,t,r)=>(r=e!=null?Wn(zn(e)):{},Ft(t||!e||!e.__esModule?ve(r,"default",{value:e,enumerable:!0}):r,e)),Xn=e=>Ft(ve({},"__esModule",{value:!0}),e);var Ni={};Jn(Ni,{extendedLintPlugin:()=>Fi});module.exports=Xn(Ni);var J=require("@typescript-eslint/utils");var Be=Symbol.for("optional");function P(e){return{...e,[Be]:!0}}function Pe(e,t){return{enum:e,...t}}function le(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function Z(e){return{...e,type:"number"}}function Je(e){return{...e,type:"integer"}}function Y(e,t){return{...t,type:"array",items:e}}function j(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][Be]?e[n][Be]=void 0:o.push(n);o.length>0&&(r.required=o)}return r}function Fe(...e){return{anyOf:e}}var qn=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dt="react-compiler-extra",Kn=j({runOnlyWithEnableCompilerDirective:P(le())}),Gn=/eslint +react-compiler\/react-compiler: +\["error/;function Zn(e){return e.type===J.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===J.AST_NODE_TYPES.MemberExpression&&e.property.type===J.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Qn=/\bthis[.[]/;function Nt(e){return Qn.test(e)}var er=qn({name:Dt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[Kn]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(Gn.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let s of a.properties)if(s.type===J.AST_NODE_TYPES.Property&&s.method&&s.value.type===J.AST_NODE_TYPES.FunctionExpression){let i=e.sourceCode,l=i.getText(s.key),c=s.value,p=i.getText(c.body);if(Nt(p))e.report({node:s,messageId:"thisKeywordInMethod"});else{let u=c.params.map(S=>i.getText(S)).join(", "),g="";c.generator?g=`${l}: function* (${u}) ${p}`:g=`${l}: (${u}) => ${p}`,e.report({node:s,messageId:"objectMethodIsNotSupported",fix:S=>S.replaceText(s,g)})}}}function o(a){for(let s of a.properties)if(s.type===J.AST_NODE_TYPES.Property&&s.value.type===J.AST_NODE_TYPES.ObjectExpression){for(let i of s.value.properties)if(i.type===J.AST_NODE_TYPES.Property&&i.method&&i.value.type===J.AST_NODE_TYPES.FunctionExpression){let c=e.sourceCode.getText(i.value.body);Nt(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Zn(a.callee))for(let s of a.arguments){if(s.type===J.AST_NODE_TYPES.ObjectExpression&&(n(s),o(s)),s.type===J.AST_NODE_TYPES.ArrowFunctionExpression&&(s.body.type===J.AST_NODE_TYPES.ObjectExpression&&(n(s.body),o(s.body)),s.body.type===J.AST_NODE_TYPES.BlockStatement))for(let i of s.body.body)i.type===J.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===J.AST_NODE_TYPES.ObjectExpression&&(n(i.argument),o(i.argument));if(s.type===J.AST_NODE_TYPES.FunctionExpression)for(let i of s.body.body)i.type===J.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===J.AST_NODE_TYPES.ObjectExpression&&(n(i.argument),o(i.argument))}}}}}),Xe={name:Dt,rule:er};var Q=require("@typescript-eslint/utils");var jt=require("@typescript-eslint/utils");function ne(e){let r=jt.ESLintUtils.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}var tr=j({disallow:P(Y(j({selector:F(),message:F(),replace:P(Fe(F(),j({regex:F(),with:F()}))),replaceType:P(Pe(["suggestion","autofix"]))}))),disallowFnCalls:P(Y(j({fn:F(),withArgs:P(Y(j({atIndex:Je(),value:Fe(F(),Z(),le())}))),message:F(),replaceWith:P(F()),ignoreRegex:P(F())}))),__dev_simulateFileName:P(F()),mustMatchSyntax:P(Y(j({includeRegex:F(),mustCallFn:P(Y(j({anyCall:Y(j({fn:F(),withArgs:Y(j({atIndex:Je(),literal:Fe(F(),Z(),le())}))})),message:P(F())}))),mustMatchSelector:P(Y(j({selector:F(),message:F()})))})))}),qe=ne({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[tr],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:o,disallow:a,disallowFnCalls:s}=t,i=o??e.filename,l=[],c=new Map,p=new Set,u=new Map,g=new Map;function S(d){for(let m of d.specifiers)m.type===Q.AST_NODE_TYPES.ImportSpecifier&&m.imported.type===Q.AST_NODE_TYPES.Identifier&&m.local.type===Q.AST_NODE_TYPES.Identifier&&m.imported.name!==m.local.name&&g.set(m.local.name,m.imported.name)}function h(d){d.id.type===Q.AST_NODE_TYPES.Identifier&&d.init?.type===Q.AST_NODE_TYPES.Identifier&&g.set(d.id.name,d.init.name)}function T(d){return g.get(d)??d}function I(d,m){return T(d)===m||d===m}for(let{includeRegex:d,mustCallFn:m,mustMatchSelector:A}of n??[]){let R=nr(i,new RegExp(d));if(!R)continue;let v=O=>{let x=O;for(let{name:U,value:B}of R)x=x.replaceAll(U,B);return x};for(let{anyCall:O,message:x}of m??[]){let U=`Expected file to call the function: ${O.map(({fn:B})=>B).join(" or ")}`;p.add(U),l.push(B=>{let{callee:oe}=B;if(oe.type===Q.AST_NODE_TYPES.Identifier){for(let{fn:We,withArgs:Ie}of O)if(oe.name===We){p.delete(U);for(let fe of Ie){let X=B.arguments[fe.atIndex],ie=typeof fe.literal=="string"?v(fe.literal):fe.literal;if(!X){e.report({node:B,messageId:"default",data:{message:`Missing argument with value "${ie}" at index ${fe.atIndex}${x?`: ${v(x)}`:""}`}});continue}if(X.type!==Q.AST_NODE_TYPES.Literal){e.report({node:X,messageId:"default",data:{message:`Argument at position ${fe.atIndex} should the literal "${ie}"${x?`: ${v(x)}`:""}`}});continue}X.value!==ie&&e.report({node:X,messageId:"default",data:{message:`Argument should have the value "${ie}"${x?`: ${v(x)}`:""}`},fix:Ce=>Ce.replaceText(X,typeof ie=="string"?`'${ie}'`:String(ie))})}break}}})}for(let{selector:O,message:x}of A??[])u.set(O,v(x)),c.set(v(O),()=>{u.delete(O)})}for(let{fn:d,withArgs:m,message:A,replaceWith:R,ignoreRegex:v}of s??[])v&&new RegExp(v).test(i)||l.push(O=>{let{callee:x}=O;if(x.type!==Q.AST_NODE_TYPES.Identifier||!I(x.name,d))return;if(m)for(let B of m){let oe=O.arguments[B.atIndex];if(!oe){e.report({node:O,messageId:"default",data:{message:`Missing argument with value "${B.value}" at index ${B.atIndex}: ${A}`}});return}if(oe.type!==Q.AST_NODE_TYPES.Literal||oe.value!==B.value)return}let U=B=>R?B.replaceText(O,R):null;e.report({node:O,messageId:"default",data:{message:A},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:U}]:void 0})});function E(d,m){let A=r[d];A?r[d]=R=>{A(R),m(R)}:r[d]=m}for(let{selector:d,message:m,replace:A,replaceType:R="suggestion"}of a??[]){if(d==="CallExpression"){l.push(v=>{M(A,v,m,R)});continue}r[d]=v=>{M(A,v,m,R)}}if(c.size>0)for(let[d,m]of c)E(d,m);return l.length>0&&(r.CallExpression=d=>{if(d.type===Q.AST_NODE_TYPES.CallExpression)for(let m of l)m(d)}),r.ImportDeclaration=d=>{d.type===Q.AST_NODE_TYPES.ImportDeclaration&&S(d)},r.VariableDeclarator=d=>{d.type===Q.AST_NODE_TYPES.VariableDeclarator&&h(d)},r["Program:exit"]=d=>{for(let m of p)e.report({node:d,messageId:"default",data:{message:m}});for(let[,m]of u)e.report({node:d,messageId:"default",data:{message:m}})},r;function M(d,m,A,R){let v=O=>{if(!d)return null;if(typeof d=="string")return O.replaceText(m,d);{let x=new RegExp(d.regex),U=e.sourceCode.getText(m);return O.replaceText(m,U.replace(x,d.with))}};e.report({node:m,messageId:"default",data:{message:A},fix:d&&R==="autofix"?v:void 0,suggest:d&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof d=="string"?d:d.with}"`},fix:v}]:void 0})}}});function nr(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:Lt(o)}),r.push({name:"$0_uncapitalize",value:Mt(o)}),r.push({name:"$0",value:o});for(let s=0;s<a.length;s++){let i=`$${s+1}`,l=a[s];r.push({name:`${i}_lowercase`,value:l.toLowerCase()}),r.push({name:`${i}_capitalize`,value:Lt(l)}),r.push({name:`${i}_uncapitalize`,value:Mt(l)}),r.push({name:i,value:l})}return r}function Lt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Mt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var _=require("@typescript-eslint/utils");var rr=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="collapse-simple-objs-in-one-line",ir=j({maxLineLength:P(Z()),maxProperties:P(Z()),nestedObjMaxLineLength:P(Z()),nestedObjMaxProperties:P(Z()),ignoreTypesWithSuffix:P(Y(F()))}),sr=rr({name:$t,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:[ir]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,s=t.nestedObjMaxProperties??3;function i(c){if(c.type===_.AST_NODE_TYPES.ObjectExpression){let p=c.parent.type===_.AST_NODE_TYPES.Property,u=p?s:o,g=c.properties.length;if(g>u)return!1;if(g===1){let h=c.properties[0];return h.type===_.AST_NODE_TYPES.Property&&h.value.type===_.AST_NODE_TYPES.ObjectExpression||h.type===_.AST_NODE_TYPES.Property&&h.value.type===_.AST_NODE_TYPES.ArrayExpression&&!h.value.elements.every(I=>I&&Ke(I))?!1:{text:r.getText(h),isNested:p,propsSize:g}}let S=[];for(let h of c.properties){if(h.type===_.AST_NODE_TYPES.Property&&!Ke(h.value))return!1;S.push(r.getText(h))}return{text:S.join(", "),isNested:p,propsSize:g}}else{let p=c.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,u=p?s:o,g=c.members.length;if(g>u)return!1;if(n.length>0&&c.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let h=c.parent.id.name;if(n.some(T=>h.endsWith(T)))return!1}if(g===1){let h=c.members[0];return h.type===_.AST_NODE_TYPES.TSPropertySignature&&h.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:r.getText(h),isNested:p,propsSize:1}}if(c.parent.type===_.AST_NODE_TYPES.TSIntersectionType||c.parent.type===_.AST_NODE_TYPES.TSUnionType&&c.parent.types[0]!==c)return!1;let S=[];for(let h of c.members){if(h.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let T=h.typeAnnotation?.typeAnnotation;if(!T||T.type===_.AST_NODE_TYPES.TSTypeLiteral||!_t(T))return!1;if(T.type===_.AST_NODE_TYPES.TSTypeReference&&T.typeArguments){if(T.typeArguments.params.length>1)return!1;let E=T.typeArguments.params[0];if(!_t(E))return!1}let I=r.getText(h).trim();(I.endsWith(";")||I.endsWith(","))&&(I=I.slice(0,-1)),S.push(I)}return{text:S.join("; "),isNested:p,propsSize:g}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer){let T=0,I=!1,E=r.getTokenAfter(c,{filter:d=>d.type!==_.AST_TOKEN_TYPES.Punctuator||I?!0:d.value===","?(T++,!1):d.value===";"?(T++,I=!0,!1):d.value===")"||d.value==="}"?(T++,!1):!0});if(T>4)return;let M=E?.type===_.AST_TOKEN_TYPES.Template&&E.value.startsWith(`}
|
|
2
|
-
`);if(
|
|
3
|
-
`)||r.getCommentsInside(c).length>0)return;u.endsWith(";")&&(u=u.slice(0,-1));let
|
|
4
|
-
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function
|
|
1
|
+
"use strict";var Un=Object.create;var De=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var Hn=Object.getPrototypeOf,Yn=Object.prototype.hasOwnProperty;var Bn=(e,t)=>{for(var r in t)De(e,r,{get:t[r],enumerable:!0})},Pt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Wn(t))!Yn.call(e,o)&&o!==r&&De(e,o,{get:()=>t[o],enumerable:!(n=Vn(t,o))||n.enumerable});return e};var Oe=(e,t,r)=>(r=e!=null?Un(Hn(e)):{},Pt(t||!e||!e.__esModule?De(r,"default",{value:e,enumerable:!0}):r,e)),Jn=e=>Pt(De({},"__esModule",{value:!0}),e);var Fi={};Bn(Fi,{extendedLintPlugin:()=>Pi});module.exports=Jn(Fi);var X=require("@typescript-eslint/utils");var Be=Symbol.for("optional");function _(e){return{...e,[Be]:!0}}function Ft(e,t){return{enum:e,...t}}function we(e){return{...e,type:"boolean"}}function V(e){return{...e,type:"string"}}function ce(e){return{...e,type:"number"}}function q(e,t){return{...t,type:"array",items:e}}function W(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let n,o=[];for(n in e)e[n][Be]?e[n][Be]=void 0:o.push(n);o.length>0&&(r.required=o)}return r}var Xn=X.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dt="react-compiler-extra",qn=W({runOnlyWithEnableCompilerDirective:_(we())}),Kn=/eslint +react-compiler\/react-compiler: +\["error/;function Gn(e){return e.type===X.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===X.AST_NODE_TYPES.MemberExpression&&e.property.type===X.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Zn=/\bthis[.[]/;function Nt(e){return Zn.test(e)}var Qn=Xn({name:Dt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[qn]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(Kn.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let s of a.properties)if(s.type===X.AST_NODE_TYPES.Property&&s.method&&s.value.type===X.AST_NODE_TYPES.FunctionExpression){let i=e.sourceCode,l=i.getText(s.key),c=s.value,p=i.getText(c.body);if(Nt(p))e.report({node:s,messageId:"thisKeywordInMethod"});else{let u=c.params.map(h=>i.getText(h)).join(", "),S="";c.generator?S=`${l}: function* (${u}) ${p}`:S=`${l}: (${u}) => ${p}`,e.report({node:s,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(s,S)})}}}function o(a){for(let s of a.properties)if(s.type===X.AST_NODE_TYPES.Property&&s.value.type===X.AST_NODE_TYPES.ObjectExpression){for(let i of s.value.properties)if(i.type===X.AST_NODE_TYPES.Property&&i.method&&i.value.type===X.AST_NODE_TYPES.FunctionExpression){let c=e.sourceCode.getText(i.value.body);Nt(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Gn(a.callee))for(let s of a.arguments){if(s.type===X.AST_NODE_TYPES.ObjectExpression&&(n(s),o(s)),s.type===X.AST_NODE_TYPES.ArrowFunctionExpression&&(s.body.type===X.AST_NODE_TYPES.ObjectExpression&&(n(s.body),o(s.body)),s.body.type===X.AST_NODE_TYPES.BlockStatement))for(let i of s.body.body)i.type===X.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===X.AST_NODE_TYPES.ObjectExpression&&(n(i.argument),o(i.argument));if(s.type===X.AST_NODE_TYPES.FunctionExpression)for(let i of s.body.body)i.type===X.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===X.AST_NODE_TYPES.ObjectExpression&&(n(i.argument),o(i.argument))}}}}}),Je={name:Dt,rule:Qn};var K=require("@typescript-eslint/utils"),g=Oe(require("zod/v4"));var jt=require("@typescript-eslint/utils");function ie(e){let r=jt.ESLintUtils.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}var er=g.object({disallow:g.array(g.object({selector:g.string(),message:g.string(),replace:g.optional(g.union([g.string(),g.object({regex:g.string(),with:g.string()})])),replaceType:g.optional(g.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:g.optional(g.array(g.object({fn:g.string(),withArgs:g.optional(g.array(g.object({atIndex:g.number(),value:g.union([g.string(),g.number(),g.boolean()])}))),message:g.string(),replaceWith:g.optional(g.string()),ignoreRegex:g.optional(g.string())}))),__dev_simulateFileName:g.optional(g.string()),mustMatchSyntax:g.optional(g.array(g.object({includeRegex:g.string(),mustCallFn:g.optional(g.array(g.object({anyCall:g.array(g.object({fn:g.string(),withArgs:g.array(g.object({atIndex:g.number(),literal:g.union([g.string(),g.number(),g.boolean()])}))})),message:g.optional(g.string())}))),mustMatchSelector:g.optional(g.array(g.object({selector:g.string(),message:g.string()}))),mustHaveExport:g.optional(g.array(g.object({name:g.string(),type:g.enum(["function","variable","any"]).default("any"),message:g.string()})))})))}),Xe=ie({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[g.toJSONSchema(er)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:o,disallow:a,disallowFnCalls:s}=t,i=o??e.filename,l=[],c=new Map,p=new Set,u=new Map,S=new Set,h=new Map;function x(m){for(let y of m.specifiers)y.type===K.AST_NODE_TYPES.ImportSpecifier&&y.imported.type===K.AST_NODE_TYPES.Identifier&&y.imported.name!==y.local.name&&h.set(y.local.name,y.imported.name)}function b(m){if(m.declaration){if(m.declaration.type===K.AST_NODE_TYPES.FunctionDeclaration&&m.declaration.id){let y=m.declaration.id.name;for(let R of Array.from(S)){let[C,E]=R.split(":");C===y&&(E==="function"||E==="any")&&S.delete(R)}}else if(m.declaration.type===K.AST_NODE_TYPES.VariableDeclaration){for(let y of m.declaration.declarations)if(y.id.type===K.AST_NODE_TYPES.Identifier){let R=y.id.name;for(let C of Array.from(S)){let[E,F]=C.split(":");E===R&&(F==="variable"||F==="any")&&S.delete(C)}}}}for(let y of m.specifiers)if(y.exported.type===K.AST_NODE_TYPES.Identifier){let R=y.exported.name;for(let C of Array.from(S)){let[E,F]=C.split(":");E===R&&F==="any"&&S.delete(C)}}}function k(m){m.id.type===K.AST_NODE_TYPES.Identifier&&m.init?.type===K.AST_NODE_TYPES.Identifier&&h.set(m.id.name,m.init.name)}function w(m){return h.get(m)??m}function L(m,y){return w(m)===y||m===y}for(let{includeRegex:m,mustCallFn:y,mustMatchSelector:R,mustHaveExport:C}of n??[]){let E=tr(i,new RegExp(m));if(!E)continue;let F=Y=>{let J=Y;for(let{name:Q,value:G}of E)J=J.replaceAll(Q,G);return J};for(let{anyCall:Y,message:J}of y??[]){let Q=`Expected file to call the function: ${Y.map(({fn:G})=>G).join(" or ")}`;p.add(Q),l.push(G=>{let{callee:be}=G;if(be.type===K.AST_NODE_TYPES.Identifier){for(let{fn:te,withArgs:Ae}of Y)if(be.name===te){p.delete(Q);for(let pe of Ae){let le=G.arguments[pe.atIndex],ue=typeof pe.literal=="string"?F(pe.literal):pe.literal;if(!le){e.report({node:G,messageId:"default",data:{message:`Missing argument with value "${ue}" at index ${pe.atIndex}${J?`: ${F(J)}`:""}`}});continue}if(le.type!==K.AST_NODE_TYPES.Literal){e.report({node:le,messageId:"default",data:{message:`Argument at position ${pe.atIndex} should the literal "${ue}"${J?`: ${F(J)}`:""}`}});continue}le.value!==ue&&e.report({node:le,messageId:"default",data:{message:`Argument should have the value "${ue}"${J?`: ${F(J)}`:""}`},fix:xe=>xe.replaceText(le,typeof ue=="string"?`'${ue}'`:String(ue))})}break}}})}for(let{selector:Y,message:J}of R??[])u.set(Y,F(J)),c.set(F(Y),()=>{u.delete(Y)});for(let{name:Y,type:J,message:Q}of C??[]){let G=F(Y),be=F(Q);S.add(`${G}:${J}:${be}`)}}for(let{fn:m,withArgs:y,message:R,replaceWith:C,ignoreRegex:E}of s??[])E&&new RegExp(E).test(i)||l.push(F=>{let{callee:Y}=F;if(Y.type!==K.AST_NODE_TYPES.Identifier||!L(Y.name,m))return;if(y)for(let Q of y){let G=F.arguments[Q.atIndex];if(!G){e.report({node:F,messageId:"default",data:{message:`Missing argument with value "${Q.value}" at index ${Q.atIndex}: ${R}`}});return}if(G.type!==K.AST_NODE_TYPES.Literal||G.value!==Q.value)return}let J=Q=>C?Q.replaceText(F,C):null;e.report({node:F,messageId:"default",data:{message:R},suggest:C?[{messageId:"default",data:{message:`Replace with "${C}"`},fix:J}]:void 0})});function P(m,y){let R=r[m];R?r[m]=C=>{R(C),y(C)}:r[m]=y}for(let{selector:m,message:y,replace:R,replaceType:C="suggestion"}of a??[]){if(m==="CallExpression"){l.push(E=>{T(R,E,y,C)});continue}r[m]=E=>{T(R,E,y,C)}}if(c.size>0)for(let[m,y]of c)P(m,y);return l.length>0&&(r.CallExpression=m=>{if(m.type===K.AST_NODE_TYPES.CallExpression)for(let y of l)y(m)}),r.ImportDeclaration=m=>{m.type===K.AST_NODE_TYPES.ImportDeclaration&&x(m)},r.ExportNamedDeclaration=m=>{m.type===K.AST_NODE_TYPES.ExportNamedDeclaration&&b(m)},r.VariableDeclarator=m=>{m.type===K.AST_NODE_TYPES.VariableDeclarator&&k(m)},r["Program:exit"]=m=>{for(let y of p)e.report({node:m,messageId:"default",data:{message:y}});for(let[,y]of u)e.report({node:m,messageId:"default",data:{message:y}});for(let y of S){let[R,C,E]=y.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${R}" of type ${C}: ${E}`}})}},r;function T(m,y,R,C){let E=F=>{if(!m)return null;if(typeof m=="string")return F.replaceText(y,m);{let Y=new RegExp(m.regex),J=e.sourceCode.getText(y);return F.replaceText(y,J.replace(Y,m.with))}};e.report({node:y,messageId:"default",data:{message:R},fix:m&&C==="autofix"?E:void 0,suggest:m&&C==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:E}]:void 0})}}});function tr(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:Lt(o)}),r.push({name:"$0_uncapitalize",value:Mt(o)}),r.push({name:"$0",value:o});for(let s=0;s<a.length;s++){let i=`$${s+1}`,l=a[s];r.push({name:`${i}_lowercase`,value:l.toLowerCase()}),r.push({name:`${i}_capitalize`,value:Lt(l)}),r.push({name:`${i}_uncapitalize`,value:Mt(l)}),r.push({name:i,value:l})}return r}function Lt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Mt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var M=require("@typescript-eslint/utils");var nr=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="collapse-simple-objs-in-one-line",rr=W({maxLineLength:_(ce()),maxProperties:_(ce()),nestedObjMaxLineLength:_(ce()),nestedObjMaxProperties:_(ce()),ignoreTypesWithSuffix:_(q(V()))}),ir=nr({name:$t,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:[rr]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,s=t.nestedObjMaxProperties??3;function i(c){if(c.type===M.AST_NODE_TYPES.ObjectExpression){let p=c.parent.type===M.AST_NODE_TYPES.Property,u=p?s:o,S=c.properties.length;if(S>u)return!1;if(S===1){let x=c.properties[0];return x.type===M.AST_NODE_TYPES.Property&&x.value.type===M.AST_NODE_TYPES.ObjectExpression||x.type===M.AST_NODE_TYPES.Property&&x.value.type===M.AST_NODE_TYPES.ArrayExpression&&!x.value.elements.every(k=>k&&qe(k))?!1:{text:r.getText(x),isNested:p,propsSize:S}}let h=[];for(let x of c.properties){if(x.type===M.AST_NODE_TYPES.Property&&!qe(x.value))return!1;h.push(r.getText(x))}return{text:h.join(", "),isNested:p,propsSize:S}}else{let p=c.parent.parent?.type===M.AST_NODE_TYPES.TSPropertySignature,u=p?s:o,S=c.members.length;if(S>u)return!1;if(n.length>0&&c.parent.type===M.AST_NODE_TYPES.TSTypeAliasDeclaration){let x=c.parent.id.name;if(n.some(b=>x.endsWith(b)))return!1}if(S===1){let x=c.members[0];return x.type===M.AST_NODE_TYPES.TSPropertySignature&&x.typeAnnotation?.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeLiteral?!1:{text:r.getText(x),isNested:p,propsSize:1}}if(c.parent.type===M.AST_NODE_TYPES.TSIntersectionType||c.parent.type===M.AST_NODE_TYPES.TSUnionType&&c.parent.types[0]!==c)return!1;let h=[];for(let x of c.members){if(x.type!==M.AST_NODE_TYPES.TSPropertySignature)return!1;let b=x.typeAnnotation?.typeAnnotation;if(!b||b.type===M.AST_NODE_TYPES.TSTypeLiteral||!_t(b))return!1;if(b.type===M.AST_NODE_TYPES.TSTypeReference&&b.typeArguments){if(b.typeArguments.params.length>1)return!1;let w=b.typeArguments.params[0];if(!_t(w))return!1}let k=r.getText(x).trim();(k.endsWith(";")||k.endsWith(","))&&(k=k.slice(0,-1)),h.push(k)}return{text:h.join("; "),isNested:p,propsSize:S}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==M.AST_NODE_TYPES.JSXExpressionContainer){let b=0,k=!1,w=r.getTokenAfter(c,{filter:P=>P.type!==M.AST_TOKEN_TYPES.Punctuator||k?!0:P.value===","?(b++,!1):P.value===";"?(b++,k=!0,!1):P.value===")"||P.value==="}"?(b++,!1):!0});if(b>4)return;let L=w?.type===M.AST_TOKEN_TYPES.Template&&w.value.startsWith(`}
|
|
2
|
+
`);if(w?.loc.start.line===c.loc.end.line&&!L)return}let p=i(c);if(!p)return;let u=p.text;if(u.includes(`
|
|
3
|
+
`)||r.getCommentsInside(c).length>0)return;u.endsWith(";")&&(u=u.slice(0,-1));let S=`{ ${u} }`,h=or(r,c),x=p.isNested&&p.propsSize>2?a:t.maxLineLength;x&&S.length+h.length+sr(c,r)>x||e.report({node:c,messageId:"singleLineProp",fix:b=>b.replaceText(c,S)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function _t(e){return e.type===M.AST_NODE_TYPES.TSLiteralType||e.type===M.AST_NODE_TYPES.TSTypeReference||e.type===M.AST_NODE_TYPES.TSNumberKeyword||e.type===M.AST_NODE_TYPES.TSStringKeyword||e.type===M.AST_NODE_TYPES.TSBooleanKeyword||e.type===M.AST_NODE_TYPES.TSNullKeyword||e.type===M.AST_NODE_TYPES.TSUndefinedKeyword}function qe(e,t){return!!(e.type===M.AST_NODE_TYPES.Literal||e.type===M.AST_NODE_TYPES.Identifier||e.type===M.AST_NODE_TYPES.TemplateLiteral||e.type===M.AST_NODE_TYPES.TaggedTemplateExpression||!t&&e.type===M.AST_NODE_TYPES.ArrayExpression&&e.elements.every(r=>r&&qe(r,!0)))}function sr(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 or(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ke={name:$t,rule:ir};var ar=/eslint +react-compiler\/react-compiler: +\["error/,Ut={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"?w=>r(w):w=>e.sourceCode.getText(w),n=typeof e.getScope=="function"?()=>n():w=>e.sourceCode.getScope(w),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,s={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function i(w){a&&Array.isArray(w.suggest)&&w.suggest.length>0&&(w.fix=w.suggest[0].fix),e.report(w)}let l=e.getSourceCode().scopeManager,c=new WeakMap,p=new WeakSet,u=new WeakMap,S=new WeakMap,h=new WeakSet;function x(w,L){return function(P){if(L.has(P))return L.get(P);let T=w(P);return L.set(P,T),T}}function b(w,L,P,T,m){m&&w.async&&i({node:w,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
5
5
|
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
async function fetchData() {
|
|
@@ -12,5 +12,5 @@ useEffect(() => {
|
|
|
12
12
|
fetchData();
|
|
13
13
|
}, [someId]); // Or [] if effect doesn't need props or state
|
|
14
14
|
|
|
15
|
-
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=l.acquire(E),v=new Set,O=null;{let f=R.upper;for(;f&&(v.add(f),f.type!=="function");)f=f.upper;if(!f)return;O=f}let x=Array.isArray;function U(f){if(!x(f.defs))return!1;let y=f.defs[0];if(y==null||y.node.type!=="VariableDeclarator")return!1;let b=y.node.init;if(b==null)return!1;for(;b.type==="TSAsExpression";)b=b.expression;let w=y.node.parent;if(w==null&&(et(O.block,y.node.id),w=y.node.parent,w==null))return!1;if(w.kind==="const"&&b.type==="Literal"&&(typeof b.value=="string"||typeof b.value=="number"||b.value===null))return!0;if(b.type!=="CallExpression")return!1;let k=b.callee;if(k.type==="MemberExpression"&&k.object.name==="React"&&k.property!=null&&!k.computed&&(k=k.property),k.type!=="Identifier")return!1;let C=y.node.id,{name:D}=k;if(D==="useRef"&&C.type==="Identifier")return!0;if(mr(k)&&C.type==="Identifier"){for(let L of f.references)L!==C&&S.add(L.identifier);return!0}else if(D==="useState"||D==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&x(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(D==="useState"){let L=f.references,ee=0;for(let ae=0;ae<L.length;ae++){if(L[ae].isWrite()&&ee++,ee>1)return!1;c.set(L[ae].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(D==="useState"){let L=f.references;for(let ee=0;ee<L.length;ee++)p.add(L[ee].identifier)}return!1}}}else if(D==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function B(f){if(!x(f.defs))return!1;let y=f.defs[0];if(y==null||y.node==null||y.node.id==null)return!1;let b=y.node,w=O.childScopes,k=null,C;for(C=0;C<w.length;C++){let D=w[C],L=D.block;if(b.type==="FunctionDeclaration"&&L===b||b.type==="VariableDeclarator"&&L.parent===b){k=D;break}}if(k==null)return!1;for(C=0;C<k.through.length;C++){let D=k.through[C];if(D.resolved!=null&&v.has(D.resolved.scope)&&!oe(D.resolved))return!1}return!0}let oe=h(U,u),We=h(B,g),Ie=new Map;function fe(f){let y=f.from,b=!1;for(;y.block!==E;)y.type==="function"&&(b=y.block.parent!=null&&y.block.parent.type==="ReturnStatement"),y=y.upper;return b}let X=new Map,ie=new Map;Ce(R);function Ce(f){for(let y of f.references){if(!y.resolved||!v.has(y.resolved.scope))continue;let b=et(E,y.identifier),w=Wt(b),k=ce(w,ie);if(A&&w.type==="Identifier"&&(w.parent.type==="MemberExpression"||w.parent.type==="OptionalMemberExpression")&&!w.parent.computed&&w.parent.property.type==="Identifier"&&w.parent.property.name==="current"&&fe(y)&&Ie.set(k,{reference:y,dependencyNode:w}),w.parent.type==="TSTypeQuery"||w.parent.type==="TSTypeReference")continue;let C=y.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===E.parent)&&C.type!=="TypeParameter")if(X.has(k))X.get(k).references.push(y);else{let D=y.resolved,L=oe(D)||We(D);X.set(k,{isStable:L,references:[y]})}}for(let y of f.childScopes)Ce(y)}Ie.forEach(({reference:f,dependencyNode:y},b)=>{let w=f.resolved.references,k=!1;for(let C=0;C<w.length;C++){let{identifier:D}=w[C],{parent:L}=D;if(L!=null&&L.type==="MemberExpression"&&!L.computed&&L.property.type==="Identifier"&&L.property.name==="current"&&L.parent.type==="AssignmentExpression"&&L.parent.left===L){k=!0;break}}k||i({node:y.parent.property,message:`The ref value '${b}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${b}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let He=new Set;function Mn(f,y){He.has(y)||(He.add(y),i({node:f,message:`Assignments to the '${y}' variable from inside React Hook ${r(d)} 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(d)}.`}))}let Re=new Set;if(X.forEach(({isStable:f,references:y},b)=>{f&&Re.add(b),y.forEach(w=>{w.writeExpr&&Mn(w.writeExpr,b)})}),He.size>0)return;if(!M){let f=null;if(X.forEach(({isStable:y,references:b},w)=>{f||b.forEach(k=>{if(f)return;let C=k.identifier;if(!c.has(C))return;let L=k.from;for(;L.type!=="function";)L=L.upper;L.block===E&&(f=w)})}),f){let{suggestedDependencies:y}=Ze({dependencies:X,declaredDependencies:[],stableDependencies:Re,externalDependencies:new Set,isEffect:!0});i({node:d,message:`React Hook ${m} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+y.join(", ")+`] as a second argument to the ${m} Hook.`,suggest:[{desc:`Add dependencies array: [${y.join(", ")}]`,fix(b){return b.insertTextAfter(E,`, [${y.join(", ")}]`)}}]})}return}let be=[],xe=new Set;M.type!=="ArrayExpression"?i({node:M,message:`React Hook ${r(d)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):M.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(d)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}S.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(k){return k.removeRange(f.range)}}]});let y;try{y=ce(f,ie)}catch(k){if(/Unsupported node type/.test(k.message)){f.type==="Literal"?X.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(d)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw k}let b=f;for(;b.type==="MemberExpression"||b.type==="OptionalMemberExpression"||b.type==="ChainExpression";)b=b.object||b.expression.object;let w=!O.through.some(k=>k.identifier===b);be.push({key:y,node:f}),w||xe.add(y)});let{suggestedDependencies:_n,unnecessaryDependencies:Ae,missingDependencies:me,duplicateDependencies:vt}=Ze({dependencies:X,declaredDependencies:be,stableDependencies:Re,externalDependencies:xe,isEffect:A}),ke=_n;if(vt.size+me.size+Ae.size===0){if(t)return;cr({declaredDependencies:be,declaredDependenciesNode:M,componentScope:O,scope:R}).forEach(({construction:y,isUsedOutsideOfHook:b,depType:w})=>{let k=w==="function"?"useCallback":"useMemo",C=w==="function"?"definition":"initialization",D=`wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,L=b?`To fix this, ${D}`:`Move it inside the ${m} callback. Alternatively, ${D}`,ee=w==="conditional"||w==="logical expression"?"could make":"makes",ae=`The '${y.name.name}' ${w} ${ee} the dependencies of ${m} Hook (at line ${M.loc.start.line}) change on every render. ${L}`,Ot;b&&y.type==="Variable"&&w==="function"&&(Ot=[{desc:`Wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,fix(Pt){let[Un,Vn]=k==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Pt.insertTextBefore(y.node.init,Un),Pt.insertTextAfter(y.node.init,Vn)]}}]),i({node:y.node,message:ae,suggest:Ot})});return}!A&&me.size>0&&(ke=Ze({dependencies:X,declaredDependencies:[],stableDependencies:Re,externalDependencies:xe,isEffect:A}).suggestedDependencies);function $n(){if(be.length===0)return!0;let f=be.map(b=>b.key),y=f.slice().sort();return f.join(",")===y.join(",")}$n()&&ke.sort();function Ye(f){let y=f.split("."),b="";for(let w=0;w<y.length;w++){if(w!==0){let k=y.slice(0,w+1).join("."),C=ie.get(k)===!0;b+=C?"?.":"."}b+=y[w]}return b}function ze(f,y,b,w){return f.size===0?null:(f.size>1?"":y+" ")+b+" "+(f.size>1?"dependencies":"dependency")+": "+ur(Array.from(f).sort().map(k=>"'"+Ye(k)+"'"))+`. Either ${w} ${f.size>1?"them":"it"} or remove the dependency array.`}let se="";if(Ae.size>0){let f=null;if(Array.from(Ae.keys()).forEach(y=>{f===null&&y.endsWith(".current")&&(f=y)}),f!==null)se=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(xe.size>0){let y=Array.from(xe)[0];R.set.has(y)||(se=` Outer scope values like '${y}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!se&&me.has("props")){let f=X.get("props");if(f==null)return;let y=f.references;if(!Array.isArray(y))return;let b=!0;for(let w=0;w<y.length;w++){let k=y[w],C=et(O.block,k.identifier);if(!C){b=!1;break}let D=C.parent;if(D==null){b=!1;break}if(D.type!=="MemberExpression"&&D.type!=="OptionalMemberExpression"){b=!1;break}}b&&(se=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${m} call and refer to those specific props inside ${r(d)}.`)}if(!se&&me.size>0){let f=null;me.forEach(y=>{if(f)return;let b=O.set.get(y),w=X.get(y);if(w.references[0].resolved!==b)return;let k=b.defs[0];if(k==null||k.name==null||k.type!=="Parameter")return;let C=!1,D;for(let L=0;L<w.references.length;L++)if(D=w.references[L].identifier,D!=null&&D.parent!=null&&(D.parent.type==="CallExpression"||D.parent.type==="OptionalCallExpression")&&D.parent.callee===D){C=!0;break}C&&(f=y)}),f!==null&&(se=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!se&&me.size>0){let f=null;if(me.forEach(y=>{if(f!==null)return;let w=X.get(y).references,k,C;for(let D=0;D<w.length;D++){for(k=w[D].identifier,C=k.parent;C!=null&&C!==O.block;){if(C.type==="CallExpression"){let L=c.get(C.callee);if(L!=null){if(L.name===y)f={missingDep:y,setter:C.callee.name,form:"updater"};else if(p.has(k))f={missingDep:y,setter:C.callee.name,form:"reducer"};else{let ee=w[D].resolved;if(ee!=null){let ae=ee.defs[0];ae!=null&&ae.type==="Parameter"&&(f={missingDep:y,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":se=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":se=` 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":se=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:M,message:`React Hook ${r(d)} has `+(ze(me,"a","missing","include")||ze(Ae,"an","unnecessary","exclude")||ze(vt,"a","duplicate","omit"))+se,suggest:[{desc:`Update the dependencies array to be: [${ke.map(Ye).join(", ")}]`,fix(f){return f.replaceText(M,`[${ke.map(Ye).join(", ")}]`)}}]})}function I(E){let M=pr(E.callee,s);if(M===-1)return;let d=E.arguments[M],m=E.callee,A=Ht(m).name,R=E.arguments[M+1],v=/Effect($|[^a-z])/g.test(A);if(!d){i({node:m,message:`React Hook ${A} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!v)){if(!R&&!v){(A==="useMemo"||A==="useCallback")&&i({node:m,message:`React Hook ${A} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(d.type){case"FunctionExpression":case"ArrowFunctionExpression":T(d,R,m,A,v);return;case"Identifier":if(!R||R.elements&&R.elements.some(U=>U&&U.type==="Identifier"&&U.name===d.name))return;let O=n(E).set.get(d.name);if(O==null||O.defs==null)return;let x=O.defs[0];if(!x||!x.node||x.type!=="Variable"&&x.type!=="FunctionName")break;switch(x.node.type){case"FunctionDeclaration":T(x.node,R,m,A,v);return;case"VariableDeclarator":let U=x.node.init;if(!U)break;switch(U.type){case"ArrowFunctionExpression":case"FunctionExpression":T(U,R,m,A,v);return}break}break;default:i({node:m,message:`React Hook ${A} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:m,message:`React Hook ${A} has a missing dependency: '${d.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${d.name}]`,fix(O){return O.replaceText(R,`[${d.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let E of e.sourceCode.getAllComments())if(lr.test(E.value))return t=!0,{CallExpression:M=>I(M,!0)}}return{CallExpression:E=>I(E)}}};function Ze({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,I)=>{let E=i(a,I);E.isUsed=!0,l(a,I,M=>{M.isSubtreeUsed=!0})}),t.forEach(({key:T})=>{let I=i(a,T);I.isSatisfiedRecursively=!0}),r.forEach(T=>{let I=i(a,T);I.isSatisfiedRecursively=!0});function i(T,I){let E=I.split("."),M=T;for(let d of E){let m=M.children.get(d);m||(m=s(),M.children.set(d,m)),M=m}return M}function l(T,I,E){let M=I.split("."),d=T;for(let m of M){let A=d.children.get(m);if(!A)return;E(A),d=A}}let c=new Set,p=new Set;u(a,c,p,T=>T);function u(T,I,E,M){T.children.forEach((d,m)=>{let A=M(m);if(d.isSatisfiedRecursively){d.isSubtreeUsed&&E.add(A);return}if(d.isUsed){I.add(A);return}u(d,I,E,R=>A+"."+R)})}let g=[],S=new Set,h=new Set;return t.forEach(({key:T})=>{p.has(T)?g.indexOf(T)===-1?g.push(T):h.add(T):S.add(T)}),c.forEach(T=>{g.push(T)}),{suggestedDependencies:g,unnecessaryDependencies:S,duplicateDependencies:h,missingDependencies:c}}function de(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 de(e.consequent)!=null||de(e.alternate)!=null?"conditional":null;case"LogicalExpression":return de(e.left)!=null||de(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return de(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return de(e.expression);case"TSAsExpression":return de(e.expression)}return null}function cr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:s})=>{let i=r.variables.find(c=>c.name===s);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=de(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(s){let i=!1;for(let l=0;l<s.references.length;l++){let c=s.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==n&&p!=null;)p=p.upper;if(p!==n&&!Yt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}function Wt(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)?Wt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Qe(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function ce(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=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Qe(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Qe(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=ce(r.object,t),o=ce(r.property,null),a=`${n}.${o}`;return Qe(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Ht(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function pr(e,t){let r=Ht(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=ce(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 et(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),fr(n,t))return n;if(Yt(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(Ut(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(s=>{Ut(s)&&(s.parent=n,r.push(s))}))}return null}function ur(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 Ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function fr(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 Yt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function mr(e){return!1}var ye=require("@typescript-eslint/utils");var q=Oe(require("typescript")),dr=ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="improved-no-unnecessary-condition",yr=j({}),gr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Sr=new Set(gr),tt={name:zt,rule:dr({name:zt,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:[yr]},defaultOptions:[{}],create(e){let t=ye.ESLintUtils.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===ye.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&q.default.TypeFlags.Any||i.flags&q.default.TypeFlags.Unknown?null:i.flags&q.default.TypeFlags.StringLike?["string"]:i.flags&q.default.TypeFlags.NumberLike?["number"]:i.flags&q.default.TypeFlags.BigIntLike?["bigint"]:i.flags&q.default.TypeFlags.BooleanLike?["boolean"]:i.flags&q.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&q.default.TypeFlags.Undefined||i.flags&q.default.TypeFlags.Void?["undefined"]:i.flags&q.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&q.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&q.default.TypeFlags.NonPrimitive?["object"]:i.flags&q.default.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=r.getTypeAtLocation(l.expression);if(c.flags&q.default.TypeFlags.Any||c.flags&q.default.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let g of c.types){let S=o(g);if(S)p.push(...S);else return null}return p}let u=o(c);return u?(p.push(...u),p):null}function s(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(n(i.left)?(c=i.left,p=i.right.type===ye.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(c=i.right,p=i.left.type===ye.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!Tr(p,Sr))return;let u=a(c);if(!u)return;let g=i.operator==="!==",S=u.includes(p);u.length===1?S&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Te(c,e),type:p}}):!S&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Te(c,e),type:Array.from(u)[0]}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Te(c,e),actualType:Ne(u),conditionType:p}}):S&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Te(c,e),actualType:Ne(u),conditionType:p}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Te(c,e),actualType:Ne(u),conditionType:p}}):!S&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Te(c,e),type:Ne(u)}})}return{BinaryExpression:s}}})};function Ne(e){return Array.from(new Set(e)).join(" | ")||"never"}function Te(e,t){let r=e.argument;return r.type===ye.AST_NODE_TYPES.Identifier?r.name:t.sourceCode.getText(r)}function Tr(e,t){return t.has(e)}var De=require("@typescript-eslint/utils");var hr=De.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt="no-call-with-explicit-generics",Er=j({functions:Y(F())}),br=hr({name:Bt,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:[Er]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===De.AST_NODE_TYPES.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),nt={name:Bt,rule:br};var ge=require("@typescript-eslint/utils"),xr=ge.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-call-with-inferred-generics",wr=xr({name:Jt,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!==ge.AST_NODE_TYPES.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(s||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&n.typeArguments?.params?.some(p=>!i&&p.type===ge.AST_NODE_TYPES.TSAnyKeyword||l&&p.type===ge.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===ge.AST_NODE_TYPES.Identifier&&l.includes(p.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),rt={name:Jt,rule:wr};var qt=require("@typescript-eslint/utils"),Ir=qt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="no-commented-out-code",Cr=["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:"],Rr=[") {","return;",/^\s*return\s+/,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",/\w=("|'|`)/,");",/\w+:\s*('|"|`)/,/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,/\w+-\w+:/,/\w+_\w+:/,"&&","||","()",/\?\s+\w/,/:\s+\w/,/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,/^\s*\d+[,}]/,/^\s*\[[^\]]*\][,}]/,/^\s*\{[^}]*\}[,}]/,/\.\w+\(/,/\[\w+\]/,"?.(","??","=>",/^\s*(['"`]).+?\1\s*:/],Ar=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Xt=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],kr=Ir({name:Kt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with 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")||/^\s*[*\s]*$/.test(n))return!1;for(let s of Xt)if(a.startsWith(s))return!1;if(n.includes("https://"))return!1;if(o==="Block"){for(let s of Ar)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of Cr)if(a.startsWith(s))return{wrongPattern:s};for(let s of Rr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}function r(n,o){let a=n,s=a.trim();if(s.startsWith("`")&&(s.endsWith("`,")||s.endsWith("`;")||s.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let c=a.split(/```[\s\S]*?```/g);c.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=c.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(c=>/[a-zA-Z0-9]/.test(c))?i.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let s=r(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Xt.join(", ")}})}}}}}),it={name:Kt,rule:kr};var je=require("@typescript-eslint/utils"),vr=je.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="no-default-export",Or=vr({name:Gt,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===je.TSESTree.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),st={name:Gt,rule:Or};var Zt=require("@typescript-eslint/utils"),Pr=Zt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="no-leaked-text-in-jsx",Fr=[",",";","[","]","(",")"],Nr=Pr({name:Qt,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="";Fr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),ot={name:Qt,rule:Nr};var pe=require("@typescript-eslint/utils"),Dr=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-non-camel-case-functions",jr=/^[a-z][a-zA-Z0-9]*$/;function en(e){return e.typeName.type===pe.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===pe.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===pe.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var Lr=Dr({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&&!jr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===pe.AST_NODE_TYPES.TSTypeReference?en(r):r.type===pe.AST_NODE_TYPES.TSUnionType&&r.types.some(o=>o.type===pe.AST_NODE_TYPES.TSTypeReference&&en(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),at={name:tn,rule:Lr};var V=require("@typescript-eslint/utils");var lt=require("@typescript-eslint/utils");function he(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:he(e.parent,t,r===1/0?r:r-1)}function*ct(e){yield e,e.parent&&(yield*ct(e.parent))}function pt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function nn(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===lt.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===lt.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Mr=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rn="no-optional-root-props",_r=Mr({name:rn,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 s=a.references[0];if(!s)return!1;for(let i of ct(s.identifier)){if("returnType"in i||i.type===V.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===V.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===V.TSESTree.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===V.TSESTree.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=he(l.parent.parent,V.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=Le(p,e.sourceCode);return u?!(u.parent.type===V.TSESTree.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===V.TSESTree.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===V.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===V.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let c=he(l,V.TSESTree.AST_NODE_TYPES.VariableDeclaration);return c?!!Le(c,e.sourceCode):!1}if(l.type===V.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Le(l,e.sourceCode)}return!1}function r(n){n.key.type!==V.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=he(n,V.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let s=e.sourceCode.getText(a);return o.replaceText(a,s.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===V.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Me(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Me(n)||!t(n)))for(let o of n.body.body)o.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==V.TSESTree.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==V.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=he(n.parent,V.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=Le(a,e.sourceCode);if(!(!s||s.parent.type===V.TSESTree.AST_NODE_TYPES.CallExpression&&s.parent.callee.type===V.TSESTree.AST_NODE_TYPES.Identifier&&s.parent.callee.name==="memo"))for(let l of o.members)l.type===V.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Me(e){return e?e.parent?.type===V.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===V.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Le(e,t){if(Me(e))return;let r;if(e.type===V.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===V.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===V.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(s=>s.identifiers.includes(r));if(!o)return;let a=o.references.filter(s=>s.identifier!==r);if(!(a.length!==1||!a[0])&&!Me(a[0].identifier.parent.parent))return a[0].identifier}var ut={name:rn,rule:_r};var sn=require("@typescript-eslint/utils"),_e=Oe(require("path"));var $r=sn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-relative-imports",Ur=j({find:F(),replacement:F()}),Vr=j({aliases:Y(Ur),rootDir:P(F()),allowNotFoundAliases:P(le()),_dev_simulateFileName:P(F())}),Wr=$r({name:on,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[Vr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=_e.default.dirname(i);return _e.default.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=_e.default.relative(i,s);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let u=l.replace(p,c);return{alias:c,newPath:u}}return null}return{ImportDeclaration(s){let i=s.source.value;if(!n(i))return;let l=o(i,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:s,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(s.source,`'${c.newPath}'`):void 0})}}}}),ft={name:on,rule:Wr};var Se=require("@typescript-eslint/utils");var Hr="no-unnecessary-async-on-jsx-props";function Yr(e){if(e.body.type!==Se.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!==Se.AST_NODE_TYPES.ExpressionStatement?!1:r.expression.type===Se.AST_NODE_TYPES.AwaitExpression}var mt=ne({name:Hr,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){Yr(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let o=e.sourceCode,a=[],s=o.getFirstToken(r,l=>l.value==="async");if(s){let l=o.getTokenAfter(s);l?a.push(n.replaceTextRange([s.range[0],l.range[0]],"")):a.push(n.remove(s))}function i(l){if(l.type===Se.AST_NODE_TYPES.AwaitExpression){let c=o.getFirstToken(l);if(c&&c.value==="await"){let p=o.getTokenAfter(c);p?a.push(n.replaceTextRange([c.range[0],p.range[0]],"")):a.push(n.remove(c))}}if(l.type===Se.AST_NODE_TYPES.BlockStatement)for(let c of l.body)i(c);else l.type===Se.AST_NODE_TYPES.ExpressionStatement&&i(l.expression)}return i(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});var ue=require("@typescript-eslint/utils");var dt=Oe(require("typescript")),zr=ue.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="no-unnecessary-casting",Br=j({additionalCastFunctions:P(Y(j({name:F(),expectedType:Pe(["string","number"])})))}),yt={name:an,rule:zr({name:an,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:[Br],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=ue.ESLintUtils.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function s(p,u){switch(p.type){case ue.AST_NODE_TYPES.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case ue.AST_NODE_TYPES.TemplateLiteral:return u==="string";case ue.AST_NODE_TYPES.UnaryExpression:return u==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,u){return u==="number"?!!(p.flags&dt.TypeFlags.NumberLike):!!(p.flags&dt.TypeFlags.StringLike)}function l(p,u){return g=>g.replaceText(p,e.sourceCode.getText(u))}function c(p){if(!a||p.arguments.length!==1)return;let u=p.arguments[0];if(!u||u.type===ue.AST_NODE_TYPES.SpreadElement)return;let{callee:g}=p;if(g.type!==ue.AST_NODE_TYPES.Identifier)return;let S=g.name,h=n.find(I=>I.name===S);if(!h)return;if(s(u,h.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),h.expectedType)){let I,E;S==="Number"?I="unnecessaryNumberCasting":S==="String"?I="unnecessaryStringCasting":(I="unnecessaryCustomCasting",E={name:h.name,type:h.expectedType}),e.report({node:p,messageId:I,...E?{data:E}:{},fix:l(p,u)})}}return{CallExpression:c}}})};var we=require("@typescript-eslint/utils"),re=Oe(require("zod/v4"));var Jr=re.object({methods:re.union([re.array(re.string()),re.literal("array")])}),gt=ne({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:[re.toJSONSchema(Jr)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===we.AST_NODE_TYPES.MemberExpression){let c=l.property;if(c.type===we.AST_NODE_TYPES.Identifier)return c.name}return null}function s(i,l){if(i.type!==we.AST_NODE_TYPES.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===we.AST_NODE_TYPES.CallExpression){let p=a(c);p&&o(p)&&c.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(g){return g.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)s(l,i)},FunctionExpression(i){for(let l of i.params)s(l,i)}}}});var G=require("@typescript-eslint/utils");var St=ne({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===G.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==G.AST_NODE_TYPES.ObjectExpression||t.id.type===G.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===G.AST_NODE_TYPES.ExportNamedDeclaration)return;let r=new Map;for(let s of t.init.properties)s.type===G.AST_NODE_TYPES.Property&&s.key.type===G.AST_NODE_TYPES.Identifier&&r.set(s.key.name,s);if(r.size===0||t.id.type!==G.AST_NODE_TYPES.Identifier)return;let n=Xr(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(s=>s.type!==G.AST_NODE_TYPES.Property?!1:s.value.type===G.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let s of n){if(s.identifier.parent.type!==G.AST_NODE_TYPES.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===G.AST_NODE_TYPES.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==G.AST_NODE_TYPES.Identifier)return;a.add(i.property.name)}if(i.parent.type===G.AST_NODE_TYPES.CallExpression&&o)return}for(let[s,i]of r)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function Xr(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 W=require("@typescript-eslint/utils");var qr=j({selectors:Y(j({name:F(),selectorProp:P(F()),selectorArgPos:P(Z()),returnProp:P(F())}))}),Kr=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ln="no-unused-selected-values",Tt={name:ln,rule:Kr({name:ln,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[qr]},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===W.AST_NODE_TYPES.CallExpression&&(a=o.init),!a)return;let s=Zr(a);if(!s)return;let i=n.get(s);if(!i)return;let l=Gr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=Qr(l);if(!c)return;let p=cn(c.properties,void 0);if(!p)return;if(o.id.type===W.AST_NODE_TYPES.ObjectPattern){let S=cn(o.id.properties,i.returnProp);if(!S)return;for(let[h,T]of p)S.has(h)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:h}});return}if(o.id.type!==W.AST_NODE_TYPES.Identifier||i.returnProp)return;let u=ei(o,e.sourceCode);if(u.length===0)return;let g=new Set;for(let S of u){if(S.identifier.parent.type!==W.AST_NODE_TYPES.MemberExpression)return;let h=S.identifier.parent.property;if(h.type!==W.AST_NODE_TYPES.Identifier)return;g.add(h.name)}for(let[S,h]of p)g.has(S)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:S}})}}}})};function Gr(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===W.AST_NODE_TYPES.ArrowFunctionExpression||n.type===W.AST_NODE_TYPES.FunctionExpression)return n;if(r&&n.type===W.AST_NODE_TYPES.ObjectExpression){let o=n.properties.find(s=>s.type===W.AST_NODE_TYPES.Property&&s.key.type===W.AST_NODE_TYPES.Identifier&&s.key.name===r);if(o?.type!==W.AST_NODE_TYPES.Property)return null;let a=o.value;if(a.type===W.AST_NODE_TYPES.ArrowFunctionExpression||a.type===W.AST_NODE_TYPES.FunctionExpression)return a}return null}function Zr(e){return e.callee.type===W.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===W.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===W.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Qr(e){if(e.body.type===W.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===W.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===W.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==W.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function cn(e,t){let r=e;if(t){let o=e.find(a=>a.type===W.AST_NODE_TYPES.Property&&a.key.type===W.AST_NODE_TYPES.Identifier&&a.key.name===t);if(o?.type!==W.AST_NODE_TYPES.Property||o.value.type!==W.AST_NODE_TYPES.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==W.AST_NODE_TYPES.Property||o.key.type!==W.AST_NODE_TYPES.Identifier)return null;n.set(o.key.name,o)}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(o=>o.identifier!==e.id):[]}var H=require("@typescript-eslint/utils");var ht=ne({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===H.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let i=ti(a);i&&(n=i);return}let s=ni(a,e.sourceCode);if(s){o=!0;for(let i of s)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function ti(e){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==H.AST_NODE_TYPES.ObjectExpression)return null;let n=pt(r.properties,a=>a.type!==H.AST_NODE_TYPES.Property||a.key.type!==H.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===H.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===H.AST_NODE_TYPES.FunctionExpression?ri(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===H.AST_NODE_TYPES.Property&&a.key.type===H.AST_NODE_TYPES.Identifier&&o.set(a.key.name,a);return o}function ni(e,t){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==H.AST_NODE_TYPES.ObjectPattern||!pt(e.parent.id.properties,s=>s.type===H.AST_NODE_TYPES.Property&&s.key.type===H.AST_NODE_TYPES.Identifier&&s.key.name==="formFields"&&s))return null;let o=nn(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==H.AST_NODE_TYPES.Identifier||s.parent.type===H.AST_NODE_TYPES.Property&&s.parent.parent.type===H.AST_NODE_TYPES.ObjectExpression&&s.parent.parent.parent.type===H.AST_NODE_TYPES.ReturnStatement||s.parent.type===H.AST_NODE_TYPES.ReturnStatement)return null;if(s.parent.type===H.AST_NODE_TYPES.MemberExpression){if(s.parent.object.type!==H.AST_NODE_TYPES.Identifier||s.parent.property.type!==H.AST_NODE_TYPES.Identifier)return null;a.add(s.parent.property.name)}}return a}function ri(e){if(e.body.type===H.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===H.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===H.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var $=require("@typescript-eslint/utils");var ii=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function pn(e){let t=[];for(let r of e.members)r.type===$.AST_NODE_TYPES.TSPropertySignature&&r.key.type===$.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function un(e,...t){for(let r of t)e.set(...r);return e}var si=j({forceCheckOnFCPropTypesWithName:P(Y(F()))}),fn="no-unused-type-props-in-args",Et=null,oi=ii({name:fn,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:[si],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!Et&&(Et=r.map(i=>new RegExp(i)));function n(i,l,c,p,u=!0){let g=c.name,S=e.sourceCode.getScope(l).references.find(I=>I.identifier.name===g)?.resolved,h=i&&Et?.some(I=>I.test(g));if(!S||!h&&S.references.filter(I=>I.isTypeReference).length>1)return;let T=S?.defs[0]?.node;if(!(u&&T?.parent?.type===$.AST_NODE_TYPES.ExportNamedDeclaration)){if(T?.type===$.AST_NODE_TYPES.TSTypeAliasDeclaration){o(i,l,p,T.typeAnnotation,!0);return}if(T?.type===$.AST_NODE_TYPES.TSInterfaceDeclaration){o(i,l,p,T.body,!0);return}}}function o(i,l,c,p,u){if(p.type===$.AST_NODE_TYPES.TSInterfaceBody){for(let g of p.body)g.type===$.AST_NODE_TYPES.TSPropertySignature&&g.key.type===$.AST_NODE_TYPES.Identifier&&c.set(g.key.name,g);return}if(p.type===$.AST_NODE_TYPES.TSTypeLiteral){un(c,...pn(p));return}if(p.type===$.AST_NODE_TYPES.TSIntersectionType){for(let g of p.types)o(i,l,c,g,!0);return}u||p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier&&n(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let u=new Map;if(o(i,l,u,p.typeAnnotation.typeAnnotation,!1),u.size===0)continue;s(p,u)}else p.type===$.AST_NODE_TYPES.AssignmentPattern&&p.left.type===$.AST_NODE_TYPES.ObjectPattern&&a(i,l,[p.left])}function s(i,l){let c=[];if(i.properties.at(-1)?.type===$.AST_NODE_TYPES.RestElement)return;for(let S of i.properties)S.type===$.AST_NODE_TYPES.Property&&S.key.type===$.AST_NODE_TYPES.Identifier&&c.push(S.key.name);let u=[],g=[];for(let[S,h]of l)c.includes(S)||(g.push(S),u.push({node:h,messageId:"unusedObjectTypeProperty",data:{propertyName:S}}));for(let[S,h]of u.entries())e.report({...h,fix:S===u.length-1?T=>{let I=i.properties.at(-1),E=g.join(", ");return I?I?.type===$.AST_NODE_TYPES.RestElement?null:T.insertTextAfter(I,`, ${E}`):T.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${E}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let c=new Map,p=l.id.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===$.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(p){if(p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier)n(!0,i,p.typeName,c,!1);else if(p.type===$.AST_NODE_TYPES.TSTypeLiteral)un(c,...pn(p));else if(p.type===$.AST_NODE_TYPES.TSIntersectionType)for(let u of p.types)u.type===$.AST_NODE_TYPES.TSTypeReference&&u.typeName.type===$.AST_NODE_TYPES.Identifier?n(!0,i,u.typeName,c,!1):o(!0,i,c,u,!0);if(c.size!==0&&l.init?.type===$.AST_NODE_TYPES.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===$.AST_NODE_TYPES.ObjectPattern&&s(u,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),bt={name:fn,rule:oi};var Ee=require("@typescript-eslint/utils"),ai=Ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="prefer-named-functions",mn=new Map,li=ai({name:dn,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=mn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),mn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Ee.AST_NODE_TYPES.ArrowFunctionExpression&&n.id.type===Ee.AST_NODE_TYPES.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Ee.AST_NODE_TYPES.BlockStatement)return;let a=n.parent,s=n.init.params,i=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:c=>c.replaceText(a,`${l.async?"async ":""}function ${o}(${s.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),xt={name:dn,rule:li};var N=require("@typescript-eslint/utils");var ci=j({disallowedFunctions:Y(j({name:F(),allowUsingWithArgs:P(le()),hookAlternative:P(F()),message:P(F()),allowUseInside:P(Y(F()))}))});function $e(e){return/^use[A-Z]/.test(e)}function yn(e){return/^[A-Z]/.test(e)}function pi(e){return e.type===N.AST_NODE_TYPES.Identifier?$e(e.name):e.type===N.AST_NODE_TYPES.MemberExpression&&e.property.type===N.AST_NODE_TYPES.Identifier?$e(e.property.name):!1}function gn(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 Sn(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&gn(e.parent.callee,"forwardRef"))}function Tn(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&gn(e.parent.callee,"memo"))}function wt(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 ui(e){let t=e.parent,r=!1;for(;t;){if(t.type===N.AST_NODE_TYPES.FunctionDeclaration||t.type===N.AST_NODE_TYPES.FunctionExpression||t.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let n=wt(t);if(n&&n.type===N.AST_NODE_TYPES.Identifier){if(yn(n.name)||$e(n.name))return!r;r=!0}else{if(Sn(t)||Tn(t))return!r;if(t.parent.type===N.AST_NODE_TYPES.CallExpression){let o=t.parent;pi(o.callee)||(r=!0)}else t.parent.type===N.AST_NODE_TYPES.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function hn(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 fi(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===N.AST_NODE_TYPES.FunctionDeclaration||r.type===N.AST_NODE_TYPES.FunctionExpression||r.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let n=wt(r);if(n&&n.type===N.AST_NODE_TYPES.Identifier&&t.includes(n.name))return!0}else if(r.type===N.AST_NODE_TYPES.CallExpression){let n=hn(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===N.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function di(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===N.AST_NODE_TYPES.FunctionDeclaration||n.type===N.AST_NODE_TYPES.FunctionExpression||n.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let o=wt(n);if(o&&o.type===N.AST_NODE_TYPES.Identifier){if(yn(o.name)||$e(o.name)){r=!0;break}}else if(Sn(n)||Tn(n)){r=!0;break}}n=n.parent}return r?t.length===0?ui(e):!fi(e,t):!1}var It=ne({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:[ci],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=hn(o);if(!a)return;let s=n.get(a);if(!s||s.allowUsingWithArgs&&mi(o))return;let i=s.allowUseInside||[];di(o,i)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:s.message?` ${s.message}`:` use ${s.hookAlternative} instead`},suggest:s.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${s.hookAlternative}`,hookAlternative:s.hookAlternative},fix:l=>{let c=s.hookAlternative;return o.callee.type===N.AST_NODE_TYPES.Identifier?l.replaceText(o.callee,c):o.callee.type===N.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===N.AST_NODE_TYPES.Identifier?l.replaceText(o.callee.property,c):null}}]:[]})}}}});var z=require("@typescript-eslint/utils");var yi=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bn="prefer-single-line-if",gi=j({maxLineLength:P(Z()),maxNonSimpleConditionLength:P(Z())}),Si=yi({name:bn,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:[gi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==z.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===z.AST_NODE_TYPES.ReturnStatement){if(!wn(a))return}else if(!(a.type===z.AST_NODE_TYPES.ContinueStatement||a.type===z.AST_NODE_TYPES.BreakStatement))return;if(n.test.type===z.AST_NODE_TYPES.LogicalExpression||n.test.type===z.AST_NODE_TYPES.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=En(n.test);if(!u&&n.test.type===z.AST_NODE_TYPES.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;En(g)&&(u=!0)}if(u&&(s=r.getText(n.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=r.getText(n.test));let i=r.getText(a);if(s.includes(`
|
|
16
|
-
`))return;let l=r.getTokenAfter(n);if(l&&l.type===z.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let u=r.getTokenAfter(l);if(u&&u.type===z.AST_TOKEN_TYPES.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=Ti(r,n),p=`if (${s}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:u=>u.replaceText(n,p)})}}}});function En(e){return e.type===z.AST_NODE_TYPES.CallExpression||e.type===z.AST_NODE_TYPES.BinaryExpression||e.type===z.AST_NODE_TYPES.MemberExpression&&xn(e)}function xn(e){return e.object.type===z.AST_NODE_TYPES.MemberExpression?xn(e.object):e.object.type!==z.AST_NODE_TYPES.Identifier}function Ti(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function wn(e){if(!e.argument)return!0;let t=e.argument;return t.type===z.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===z.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===z.AST_NODE_TYPES.Literal||t.type===z.AST_NODE_TYPES.Identifier||t.type===z.AST_NODE_TYPES.TemplateLiteral||t.type===z.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===z.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===z.AST_NODE_TYPES.UnaryExpression?wn(t):!1}var Ct={name:bn,rule:Si};var K=require("@typescript-eslint/utils");var hi=K.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),In="react-compiler-migration",Ei=j({disallowHooks:P(Y(j({name:F(),replacement:F()}))),disallowMethods:P(Y(j({name:F(),replacement:P(F()),requireTrueProp:P(F())})))}),bi=/eslint +react-compiler\/react-compiler: +\["error/;function xi(e){return e.type===K.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===K.AST_NODE_TYPES.MemberExpression&&e.property.type===K.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var wi=hi({name:In,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:[Ei]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(bi.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===K.AST_NODE_TYPES.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===K.AST_NODE_TYPES.MemberExpression&&n.callee.property.type===K.AST_NODE_TYPES.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let s=t.disallowHooks.find(i=>i.name===o);s&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:i=>i.replaceText(a,s.replacement)}]})}}if(t.disallowMethods?.length&&xi(n.callee)){for(let o of n.arguments)if(o.type===K.AST_NODE_TYPES.ObjectExpression){for(let a of o.properties)if(a.type===K.AST_NODE_TYPES.Property&&a.key.type===K.AST_NODE_TYPES.Identifier){let s=a.key.name,i=t.disallowMethods.find(l=>l.name===s);if(i){if(i.requireTrueProp){let l=i.requireTrueProp,c=!1;for(let p of o.properties)if(p.type===K.AST_NODE_TYPES.Property&&p.key.type===K.AST_NODE_TYPES.Identifier&&p.key.name===l&&p.value.type===K.AST_NODE_TYPES.Literal&&p.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:l}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),Rt={name:In,rule:wi};var Ue=require("@typescript-eslint/utils"),Ii=Ue.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cn="require-description",Ci=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Ri=/^eslint-disable-(next-)?line$/u,Ai=Ii({name:Cn,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=ki(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Oi(o.loc),messageId:"missingDescription"}))}}}}}),Rn={name:Cn,rule:Ai};function ki(e){let{text:t,description:r}=vi(e.value);if(!t)return null;let n=Ci.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=Ri.test(o);if(e.type===Ue.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let s=t.slice(n.index+o.length);return{kind:o,value:s.trim(),description:r}}function vi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Oi(e){return{start:{line:e.start.line,column:-1},end:e.end}}function vn(e){return/^use[A-Z0-9]/.test(e)}function Ve(e){return e.type==="Identifier"?vn(e.name):e.type==="MemberExpression"&&!e.computed&&Ve(e.property)?e.object.type==="Identifier":!1}function On(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Pn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Fn(e){return!!(e.parent&&e.parent.callee&&Pn(e.parent.callee,"forwardRef"))}function Nn(e){return!!(e.parent&&e.parent.callee&&Pn(e.parent.callee,"memo"))}function At(e){for(;e;){let t=jn(e);if(t&&(On(t)||Ve(t))||Fn(e)||Nn(e))return!0;e=e.parent}return!1}function An(e){return!1}function kt(e){return!1}var Pi=/eslint +react-compiler\/react-compiler: +\["error/,Dn={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(Pi.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,o=[],a=[],s=new WeakSet;function i(l){for(let c of l.references){let p=c.identifier.parent;if(p.type==="VariableDeclarator"&&p.init&&p.init.type==="CallExpression"&&p.init.callee&&An(p.init.callee))for(let u of c.resolved.references)u!==c&&s.add(u.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,c){let p=o.pop();if(p.size===0)return;let u=new Set;function g(m,A){let{cache:R}=g,v=R.get(m.id),O=new Set(A);if(O.has(m.id)){let x=[...O],U=x.slice(x.indexOf(m.id)+1);for(let B of U)u.add(B);return BigInt("0")}if(O.add(m.id),v!==void 0)return v;if(l.thrownSegments.includes(m))v=BigInt("0");else if(m.prevSegments.length===0)v=BigInt("1");else{v=BigInt("0");for(let x of m.prevSegments)v+=g(x,O)}return m.reachable&&v===BigInt("0")?R.delete(m.id):R.set(m.id,v),v}function S(m,A){let{cache:R}=S,v=R.get(m.id),O=new Set(A);if(O.has(m.id)){let x=Array.from(O),U=x.slice(x.indexOf(m.id)+1);for(let B of U)u.add(B);return BigInt("0")}if(O.add(m.id),v!==void 0)return v;if(l.thrownSegments.includes(m))v=BigInt("0");else if(m.nextSegments.length===0)v=BigInt("1");else{v=BigInt("0");for(let x of m.nextSegments)v+=S(x,O)}return R.set(m.id,v),v}function h(m){let{cache:A}=h,R=A.get(m.id);if(R===null)return 1/0;if(R!==void 0)return R;if(A.set(m.id,null),m.prevSegments.length===0)R=1;else{R=1/0;for(let v of m.prevSegments){let O=h(v);O<R&&(R=O)}R+=1}return A.set(m.id,R),R}g.cache=new Map,S.cache=new Map,h.cache=new Map;let T=S(l.initialSegment),I=jn(c),E=At(c),M=I?On(I)||Ve(I):Fn(c)||Nn(c),d=1/0;for(let m of l.finalSegments){if(!m.reachable)continue;let A=h(m);A<d&&(d=A)}for(let[m,A]of p){if(!m.reachable)continue;let R=m.nextSegments.length===0?d<=h(m):d<h(m),v=g(m)*S(m),O=u.has(m.id);for(let x of A)if(O&&!kt(x)&&e.report({node:x,message:`React Hook "${t(x)}" 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(c.async&&e.report({node:x,message:`React Hook "${t(x)}" cannot be called in an async function.`}),!O&&v!==T&&!kt(x)){let B=`React Hook "${t(x)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:x,message:B})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let U=`React Hook "${t(x)}" 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:x,message:U})}else if(I){let U=`React Hook "${t(x)}" is called in function "${t(I)}" 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:x,message:U})}else if(c.type==="Program"){let U=`React Hook "${t(x)}" 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:x,message:U})}else if(E&&!kt(x)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let B=c.parent;if(B.parent.type==="VariableDeclarator"&&vn(B.parent.id.name))return}let U=`React Hook "${t(x)}" 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:x,message:U})}}},CallExpression(l){if(Ve(l.callee)){let c=kn(o),p=kn(a),u=c.get(p);u||(u=[],c.set(p,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||An(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&s.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){At(l)&&i(r(l))},ArrowFunctionExpression(l){At(l)&&i(r(l))}}}};function jn(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 kn(e){return e[e.length-1]}var Ln={[bt.name]:bt.rule,[it.name]:it.rule,[rt.name]:rt.rule,"rules-of-hooks":Dn,"exhaustive-deps":Vt,"require-description":Rn.rule,[st.name]:st.rule,[at.name]:at.rule,[xt.name]:xt.rule,[qe.name]:qe.rule,[nt.name]:nt.rule,[ft.name]:ft.rule,[Ct.name]:Ct.rule,[ut.name]:ut.rule,[ot.name]:ot.rule,[Ge.name]:Ge.rule,[Rt.name]:Rt.rule,[Xe.name]:Xe.rule,[tt.name]:tt.rule,[yt.name]:yt.rule,[gt.name]:gt.rule,[Tt.name]:Tt.rule,[ht.name]:ht.rule,[St.name]:St.rule,[It.name]:It.rule,[mt.name]:mt.rule};var Fi={rules:Ln};0&&(module.exports={extendedLintPlugin});
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let y=l.acquire(w),R=new Set,C=null;{let f=y.upper;for(;f&&(R.add(f),f.type!=="function");)f=f.upper;if(!f)return;C=f}let E=Array.isArray;function F(f){if(!E(f.defs))return!1;let d=f.defs[0];if(d==null||d.node.type!=="VariableDeclarator")return!1;let I=d.node.init;if(I==null)return!1;for(;I.type==="TSAsExpression";)I=I.expression;let A=d.node.parent;if(A==null&&(Qe(C.block,d.node.id),A=d.node.parent,A==null))return!1;if(A.kind==="const"&&I.type==="Literal"&&(typeof I.value=="string"||typeof I.value=="number"||I.value===null))return!0;if(I.type!=="CallExpression")return!1;let O=I.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let v=d.node.id,{name:D}=O;if(D==="useRef"&&v.type==="Identifier")return!0;if(fr(O)&&v.type==="Identifier"){for(let j of f.references)j!==v&&h.add(j.identifier);return!0}else if(D==="useState"||D==="useReducer"){if(v.type==="ArrayPattern"&&v.elements.length===2&&E(f.identifiers)){if(v.elements[1]===f.identifiers[0]){if(D==="useState"){let j=f.references,re=0;for(let fe=0;fe<j.length;fe++){if(j[fe].isWrite()&&re++,re>1)return!1;c.set(j[fe].identifier,v.elements[0])}}return!0}else if(v.elements[0]===f.identifiers[0]){if(D==="useState"){let j=f.references;for(let re=0;re<j.length;re++)p.add(j[re].identifier)}return!1}}}else if(D==="useTransition"&&v.type==="ArrayPattern"&&v.elements.length===2&&Array.isArray(f.identifiers)&&v.elements[1]===f.identifiers[0])return!0;return!1}function Y(f){if(!E(f.defs))return!1;let d=f.defs[0];if(d==null||d.node==null||d.node.id==null)return!1;let I=d.node,A=C.childScopes,O=null,v;for(v=0;v<A.length;v++){let D=A[v],j=D.block;if(I.type==="FunctionDeclaration"&&j===I||I.type==="VariableDeclarator"&&j.parent===I){O=D;break}}if(O==null)return!1;for(v=0;v<O.through.length;v++){let D=O.through[v];if(D.resolved!=null&&R.has(D.resolved.scope)&&!J(D.resolved))return!1}return!0}let J=x(F,u),Q=x(Y,S),G=new Map;function be(f){let d=f.from,I=!1;for(;d.block!==w;)d.type==="function"&&(I=d.block.parent!=null&&d.block.parent.type==="ReturnStatement"),d=d.upper;return I}let te=new Map,Ae=new Map;pe(y);function pe(f){for(let d of f.references){if(!d.resolved||!R.has(d.resolved.scope))continue;let I=Qe(w,d.identifier),A=Vt(I),O=me(A,Ae);if(m&&A.type==="Identifier"&&(A.parent.type==="MemberExpression"||A.parent.type==="OptionalMemberExpression")&&!A.parent.computed&&A.parent.property.type==="Identifier"&&A.parent.property.name==="current"&&be(d)&&G.set(O,{reference:d,dependencyNode:A}),A.parent.type==="TSTypeQuery"||A.parent.type==="TSTypeReference")continue;let v=d.resolved.defs[0];if(v!=null&&!(v.node!=null&&v.node.init===w.parent)&&v.type!=="TypeParameter")if(te.has(O))te.get(O).references.push(d);else{let D=d.resolved,j=J(D)||Q(D);te.set(O,{isStable:j,references:[d]})}}for(let d of f.childScopes)pe(d)}G.forEach(({reference:f,dependencyNode:d},I)=>{let A=f.resolved.references,O=!1;for(let v=0;v<A.length;v++){let{identifier:D}=A[v],{parent:j}=D;if(j!=null&&j.type==="MemberExpression"&&!j.computed&&j.property.type==="Identifier"&&j.property.name==="current"&&j.parent.type==="AssignmentExpression"&&j.parent.left===j){O=!0;break}}O||i({node:d.parent.property,message:`The ref value '${I}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${I}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let le=new Set;function ue(f,d){le.has(d)||(le.add(d),i({node:f,message:`Assignments to the '${d}' variable from inside React Hook ${r(P)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${r(P)}.`}))}let xe=new Set;if(te.forEach(({isStable:f,references:d},I)=>{f&&xe.add(I),d.forEach(A=>{A.writeExpr&&ue(A.writeExpr,I)})}),le.size>0)return;if(!L){let f=null;if(te.forEach(({isStable:d,references:I},A)=>{f||I.forEach(O=>{if(f)return;let v=O.identifier;if(!c.has(v))return;let j=O.from;for(;j.type!=="function";)j=j.upper;j.block===w&&(f=A)})}),f){let{suggestedDependencies:d}=Ge({dependencies:te,declaredDependencies:[],stableDependencies:xe,externalDependencies:new Set,isEffect:!0});i({node:P,message:`React Hook ${T} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+d.join(", ")+`] as a second argument to the ${T} Hook.`,suggest:[{desc:`Add dependencies array: [${d.join(", ")}]`,fix(I){return I.insertTextAfter(w,`, [${d.join(", ")}]`)}}]})}return}let ke=[],ve=new Set;L.type!=="ArrayExpression"?i({node:L,message:`React Hook ${r(P)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):L.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(P)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}h.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(O){return O.removeRange(f.range)}}]});let d;try{d=me(f,Ae)}catch(O){if(/Unsupported node type/.test(O.message)){f.type==="Literal"?te.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(P)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let I=f;for(;I.type==="MemberExpression"||I.type==="OptionalMemberExpression"||I.type==="ChainExpression";)I=I.object||I.expression.object;let A=!C.through.some(O=>O.identifier===I);ke.push({key:d,node:f}),A||ve.add(d)});let{suggestedDependencies:Mn,unnecessaryDependencies:Fe,missingDependencies:ye,duplicateDependencies:kt}=Ge({dependencies:te,declaredDependencies:ke,stableDependencies:xe,externalDependencies:ve,isEffect:m}),Ne=Mn;if(kt.size+ye.size+Fe.size===0){if(t)return;lr({declaredDependencies:ke,declaredDependenciesNode:L,componentScope:C,scope:y}).forEach(({construction:d,isUsedOutsideOfHook:I,depType:A})=>{let O=A==="function"?"useCallback":"useMemo",v=A==="function"?"definition":"initialization",D=`wrap the ${v} of '${d.name.name}' in its own ${O}() Hook.`,j=I?`To fix this, ${D}`:`Move it inside the ${T} callback. Alternatively, ${D}`,re=A==="conditional"||A==="logical expression"?"could make":"makes",fe=`The '${d.name.name}' ${A} ${re} the dependencies of ${T} Hook (at line ${L.loc.start.line}) change on every render. ${j}`,vt;I&&d.type==="Variable"&&A==="function"&&(vt=[{desc:`Wrap the ${v} of '${d.name.name}' in its own ${O}() Hook.`,fix(Ot){let[$n,zn]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Ot.insertTextBefore(d.node.init,$n),Ot.insertTextAfter(d.node.init,zn)]}}]),i({node:d.node,message:fe,suggest:vt})});return}!m&&ye.size>0&&(Ne=Ge({dependencies:te,declaredDependencies:[],stableDependencies:xe,externalDependencies:ve,isEffect:m}).suggestedDependencies);function _n(){if(ke.length===0)return!0;let f=ke.map(I=>I.key),d=f.slice().sort();return f.join(",")===d.join(",")}_n()&&Ne.sort();function He(f){let d=f.split("."),I="";for(let A=0;A<d.length;A++){if(A!==0){let O=d.slice(0,A+1).join("."),v=Ae.get(O)===!0;I+=v?"?.":"."}I+=d[A]}return I}function Ye(f,d,I,A){return f.size===0?null:(f.size>1?"":d+" ")+I+" "+(f.size>1?"dependencies":"dependency")+": "+pr(Array.from(f).sort().map(O=>"'"+He(O)+"'"))+`. Either ${A} ${f.size>1?"them":"it"} or remove the dependency array.`}let oe="";if(Fe.size>0){let f=null;if(Array.from(Fe.keys()).forEach(d=>{f===null&&d.endsWith(".current")&&(f=d)}),f!==null)oe=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ve.size>0){let d=Array.from(ve)[0];y.set.has(d)||(oe=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!oe&&ye.has("props")){let f=te.get("props");if(f==null)return;let d=f.references;if(!Array.isArray(d))return;let I=!0;for(let A=0;A<d.length;A++){let O=d[A],v=Qe(C.block,O.identifier);if(!v){I=!1;break}let D=v.parent;if(D==null){I=!1;break}if(D.type!=="MemberExpression"&&D.type!=="OptionalMemberExpression"){I=!1;break}}I&&(oe=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${T} call and refer to those specific props inside ${r(P)}.`)}if(!oe&&ye.size>0){let f=null;ye.forEach(d=>{if(f)return;let I=C.set.get(d),A=te.get(d);if(A.references[0].resolved!==I)return;let O=I.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let v=!1,D;for(let j=0;j<A.references.length;j++)if(D=A.references[j].identifier,D!=null&&D.parent!=null&&(D.parent.type==="CallExpression"||D.parent.type==="OptionalCallExpression")&&D.parent.callee===D){v=!0;break}v&&(f=d)}),f!==null&&(oe=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!oe&&ye.size>0){let f=null;if(ye.forEach(d=>{if(f!==null)return;let A=te.get(d).references,O,v;for(let D=0;D<A.length;D++){for(O=A[D].identifier,v=O.parent;v!=null&&v!==C.block;){if(v.type==="CallExpression"){let j=c.get(v.callee);if(j!=null){if(j.name===d)f={missingDep:d,setter:v.callee.name,form:"updater"};else if(p.has(O))f={missingDep:d,setter:v.callee.name,form:"reducer"};else{let re=A[D].resolved;if(re!=null){let fe=re.defs[0];fe!=null&&fe.type==="Parameter"&&(f={missingDep:d,setter:v.callee.name,form:"inlineReducer"})}}break}}v=v.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":oe=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":oe=` 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":oe=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:L,message:`React Hook ${r(P)} has `+(Ye(ye,"a","missing","include")||Ye(Fe,"an","unnecessary","exclude")||Ye(kt,"a","duplicate","omit"))+oe,suggest:[{desc:`Update the dependencies array to be: [${Ne.map(He).join(", ")}]`,fix(f){return f.replaceText(L,`[${Ne.map(He).join(", ")}]`)}}]})}function k(w){let L=cr(w.callee,s);if(L===-1)return;let P=w.arguments[L],T=w.callee,m=Wt(T).name,y=w.arguments[L+1],R=/Effect($|[^a-z])/g.test(m);if(!P){i({node:T,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!R)){if(!y&&!R){(m==="useMemo"||m==="useCallback")&&i({node:T,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(P.type){case"FunctionExpression":case"ArrowFunctionExpression":b(P,y,T,m,R);return;case"Identifier":if(!y||y.elements&&y.elements.some(F=>F&&F.type==="Identifier"&&F.name===P.name))return;let C=n(w).set.get(P.name);if(C==null||C.defs==null)return;let E=C.defs[0];if(!E||!E.node||E.type!=="Variable"&&E.type!=="FunctionName")break;switch(E.node.type){case"FunctionDeclaration":b(E.node,y,T,m,R);return;case"VariableDeclarator":let F=E.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":b(F,y,T,m,R);return}break}break;default:i({node:T,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:T,message:`React Hook ${m} has a missing dependency: '${P.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${P.name}]`,fix(C){return C.replaceText(y,`[${P.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let w of e.sourceCode.getAllComments())if(ar.test(w.value))return t=!0,{CallExpression:L=>k(L,!0)}}return{CallExpression:w=>k(w)}}};function Ge({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((b,k)=>{let w=i(a,k);w.isUsed=!0,l(a,k,L=>{L.isSubtreeUsed=!0})}),t.forEach(({key:b})=>{let k=i(a,b);k.isSatisfiedRecursively=!0}),r.forEach(b=>{let k=i(a,b);k.isSatisfiedRecursively=!0});function i(b,k){let w=k.split("."),L=b;for(let P of w){let T=L.children.get(P);T||(T=s(),L.children.set(P,T)),L=T}return L}function l(b,k,w){let L=k.split("."),P=b;for(let T of L){let m=P.children.get(T);if(!m)return;w(m),P=m}}let c=new Set,p=new Set;u(a,c,p,b=>b);function u(b,k,w,L){b.children.forEach((P,T)=>{let m=L(T);if(P.isSatisfiedRecursively){P.isSubtreeUsed&&w.add(m);return}if(P.isUsed){k.add(m);return}u(P,k,w,y=>m+"."+y)})}let S=[],h=new Set,x=new Set;return t.forEach(({key:b})=>{p.has(b)?S.indexOf(b)===-1?S.push(b):x.add(b):h.add(b)}),c.forEach(b=>{S.push(b)}),{suggestedDependencies:S,unnecessaryDependencies:h,duplicateDependencies:x,missingDependencies:c}}function ge(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 ge(e.consequent)!=null||ge(e.alternate)!=null?"conditional":null;case"LogicalExpression":return ge(e.left)!=null||ge(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return ge(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return ge(e.expression);case"TSAsExpression":return ge(e.expression)}return null}function lr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:s})=>{let i=r.variables.find(c=>c.name===s);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=ge(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(s){let i=!1;for(let l=0;l<s.references.length;l++){let c=s.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==n&&p!=null;)p=p.upper;if(p!==n&&!Ht(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}function Vt(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)?Vt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ze(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function me(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=me(e.object,t),n=me(e.property,null),o=`${r}.${n}`;return Ze(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=me(e.object,t),n=me(e.property,null),o=`${r}.${n}`;return Ze(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=me(r.object,t),o=me(r.property,null),a=`${n}.${o}`;return Ze(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Wt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function cr(e,t){let r=Wt(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=me(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 Qe(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),ur(n,t))return n;if(Ht(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(zt(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(s=>{zt(s)&&(s.parent=n,r.push(s))}))}return null}function pr(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 zt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function ur(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 Ht(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function fr(e){return!1}var Se=require("@typescript-eslint/utils");var Z=Oe(require("typescript")),mr=Se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="improved-no-unnecessary-condition",dr=W({}),yr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],gr=new Set(yr),et={name:Yt,rule:mr({name:Yt,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:[dr]},defaultOptions:[{}],create(e){let t=Se.ESLintUtils.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===Se.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&Z.default.TypeFlags.Any||i.flags&Z.default.TypeFlags.Unknown?null:i.flags&Z.default.TypeFlags.StringLike?["string"]:i.flags&Z.default.TypeFlags.NumberLike?["number"]:i.flags&Z.default.TypeFlags.BigIntLike?["bigint"]:i.flags&Z.default.TypeFlags.BooleanLike?["boolean"]:i.flags&Z.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&Z.default.TypeFlags.Undefined||i.flags&Z.default.TypeFlags.Void?["undefined"]:i.flags&Z.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&Z.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&Z.default.TypeFlags.NonPrimitive?["object"]:i.flags&Z.default.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=r.getTypeAtLocation(l.expression);if(c.flags&Z.default.TypeFlags.Any||c.flags&Z.default.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let S of c.types){let h=o(S);if(h)p.push(...h);else return null}return p}let u=o(c);return u?(p.push(...u),p):null}function s(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(n(i.left)?(c=i.left,p=i.right.type===Se.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(c=i.right,p=i.left.type===Se.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!Sr(p,gr))return;let u=a(c);if(!u)return;let S=i.operator==="!==",h=u.includes(p);u.length===1?h&&!S?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Ie(c,e),type:p}}):!h&&S?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Ie(c,e),type:Array.from(u)[0]}}):!h&&!S?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Ie(c,e),actualType:je(u),conditionType:p}}):h&&S&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Ie(c,e),actualType:je(u),conditionType:p}}):!h&&!S?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Ie(c,e),actualType:je(u),conditionType:p}}):!h&&S&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Ie(c,e),type:je(u)}})}return{BinaryExpression:s}}})};function je(e){return Array.from(new Set(e)).join(" | ")||"never"}function Ie(e,t){let r=e.argument;return r.type===Se.AST_NODE_TYPES.Identifier?r.name:t.sourceCode.getText(r)}function Sr(e,t){return t.has(e)}var Le=require("@typescript-eslint/utils");var Tr=Le.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt="no-call-with-explicit-generics",hr=W({functions:q(V())}),Er=Tr({name:Bt,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:[hr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===Le.AST_NODE_TYPES.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),tt={name:Bt,rule:Er};var he=require("@typescript-eslint/utils"),br=he.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-call-with-inferred-generics",xr=br({name:Jt,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!==he.AST_NODE_TYPES.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(s||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&n.typeArguments?.params?.some(p=>!i&&p.type===he.AST_NODE_TYPES.TSAnyKeyword||l&&p.type===he.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===he.AST_NODE_TYPES.Identifier&&l.includes(p.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),nt={name:Jt,rule:xr};var qt=require("@typescript-eslint/utils"),wr=qt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="no-commented-out-code",Ir=["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:"],Cr=[") {","return;",/^\s*return\s+/,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",/\w=("|'|`)/,");",/\w+:\s*('|"|`)/,/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,/\w+-\w+:/,/\w+_\w+:/,"&&","||","()",/\?\s+\w/,/:\s+\w/,/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,/^\s*\d+[,}]/,/^\s*\[[^\]]*\][,}]/,/^\s*\{[^}]*\}[,}]/,/\.\w+\(/,/\[\w+\]/,"?.(","??","=>",/^\s*(['"`]).+?\1\s*:/],Rr=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Xt=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Ar=wr({name:Kt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with 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")||/^\s*[*\s]*$/.test(n))return!1;for(let s of Xt)if(a.startsWith(s))return!1;if(n.includes("https://"))return!1;if(o==="Block"){for(let s of Rr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of Ir)if(a.startsWith(s))return{wrongPattern:s};for(let s of Cr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}function r(n,o){let a=n,s=a.trim();if(s.startsWith("`")&&(s.endsWith("`,")||s.endsWith("`;")||s.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let c=a.split(/```[\s\S]*?```/g);c.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=c.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(c=>/[a-zA-Z0-9]/.test(c))?i.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let s=r(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Xt.join(", ")}})}}}}}),rt={name:Kt,rule:Ar};var Me=require("@typescript-eslint/utils"),kr=Me.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="no-default-export",vr=kr({name:Gt,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===Me.TSESTree.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),it={name:Gt,rule:vr};var Zt=require("@typescript-eslint/utils"),Or=Zt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="no-leaked-text-in-jsx",Pr=[",",";","[","]","(",")"],Fr=Or({name:Qt,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="";Pr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),st={name:Qt,rule:Fr};var Te=require("@typescript-eslint/utils"),Nr=Te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-non-camel-case-functions",Dr=/^(\$?[a-z][a-zA-Z0-9]*)$/;function en(e){if(e.typeName.type!==Te.AST_NODE_TYPES.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Te.AST_NODE_TYPES.Identifier&&t.name==="JSX"&&r.name==="Element"}var jr=Nr({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&&!Dr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Te.AST_NODE_TYPES.TSTypeReference?en(r):r.type===Te.AST_NODE_TYPES.TSUnionType&&r.types.some(o=>o.type===Te.AST_NODE_TYPES.TSTypeReference&&en(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ot={name:tn,rule:jr};var z=require("@typescript-eslint/utils");var at=require("@typescript-eslint/utils");function Ce(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Ce(e.parent,t,r===1/0?r:r-1)}function*lt(e){yield e,e.parent&&(yield*lt(e.parent))}function ct(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function nn(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===at.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===at.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Lr=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rn="no-optional-root-props",Mr=Lr({name:rn,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 s=a.references[0];if(!s)return!1;for(let i of lt(s.identifier)){if("returnType"in i||i.type===z.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===z.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===z.TSESTree.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===z.TSESTree.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=Ce(l.parent.parent,z.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=_e(p,e.sourceCode);return u?!(u.parent.type===z.TSESTree.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===z.TSESTree.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===z.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===z.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let c=Ce(l,z.TSESTree.AST_NODE_TYPES.VariableDeclaration);return c?!!_e(c,e.sourceCode):!1}if(l.type===z.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!_e(l,e.sourceCode)}return!1}function r(n){n.key.type!==z.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=Ce(n,z.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let s=e.sourceCode.getText(a);return o.replaceText(a,s.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===z.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!($e(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===z.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!($e(n)||!t(n)))for(let o of n.body.body)o.type===z.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==z.TSESTree.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==z.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=Ce(n.parent,z.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=_e(a,e.sourceCode);if(!(!s||s.parent.type===z.TSESTree.AST_NODE_TYPES.CallExpression&&s.parent.callee.type===z.TSESTree.AST_NODE_TYPES.Identifier&&s.parent.callee.name==="memo"))for(let l of o.members)l.type===z.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function $e(e){return e?e.parent?.type===z.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===z.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function _e(e,t){if($e(e))return;let r;if(e.type===z.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===z.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===z.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(s=>s.identifiers.includes(r));if(!o)return;let a=o.references.filter(s=>s.identifier!==r);if(!(a.length!==1||!a[0])&&!$e(a[0].identifier.parent.parent))return a[0].identifier}var pt={name:rn,rule:Mr};var sn=require("@typescript-eslint/utils"),ze=Oe(require("path"));var _r=sn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-relative-imports",$r=W({find:V(),replacement:V()}),zr=W({aliases:q($r),rootDir:_(V()),allowNotFoundAliases:_(we()),_dev_simulateFileName:_(V())}),Ur=_r({name:on,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:[zr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=ze.default.dirname(i);return ze.default.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=ze.default.relative(i,s);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let u=l.replace(p,c);return{alias:c,newPath:u}}return null}return{ImportDeclaration(s){let i=s.source.value;if(!n(i))return;let l=o(i,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:s,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(s.source,`'${c.newPath}'`):void 0})}}}}),ut={name:on,rule:Ur};var Ee=require("@typescript-eslint/utils");var Vr="no-unnecessary-async-on-jsx-props";function Wr(e){if(e.body.type!==Ee.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!==Ee.AST_NODE_TYPES.ExpressionStatement?!1:r.expression.type===Ee.AST_NODE_TYPES.AwaitExpression}var ft=ie({name:Vr,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){Wr(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let o=e.sourceCode,a=[],s=o.getFirstToken(r,l=>l.value==="async");if(s){let l=o.getTokenAfter(s);l?a.push(n.replaceTextRange([s.range[0],l.range[0]],"")):a.push(n.remove(s))}function i(l){if(l.type===Ee.AST_NODE_TYPES.AwaitExpression){let c=o.getFirstToken(l);if(c&&c.value==="await"){let p=o.getTokenAfter(c);p?a.push(n.replaceTextRange([c.range[0],p.range[0]],"")):a.push(n.remove(c))}}if(l.type===Ee.AST_NODE_TYPES.BlockStatement)for(let c of l.body)i(c);else l.type===Ee.AST_NODE_TYPES.ExpressionStatement&&i(l.expression)}return i(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});var de=require("@typescript-eslint/utils");var mt=Oe(require("typescript")),Hr=de.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="no-unnecessary-casting",Yr=W({additionalCastFunctions:_(q(W({name:V(),expectedType:Ft(["string","number"])})))}),dt={name:an,rule:Hr({name:an,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:[Yr],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=de.ESLintUtils.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function s(p,u){switch(p.type){case de.AST_NODE_TYPES.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case de.AST_NODE_TYPES.TemplateLiteral:return u==="string";case de.AST_NODE_TYPES.UnaryExpression:return u==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,u){return u==="number"?!!(p.flags&mt.TypeFlags.NumberLike):!!(p.flags&mt.TypeFlags.StringLike)}function l(p,u){return S=>S.replaceText(p,e.sourceCode.getText(u))}function c(p){if(!a||p.arguments.length!==1)return;let u=p.arguments[0];if(!u||u.type===de.AST_NODE_TYPES.SpreadElement)return;let{callee:S}=p;if(S.type!==de.AST_NODE_TYPES.Identifier)return;let h=S.name,x=n.find(k=>k.name===h);if(!x)return;if(s(u,x.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),x.expectedType)){let k,w;h==="Number"?k="unnecessaryNumberCasting":h==="String"?k="unnecessaryStringCasting":(k="unnecessaryCustomCasting",w={name:x.name,type:x.expectedType}),e.report({node:p,messageId:k,...w?{data:w}:{},fix:l(p,u)})}}return{CallExpression:c}}})};var Pe=require("@typescript-eslint/utils"),se=Oe(require("zod/v4"));var Br=se.object({methods:se.union([se.array(se.string()),se.literal("array")])}),yt=ie({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:[se.toJSONSchema(Br)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===Pe.AST_NODE_TYPES.MemberExpression){let c=l.property;if(c.type===Pe.AST_NODE_TYPES.Identifier)return c.name}return null}function s(i,l){if(i.type!==Pe.AST_NODE_TYPES.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===Pe.AST_NODE_TYPES.CallExpression){let p=a(c);p&&o(p)&&c.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(S){return S.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)s(l,i)},FunctionExpression(i){for(let l of i.params)s(l,i)}}}});var ne=require("@typescript-eslint/utils");var gt=ie({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===ne.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==ne.AST_NODE_TYPES.ObjectExpression||t.id.type===ne.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ne.AST_NODE_TYPES.ExportNamedDeclaration)return;let r=new Map;for(let s of t.init.properties)s.type===ne.AST_NODE_TYPES.Property&&s.key.type===ne.AST_NODE_TYPES.Identifier&&r.set(s.key.name,s);if(r.size===0||t.id.type!==ne.AST_NODE_TYPES.Identifier)return;let n=Jr(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(s=>s.type!==ne.AST_NODE_TYPES.Property?!1:s.value.type===ne.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let s of n){if(s.identifier.parent.type!==ne.AST_NODE_TYPES.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===ne.AST_NODE_TYPES.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==ne.AST_NODE_TYPES.Identifier)return;a.add(i.property.name)}if(i.parent.type===ne.AST_NODE_TYPES.CallExpression&&o)return}for(let[s,i]of r)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function Jr(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 U=require("@typescript-eslint/utils");var Xr=W({selectors:q(W({name:V(),selectorProp:_(V()),selectorArgPos:_(ce()),returnProp:_(V())}))}),qr=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ln="no-unused-selected-values",St={name:ln,rule:qr({name:ln,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Xr]},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===U.AST_NODE_TYPES.CallExpression&&(a=o.init),!a)return;let s=Gr(a);if(!s)return;let i=n.get(s);if(!i)return;let l=Kr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=Zr(l);if(!c)return;let p=cn(c.properties,void 0);if(!p)return;if(o.id.type===U.AST_NODE_TYPES.ObjectPattern){let h=cn(o.id.properties,i.returnProp);if(!h)return;for(let[x,b]of p)h.has(x)||e.report({node:b,messageId:"unusedSelectedValue",data:{name:x}});return}if(o.id.type!==U.AST_NODE_TYPES.Identifier||i.returnProp)return;let u=Qr(o,e.sourceCode);if(u.length===0)return;let S=new Set;for(let h of u){if(h.identifier.parent.type!==U.AST_NODE_TYPES.MemberExpression)return;let x=h.identifier.parent.property;if(x.type!==U.AST_NODE_TYPES.Identifier)return;S.add(x.name)}for(let[h,x]of p)S.has(h)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:h}})}}}})};function Kr(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===U.AST_NODE_TYPES.ArrowFunctionExpression||n.type===U.AST_NODE_TYPES.FunctionExpression)return n;if(r&&n.type===U.AST_NODE_TYPES.ObjectExpression){let o=n.properties.find(s=>s.type===U.AST_NODE_TYPES.Property&&s.key.type===U.AST_NODE_TYPES.Identifier&&s.key.name===r);if(o?.type!==U.AST_NODE_TYPES.Property)return null;let a=o.value;if(a.type===U.AST_NODE_TYPES.ArrowFunctionExpression||a.type===U.AST_NODE_TYPES.FunctionExpression)return a}return null}function Gr(e){return e.callee.type===U.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===U.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===U.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Zr(e){if(e.body.type===U.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===U.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===U.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==U.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function cn(e,t){let r=e;if(t){let o=e.find(a=>a.type===U.AST_NODE_TYPES.Property&&a.key.type===U.AST_NODE_TYPES.Identifier&&a.key.name===t);if(o?.type!==U.AST_NODE_TYPES.Property||o.value.type!==U.AST_NODE_TYPES.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==U.AST_NODE_TYPES.Property||o.key.type!==U.AST_NODE_TYPES.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function Qr(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 H=require("@typescript-eslint/utils");var Tt=ie({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===H.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let i=ei(a);i&&(n=i);return}let s=ti(a,e.sourceCode);if(s){o=!0;for(let i of s)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function ei(e){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==H.AST_NODE_TYPES.ObjectExpression)return null;let n=ct(r.properties,a=>a.type!==H.AST_NODE_TYPES.Property||a.key.type!==H.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===H.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===H.AST_NODE_TYPES.FunctionExpression?ni(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===H.AST_NODE_TYPES.Property&&a.key.type===H.AST_NODE_TYPES.Identifier&&o.set(a.key.name,a);return o}function ti(e,t){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==H.AST_NODE_TYPES.ObjectPattern||!ct(e.parent.id.properties,s=>s.type===H.AST_NODE_TYPES.Property&&s.key.type===H.AST_NODE_TYPES.Identifier&&s.key.name==="formFields"&&s))return null;let o=nn(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==H.AST_NODE_TYPES.Identifier||s.parent.type===H.AST_NODE_TYPES.Property&&s.parent.parent.type===H.AST_NODE_TYPES.ObjectExpression&&s.parent.parent.parent.type===H.AST_NODE_TYPES.ReturnStatement||s.parent.type===H.AST_NODE_TYPES.ReturnStatement)return null;if(s.parent.type===H.AST_NODE_TYPES.MemberExpression){if(s.parent.object.type!==H.AST_NODE_TYPES.Identifier||s.parent.property.type!==H.AST_NODE_TYPES.Identifier)return null;a.add(s.parent.property.name)}}return a}function ni(e){if(e.body.type===H.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===H.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===H.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var $=require("@typescript-eslint/utils");var ri=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function pn(e){let t=[];for(let r of e.members)r.type===$.AST_NODE_TYPES.TSPropertySignature&&r.key.type===$.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function un(e,...t){for(let r of t)e.set(...r);return e}var ii=W({forceCheckOnFCPropTypesWithName:_(q(V()))}),fn="no-unused-type-props-in-args",ht=null,si=ri({name:fn,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:[ii],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!ht&&(ht=r.map(i=>new RegExp(i)));function n(i,l,c,p,u=!0){let S=c.name,h=e.sourceCode.getScope(l).references.find(k=>k.identifier.name===S)?.resolved,x=i&&ht?.some(k=>k.test(S));if(!h||!x&&h.references.filter(k=>k.isTypeReference).length>1)return;let b=h?.defs[0]?.node;if(!(u&&b?.parent?.type===$.AST_NODE_TYPES.ExportNamedDeclaration)){if(b?.type===$.AST_NODE_TYPES.TSTypeAliasDeclaration){o(i,l,p,b.typeAnnotation,!0);return}if(b?.type===$.AST_NODE_TYPES.TSInterfaceDeclaration){o(i,l,p,b.body,!0);return}}}function o(i,l,c,p,u){if(p.type===$.AST_NODE_TYPES.TSInterfaceBody){for(let S of p.body)S.type===$.AST_NODE_TYPES.TSPropertySignature&&S.key.type===$.AST_NODE_TYPES.Identifier&&c.set(S.key.name,S);return}if(p.type===$.AST_NODE_TYPES.TSTypeLiteral){un(c,...pn(p));return}if(p.type===$.AST_NODE_TYPES.TSIntersectionType){for(let S of p.types)o(i,l,c,S,!0);return}u||p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier&&n(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let u=new Map;if(o(i,l,u,p.typeAnnotation.typeAnnotation,!1),u.size===0)continue;s(p,u)}else p.type===$.AST_NODE_TYPES.AssignmentPattern&&p.left.type===$.AST_NODE_TYPES.ObjectPattern&&a(i,l,[p.left])}function s(i,l){let c=[];if(i.properties.at(-1)?.type===$.AST_NODE_TYPES.RestElement)return;for(let h of i.properties)h.type===$.AST_NODE_TYPES.Property&&h.key.type===$.AST_NODE_TYPES.Identifier&&c.push(h.key.name);let u=[],S=[];for(let[h,x]of l)c.includes(h)||(S.push(h),u.push({node:x,messageId:"unusedObjectTypeProperty",data:{propertyName:h}}));for(let[h,x]of u.entries())e.report({...x,fix:h===u.length-1?b=>{let k=i.properties.at(-1),w=S.join(", ");return k?k?.type===$.AST_NODE_TYPES.RestElement?null:b.insertTextAfter(k,`, ${w}`):b.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${w}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let c=new Map,p=l.id.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===$.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===$.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(p){if(p.type===$.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===$.AST_NODE_TYPES.Identifier)n(!0,i,p.typeName,c,!1);else if(p.type===$.AST_NODE_TYPES.TSTypeLiteral)un(c,...pn(p));else if(p.type===$.AST_NODE_TYPES.TSIntersectionType)for(let u of p.types)u.type===$.AST_NODE_TYPES.TSTypeReference&&u.typeName.type===$.AST_NODE_TYPES.Identifier?n(!0,i,u.typeName,c,!1):o(!0,i,c,u,!0);if(c.size!==0&&l.init?.type===$.AST_NODE_TYPES.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===$.AST_NODE_TYPES.ObjectPattern&&s(u,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),Et={name:fn,rule:si};var Re=require("@typescript-eslint/utils"),oi=Re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="prefer-named-functions",mn=new Map,ai=oi({name:dn,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=mn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),mn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Re.AST_NODE_TYPES.ArrowFunctionExpression&&n.id.type===Re.AST_NODE_TYPES.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Re.AST_NODE_TYPES.BlockStatement)return;let a=n.parent,s=n.init.params,i=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:c=>c.replaceText(a,`${l.async?"async ":""}function ${o}(${s.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),bt={name:dn,rule:ai};var N=require("@typescript-eslint/utils");var li=W({disallowedFunctions:q(W({name:V(),allowUsingWithArgs:_(we()),hookAlternative:_(V()),message:_(V()),allowUseInside:_(q(V()))}))});function Ue(e){return/^use[A-Z]/.test(e)}function yn(e){return/^[A-Z]/.test(e)}function ci(e){return e.type===N.AST_NODE_TYPES.Identifier?Ue(e.name):e.type===N.AST_NODE_TYPES.MemberExpression&&e.property.type===N.AST_NODE_TYPES.Identifier?Ue(e.property.name):!1}function gn(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 Sn(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&gn(e.parent.callee,"forwardRef"))}function Tn(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&gn(e.parent.callee,"memo"))}function xt(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 pi(e){let t=e.parent,r=!1;for(;t;){if(t.type===N.AST_NODE_TYPES.FunctionDeclaration||t.type===N.AST_NODE_TYPES.FunctionExpression||t.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let n=xt(t);if(n&&n.type===N.AST_NODE_TYPES.Identifier){if(yn(n.name)||Ue(n.name))return!r;r=!0}else{if(Sn(t)||Tn(t))return!r;if(t.parent.type===N.AST_NODE_TYPES.CallExpression){let o=t.parent;ci(o.callee)||(r=!0)}else t.parent.type===N.AST_NODE_TYPES.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function hn(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 ui(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===N.AST_NODE_TYPES.FunctionDeclaration||r.type===N.AST_NODE_TYPES.FunctionExpression||r.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let n=xt(r);if(n&&n.type===N.AST_NODE_TYPES.Identifier&&t.includes(n.name))return!0}else if(r.type===N.AST_NODE_TYPES.CallExpression){let n=hn(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===N.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function mi(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===N.AST_NODE_TYPES.FunctionDeclaration||n.type===N.AST_NODE_TYPES.FunctionExpression||n.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let o=xt(n);if(o&&o.type===N.AST_NODE_TYPES.Identifier){if(yn(o.name)||Ue(o.name)){r=!0;break}}else if(Sn(n)||Tn(n)){r=!0;break}}n=n.parent}return r?t.length===0?pi(e):!ui(e,t):!1}var wt=ie({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:[li],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=hn(o);if(!a)return;let s=n.get(a);if(!s||s.allowUsingWithArgs&&fi(o))return;let i=s.allowUseInside||[];mi(o,i)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:s.message?` ${s.message}`:` use ${s.hookAlternative} instead`},suggest:s.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${s.hookAlternative}`,hookAlternative:s.hookAlternative},fix:l=>{let c=s.hookAlternative;return o.callee.type===N.AST_NODE_TYPES.Identifier?l.replaceText(o.callee,c):o.callee.type===N.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===N.AST_NODE_TYPES.Identifier?l.replaceText(o.callee.property,c):null}}]:[]})}}}});var B=require("@typescript-eslint/utils");var di=B.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bn="prefer-single-line-if",yi=W({maxLineLength:_(ce()),maxNonSimpleConditionLength:_(ce())}),gi=di({name:bn,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:[yi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==B.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===B.AST_NODE_TYPES.ReturnStatement){if(!wn(a))return}else if(!(a.type===B.AST_NODE_TYPES.ContinueStatement||a.type===B.AST_NODE_TYPES.BreakStatement))return;if(n.test.type===B.AST_NODE_TYPES.LogicalExpression||n.test.type===B.AST_NODE_TYPES.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=En(n.test);if(!u&&n.test.type===B.AST_NODE_TYPES.UnaryExpression&&n.test.operator==="!"){let S=n.test.argument;En(S)&&(u=!0)}if(u&&(s=r.getText(n.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=r.getText(n.test));let i=r.getText(a);if(s.includes(`
|
|
16
|
+
`))return;let l=r.getTokenAfter(n);if(l&&l.type===B.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let u=r.getTokenAfter(l);if(u&&u.type===B.AST_TOKEN_TYPES.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=Si(r,n),p=`if (${s}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:u=>u.replaceText(n,p)})}}}});function En(e){return e.type===B.AST_NODE_TYPES.CallExpression||e.type===B.AST_NODE_TYPES.BinaryExpression||e.type===B.AST_NODE_TYPES.MemberExpression&&xn(e)}function xn(e){return e.object.type===B.AST_NODE_TYPES.MemberExpression?xn(e.object):e.object.type!==B.AST_NODE_TYPES.Identifier}function Si(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function wn(e){if(!e.argument)return!0;let t=e.argument;return t.type===B.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===B.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===B.AST_NODE_TYPES.Literal||t.type===B.AST_NODE_TYPES.Identifier||t.type===B.AST_NODE_TYPES.TemplateLiteral||t.type===B.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===B.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===B.AST_NODE_TYPES.UnaryExpression?wn(t):!1}var It={name:bn,rule:gi};var ee=require("@typescript-eslint/utils");var Ti=ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),In="react-compiler-migration",hi=W({disallowHooks:_(q(W({name:V(),replacement:V()}))),disallowMethods:_(q(W({name:V(),replacement:_(V()),requireTrueProp:_(V())})))}),Ei=/eslint +react-compiler\/react-compiler: +\["error/;function bi(e){return e.type===ee.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===ee.AST_NODE_TYPES.MemberExpression&&e.property.type===ee.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var xi=Ti({name:In,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(Ei.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===ee.AST_NODE_TYPES.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===ee.AST_NODE_TYPES.MemberExpression&&n.callee.property.type===ee.AST_NODE_TYPES.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let s=t.disallowHooks.find(i=>i.name===o);s&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:i=>i.replaceText(a,s.replacement)}]})}}if(t.disallowMethods?.length&&bi(n.callee)){for(let o of n.arguments)if(o.type===ee.AST_NODE_TYPES.ObjectExpression){for(let a of o.properties)if(a.type===ee.AST_NODE_TYPES.Property&&a.key.type===ee.AST_NODE_TYPES.Identifier){let s=a.key.name,i=t.disallowMethods.find(l=>l.name===s);if(i){if(i.requireTrueProp){let l=i.requireTrueProp,c=!1;for(let p of o.properties)if(p.type===ee.AST_NODE_TYPES.Property&&p.key.type===ee.AST_NODE_TYPES.Identifier&&p.key.name===l&&p.value.type===ee.AST_NODE_TYPES.Literal&&p.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:l}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),Ct={name:In,rule:xi};var Ve=require("@typescript-eslint/utils"),wi=Ve.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cn="require-description",Ii=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Ci=/^eslint-disable-(next-)?line$/u,Ri=wi({name:Cn,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=Ai(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:vi(o.loc),messageId:"missingDescription"}))}}}}}),Rn={name:Cn,rule:Ri};function Ai(e){let{text:t,description:r}=ki(e.value);if(!t)return null;let n=Ii.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=Ci.test(o);if(e.type===Ve.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let s=t.slice(n.index+o.length);return{kind:o,value:s.trim(),description:r}}function ki(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function vi(e){return{start:{line:e.start.line,column:-1},end:e.end}}function vn(e){return/^use[A-Z0-9]/.test(e)}function We(e){return e.type==="Identifier"?vn(e.name):e.type==="MemberExpression"&&!e.computed&&We(e.property)?e.object.type==="Identifier":!1}function On(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Pn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Fn(e){return!!(e.parent&&e.parent.callee&&Pn(e.parent.callee,"forwardRef"))}function Nn(e){return!!(e.parent&&e.parent.callee&&Pn(e.parent.callee,"memo"))}function Rt(e){for(;e;){let t=jn(e);if(t&&(On(t)||We(t))||Fn(e)||Nn(e))return!0;e=e.parent}return!1}function An(e){return!1}function At(e){return!1}var Oi=/eslint +react-compiler\/react-compiler: +\["error/,Dn={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(Oi.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,o=[],a=[],s=new WeakSet;function i(l){for(let c of l.references){let p=c.identifier.parent;if(p.type==="VariableDeclarator"&&p.init&&p.init.type==="CallExpression"&&p.init.callee&&An(p.init.callee))for(let u of c.resolved.references)u!==c&&s.add(u.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,c){let p=o.pop();if(p.size===0)return;let u=new Set;function S(T,m){let{cache:y}=S,R=y.get(T.id),C=new Set(m);if(C.has(T.id)){let E=[...C],F=E.slice(E.indexOf(T.id)+1);for(let Y of F)u.add(Y);return BigInt("0")}if(C.add(T.id),R!==void 0)return R;if(l.thrownSegments.includes(T))R=BigInt("0");else if(T.prevSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let E of T.prevSegments)R+=S(E,C)}return T.reachable&&R===BigInt("0")?y.delete(T.id):y.set(T.id,R),R}function h(T,m){let{cache:y}=h,R=y.get(T.id),C=new Set(m);if(C.has(T.id)){let E=Array.from(C),F=E.slice(E.indexOf(T.id)+1);for(let Y of F)u.add(Y);return BigInt("0")}if(C.add(T.id),R!==void 0)return R;if(l.thrownSegments.includes(T))R=BigInt("0");else if(T.nextSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let E of T.nextSegments)R+=h(E,C)}return y.set(T.id,R),R}function x(T){let{cache:m}=x,y=m.get(T.id);if(y===null)return 1/0;if(y!==void 0)return y;if(m.set(T.id,null),T.prevSegments.length===0)y=1;else{y=1/0;for(let R of T.prevSegments){let C=x(R);C<y&&(y=C)}y+=1}return m.set(T.id,y),y}S.cache=new Map,h.cache=new Map,x.cache=new Map;let b=h(l.initialSegment),k=jn(c),w=Rt(c),L=k?On(k)||We(k):Fn(c)||Nn(c),P=1/0;for(let T of l.finalSegments){if(!T.reachable)continue;let m=x(T);m<P&&(P=m)}for(let[T,m]of p){if(!T.reachable)continue;let y=T.nextSegments.length===0?P<=x(T):P<x(T),R=S(T)*h(T),C=u.has(T.id);for(let E of m)if(C&&!At(E)&&e.report({node:E,message:`React Hook "${t(E)}" 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(c.async&&e.report({node:E,message:`React Hook "${t(E)}" cannot be called in an async function.`}),!C&&R!==b&&!At(E)){let Y=`React Hook "${t(E)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(y?" Did you accidentally call a React Hook after an early return?":"");e.report({node:E,message:Y})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let F=`React Hook "${t(E)}" 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:E,message:F})}else if(k){let F=`React Hook "${t(E)}" is called in function "${t(k)}" 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:E,message:F})}else if(c.type==="Program"){let F=`React Hook "${t(E)}" 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:E,message:F})}else if(w&&!At(E)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let Y=c.parent;if(Y.parent.type==="VariableDeclarator"&&vn(Y.parent.id.name))return}let F=`React Hook "${t(E)}" 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:E,message:F})}}},CallExpression(l){if(We(l.callee)){let c=kn(o),p=kn(a),u=c.get(p);u||(u=[],c.set(p,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||An(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&s.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){Rt(l)&&i(r(l))},ArrowFunctionExpression(l){Rt(l)&&i(r(l))}}}};function jn(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 kn(e){return e[e.length-1]}var Ln={[Et.name]:Et.rule,[rt.name]:rt.rule,[nt.name]:nt.rule,"rules-of-hooks":Dn,"exhaustive-deps":Ut,"require-description":Rn.rule,[it.name]:it.rule,[ot.name]:ot.rule,[bt.name]:bt.rule,[Xe.name]:Xe.rule,[tt.name]:tt.rule,[ut.name]:ut.rule,[It.name]:It.rule,[pt.name]:pt.rule,[st.name]:st.rule,[Ke.name]:Ke.rule,[Ct.name]:Ct.rule,[Je.name]:Je.rule,[et.name]:et.rule,[dt.name]:dt.rule,[yt.name]:yt.rule,[St.name]:St.rule,[Tt.name]:Tt.rule,[gt.name]:gt.rule,[wt.name]:wt.rule,[ft.name]:ft.rule};var Pi={rules:Ln};0&&(module.exports={extendedLintPlugin});
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{AST_NODE_TYPES as X,ESLintUtils as Ln}from"@typescript-eslint/utils";var $e=Symbol.for("optional");function P(e){return{...e,[$e]:!0}}function Ce(e,t){return{enum:e,...t}}function le(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function K(e){return{...e,type:"number"}}function Ue(e){return{...e,type:"integer"}}function V(e,t){return{...t,type:"array",items:e}}function D(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][$e]?e[n][$e]=void 0:o.push(n);o.length>0&&(r.required=o)}return r}function Re(...e){return{anyOf:e}}var Mn=Ln.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="react-compiler-extra",_n=D({runOnlyWithEnableCompilerDirective:P(le())}),$n=/eslint +react-compiler\/react-compiler: +\["error/;function Un(e){return e.type===X.Identifier?e.name.startsWith("use"):e.type===X.MemberExpression&&e.property.type===X.Identifier?e.property.name.startsWith("use"):!1}var Vn=/\bthis[.[]/;function Rt(e){return Vn.test(e)}var Wn=Mn({name:At,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[_n]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if($n.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let s of a.properties)if(s.type===X.Property&&s.method&&s.value.type===X.FunctionExpression){let i=e.sourceCode,l=i.getText(s.key),c=s.value,p=i.getText(c.body);if(Rt(p))e.report({node:s,messageId:"thisKeywordInMethod"});else{let u=c.params.map(S=>i.getText(S)).join(", "),g="";c.generator?g=`${l}: function* (${u}) ${p}`:g=`${l}: (${u}) => ${p}`,e.report({node:s,messageId:"objectMethodIsNotSupported",fix:S=>S.replaceText(s,g)})}}}function o(a){for(let s of a.properties)if(s.type===X.Property&&s.value.type===X.ObjectExpression){for(let i of s.value.properties)if(i.type===X.Property&&i.method&&i.value.type===X.FunctionExpression){let c=e.sourceCode.getText(i.value.body);Rt(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Un(a.callee))for(let s of a.arguments){if(s.type===X.ObjectExpression&&(n(s),o(s)),s.type===X.ArrowFunctionExpression&&(s.body.type===X.ObjectExpression&&(n(s.body),o(s.body)),s.body.type===X.BlockStatement))for(let i of s.body.body)i.type===X.ReturnStatement&&i.argument?.type===X.ObjectExpression&&(n(i.argument),o(i.argument));if(s.type===X.FunctionExpression)for(let i of s.body.body)i.type===X.ReturnStatement&&i.argument?.type===X.ObjectExpression&&(n(i.argument),o(i.argument))}}}}}),Ve={name:At,rule:Wn};import{AST_NODE_TYPES as te}from"@typescript-eslint/utils";import{ESLintUtils as Hn}from"@typescript-eslint/utils";function ee(e){let r=Hn.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}var Yn=D({disallow:P(V(D({selector:F(),message:F(),replace:P(Re(F(),D({regex:F(),with:F()}))),replaceType:P(Ce(["suggestion","autofix"]))}))),disallowFnCalls:P(V(D({fn:F(),withArgs:P(V(D({atIndex:Ue(),value:Re(F(),K(),le())}))),message:F(),replaceWith:P(F()),ignoreRegex:P(F())}))),__dev_simulateFileName:P(F()),mustMatchSyntax:P(V(D({includeRegex:F(),mustCallFn:P(V(D({anyCall:V(D({fn:F(),withArgs:V(D({atIndex:Ue(),literal:Re(F(),K(),le())}))})),message:P(F())}))),mustMatchSelector:P(V(D({selector:F(),message:F()})))})))}),We=ee({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Yn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:o,disallow:a,disallowFnCalls:s}=t,i=o??e.filename,l=[],c=new Map,p=new Set,u=new Map,g=new Map;function S(d){for(let m of d.specifiers)m.type===te.ImportSpecifier&&m.imported.type===te.Identifier&&m.local.type===te.Identifier&&m.imported.name!==m.local.name&&g.set(m.local.name,m.imported.name)}function h(d){d.id.type===te.Identifier&&d.init?.type===te.Identifier&&g.set(d.id.name,d.init.name)}function T(d){return g.get(d)??d}function I(d,m){return T(d)===m||d===m}for(let{includeRegex:d,mustCallFn:m,mustMatchSelector:A}of n??[]){let R=zn(i,new RegExp(d));if(!R)continue;let v=O=>{let x=O;for(let{name:_,value:z}of R)x=x.replaceAll(_,z);return x};for(let{anyCall:O,message:x}of m??[]){let _=`Expected file to call the function: ${O.map(({fn:z})=>z).join(" or ")}`;p.add(_),l.push(z=>{let{callee:oe}=z;if(oe.type===te.Identifier){for(let{fn:je,withArgs:Ee}of O)if(oe.name===je){p.delete(_);for(let pe of Ee){let J=z.arguments[pe.atIndex],ie=typeof pe.literal=="string"?v(pe.literal):pe.literal;if(!J){e.report({node:z,messageId:"default",data:{message:`Missing argument with value "${ie}" at index ${pe.atIndex}${x?`: ${v(x)}`:""}`}});continue}if(J.type!==te.Literal){e.report({node:J,messageId:"default",data:{message:`Argument at position ${pe.atIndex} should the literal "${ie}"${x?`: ${v(x)}`:""}`}});continue}J.value!==ie&&e.report({node:J,messageId:"default",data:{message:`Argument should have the value "${ie}"${x?`: ${v(x)}`:""}`},fix:be=>be.replaceText(J,typeof ie=="string"?`'${ie}'`:String(ie))})}break}}})}for(let{selector:O,message:x}of A??[])u.set(O,v(x)),c.set(v(O),()=>{u.delete(O)})}for(let{fn:d,withArgs:m,message:A,replaceWith:R,ignoreRegex:v}of s??[])v&&new RegExp(v).test(i)||l.push(O=>{let{callee:x}=O;if(x.type!==te.Identifier||!I(x.name,d))return;if(m)for(let z of m){let oe=O.arguments[z.atIndex];if(!oe){e.report({node:O,messageId:"default",data:{message:`Missing argument with value "${z.value}" at index ${z.atIndex}: ${A}`}});return}if(oe.type!==te.Literal||oe.value!==z.value)return}let _=z=>R?z.replaceText(O,R):null;e.report({node:O,messageId:"default",data:{message:A},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:_}]:void 0})});function E(d,m){let A=r[d];A?r[d]=R=>{A(R),m(R)}:r[d]=m}for(let{selector:d,message:m,replace:A,replaceType:R="suggestion"}of a??[]){if(d==="CallExpression"){l.push(v=>{M(A,v,m,R)});continue}r[d]=v=>{M(A,v,m,R)}}if(c.size>0)for(let[d,m]of c)E(d,m);return l.length>0&&(r.CallExpression=d=>{if(d.type===te.CallExpression)for(let m of l)m(d)}),r.ImportDeclaration=d=>{d.type===te.ImportDeclaration&&S(d)},r.VariableDeclarator=d=>{d.type===te.VariableDeclarator&&h(d)},r["Program:exit"]=d=>{for(let m of p)e.report({node:d,messageId:"default",data:{message:m}});for(let[,m]of u)e.report({node:d,messageId:"default",data:{message:m}})},r;function M(d,m,A,R){let v=O=>{if(!d)return null;if(typeof d=="string")return O.replaceText(m,d);{let x=new RegExp(d.regex),_=e.sourceCode.getText(m);return O.replaceText(m,_.replace(x,d.with))}};e.report({node:m,messageId:"default",data:{message:A},fix:d&&R==="autofix"?v:void 0,suggest:d&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof d=="string"?d:d.with}"`},fix:v}]:void 0})}}});function zn(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:kt(o)}),r.push({name:"$0_uncapitalize",value:vt(o)}),r.push({name:"$0",value:o});for(let s=0;s<a.length;s++){let i=`$${s+1}`,l=a[s];r.push({name:`${i}_lowercase`,value:l.toLowerCase()}),r.push({name:`${i}_capitalize`,value:kt(l)}),r.push({name:`${i}_uncapitalize`,value:vt(l)}),r.push({name:i,value:l})}return r}function kt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function vt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as $,AST_TOKEN_TYPES as Ot,ESLintUtils as Bn}from"@typescript-eslint/utils";var Jn=Bn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="collapse-simple-objs-in-one-line",Xn=D({maxLineLength:P(K()),maxProperties:P(K()),nestedObjMaxLineLength:P(K()),nestedObjMaxProperties:P(K()),ignoreTypesWithSuffix:P(V(F()))}),qn=Jn({name:Ft,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[Xn]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,s=t.nestedObjMaxProperties??3;function i(c){if(c.type===$.ObjectExpression){let p=c.parent.type===$.Property,u=p?s:o,g=c.properties.length;if(g>u)return!1;if(g===1){let h=c.properties[0];return h.type===$.Property&&h.value.type===$.ObjectExpression||h.type===$.Property&&h.value.type===$.ArrayExpression&&!h.value.elements.every(I=>I&&He(I))?!1:{text:r.getText(h),isNested:p,propsSize:g}}let S=[];for(let h of c.properties){if(h.type===$.Property&&!He(h.value))return!1;S.push(r.getText(h))}return{text:S.join(", "),isNested:p,propsSize:g}}else{let p=c.parent.parent?.type===$.TSPropertySignature,u=p?s:o,g=c.members.length;if(g>u)return!1;if(n.length>0&&c.parent.type===$.TSTypeAliasDeclaration){let h=c.parent.id.name;if(n.some(T=>h.endsWith(T)))return!1}if(g===1){let h=c.members[0];return h.type===$.TSPropertySignature&&h.typeAnnotation?.typeAnnotation.type===$.TSTypeLiteral?!1:{text:r.getText(h),isNested:p,propsSize:1}}if(c.parent.type===$.TSIntersectionType||c.parent.type===$.TSUnionType&&c.parent.types[0]!==c)return!1;let S=[];for(let h of c.members){if(h.type!==$.TSPropertySignature)return!1;let T=h.typeAnnotation?.typeAnnotation;if(!T||T.type===$.TSTypeLiteral||!Pt(T))return!1;if(T.type===$.TSTypeReference&&T.typeArguments){if(T.typeArguments.params.length>1)return!1;let E=T.typeArguments.params[0];if(!Pt(E))return!1}let I=r.getText(h).trim();(I.endsWith(";")||I.endsWith(","))&&(I=I.slice(0,-1)),S.push(I)}return{text:S.join("; "),isNested:p,propsSize:g}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==$.JSXExpressionContainer){let T=0,I=!1,E=r.getTokenAfter(c,{filter:d=>d.type!==Ot.Punctuator||I?!0:d.value===","?(T++,!1):d.value===";"?(T++,I=!0,!1):d.value===")"||d.value==="}"?(T++,!1):!0});if(T>4)return;let M=E?.type===Ot.Template&&E.value.startsWith(`}
|
|
2
|
-
`);if(
|
|
3
|
-
`)||r.getCommentsInside(c).length>0)return;u.endsWith(";")&&(u=u.slice(0,-1));let
|
|
4
|
-
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function
|
|
1
|
+
import{AST_NODE_TYPES as q,ESLintUtils as jn}from"@typescript-eslint/utils";var $e=Symbol.for("optional");function M(e){return{...e,[$e]:!0}}function Ct(e,t){return{enum:e,...t}}function Te(e){return{...e,type:"boolean"}}function z(e){return{...e,type:"string"}}function ce(e){return{...e,type:"number"}}function X(e,t){return{...t,type:"array",items:e}}function U(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][$e]?e[n][$e]=void 0:o.push(n);o.length>0&&(r.required=o)}return r}var Ln=jn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="react-compiler-extra",Mn=U({runOnlyWithEnableCompilerDirective:M(Te())}),_n=/eslint +react-compiler\/react-compiler: +\["error/;function $n(e){return e.type===q.Identifier?e.name.startsWith("use"):e.type===q.MemberExpression&&e.property.type===q.Identifier?e.property.name.startsWith("use"):!1}var zn=/\bthis[.[]/;function Rt(e){return zn.test(e)}var Un=Ln({name:At,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:[Mn]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(_n.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let s of a.properties)if(s.type===q.Property&&s.method&&s.value.type===q.FunctionExpression){let i=e.sourceCode,l=i.getText(s.key),c=s.value,p=i.getText(c.body);if(Rt(p))e.report({node:s,messageId:"thisKeywordInMethod"});else{let u=c.params.map(h=>i.getText(h)).join(", "),S="";c.generator?S=`${l}: function* (${u}) ${p}`:S=`${l}: (${u}) => ${p}`,e.report({node:s,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(s,S)})}}}function o(a){for(let s of a.properties)if(s.type===q.Property&&s.value.type===q.ObjectExpression){for(let i of s.value.properties)if(i.type===q.Property&&i.method&&i.value.type===q.FunctionExpression){let c=e.sourceCode.getText(i.value.body);Rt(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if($n(a.callee))for(let s of a.arguments){if(s.type===q.ObjectExpression&&(n(s),o(s)),s.type===q.ArrowFunctionExpression&&(s.body.type===q.ObjectExpression&&(n(s.body),o(s.body)),s.body.type===q.BlockStatement))for(let i of s.body.body)i.type===q.ReturnStatement&&i.argument?.type===q.ObjectExpression&&(n(i.argument),o(i.argument));if(s.type===q.FunctionExpression)for(let i of s.body.body)i.type===q.ReturnStatement&&i.argument?.type===q.ObjectExpression&&(n(i.argument),o(i.argument))}}}}}),ze={name:At,rule:Un};import{AST_NODE_TYPES as G}from"@typescript-eslint/utils";import*as g from"zod/v4";import{ESLintUtils as Vn}from"@typescript-eslint/utils";function re(e){let r=Vn.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}var Wn=g.object({disallow:g.array(g.object({selector:g.string(),message:g.string(),replace:g.optional(g.union([g.string(),g.object({regex:g.string(),with:g.string()})])),replaceType:g.optional(g.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:g.optional(g.array(g.object({fn:g.string(),withArgs:g.optional(g.array(g.object({atIndex:g.number(),value:g.union([g.string(),g.number(),g.boolean()])}))),message:g.string(),replaceWith:g.optional(g.string()),ignoreRegex:g.optional(g.string())}))),__dev_simulateFileName:g.optional(g.string()),mustMatchSyntax:g.optional(g.array(g.object({includeRegex:g.string(),mustCallFn:g.optional(g.array(g.object({anyCall:g.array(g.object({fn:g.string(),withArgs:g.array(g.object({atIndex:g.number(),literal:g.union([g.string(),g.number(),g.boolean()])}))})),message:g.optional(g.string())}))),mustMatchSelector:g.optional(g.array(g.object({selector:g.string(),message:g.string()}))),mustHaveExport:g.optional(g.array(g.object({name:g.string(),type:g.enum(["function","variable","any"]).default("any"),message:g.string()})))})))}),Ue=re({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[g.toJSONSchema(Wn)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:o,disallow:a,disallowFnCalls:s}=t,i=o??e.filename,l=[],c=new Map,p=new Set,u=new Map,S=new Set,h=new Map;function x(m){for(let y of m.specifiers)y.type===G.ImportSpecifier&&y.imported.type===G.Identifier&&y.imported.name!==y.local.name&&h.set(y.local.name,y.imported.name)}function b(m){if(m.declaration){if(m.declaration.type===G.FunctionDeclaration&&m.declaration.id){let y=m.declaration.id.name;for(let R of Array.from(S)){let[C,E]=R.split(":");C===y&&(E==="function"||E==="any")&&S.delete(R)}}else if(m.declaration.type===G.VariableDeclaration){for(let y of m.declaration.declarations)if(y.id.type===G.Identifier){let R=y.id.name;for(let C of Array.from(S)){let[E,F]=C.split(":");E===R&&(F==="variable"||F==="any")&&S.delete(C)}}}}for(let y of m.specifiers)if(y.exported.type===G.Identifier){let R=y.exported.name;for(let C of Array.from(S)){let[E,F]=C.split(":");E===R&&F==="any"&&S.delete(C)}}}function k(m){m.id.type===G.Identifier&&m.init?.type===G.Identifier&&h.set(m.id.name,m.init.name)}function w(m){return h.get(m)??m}function L(m,y){return w(m)===y||m===y}for(let{includeRegex:m,mustCallFn:y,mustMatchSelector:R,mustHaveExport:C}of n??[]){let E=Hn(i,new RegExp(m));if(!E)continue;let F=H=>{let B=H;for(let{name:Z,value:K}of E)B=B.replaceAll(Z,K);return B};for(let{anyCall:H,message:B}of y??[]){let Z=`Expected file to call the function: ${H.map(({fn:K})=>K).join(" or ")}`;p.add(Z),l.push(K=>{let{callee:ge}=K;if(ge.type===G.Identifier){for(let{fn:ee,withArgs:xe}of H)if(ge.name===ee){p.delete(Z);for(let pe of xe){let le=K.arguments[pe.atIndex],ue=typeof pe.literal=="string"?F(pe.literal):pe.literal;if(!le){e.report({node:K,messageId:"default",data:{message:`Missing argument with value "${ue}" at index ${pe.atIndex}${B?`: ${F(B)}`:""}`}});continue}if(le.type!==G.Literal){e.report({node:le,messageId:"default",data:{message:`Argument at position ${pe.atIndex} should the literal "${ue}"${B?`: ${F(B)}`:""}`}});continue}le.value!==ue&&e.report({node:le,messageId:"default",data:{message:`Argument should have the value "${ue}"${B?`: ${F(B)}`:""}`},fix:Se=>Se.replaceText(le,typeof ue=="string"?`'${ue}'`:String(ue))})}break}}})}for(let{selector:H,message:B}of R??[])u.set(H,F(B)),c.set(F(H),()=>{u.delete(H)});for(let{name:H,type:B,message:Z}of C??[]){let K=F(H),ge=F(Z);S.add(`${K}:${B}:${ge}`)}}for(let{fn:m,withArgs:y,message:R,replaceWith:C,ignoreRegex:E}of s??[])E&&new RegExp(E).test(i)||l.push(F=>{let{callee:H}=F;if(H.type!==G.Identifier||!L(H.name,m))return;if(y)for(let Z of y){let K=F.arguments[Z.atIndex];if(!K){e.report({node:F,messageId:"default",data:{message:`Missing argument with value "${Z.value}" at index ${Z.atIndex}: ${R}`}});return}if(K.type!==G.Literal||K.value!==Z.value)return}let B=Z=>C?Z.replaceText(F,C):null;e.report({node:F,messageId:"default",data:{message:R},suggest:C?[{messageId:"default",data:{message:`Replace with "${C}"`},fix:B}]:void 0})});function P(m,y){let R=r[m];R?r[m]=C=>{R(C),y(C)}:r[m]=y}for(let{selector:m,message:y,replace:R,replaceType:C="suggestion"}of a??[]){if(m==="CallExpression"){l.push(E=>{T(R,E,y,C)});continue}r[m]=E=>{T(R,E,y,C)}}if(c.size>0)for(let[m,y]of c)P(m,y);return l.length>0&&(r.CallExpression=m=>{if(m.type===G.CallExpression)for(let y of l)y(m)}),r.ImportDeclaration=m=>{m.type===G.ImportDeclaration&&x(m)},r.ExportNamedDeclaration=m=>{m.type===G.ExportNamedDeclaration&&b(m)},r.VariableDeclarator=m=>{m.type===G.VariableDeclarator&&k(m)},r["Program:exit"]=m=>{for(let y of p)e.report({node:m,messageId:"default",data:{message:y}});for(let[,y]of u)e.report({node:m,messageId:"default",data:{message:y}});for(let y of S){let[R,C,E]=y.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${R}" of type ${C}: ${E}`}})}},r;function T(m,y,R,C){let E=F=>{if(!m)return null;if(typeof m=="string")return F.replaceText(y,m);{let H=new RegExp(m.regex),B=e.sourceCode.getText(y);return F.replaceText(y,B.replace(H,m.with))}};e.report({node:y,messageId:"default",data:{message:R},fix:m&&C==="autofix"?E:void 0,suggest:m&&C==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:E}]:void 0})}}});function Hn(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:kt(o)}),r.push({name:"$0_uncapitalize",value:vt(o)}),r.push({name:"$0",value:o});for(let s=0;s<a.length;s++){let i=`$${s+1}`,l=a[s];r.push({name:`${i}_lowercase`,value:l.toLowerCase()}),r.push({name:`${i}_capitalize`,value:kt(l)}),r.push({name:`${i}_uncapitalize`,value:vt(l)}),r.push({name:i,value:l})}return r}function kt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function vt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as _,AST_TOKEN_TYPES as Ot,ESLintUtils as Yn}from"@typescript-eslint/utils";var Bn=Yn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="collapse-simple-objs-in-one-line",Jn=U({maxLineLength:M(ce()),maxProperties:M(ce()),nestedObjMaxLineLength:M(ce()),nestedObjMaxProperties:M(ce()),ignoreTypesWithSuffix:M(X(z()))}),Xn=Bn({name:Ft,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[Jn]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,s=t.nestedObjMaxProperties??3;function i(c){if(c.type===_.ObjectExpression){let p=c.parent.type===_.Property,u=p?s:o,S=c.properties.length;if(S>u)return!1;if(S===1){let x=c.properties[0];return x.type===_.Property&&x.value.type===_.ObjectExpression||x.type===_.Property&&x.value.type===_.ArrayExpression&&!x.value.elements.every(k=>k&&Ve(k))?!1:{text:r.getText(x),isNested:p,propsSize:S}}let h=[];for(let x of c.properties){if(x.type===_.Property&&!Ve(x.value))return!1;h.push(r.getText(x))}return{text:h.join(", "),isNested:p,propsSize:S}}else{let p=c.parent.parent?.type===_.TSPropertySignature,u=p?s:o,S=c.members.length;if(S>u)return!1;if(n.length>0&&c.parent.type===_.TSTypeAliasDeclaration){let x=c.parent.id.name;if(n.some(b=>x.endsWith(b)))return!1}if(S===1){let x=c.members[0];return x.type===_.TSPropertySignature&&x.typeAnnotation?.typeAnnotation.type===_.TSTypeLiteral?!1:{text:r.getText(x),isNested:p,propsSize:1}}if(c.parent.type===_.TSIntersectionType||c.parent.type===_.TSUnionType&&c.parent.types[0]!==c)return!1;let h=[];for(let x of c.members){if(x.type!==_.TSPropertySignature)return!1;let b=x.typeAnnotation?.typeAnnotation;if(!b||b.type===_.TSTypeLiteral||!Pt(b))return!1;if(b.type===_.TSTypeReference&&b.typeArguments){if(b.typeArguments.params.length>1)return!1;let w=b.typeArguments.params[0];if(!Pt(w))return!1}let k=r.getText(x).trim();(k.endsWith(";")||k.endsWith(","))&&(k=k.slice(0,-1)),h.push(k)}return{text:h.join("; "),isNested:p,propsSize:S}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==_.JSXExpressionContainer){let b=0,k=!1,w=r.getTokenAfter(c,{filter:P=>P.type!==Ot.Punctuator||k?!0:P.value===","?(b++,!1):P.value===";"?(b++,k=!0,!1):P.value===")"||P.value==="}"?(b++,!1):!0});if(b>4)return;let L=w?.type===Ot.Template&&w.value.startsWith(`}
|
|
2
|
+
`);if(w?.loc.start.line===c.loc.end.line&&!L)return}let p=i(c);if(!p)return;let u=p.text;if(u.includes(`
|
|
3
|
+
`)||r.getCommentsInside(c).length>0)return;u.endsWith(";")&&(u=u.slice(0,-1));let S=`{ ${u} }`,h=Kn(r,c),x=p.isNested&&p.propsSize>2?a:t.maxLineLength;x&&S.length+h.length+qn(c,r)>x||e.report({node:c,messageId:"singleLineProp",fix:b=>b.replaceText(c,S)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function Pt(e){return e.type===_.TSLiteralType||e.type===_.TSTypeReference||e.type===_.TSNumberKeyword||e.type===_.TSStringKeyword||e.type===_.TSBooleanKeyword||e.type===_.TSNullKeyword||e.type===_.TSUndefinedKeyword}function Ve(e,t){return!!(e.type===_.Literal||e.type===_.Identifier||e.type===_.TemplateLiteral||e.type===_.TaggedTemplateExpression||!t&&e.type===_.ArrayExpression&&e.elements.every(r=>r&&Ve(r,!0)))}function qn(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 Kn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var We={name:Ft,rule:Xn};var Gn=/eslint +react-compiler\/react-compiler: +\["error/,Dt={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"?w=>r(w):w=>e.sourceCode.getText(w),n=typeof e.getScope=="function"?()=>n():w=>e.sourceCode.getScope(w),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,s={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function i(w){a&&Array.isArray(w.suggest)&&w.suggest.length>0&&(w.fix=w.suggest[0].fix),e.report(w)}let l=e.getSourceCode().scopeManager,c=new WeakMap,p=new WeakSet,u=new WeakMap,S=new WeakMap,h=new WeakSet;function x(w,L){return function(P){if(L.has(P))return L.get(P);let T=w(P);return L.set(P,T),T}}function b(w,L,P,T,m){m&&w.async&&i({node:w,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
5
5
|
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
async function fetchData() {
|
|
@@ -12,5 +12,5 @@ useEffect(() => {
|
|
|
12
12
|
fetchData();
|
|
13
13
|
}, [someId]); // Or [] if effect doesn't need props or state
|
|
14
14
|
|
|
15
|
-
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=l.acquire(E),v=new Set,O=null;{let f=R.upper;for(;f&&(v.add(f),f.type!=="function");)f=f.upper;if(!f)return;O=f}let x=Array.isArray;function _(f){if(!x(f.defs))return!1;let y=f.defs[0];if(y==null||y.node.type!=="VariableDeclarator")return!1;let b=y.node.init;if(b==null)return!1;for(;b.type==="TSAsExpression";)b=b.expression;let w=y.node.parent;if(w==null&&(Je(O.block,y.node.id),w=y.node.parent,w==null))return!1;if(w.kind==="const"&&b.type==="Literal"&&(typeof b.value=="string"||typeof b.value=="number"||b.value===null))return!0;if(b.type!=="CallExpression")return!1;let k=b.callee;if(k.type==="MemberExpression"&&k.object.name==="React"&&k.property!=null&&!k.computed&&(k=k.property),k.type!=="Identifier")return!1;let C=y.node.id,{name:N}=k;if(N==="useRef"&&C.type==="Identifier")return!0;if(rr(k)&&C.type==="Identifier"){for(let L of f.references)L!==C&&S.add(L.identifier);return!0}else if(N==="useState"||N==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&x(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(N==="useState"){let L=f.references,Z=0;for(let ae=0;ae<L.length;ae++){if(L[ae].isWrite()&&Z++,Z>1)return!1;c.set(L[ae].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(N==="useState"){let L=f.references;for(let Z=0;Z<L.length;Z++)p.add(L[Z].identifier)}return!1}}}else if(N==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function z(f){if(!x(f.defs))return!1;let y=f.defs[0];if(y==null||y.node==null||y.node.id==null)return!1;let b=y.node,w=O.childScopes,k=null,C;for(C=0;C<w.length;C++){let N=w[C],L=N.block;if(b.type==="FunctionDeclaration"&&L===b||b.type==="VariableDeclarator"&&L.parent===b){k=N;break}}if(k==null)return!1;for(C=0;C<k.through.length;C++){let N=k.through[C];if(N.resolved!=null&&v.has(N.resolved.scope)&&!oe(N.resolved))return!1}return!0}let oe=h(_,u),je=h(z,g),Ee=new Map;function pe(f){let y=f.from,b=!1;for(;y.block!==E;)y.type==="function"&&(b=y.block.parent!=null&&y.block.parent.type==="ReturnStatement"),y=y.upper;return b}let J=new Map,ie=new Map;be(R);function be(f){for(let y of f.references){if(!y.resolved||!v.has(y.resolved.scope))continue;let b=Je(E,y.identifier),w=jt(b),k=ce(w,ie);if(A&&w.type==="Identifier"&&(w.parent.type==="MemberExpression"||w.parent.type==="OptionalMemberExpression")&&!w.parent.computed&&w.parent.property.type==="Identifier"&&w.parent.property.name==="current"&&pe(y)&&Ee.set(k,{reference:y,dependencyNode:w}),w.parent.type==="TSTypeQuery"||w.parent.type==="TSTypeReference")continue;let C=y.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===E.parent)&&C.type!=="TypeParameter")if(J.has(k))J.get(k).references.push(y);else{let N=y.resolved,L=oe(N)||je(N);J.set(k,{isStable:L,references:[y]})}}for(let y of f.childScopes)be(y)}Ee.forEach(({reference:f,dependencyNode:y},b)=>{let w=f.resolved.references,k=!1;for(let C=0;C<w.length;C++){let{identifier:N}=w[C],{parent:L}=N;if(L!=null&&L.type==="MemberExpression"&&!L.computed&&L.property.type==="Identifier"&&L.property.name==="current"&&L.parent.type==="AssignmentExpression"&&L.parent.left===L){k=!0;break}}k||i({node:y.parent.property,message:`The ref value '${b}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${b}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Le=new Set;function Pn(f,y){Le.has(y)||(Le.add(y),i({node:f,message:`Assignments to the '${y}' variable from inside React Hook ${r(d)} 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(d)}.`}))}let xe=new Set;if(J.forEach(({isStable:f,references:y},b)=>{f&&xe.add(b),y.forEach(w=>{w.writeExpr&&Pn(w.writeExpr,b)})}),Le.size>0)return;if(!M){let f=null;if(J.forEach(({isStable:y,references:b},w)=>{f||b.forEach(k=>{if(f)return;let C=k.identifier;if(!c.has(C))return;let L=k.from;for(;L.type!=="function";)L=L.upper;L.block===E&&(f=w)})}),f){let{suggestedDependencies:y}=ze({dependencies:J,declaredDependencies:[],stableDependencies:xe,externalDependencies:new Set,isEffect:!0});i({node:d,message:`React Hook ${m} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+y.join(", ")+`] as a second argument to the ${m} Hook.`,suggest:[{desc:`Add dependencies array: [${y.join(", ")}]`,fix(b){return b.insertTextAfter(E,`, [${y.join(", ")}]`)}}]})}return}let Se=[],Te=new Set;M.type!=="ArrayExpression"?i({node:M,message:`React Hook ${r(d)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):M.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(d)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}S.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(k){return k.removeRange(f.range)}}]});let y;try{y=ce(f,ie)}catch(k){if(/Unsupported node type/.test(k.message)){f.type==="Literal"?J.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(d)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw k}let b=f;for(;b.type==="MemberExpression"||b.type==="OptionalMemberExpression"||b.type==="ChainExpression";)b=b.object||b.expression.object;let w=!O.through.some(k=>k.identifier===b);Se.push({key:y,node:f}),w||Te.add(y)});let{suggestedDependencies:Fn,unnecessaryDependencies:we,missingDependencies:ue,duplicateDependencies:wt}=ze({dependencies:J,declaredDependencies:Se,stableDependencies:xe,externalDependencies:Te,isEffect:A}),Ie=Fn;if(wt.size+ue.size+we.size===0){if(t)return;Qn({declaredDependencies:Se,declaredDependenciesNode:M,componentScope:O,scope:R}).forEach(({construction:y,isUsedOutsideOfHook:b,depType:w})=>{let k=w==="function"?"useCallback":"useMemo",C=w==="function"?"definition":"initialization",N=`wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,L=b?`To fix this, ${N}`:`Move it inside the ${m} callback. Alternatively, ${N}`,Z=w==="conditional"||w==="logical expression"?"could make":"makes",ae=`The '${y.name.name}' ${w} ${Z} the dependencies of ${m} Hook (at line ${M.loc.start.line}) change on every render. ${L}`,It;b&&y.type==="Variable"&&w==="function"&&(It=[{desc:`Wrap the ${C} of '${y.name.name}' in its own ${k}() Hook.`,fix(Ct){let[Dn,jn]=k==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Ct.insertTextBefore(y.node.init,Dn),Ct.insertTextAfter(y.node.init,jn)]}}]),i({node:y.node,message:ae,suggest:It})});return}!A&&ue.size>0&&(Ie=ze({dependencies:J,declaredDependencies:[],stableDependencies:xe,externalDependencies:Te,isEffect:A}).suggestedDependencies);function Nn(){if(Se.length===0)return!0;let f=Se.map(b=>b.key),y=f.slice().sort();return f.join(",")===y.join(",")}Nn()&&Ie.sort();function Me(f){let y=f.split("."),b="";for(let w=0;w<y.length;w++){if(w!==0){let k=y.slice(0,w+1).join("."),C=ie.get(k)===!0;b+=C?"?.":"."}b+=y[w]}return b}function _e(f,y,b,w){return f.size===0?null:(f.size>1?"":y+" ")+b+" "+(f.size>1?"dependencies":"dependency")+": "+tr(Array.from(f).sort().map(k=>"'"+Me(k)+"'"))+`. Either ${w} ${f.size>1?"them":"it"} or remove the dependency array.`}let se="";if(we.size>0){let f=null;if(Array.from(we.keys()).forEach(y=>{f===null&&y.endsWith(".current")&&(f=y)}),f!==null)se=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Te.size>0){let y=Array.from(Te)[0];R.set.has(y)||(se=` Outer scope values like '${y}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!se&&ue.has("props")){let f=J.get("props");if(f==null)return;let y=f.references;if(!Array.isArray(y))return;let b=!0;for(let w=0;w<y.length;w++){let k=y[w],C=Je(O.block,k.identifier);if(!C){b=!1;break}let N=C.parent;if(N==null){b=!1;break}if(N.type!=="MemberExpression"&&N.type!=="OptionalMemberExpression"){b=!1;break}}b&&(se=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${m} call and refer to those specific props inside ${r(d)}.`)}if(!se&&ue.size>0){let f=null;ue.forEach(y=>{if(f)return;let b=O.set.get(y),w=J.get(y);if(w.references[0].resolved!==b)return;let k=b.defs[0];if(k==null||k.name==null||k.type!=="Parameter")return;let C=!1,N;for(let L=0;L<w.references.length;L++)if(N=w.references[L].identifier,N!=null&&N.parent!=null&&(N.parent.type==="CallExpression"||N.parent.type==="OptionalCallExpression")&&N.parent.callee===N){C=!0;break}C&&(f=y)}),f!==null&&(se=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!se&&ue.size>0){let f=null;if(ue.forEach(y=>{if(f!==null)return;let w=J.get(y).references,k,C;for(let N=0;N<w.length;N++){for(k=w[N].identifier,C=k.parent;C!=null&&C!==O.block;){if(C.type==="CallExpression"){let L=c.get(C.callee);if(L!=null){if(L.name===y)f={missingDep:y,setter:C.callee.name,form:"updater"};else if(p.has(k))f={missingDep:y,setter:C.callee.name,form:"reducer"};else{let Z=w[N].resolved;if(Z!=null){let ae=Z.defs[0];ae!=null&&ae.type==="Parameter"&&(f={missingDep:y,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":se=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":se=` 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":se=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:M,message:`React Hook ${r(d)} has `+(_e(ue,"a","missing","include")||_e(we,"an","unnecessary","exclude")||_e(wt,"a","duplicate","omit"))+se,suggest:[{desc:`Update the dependencies array to be: [${Ie.map(Me).join(", ")}]`,fix(f){return f.replaceText(M,`[${Ie.map(Me).join(", ")}]`)}}]})}function I(E){let M=er(E.callee,s);if(M===-1)return;let d=E.arguments[M],m=E.callee,A=Lt(m).name,R=E.arguments[M+1],v=/Effect($|[^a-z])/g.test(A);if(!d){i({node:m,message:`React Hook ${A} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!v)){if(!R&&!v){(A==="useMemo"||A==="useCallback")&&i({node:m,message:`React Hook ${A} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(d.type){case"FunctionExpression":case"ArrowFunctionExpression":T(d,R,m,A,v);return;case"Identifier":if(!R||R.elements&&R.elements.some(_=>_&&_.type==="Identifier"&&_.name===d.name))return;let O=n(E).set.get(d.name);if(O==null||O.defs==null)return;let x=O.defs[0];if(!x||!x.node||x.type!=="Variable"&&x.type!=="FunctionName")break;switch(x.node.type){case"FunctionDeclaration":T(x.node,R,m,A,v);return;case"VariableDeclarator":let _=x.node.init;if(!_)break;switch(_.type){case"ArrowFunctionExpression":case"FunctionExpression":T(_,R,m,A,v);return}break}break;default:i({node:m,message:`React Hook ${A} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:m,message:`React Hook ${A} has a missing dependency: '${d.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${d.name}]`,fix(O){return O.replaceText(R,`[${d.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let E of e.sourceCode.getAllComments())if(Zn.test(E.value))return t=!0,{CallExpression:M=>I(M,!0)}}return{CallExpression:E=>I(E)}}};function ze({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((T,I)=>{let E=i(a,I);E.isUsed=!0,l(a,I,M=>{M.isSubtreeUsed=!0})}),t.forEach(({key:T})=>{let I=i(a,T);I.isSatisfiedRecursively=!0}),r.forEach(T=>{let I=i(a,T);I.isSatisfiedRecursively=!0});function i(T,I){let E=I.split("."),M=T;for(let d of E){let m=M.children.get(d);m||(m=s(),M.children.set(d,m)),M=m}return M}function l(T,I,E){let M=I.split("."),d=T;for(let m of M){let A=d.children.get(m);if(!A)return;E(A),d=A}}let c=new Set,p=new Set;u(a,c,p,T=>T);function u(T,I,E,M){T.children.forEach((d,m)=>{let A=M(m);if(d.isSatisfiedRecursively){d.isSubtreeUsed&&E.add(A);return}if(d.isUsed){I.add(A);return}u(d,I,E,R=>A+"."+R)})}let g=[],S=new Set,h=new Set;return t.forEach(({key:T})=>{p.has(T)?g.indexOf(T)===-1?g.push(T):h.add(T):S.add(T)}),c.forEach(T=>{g.push(T)}),{suggestedDependencies:g,unnecessaryDependencies:S,duplicateDependencies:h,missingDependencies:c}}function fe(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 fe(e.consequent)!=null||fe(e.alternate)!=null?"conditional":null;case"LogicalExpression":return fe(e.left)!=null||fe(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return fe(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return fe(e.expression);case"TSAsExpression":return fe(e.expression)}return null}function Qn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:s})=>{let i=r.variables.find(c=>c.name===s);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=fe(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(s){let i=!1;for(let l=0;l<s.references.length;l++){let c=s.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==n&&p!=null;)p=p.upper;if(p!==n&&!Mt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}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 Be(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function ce(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=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Be(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=ce(e.object,t),n=ce(e.property,null),o=`${r}.${n}`;return Be(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=ce(r.object,t),o=ce(r.property,null),a=`${n}.${o}`;return Be(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Lt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function er(e,t){let r=Lt(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=ce(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 Je(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),nr(n,t))return n;if(Mt(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(Nt(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(s=>{Nt(s)&&(s.parent=n,r.push(s))}))}return null}function tr(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 Nt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function nr(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 Mt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function rr(e){return!1}import{AST_NODE_TYPES as ke,ESLintUtils as $t}from"@typescript-eslint/utils";import q from"typescript";var ir=$t.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="improved-no-unnecessary-condition",sr=D({}),or=["string","number","bigint","boolean","symbol","undefined","object","function","never"],ar=new Set(or),Xe={name:_t,rule:ir({name:_t,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[sr]},defaultOptions:[{}],create(e){let t=$t.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===ke.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&q.TypeFlags.Any||i.flags&q.TypeFlags.Unknown?null:i.flags&q.TypeFlags.StringLike?["string"]:i.flags&q.TypeFlags.NumberLike?["number"]:i.flags&q.TypeFlags.BigIntLike?["bigint"]:i.flags&q.TypeFlags.BooleanLike?["boolean"]:i.flags&q.TypeFlags.ESSymbolLike?["symbol"]:i.flags&q.TypeFlags.Undefined||i.flags&q.TypeFlags.Void?["undefined"]:i.flags&q.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&q.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&q.TypeFlags.NonPrimitive?["object"]:i.flags&q.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=r.getTypeAtLocation(l.expression);if(c.flags&q.TypeFlags.Any||c.flags&q.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let g of c.types){let S=o(g);if(S)p.push(...S);else return null}return p}let u=o(c);return u?(p.push(...u),p):null}function s(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(n(i.left)?(c=i.left,p=i.right.type===ke.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(c=i.right,p=i.left.type===ke.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!lr(p,ar))return;let u=a(c);if(!u)return;let g=i.operator==="!==",S=u.includes(p);u.length===1?S&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:me(c,e),type:p}}):!S&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:me(c,e),type:Array.from(u)[0]}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:me(c,e),actualType:Ae(u),conditionType:p}}):S&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:me(c,e),actualType:Ae(u),conditionType:p}}):!S&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:me(c,e),actualType:Ae(u),conditionType:p}}):!S&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:me(c,e),type:Ae(u)}})}return{BinaryExpression:s}}})};function Ae(e){return Array.from(new Set(e)).join(" | ")||"never"}function me(e,t){let r=e.argument;return r.type===ke.Identifier?r.name:t.sourceCode.getText(r)}function lr(e,t){return t.has(e)}import{AST_NODE_TYPES as cr,ESLintUtils as pr}from"@typescript-eslint/utils";var ur=pr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="no-call-with-explicit-generics",fr=D({functions:V(F())}),mr=ur({name:Ut,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[fr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===cr.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),qe={name:Ut,rule:mr};import{AST_NODE_TYPES as ve,ESLintUtils as dr}from"@typescript-eslint/utils";var yr=dr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vt="no-call-with-inferred-generics",gr=yr({name:Vt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:o}=n;if(o.type!==ve.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(s||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&n.typeArguments?.params?.some(p=>!i&&p.type===ve.TSAnyKeyword||l&&p.type===ve.TSTypeReference&&p.typeName.type===ve.Identifier&&l.includes(p.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),Ke={name:Vt,rule:gr};import{ESLintUtils as Sr}from"@typescript-eslint/utils";var Tr=Sr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="no-commented-out-code",hr=["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:"],Er=[") {","return;",/^\s*return\s+/,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",/\w=("|'|`)/,");",/\w+:\s*('|"|`)/,/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,/\w+-\w+:/,/\w+_\w+:/,"&&","||","()",/\?\s+\w/,/:\s+\w/,/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,/^\s*\d+[,}]/,/^\s*\[[^\]]*\][,}]/,/^\s*\{[^}]*\}[,}]/,/\.\w+\(/,/\[\w+\]/,"?.(","??","=>",/^\s*(['"`]).+?\1\s*:/],br=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Wt=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],xr=Tr({name:Ht,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")||/^\s*[*\s]*$/.test(n))return!1;for(let s of Wt)if(a.startsWith(s))return!1;if(n.includes("https://"))return!1;if(o==="Block"){for(let s of br)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of hr)if(a.startsWith(s))return{wrongPattern:s};for(let s of Er)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}function r(n,o){let a=n,s=a.trim();if(s.startsWith("`")&&(s.endsWith("`,")||s.endsWith("`;")||s.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let c=a.split(/```[\s\S]*?```/g);c.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=c.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(c=>/[a-zA-Z0-9]/.test(c))?i.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let s=r(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Wt.join(", ")}})}}}}}),Ge={name:Ht,rule:xr};import{ESLintUtils as wr,TSESTree as Ir}from"@typescript-eslint/utils";var Cr=wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="no-default-export",Rr=Cr({name:Yt,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===Ir.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Ze={name:Yt,rule:Rr};import{ESLintUtils as Ar}from"@typescript-eslint/utils";var kr=Ar.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="no-leaked-text-in-jsx",vr=[",",";","[","]","(",")"],Or=kr({name:zt,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="";vr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),Qe={name:zt,rule:Or};import{AST_NODE_TYPES as de,ESLintUtils as Pr}from"@typescript-eslint/utils";var Fr=Pr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-non-camel-case-functions",Nr=/^[a-z][a-zA-Z0-9]*$/;function Bt(e){return e.typeName.type===de.TSQualifiedName&&e.typeName.left.type===de.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===de.Identifier&&e.typeName.right.name==="Element"}var Dr=Fr({name:Jt,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&&!Nr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===de.TSTypeReference?Bt(r):r.type===de.TSUnionType&&r.types.some(o=>o.type===de.TSTypeReference&&Bt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),et={name:Jt,rule:Dr};import{ESLintUtils as jr,TSESTree as W}from"@typescript-eslint/utils";import{AST_NODE_TYPES as Xt}from"@typescript-eslint/utils";function ye(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:ye(e.parent,t,r===1/0?r:r-1)}function*tt(e){yield e,e.parent&&(yield*tt(e.parent))}function nt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function qt(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Xt.Property&&a.identifiers[0]?.parent.key.type===Xt.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Lr=jr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="no-optional-root-props",Mr=Lr({name:Kt,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 s=a.references[0];if(!s)return!1;for(let i of tt(s.identifier)){if("returnType"in i||i.type===W.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===W.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===W.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===W.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=ye(l.parent.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=Oe(p,e.sourceCode);return u?!(u.parent.type===W.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===W.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===W.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===W.AST_NODE_TYPES.ArrowFunctionExpression){let c=ye(l,W.AST_NODE_TYPES.VariableDeclaration);return c?!!Oe(c,e.sourceCode):!1}if(l.type===W.AST_NODE_TYPES.FunctionDeclaration)return!!Oe(l,e.sourceCode)}return!1}function r(n){n.key.type!==W.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=ye(n,W.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let s=e.sourceCode.getText(a);return o.replaceText(a,s.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===W.AST_NODE_TYPES.TSTypeLiteral&&!(Pe(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===W.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Pe(n)||!t(n)))for(let o of n.body.body)o.type===W.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==W.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==W.AST_NODE_TYPES.TSTypeLiteral)return;let a=ye(n.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=Oe(a,e.sourceCode);if(!(!s||s.parent.type===W.AST_NODE_TYPES.CallExpression&&s.parent.callee.type===W.AST_NODE_TYPES.Identifier&&s.parent.callee.name==="memo"))for(let l of o.members)l.type===W.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Pe(e){return e?e.parent?.type===W.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===W.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Oe(e,t){if(Pe(e))return;let r;if(e.type===W.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===W.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.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(s=>s.identifiers.includes(r));if(!o)return;let a=o.references.filter(s=>s.identifier!==r);if(!(a.length!==1||!a[0])&&!Pe(a[0].identifier.parent.parent))return a[0].identifier}var rt={name:Kt,rule:Mr};import{ESLintUtils as _r}from"@typescript-eslint/utils";import it from"node:path";var $r=_r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="no-relative-imports",Ur=D({find:F(),replacement:F()}),Vr=D({aliases:V(Ur),rootDir:P(F()),allowNotFoundAliases:P(le()),_dev_simulateFileName:P(F())}),Wr=$r({name:Gt,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[Vr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=it.dirname(i);return it.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=it.relative(i,s);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let u=l.replace(p,c);return{alias:c,newPath:u}}return null}return{ImportDeclaration(s){let i=s.source.value;if(!n(i))return;let l=o(i,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:s,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(s.source,`'${c.newPath}'`):void 0})}}}}),st={name:Gt,rule:Wr};import{AST_NODE_TYPES as ge}from"@typescript-eslint/utils";var Hr="no-unnecessary-async-on-jsx-props";function Yr(e){if(e.body.type!==ge.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==ge.ExpressionStatement?!1:r.expression.type===ge.AwaitExpression}var ot=ee({name:Hr,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){Yr(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let o=e.sourceCode,a=[],s=o.getFirstToken(r,l=>l.value==="async");if(s){let l=o.getTokenAfter(s);l?a.push(n.replaceTextRange([s.range[0],l.range[0]],"")):a.push(n.remove(s))}function i(l){if(l.type===ge.AwaitExpression){let c=o.getFirstToken(l);if(c&&c.value==="await"){let p=o.getTokenAfter(c);p?a.push(n.replaceTextRange([c.range[0],p.range[0]],"")):a.push(n.remove(c))}}if(l.type===ge.BlockStatement)for(let c of l.body)i(c);else l.type===ge.ExpressionStatement&&i(l.expression)}return i(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as he,ESLintUtils as Qt}from"@typescript-eslint/utils";import*as at from"typescript";var zr=Qt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-unnecessary-casting",Br=D({additionalCastFunctions:P(V(D({name:F(),expectedType:Ce(["string","number"])})))}),lt={name:Zt,rule:zr({name:Zt,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[Br],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=Qt.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function s(p,u){switch(p.type){case he.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case he.TemplateLiteral:return u==="string";case he.UnaryExpression:return u==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,u){return u==="number"?!!(p.flags&at.TypeFlags.NumberLike):!!(p.flags&at.TypeFlags.StringLike)}function l(p,u){return g=>g.replaceText(p,e.sourceCode.getText(u))}function c(p){if(!a||p.arguments.length!==1)return;let u=p.arguments[0];if(!u||u.type===he.SpreadElement)return;let{callee:g}=p;if(g.type!==he.Identifier)return;let S=g.name,h=n.find(I=>I.name===S);if(!h)return;if(s(u,h.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),h.expectedType)){let I,E;S==="Number"?I="unnecessaryNumberCasting":S==="String"?I="unnecessaryStringCasting":(I="unnecessaryCustomCasting",E={name:h.name,type:h.expectedType}),e.report({node:p,messageId:I,...E?{data:E}:{},fix:l(p,u)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as Fe}from"@typescript-eslint/utils";import*as ne from"zod/v4";var Jr=ne.object({methods:ne.union([ne.array(ne.string()),ne.literal("array")])}),ct=ee({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:[ne.toJSONSchema(Jr)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===Fe.MemberExpression){let c=l.property;if(c.type===Fe.Identifier)return c.name}return null}function s(i,l){if(i.type!==Fe.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===Fe.CallExpression){let p=a(c);p&&o(p)&&c.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(g){return g.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)s(l,i)},FunctionExpression(i){for(let l of i.params)s(l,i)}}}});import{AST_NODE_TYPES as G}from"@typescript-eslint/utils";var pt=ee({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===G.ObjectPattern||!t.init||t.init.type!==G.ObjectExpression||t.id.type===G.Identifier&&t.id.typeAnnotation||t.parent.parent.type===G.ExportNamedDeclaration)return;let r=new Map;for(let s of t.init.properties)s.type===G.Property&&s.key.type===G.Identifier&&r.set(s.key.name,s);if(r.size===0||t.id.type!==G.Identifier)return;let n=Xr(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(s=>s.type!==G.Property?!1:s.value.type===G.FunctionExpression),a=new Set;for(let s of n){if(s.identifier.parent.type!==G.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===G.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==G.Identifier)return;a.add(i.property.name)}if(i.parent.type===G.CallExpression&&o)return}for(let[s,i]of r)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function Xr(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):[]}import{AST_NODE_TYPES as Y,ESLintUtils as qr}from"@typescript-eslint/utils";var Kr=D({selectors:V(D({name:F(),selectorProp:P(F()),selectorArgPos:P(K()),returnProp:P(F())}))}),Gr=qr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),en="no-unused-selected-values",ut={name:en,rule:Gr({name:en,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Kr]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===Y.CallExpression&&(a=o.init),!a)return;let s=Qr(a);if(!s)return;let i=n.get(s);if(!i)return;let l=Zr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=ei(l);if(!c)return;let p=tn(c.properties,void 0);if(!p)return;if(o.id.type===Y.ObjectPattern){let S=tn(o.id.properties,i.returnProp);if(!S)return;for(let[h,T]of p)S.has(h)||e.report({node:T,messageId:"unusedSelectedValue",data:{name:h}});return}if(o.id.type!==Y.Identifier||i.returnProp)return;let u=ti(o,e.sourceCode);if(u.length===0)return;let g=new Set;for(let S of u){if(S.identifier.parent.type!==Y.MemberExpression)return;let h=S.identifier.parent.property;if(h.type!==Y.Identifier)return;g.add(h.name)}for(let[S,h]of p)g.has(S)||e.report({node:h,messageId:"unusedSelectedValue",data:{name:S}})}}}})};function Zr(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===Y.ArrowFunctionExpression||n.type===Y.FunctionExpression)return n;if(r&&n.type===Y.ObjectExpression){let o=n.properties.find(s=>s.type===Y.Property&&s.key.type===Y.Identifier&&s.key.name===r);if(o?.type!==Y.Property)return null;let a=o.value;if(a.type===Y.ArrowFunctionExpression||a.type===Y.FunctionExpression)return a}return null}function Qr(e){return e.callee.type===Y.Identifier?e.callee.name:e.callee.type===Y.MemberExpression&&e.callee.property.type===Y.Identifier?e.callee.property.name:null}function ei(e){if(e.body.type===Y.ObjectExpression)return e.body;if(e.body.type===Y.BlockStatement){let t=e.body.body.filter(r=>r.type===Y.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==Y.ObjectExpression?null:t[0].argument}return null}function tn(e,t){let r=e;if(t){let o=e.find(a=>a.type===Y.Property&&a.key.type===Y.Identifier&&a.key.name===t);if(o?.type!==Y.Property||o.value.type!==Y.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==Y.Property||o.key.type!==Y.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function ti(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):[]}import{AST_NODE_TYPES as H}from"@typescript-eslint/utils";var ft=ee({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===H.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let i=ni(a);i&&(n=i);return}let s=ri(a,e.sourceCode);if(s){o=!0;for(let i of s)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function ni(e){if(!(e.callee.type===H.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==H.ObjectExpression)return null;let n=nt(r.properties,a=>a.type!==H.Property||a.key.type!==H.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.ObjectExpression?a.value:a.value.type===H.ArrowFunctionExpression||a.value.type===H.FunctionExpression?ii(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===H.Property&&a.key.type===H.Identifier&&o.set(a.key.name,a);return o}function ri(e,t){if(!(e.callee.type===H.Identifier&&e.callee.name==="useFormState")||e.parent.type!==H.VariableDeclarator||e.parent.id.type!==H.ObjectPattern||!nt(e.parent.id.properties,s=>s.type===H.Property&&s.key.type===H.Identifier&&s.key.name==="formFields"&&s))return null;let o=qt(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==H.Identifier||s.parent.type===H.Property&&s.parent.parent.type===H.ObjectExpression&&s.parent.parent.parent.type===H.ReturnStatement||s.parent.type===H.ReturnStatement)return null;if(s.parent.type===H.MemberExpression){if(s.parent.object.type!==H.Identifier||s.parent.property.type!==H.Identifier)return null;a.add(s.parent.property.name)}}return a}function ii(e){if(e.body.type===H.ObjectExpression)return e.body;if(e.body.type===H.BlockStatement){let t=e.body.body.filter(r=>r.type===H.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as U,ESLintUtils as si}from"@typescript-eslint/utils";var oi=si.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function nn(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 rn(e,...t){for(let r of t)e.set(...r);return e}var ai=D({forceCheckOnFCPropTypesWithName:P(V(F()))}),sn="no-unused-type-props-in-args",mt=null,li=oi({name:sn,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[ai],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!mt&&(mt=r.map(i=>new RegExp(i)));function n(i,l,c,p,u=!0){let g=c.name,S=e.sourceCode.getScope(l).references.find(I=>I.identifier.name===g)?.resolved,h=i&&mt?.some(I=>I.test(g));if(!S||!h&&S.references.filter(I=>I.isTypeReference).length>1)return;let T=S?.defs[0]?.node;if(!(u&&T?.parent?.type===U.ExportNamedDeclaration)){if(T?.type===U.TSTypeAliasDeclaration){o(i,l,p,T.typeAnnotation,!0);return}if(T?.type===U.TSInterfaceDeclaration){o(i,l,p,T.body,!0);return}}}function o(i,l,c,p,u){if(p.type===U.TSInterfaceBody){for(let g of p.body)g.type===U.TSPropertySignature&&g.key.type===U.Identifier&&c.set(g.key.name,g);return}if(p.type===U.TSTypeLiteral){rn(c,...nn(p));return}if(p.type===U.TSIntersectionType){for(let g of p.types)o(i,l,c,g,!0);return}u||p.type===U.TSTypeReference&&p.typeName.type===U.Identifier&&n(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let u=new Map;if(o(i,l,u,p.typeAnnotation.typeAnnotation,!1),u.size===0)continue;s(p,u)}else p.type===U.AssignmentPattern&&p.left.type===U.ObjectPattern&&a(i,l,[p.left])}function s(i,l){let c=[];if(i.properties.at(-1)?.type===U.RestElement)return;for(let S of i.properties)S.type===U.Property&&S.key.type===U.Identifier&&c.push(S.key.name);let u=[],g=[];for(let[S,h]of l)c.includes(S)||(g.push(S),u.push({node:h,messageId:"unusedObjectTypeProperty",data:{propertyName:S}}));for(let[S,h]of u.entries())e.report({...h,fix:S===u.length-1?T=>{let I=i.properties.at(-1),E=g.join(", ");return I?I?.type===U.RestElement?null:T.insertTextAfter(I,`, ${E}`):T.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${E}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let c=new Map,p=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(p){if(p.type===U.TSTypeReference&&p.typeName.type===U.Identifier)n(!0,i,p.typeName,c,!1);else if(p.type===U.TSTypeLiteral)rn(c,...nn(p));else if(p.type===U.TSIntersectionType)for(let u of p.types)u.type===U.TSTypeReference&&u.typeName.type===U.Identifier?n(!0,i,u.typeName,c,!1):o(!0,i,c,u,!0);if(c.size!==0&&l.init?.type===U.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===U.ObjectPattern&&s(u,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),dt={name:sn,rule:li};import{AST_NODE_TYPES as yt,ESLintUtils as ci}from"@typescript-eslint/utils";var pi=ci.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="prefer-named-functions",on=new Map,ui=pi({name:an,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let r=null;if(t.ignoreRegex){let n=on.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),on.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===yt.ArrowFunctionExpression&&n.id.type===yt.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==yt.BlockStatement)return;let a=n.parent,s=n.init.params,i=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:c=>c.replaceText(a,`${l.async?"async ":""}function ${o}(${s.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),gt={name:an,rule:ui};import{AST_NODE_TYPES as j}from"@typescript-eslint/utils";var fi=D({disallowedFunctions:V(D({name:F(),allowUsingWithArgs:P(le()),hookAlternative:P(F()),message:P(F()),allowUseInside:P(V(F()))}))});function Ne(e){return/^use[A-Z]/.test(e)}function ln(e){return/^[A-Z]/.test(e)}function mi(e){return e.type===j.Identifier?Ne(e.name):e.type===j.MemberExpression&&e.property.type===j.Identifier?Ne(e.property.name):!1}function cn(e,t){return e.type===j.Identifier?e.name===t:e.type===j.MemberExpression&&e.object.type===j.Identifier&&e.property.type===j.Identifier?e.object.name==="React"&&e.property.name===t:!1}function pn(e){return!!(e.parent&&e.parent.type===j.CallExpression&&cn(e.parent.callee,"forwardRef"))}function un(e){return!!(e.parent&&e.parent.type===j.CallExpression&&cn(e.parent.callee,"memo"))}function St(e){if(e.type===j.FunctionDeclaration||e.type===j.FunctionExpression&&e.id)return e.id||void 0;if(e.type===j.FunctionExpression||e.type===j.ArrowFunctionExpression){if(e.parent.type===j.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===j.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===j.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===j.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function di(e){let t=e.parent,r=!1;for(;t;){if(t.type===j.FunctionDeclaration||t.type===j.FunctionExpression||t.type===j.ArrowFunctionExpression){let n=St(t);if(n&&n.type===j.Identifier){if(ln(n.name)||Ne(n.name))return!r;r=!0}else{if(pn(t)||un(t))return!r;if(t.parent.type===j.CallExpression){let o=t.parent;mi(o.callee)||(r=!0)}else t.parent.type===j.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function fn(e){return e.callee.type===j.Identifier?e.callee.name:e.callee.type===j.MemberExpression&&e.callee.property.type===j.Identifier?e.callee.property.name:null}function yi(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===j.FunctionDeclaration||r.type===j.FunctionExpression||r.type===j.ArrowFunctionExpression){let n=St(r);if(n&&n.type===j.Identifier&&t.includes(n.name))return!0}else if(r.type===j.CallExpression){let n=fn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function gi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===j.Identifier&&t.name==="undefined")}function Si(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===j.FunctionDeclaration||n.type===j.FunctionExpression||n.type===j.ArrowFunctionExpression){let o=St(n);if(o&&o.type===j.Identifier){if(ln(o.name)||Ne(o.name)){r=!0;break}}else if(pn(n)||un(n)){r=!0;break}}n=n.parent}return r?t.length===0?di(e):!yi(e,t):!1}var Tt=ee({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:[fi],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=fn(o);if(!a)return;let s=n.get(a);if(!s||s.allowUsingWithArgs&&gi(o))return;let i=s.allowUseInside||[];Si(o,i)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:s.message?` ${s.message}`:` use ${s.hookAlternative} instead`},suggest:s.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${s.hookAlternative}`,hookAlternative:s.hookAlternative},fix:l=>{let c=s.hookAlternative;return o.callee.type===j.Identifier?l.replaceText(o.callee,c):o.callee.type===j.MemberExpression&&o.callee.property.type===j.Identifier?l.replaceText(o.callee.property,c):null}}]:[]})}}}});import{AST_NODE_TYPES as B,AST_TOKEN_TYPES as mn,ESLintUtils as Ti}from"@typescript-eslint/utils";var hi=Ti.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yn="prefer-single-line-if",Ei=D({maxLineLength:P(K()),maxNonSimpleConditionLength:P(K())}),bi=hi({name:yn,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:[Ei]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==B.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===B.ReturnStatement){if(!Sn(a))return}else if(!(a.type===B.ContinueStatement||a.type===B.BreakStatement))return;if(n.test.type===B.LogicalExpression||n.test.type===B.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=dn(n.test);if(!u&&n.test.type===B.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;dn(g)&&(u=!0)}if(u&&(s=r.getText(n.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=r.getText(n.test));let i=r.getText(a);if(s.includes(`
|
|
16
|
-
`))return;let l=r.getTokenAfter(n);if(l&&l.type===mn.Punctuator&&l.value==="}"){let u=r.getTokenAfter(l);if(u&&u.type===mn.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=xi(r,n),p=`if (${s}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:u=>u.replaceText(n,p)})}}}});function dn(e){return e.type===B.CallExpression||e.type===B.BinaryExpression||e.type===B.MemberExpression&&gn(e)}function gn(e){return e.object.type===B.MemberExpression?gn(e.object):e.object.type!==B.Identifier}function xi(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Sn(e){if(!e.argument)return!0;let t=e.argument;return t.type===B.ArrayExpression&&t.elements.length===0||t.type===B.ObjectExpression&&t.properties.length===0||t.type===B.Literal||t.type===B.Identifier||t.type===B.TemplateLiteral||t.type===B.TaggedTemplateExpression?!0:t.type===B.CallExpression?t.arguments.length===0:t.type===B.UnaryExpression?Sn(t):!1}var ht={name:yn,rule:bi};import{AST_NODE_TYPES as re,ESLintUtils as wi}from"@typescript-eslint/utils";var Ii=wi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tn="react-compiler-migration",Ci=D({disallowHooks:P(V(D({name:F(),replacement:F()}))),disallowMethods:P(V(D({name:F(),replacement:P(F()),requireTrueProp:P(F())})))}),Ri=/eslint +react-compiler\/react-compiler: +\["error/;function Ai(e){return e.type===re.Identifier?e.name.startsWith("use"):e.type===re.MemberExpression&&e.property.type===re.Identifier?e.property.name.startsWith("use"):!1}var ki=Ii({name:Tn,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:[Ci]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Ri.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===re.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===re.MemberExpression&&n.callee.property.type===re.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let s=t.disallowHooks.find(i=>i.name===o);s&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:i=>i.replaceText(a,s.replacement)}]})}}if(t.disallowMethods?.length&&Ai(n.callee)){for(let o of n.arguments)if(o.type===re.ObjectExpression){for(let a of o.properties)if(a.type===re.Property&&a.key.type===re.Identifier){let s=a.key.name,i=t.disallowMethods.find(l=>l.name===s);if(i){if(i.requireTrueProp){let l=i.requireTrueProp,c=!1;for(let p of o.properties)if(p.type===re.Property&&p.key.type===re.Identifier&&p.key.name===l&&p.value.type===re.Literal&&p.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:l}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),Et={name:Tn,rule:ki};import{ESLintUtils as vi,TSESTree as Oi}from"@typescript-eslint/utils";var Pi=vi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hn="require-description",Fi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Ni=/^eslint-disable-(next-)?line$/u,Di=Pi({name:hn,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:Mi(o.loc),messageId:"missingDescription"}))}}}}}),En={name:hn,rule:Di};function ji(e){let{text:t,description:r}=Li(e.value);if(!t)return null;let n=Fi.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=Ni.test(o);if(e.type===Oi.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let s=t.slice(n.index+o.length);return{kind:o,value:s.trim(),description:r}}function Li(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Mi(e){return{start:{line:e.start.line,column:-1},end:e.end}}function wn(e){return/^use[A-Z0-9]/.test(e)}function De(e){return e.type==="Identifier"?wn(e.name):e.type==="MemberExpression"&&!e.computed&&De(e.property)?e.object.type==="Identifier":!1}function In(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Cn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Rn(e){return!!(e.parent&&e.parent.callee&&Cn(e.parent.callee,"forwardRef"))}function An(e){return!!(e.parent&&e.parent.callee&&Cn(e.parent.callee,"memo"))}function bt(e){for(;e;){let t=vn(e);if(t&&(In(t)||De(t))||Rn(e)||An(e))return!0;e=e.parent}return!1}function bn(e){return!1}function xt(e){return!1}var _i=/eslint +react-compiler\/react-compiler: +\["error/,kn={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(_i.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,o=[],a=[],s=new WeakSet;function i(l){for(let c of l.references){let p=c.identifier.parent;if(p.type==="VariableDeclarator"&&p.init&&p.init.type==="CallExpression"&&p.init.callee&&bn(p.init.callee))for(let u of c.resolved.references)u!==c&&s.add(u.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,c){let p=o.pop();if(p.size===0)return;let u=new Set;function g(m,A){let{cache:R}=g,v=R.get(m.id),O=new Set(A);if(O.has(m.id)){let x=[...O],_=x.slice(x.indexOf(m.id)+1);for(let z of _)u.add(z);return BigInt("0")}if(O.add(m.id),v!==void 0)return v;if(l.thrownSegments.includes(m))v=BigInt("0");else if(m.prevSegments.length===0)v=BigInt("1");else{v=BigInt("0");for(let x of m.prevSegments)v+=g(x,O)}return m.reachable&&v===BigInt("0")?R.delete(m.id):R.set(m.id,v),v}function S(m,A){let{cache:R}=S,v=R.get(m.id),O=new Set(A);if(O.has(m.id)){let x=Array.from(O),_=x.slice(x.indexOf(m.id)+1);for(let z of _)u.add(z);return BigInt("0")}if(O.add(m.id),v!==void 0)return v;if(l.thrownSegments.includes(m))v=BigInt("0");else if(m.nextSegments.length===0)v=BigInt("1");else{v=BigInt("0");for(let x of m.nextSegments)v+=S(x,O)}return R.set(m.id,v),v}function h(m){let{cache:A}=h,R=A.get(m.id);if(R===null)return 1/0;if(R!==void 0)return R;if(A.set(m.id,null),m.prevSegments.length===0)R=1;else{R=1/0;for(let v of m.prevSegments){let O=h(v);O<R&&(R=O)}R+=1}return A.set(m.id,R),R}g.cache=new Map,S.cache=new Map,h.cache=new Map;let T=S(l.initialSegment),I=vn(c),E=bt(c),M=I?In(I)||De(I):Rn(c)||An(c),d=1/0;for(let m of l.finalSegments){if(!m.reachable)continue;let A=h(m);A<d&&(d=A)}for(let[m,A]of p){if(!m.reachable)continue;let R=m.nextSegments.length===0?d<=h(m):d<h(m),v=g(m)*S(m),O=u.has(m.id);for(let x of A)if(O&&!xt(x)&&e.report({node:x,message:`React Hook "${t(x)}" 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(c.async&&e.report({node:x,message:`React Hook "${t(x)}" cannot be called in an async function.`}),!O&&v!==T&&!xt(x)){let z=`React Hook "${t(x)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:x,message:z})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let _=`React Hook "${t(x)}" 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:x,message:_})}else if(I){let _=`React Hook "${t(x)}" is called in function "${t(I)}" 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:x,message:_})}else if(c.type==="Program"){let _=`React Hook "${t(x)}" 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:x,message:_})}else if(E&&!xt(x)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let z=c.parent;if(z.parent.type==="VariableDeclarator"&&wn(z.parent.id.name))return}let _=`React Hook "${t(x)}" 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:x,message:_})}}},CallExpression(l){if(De(l.callee)){let c=xn(o),p=xn(a),u=c.get(p);u||(u=[],c.set(p,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||bn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&s.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){bt(l)&&i(r(l))},ArrowFunctionExpression(l){bt(l)&&i(r(l))}}}};function vn(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 xn(e){return e[e.length-1]}var On={[dt.name]:dt.rule,[Ge.name]:Ge.rule,[Ke.name]:Ke.rule,"rules-of-hooks":kn,"exhaustive-deps":Dt,"require-description":En.rule,[Ze.name]:Ze.rule,[et.name]:et.rule,[gt.name]:gt.rule,[We.name]:We.rule,[qe.name]:qe.rule,[st.name]:st.rule,[ht.name]:ht.rule,[rt.name]:rt.rule,[Qe.name]:Qe.rule,[Ye.name]:Ye.rule,[Et.name]:Et.rule,[Ve.name]:Ve.rule,[Xe.name]:Xe.rule,[lt.name]:lt.rule,[ct.name]:ct.rule,[ut.name]:ut.rule,[ft.name]:ft.rule,[pt.name]:pt.rule,[Tt.name]:Tt.rule,[ot.name]:ot.rule};var Qo={rules:On};export{Qo as extendedLintPlugin};
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let y=l.acquire(w),R=new Set,C=null;{let f=y.upper;for(;f&&(R.add(f),f.type!=="function");)f=f.upper;if(!f)return;C=f}let E=Array.isArray;function F(f){if(!E(f.defs))return!1;let d=f.defs[0];if(d==null||d.node.type!=="VariableDeclarator")return!1;let I=d.node.init;if(I==null)return!1;for(;I.type==="TSAsExpression";)I=I.expression;let A=d.node.parent;if(A==null&&(Be(C.block,d.node.id),A=d.node.parent,A==null))return!1;if(A.kind==="const"&&I.type==="Literal"&&(typeof I.value=="string"||typeof I.value=="number"||I.value===null))return!0;if(I.type!=="CallExpression")return!1;let O=I.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let v=d.node.id,{name:N}=O;if(N==="useRef"&&v.type==="Identifier")return!0;if(nr(O)&&v.type==="Identifier"){for(let j of f.references)j!==v&&h.add(j.identifier);return!0}else if(N==="useState"||N==="useReducer"){if(v.type==="ArrayPattern"&&v.elements.length===2&&E(f.identifiers)){if(v.elements[1]===f.identifiers[0]){if(N==="useState"){let j=f.references,ne=0;for(let fe=0;fe<j.length;fe++){if(j[fe].isWrite()&&ne++,ne>1)return!1;c.set(j[fe].identifier,v.elements[0])}}return!0}else if(v.elements[0]===f.identifiers[0]){if(N==="useState"){let j=f.references;for(let ne=0;ne<j.length;ne++)p.add(j[ne].identifier)}return!1}}}else if(N==="useTransition"&&v.type==="ArrayPattern"&&v.elements.length===2&&Array.isArray(f.identifiers)&&v.elements[1]===f.identifiers[0])return!0;return!1}function H(f){if(!E(f.defs))return!1;let d=f.defs[0];if(d==null||d.node==null||d.node.id==null)return!1;let I=d.node,A=C.childScopes,O=null,v;for(v=0;v<A.length;v++){let N=A[v],j=N.block;if(I.type==="FunctionDeclaration"&&j===I||I.type==="VariableDeclarator"&&j.parent===I){O=N;break}}if(O==null)return!1;for(v=0;v<O.through.length;v++){let N=O.through[v];if(N.resolved!=null&&R.has(N.resolved.scope)&&!B(N.resolved))return!1}return!0}let B=x(F,u),Z=x(H,S),K=new Map;function ge(f){let d=f.from,I=!1;for(;d.block!==w;)d.type==="function"&&(I=d.block.parent!=null&&d.block.parent.type==="ReturnStatement"),d=d.upper;return I}let ee=new Map,xe=new Map;pe(y);function pe(f){for(let d of f.references){if(!d.resolved||!R.has(d.resolved.scope))continue;let I=Be(w,d.identifier),A=jt(I),O=me(A,xe);if(m&&A.type==="Identifier"&&(A.parent.type==="MemberExpression"||A.parent.type==="OptionalMemberExpression")&&!A.parent.computed&&A.parent.property.type==="Identifier"&&A.parent.property.name==="current"&&ge(d)&&K.set(O,{reference:d,dependencyNode:A}),A.parent.type==="TSTypeQuery"||A.parent.type==="TSTypeReference")continue;let v=d.resolved.defs[0];if(v!=null&&!(v.node!=null&&v.node.init===w.parent)&&v.type!=="TypeParameter")if(ee.has(O))ee.get(O).references.push(d);else{let N=d.resolved,j=B(N)||Z(N);ee.set(O,{isStable:j,references:[d]})}}for(let d of f.childScopes)pe(d)}K.forEach(({reference:f,dependencyNode:d},I)=>{let A=f.resolved.references,O=!1;for(let v=0;v<A.length;v++){let{identifier:N}=A[v],{parent:j}=N;if(j!=null&&j.type==="MemberExpression"&&!j.computed&&j.property.type==="Identifier"&&j.property.name==="current"&&j.parent.type==="AssignmentExpression"&&j.parent.left===j){O=!0;break}}O||i({node:d.parent.property,message:`The ref value '${I}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${I}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let le=new Set;function ue(f,d){le.has(d)||(le.add(d),i({node:f,message:`Assignments to the '${d}' variable from inside React Hook ${r(P)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${r(P)}.`}))}let Se=new Set;if(ee.forEach(({isStable:f,references:d},I)=>{f&&Se.add(I),d.forEach(A=>{A.writeExpr&&ue(A.writeExpr,I)})}),le.size>0)return;if(!L){let f=null;if(ee.forEach(({isStable:d,references:I},A)=>{f||I.forEach(O=>{if(f)return;let v=O.identifier;if(!c.has(v))return;let j=O.from;for(;j.type!=="function";)j=j.upper;j.block===w&&(f=A)})}),f){let{suggestedDependencies:d}=He({dependencies:ee,declaredDependencies:[],stableDependencies:Se,externalDependencies:new Set,isEffect:!0});i({node:P,message:`React Hook ${T} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+d.join(", ")+`] as a second argument to the ${T} Hook.`,suggest:[{desc:`Add dependencies array: [${d.join(", ")}]`,fix(I){return I.insertTextAfter(w,`, [${d.join(", ")}]`)}}]})}return}let we=[],Ie=new Set;L.type!=="ArrayExpression"?i({node:L,message:`React Hook ${r(P)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):L.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${r(P)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}h.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(f)}\``,fix(O){return O.removeRange(f.range)}}]});let d;try{d=me(f,xe)}catch(O){if(/Unsupported node type/.test(O.message)){f.type==="Literal"?ee.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${r(P)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let I=f;for(;I.type==="MemberExpression"||I.type==="OptionalMemberExpression"||I.type==="ChainExpression";)I=I.object||I.expression.object;let A=!C.through.some(O=>O.identifier===I);we.push({key:d,node:f}),A||Ie.add(d)});let{suggestedDependencies:Pn,unnecessaryDependencies:Ae,missingDependencies:de,duplicateDependencies:xt}=He({dependencies:ee,declaredDependencies:we,stableDependencies:Se,externalDependencies:Ie,isEffect:m}),ke=Pn;if(xt.size+de.size+Ae.size===0){if(t)return;Zn({declaredDependencies:we,declaredDependenciesNode:L,componentScope:C,scope:y}).forEach(({construction:d,isUsedOutsideOfHook:I,depType:A})=>{let O=A==="function"?"useCallback":"useMemo",v=A==="function"?"definition":"initialization",N=`wrap the ${v} of '${d.name.name}' in its own ${O}() Hook.`,j=I?`To fix this, ${N}`:`Move it inside the ${T} callback. Alternatively, ${N}`,ne=A==="conditional"||A==="logical expression"?"could make":"makes",fe=`The '${d.name.name}' ${A} ${ne} the dependencies of ${T} Hook (at line ${L.loc.start.line}) change on every render. ${j}`,wt;I&&d.type==="Variable"&&A==="function"&&(wt=[{desc:`Wrap the ${v} of '${d.name.name}' in its own ${O}() Hook.`,fix(It){let[Nn,Dn]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[It.insertTextBefore(d.node.init,Nn),It.insertTextAfter(d.node.init,Dn)]}}]),i({node:d.node,message:fe,suggest:wt})});return}!m&&de.size>0&&(ke=He({dependencies:ee,declaredDependencies:[],stableDependencies:Se,externalDependencies:Ie,isEffect:m}).suggestedDependencies);function Fn(){if(we.length===0)return!0;let f=we.map(I=>I.key),d=f.slice().sort();return f.join(",")===d.join(",")}Fn()&&ke.sort();function Me(f){let d=f.split("."),I="";for(let A=0;A<d.length;A++){if(A!==0){let O=d.slice(0,A+1).join("."),v=xe.get(O)===!0;I+=v?"?.":"."}I+=d[A]}return I}function _e(f,d,I,A){return f.size===0?null:(f.size>1?"":d+" ")+I+" "+(f.size>1?"dependencies":"dependency")+": "+er(Array.from(f).sort().map(O=>"'"+Me(O)+"'"))+`. Either ${A} ${f.size>1?"them":"it"} or remove the dependency array.`}let oe="";if(Ae.size>0){let f=null;if(Array.from(Ae.keys()).forEach(d=>{f===null&&d.endsWith(".current")&&(f=d)}),f!==null)oe=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Ie.size>0){let d=Array.from(Ie)[0];y.set.has(d)||(oe=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!oe&&de.has("props")){let f=ee.get("props");if(f==null)return;let d=f.references;if(!Array.isArray(d))return;let I=!0;for(let A=0;A<d.length;A++){let O=d[A],v=Be(C.block,O.identifier);if(!v){I=!1;break}let N=v.parent;if(N==null){I=!1;break}if(N.type!=="MemberExpression"&&N.type!=="OptionalMemberExpression"){I=!1;break}}I&&(oe=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${T} call and refer to those specific props inside ${r(P)}.`)}if(!oe&&de.size>0){let f=null;de.forEach(d=>{if(f)return;let I=C.set.get(d),A=ee.get(d);if(A.references[0].resolved!==I)return;let O=I.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let v=!1,N;for(let j=0;j<A.references.length;j++)if(N=A.references[j].identifier,N!=null&&N.parent!=null&&(N.parent.type==="CallExpression"||N.parent.type==="OptionalCallExpression")&&N.parent.callee===N){v=!0;break}v&&(f=d)}),f!==null&&(oe=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!oe&&de.size>0){let f=null;if(de.forEach(d=>{if(f!==null)return;let A=ee.get(d).references,O,v;for(let N=0;N<A.length;N++){for(O=A[N].identifier,v=O.parent;v!=null&&v!==C.block;){if(v.type==="CallExpression"){let j=c.get(v.callee);if(j!=null){if(j.name===d)f={missingDep:d,setter:v.callee.name,form:"updater"};else if(p.has(O))f={missingDep:d,setter:v.callee.name,form:"reducer"};else{let ne=A[N].resolved;if(ne!=null){let fe=ne.defs[0];fe!=null&&fe.type==="Parameter"&&(f={missingDep:d,setter:v.callee.name,form:"inlineReducer"})}}break}}v=v.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":oe=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":oe=` 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":oe=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:L,message:`React Hook ${r(P)} has `+(_e(de,"a","missing","include")||_e(Ae,"an","unnecessary","exclude")||_e(xt,"a","duplicate","omit"))+oe,suggest:[{desc:`Update the dependencies array to be: [${ke.map(Me).join(", ")}]`,fix(f){return f.replaceText(L,`[${ke.map(Me).join(", ")}]`)}}]})}function k(w){let L=Qn(w.callee,s);if(L===-1)return;let P=w.arguments[L],T=w.callee,m=Lt(T).name,y=w.arguments[L+1],R=/Effect($|[^a-z])/g.test(m);if(!P){i({node:T,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!R)){if(!y&&!R){(m==="useMemo"||m==="useCallback")&&i({node:T,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(P.type){case"FunctionExpression":case"ArrowFunctionExpression":b(P,y,T,m,R);return;case"Identifier":if(!y||y.elements&&y.elements.some(F=>F&&F.type==="Identifier"&&F.name===P.name))return;let C=n(w).set.get(P.name);if(C==null||C.defs==null)return;let E=C.defs[0];if(!E||!E.node||E.type!=="Variable"&&E.type!=="FunctionName")break;switch(E.node.type){case"FunctionDeclaration":b(E.node,y,T,m,R);return;case"VariableDeclarator":let F=E.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":b(F,y,T,m,R);return}break}break;default:i({node:T,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:T,message:`React Hook ${m} has a missing dependency: '${P.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${P.name}]`,fix(C){return C.replaceText(y,`[${P.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let w of e.sourceCode.getAllComments())if(Gn.test(w.value))return t=!0,{CallExpression:L=>k(L,!0)}}return{CallExpression:w=>k(w)}}};function He({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((b,k)=>{let w=i(a,k);w.isUsed=!0,l(a,k,L=>{L.isSubtreeUsed=!0})}),t.forEach(({key:b})=>{let k=i(a,b);k.isSatisfiedRecursively=!0}),r.forEach(b=>{let k=i(a,b);k.isSatisfiedRecursively=!0});function i(b,k){let w=k.split("."),L=b;for(let P of w){let T=L.children.get(P);T||(T=s(),L.children.set(P,T)),L=T}return L}function l(b,k,w){let L=k.split("."),P=b;for(let T of L){let m=P.children.get(T);if(!m)return;w(m),P=m}}let c=new Set,p=new Set;u(a,c,p,b=>b);function u(b,k,w,L){b.children.forEach((P,T)=>{let m=L(T);if(P.isSatisfiedRecursively){P.isSubtreeUsed&&w.add(m);return}if(P.isUsed){k.add(m);return}u(P,k,w,y=>m+"."+y)})}let S=[],h=new Set,x=new Set;return t.forEach(({key:b})=>{p.has(b)?S.indexOf(b)===-1?S.push(b):x.add(b):h.add(b)}),c.forEach(b=>{S.push(b)}),{suggestedDependencies:S,unnecessaryDependencies:h,duplicateDependencies:x,missingDependencies:c}}function ye(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 ye(e.consequent)!=null||ye(e.alternate)!=null?"conditional":null;case"LogicalExpression":return ye(e.left)!=null||ye(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return ye(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return ye(e.expression);case"TSAsExpression":return ye(e.expression)}return null}function Zn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:s})=>{let i=r.variables.find(c=>c.name===s);if(i==null)return null;let l=i.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let c=ye(l.node.init);if(c!=null)return[i,c]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[i,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function a(s){let i=!1;for(let l=0;l<s.references.length;l++){let c=s.references[l];if(c.writeExpr){if(i)return!0;i=!0;continue}let p=c.from;for(;p!==n&&p!=null;)p=p.upper;if(p!==n&&!Mt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}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 Ye(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function me(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=me(e.object,t),n=me(e.property,null),o=`${r}.${n}`;return Ye(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=me(e.object,t),n=me(e.property,null),o=`${r}.${n}`;return Ye(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=me(r.object,t),o=me(r.property,null),a=`${n}.${o}`;return Ye(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Lt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Qn(e,t){let r=Lt(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=me(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 Be(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),tr(n,t))return n;if(Mt(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(Nt(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(s=>{Nt(s)&&(s.parent=n,r.push(s))}))}return null}function er(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 Nt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function tr(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function Mt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function nr(e){return!1}import{AST_NODE_TYPES as Oe,ESLintUtils as $t}from"@typescript-eslint/utils";import Q from"typescript";var rr=$t.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="improved-no-unnecessary-condition",ir=U({}),sr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],or=new Set(sr),Je={name:_t,rule:rr({name:_t,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[ir]},defaultOptions:[{}],create(e){let t=$t.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(i){return i.type===Oe.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&Q.TypeFlags.Any||i.flags&Q.TypeFlags.Unknown?null:i.flags&Q.TypeFlags.StringLike?["string"]:i.flags&Q.TypeFlags.NumberLike?["number"]:i.flags&Q.TypeFlags.BigIntLike?["bigint"]:i.flags&Q.TypeFlags.BooleanLike?["boolean"]:i.flags&Q.TypeFlags.ESSymbolLike?["symbol"]:i.flags&Q.TypeFlags.Undefined||i.flags&Q.TypeFlags.Void?["undefined"]:i.flags&Q.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&Q.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&Q.TypeFlags.NonPrimitive?["object"]:i.flags&Q.TypeFlags.Never?["never"]:null}function a(i){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=r.getTypeAtLocation(l.expression);if(c.flags&Q.TypeFlags.Any||c.flags&Q.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let S of c.types){let h=o(S);if(h)p.push(...h);else return null}return p}let u=o(c);return u?(p.push(...u),p):null}function s(i){if(!(i.operator==="==="||i.operator==="!=="))return;let c=null,p=null;if(n(i.left)?(c=i.left,p=i.right.type===Oe.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(c=i.right,p=i.left.type===Oe.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!ar(p,or))return;let u=a(c);if(!u)return;let S=i.operator==="!==",h=u.includes(p);u.length===1?h&&!S?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:he(c,e),type:p}}):!h&&S?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:he(c,e),type:Array.from(u)[0]}}):!h&&!S?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:he(c,e),actualType:ve(u),conditionType:p}}):h&&S&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:he(c,e),actualType:ve(u),conditionType:p}}):!h&&!S?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:he(c,e),actualType:ve(u),conditionType:p}}):!h&&S&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:he(c,e),type:ve(u)}})}return{BinaryExpression:s}}})};function ve(e){return Array.from(new Set(e)).join(" | ")||"never"}function he(e,t){let r=e.argument;return r.type===Oe.Identifier?r.name:t.sourceCode.getText(r)}function ar(e,t){return t.has(e)}import{AST_NODE_TYPES as lr,ESLintUtils as cr}from"@typescript-eslint/utils";var pr=cr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="no-call-with-explicit-generics",ur=U({functions:X(z())}),fr=pr({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:[ur]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===lr.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),Xe={name:zt,rule:fr};import{AST_NODE_TYPES as Pe,ESLintUtils as mr}from"@typescript-eslint/utils";var dr=mr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="no-call-with-inferred-generics",yr=dr({name:Ut,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:o}=n;if(o.type!==Pe.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(s||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&n.typeArguments?.params?.some(p=>!i&&p.type===Pe.TSAnyKeyword||l&&p.type===Pe.TSTypeReference&&p.typeName.type===Pe.Identifier&&l.includes(p.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),qe={name:Ut,rule:yr};import{ESLintUtils as gr}from"@typescript-eslint/utils";var Sr=gr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="no-commented-out-code",Tr=["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:"],hr=[") {","return;",/^\s*return\s+/,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",/\w=("|'|`)/,");",/\w+:\s*('|"|`)/,/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,/\w+-\w+:/,/\w+_\w+:/,"&&","||","()",/\?\s+\w/,/:\s+\w/,/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,/^\s*\d+[,}]/,/^\s*\[[^\]]*\][,}]/,/^\s*\{[^}]*\}[,}]/,/\.\w+\(/,/\[\w+\]/,"?.(","??","=>",/^\s*(['"`]).+?\1\s*:/],Er=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Vt=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],br=Sr({name:Wt,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")||/^\s*[*\s]*$/.test(n))return!1;for(let s of Vt)if(a.startsWith(s))return!1;if(n.includes("https://"))return!1;if(o==="Block"){for(let s of Er)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of Tr)if(a.startsWith(s))return{wrongPattern:s};for(let s of hr)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}function r(n,o){let a=n,s=a.trim();if(s.startsWith("`")&&(s.endsWith("`,")||s.endsWith("`;")||s.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let c=a.split(/```[\s\S]*?```/g);c.some(u=>/[a-zA-Z0-9]/.test(u))&&(a=c.join(""))}if(!a.includes("`"))return a;let i=a.split(/`[^`]*`/g);return i.some(c=>/[a-zA-Z0-9]/.test(c))?i.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let s=r(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Vt.join(", ")}})}}}}}),Ke={name:Wt,rule:br};import{ESLintUtils as xr,TSESTree as wr}from"@typescript-eslint/utils";var Ir=xr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="no-default-export",Cr=Ir({name:Ht,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===wr.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Ge={name:Ht,rule:Cr};import{ESLintUtils as Rr}from"@typescript-eslint/utils";var Ar=Rr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="no-leaked-text-in-jsx",kr=[",",";","[","]","(",")"],vr=Ar({name:Yt,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let r=t.value.trim();if(!r)return;let n="";kr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),Ze={name:Yt,rule:vr};import{AST_NODE_TYPES as Ce,ESLintUtils as Or}from"@typescript-eslint/utils";var Pr=Or.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-non-camel-case-functions",Fr=/^(\$?[a-z][a-zA-Z0-9]*)$/;function Bt(e){if(e.typeName.type!==Ce.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Ce.Identifier&&t.name==="JSX"&&r.name==="Element"}var Nr=Pr({name:Jt,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&&!Fr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Ce.TSTypeReference?Bt(r):r.type===Ce.TSUnionType&&r.types.some(o=>o.type===Ce.TSTypeReference&&Bt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Qe={name:Jt,rule:Nr};import{ESLintUtils as Dr,TSESTree as V}from"@typescript-eslint/utils";import{AST_NODE_TYPES as Xt}from"@typescript-eslint/utils";function Ee(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Ee(e.parent,t,r===1/0?r:r-1)}function*et(e){yield e,e.parent&&(yield*et(e.parent))}function tt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function qt(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Xt.Property&&a.identifiers[0]?.parent.key.type===Xt.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var jr=Dr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="no-optional-root-props",Lr=jr({name:Kt,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 s=a.references[0];if(!s)return!1;for(let i of et(s.identifier)){if("returnType"in i||i.type===V.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=i.parent;if(!l)return!1;if(l.type===V.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===V.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===V.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let p=Ee(l.parent.parent,V.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=Fe(p,e.sourceCode);return u?!(u.parent.type===V.AST_NODE_TYPES.CallExpression&&u.parent.callee.type===V.AST_NODE_TYPES.Identifier&&u.parent.callee.name==="memo"):!1}if(i.type===V.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===V.AST_NODE_TYPES.ArrowFunctionExpression){let c=Ee(l,V.AST_NODE_TYPES.VariableDeclaration);return c?!!Fe(c,e.sourceCode):!1}if(l.type===V.AST_NODE_TYPES.FunctionDeclaration)return!!Fe(l,e.sourceCode)}return!1}function r(n){n.key.type!==V.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Ee(n,V.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let s=e.sourceCode.getText(a);return o.replaceText(a,s.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===V.AST_NODE_TYPES.TSTypeLiteral&&!(Ne(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===V.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Ne(n)||!t(n)))for(let o of n.body.body)o.type===V.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==V.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==V.AST_NODE_TYPES.TSTypeLiteral)return;let a=Ee(n.parent,V.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=Fe(a,e.sourceCode);if(!(!s||s.parent.type===V.AST_NODE_TYPES.CallExpression&&s.parent.callee.type===V.AST_NODE_TYPES.Identifier&&s.parent.callee.name==="memo"))for(let l of o.members)l.type===V.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Ne(e){return e?e.parent?.type===V.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===V.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Fe(e,t){if(Ne(e))return;let r;if(e.type===V.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===V.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===V.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(s=>s.identifiers.includes(r));if(!o)return;let a=o.references.filter(s=>s.identifier!==r);if(!(a.length!==1||!a[0])&&!Ne(a[0].identifier.parent.parent))return a[0].identifier}var nt={name:Kt,rule:Lr};import{ESLintUtils as Mr}from"@typescript-eslint/utils";import rt from"node:path";var _r=Mr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="no-relative-imports",$r=U({find:z(),replacement:z()}),zr=U({aliases:X($r),rootDir:M(z()),allowNotFoundAliases:M(Te()),_dev_simulateFileName:M(z())}),Ur=_r({name:Gt,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:[zr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=rt.dirname(i);return rt.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=rt.relative(i,s);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:c,replacement:p}of t.aliases)if(l.startsWith(p)){let u=l.replace(p,c);return{alias:c,newPath:u}}return null}return{ImportDeclaration(s){let i=s.source.value;if(!n(i))return;let l=o(i,r),c=a(l);!c&&t.allowNotFoundAliases||e.report({node:s,messageId:c?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:c?.alias},fix:c?p=>p.replaceText(s.source,`'${c.newPath}'`):void 0})}}}}),it={name:Gt,rule:Ur};import{AST_NODE_TYPES as be}from"@typescript-eslint/utils";var Vr="no-unnecessary-async-on-jsx-props";function Wr(e){if(e.body.type!==be.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==be.ExpressionStatement?!1:r.expression.type===be.AwaitExpression}var st=re({name:Vr,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){Wr(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let o=e.sourceCode,a=[],s=o.getFirstToken(r,l=>l.value==="async");if(s){let l=o.getTokenAfter(s);l?a.push(n.replaceTextRange([s.range[0],l.range[0]],"")):a.push(n.remove(s))}function i(l){if(l.type===be.AwaitExpression){let c=o.getFirstToken(l);if(c&&c.value==="await"){let p=o.getTokenAfter(c);p?a.push(n.replaceTextRange([c.range[0],p.range[0]],"")):a.push(n.remove(c))}}if(l.type===be.BlockStatement)for(let c of l.body)i(c);else l.type===be.ExpressionStatement&&i(l.expression)}return i(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as Re,ESLintUtils as Qt}from"@typescript-eslint/utils";import*as ot from"typescript";var Hr=Qt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-unnecessary-casting",Yr=U({additionalCastFunctions:M(X(U({name:z(),expectedType:Ct(["string","number"])})))}),at={name:Zt,rule:Hr({name:Zt,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[Yr],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=Qt.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function s(p,u){switch(p.type){case Re.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case Re.TemplateLiteral:return u==="string";case Re.UnaryExpression:return u==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,u){return u==="number"?!!(p.flags&ot.TypeFlags.NumberLike):!!(p.flags&ot.TypeFlags.StringLike)}function l(p,u){return S=>S.replaceText(p,e.sourceCode.getText(u))}function c(p){if(!a||p.arguments.length!==1)return;let u=p.arguments[0];if(!u||u.type===Re.SpreadElement)return;let{callee:S}=p;if(S.type!==Re.Identifier)return;let h=S.name,x=n.find(k=>k.name===h);if(!x)return;if(s(u,x.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),x.expectedType)){let k,w;h==="Number"?k="unnecessaryNumberCasting":h==="String"?k="unnecessaryStringCasting":(k="unnecessaryCustomCasting",w={name:x.name,type:x.expectedType}),e.report({node:p,messageId:k,...w?{data:w}:{},fix:l(p,u)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as De}from"@typescript-eslint/utils";import*as ie from"zod/v4";var Br=ie.object({methods:ie.union([ie.array(ie.string()),ie.literal("array")])}),lt=re({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:[ie.toJSONSchema(Br)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(r)?r.includes(i):n.has(i)}function a(i){let{callee:l}=i;if(l.type===De.MemberExpression){let c=l.property;if(c.type===De.Identifier)return c.name}return null}function s(i,l){if(i.type!==De.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===De.CallExpression){let p=a(c);p&&o(p)&&c.arguments.indexOf(l)===0&&e.report({node:i.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(S){return S.remove(i.typeAnnotation)}})}}return{ArrowFunctionExpression(i){for(let l of i.params)s(l,i)},FunctionExpression(i){for(let l of i.params)s(l,i)}}}});import{AST_NODE_TYPES as te}from"@typescript-eslint/utils";var ct=re({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===te.ObjectPattern||!t.init||t.init.type!==te.ObjectExpression||t.id.type===te.Identifier&&t.id.typeAnnotation||t.parent.parent.type===te.ExportNamedDeclaration)return;let r=new Map;for(let s of t.init.properties)s.type===te.Property&&s.key.type===te.Identifier&&r.set(s.key.name,s);if(r.size===0||t.id.type!==te.Identifier)return;let n=Jr(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(s=>s.type!==te.Property?!1:s.value.type===te.FunctionExpression),a=new Set;for(let s of n){if(s.identifier.parent.type!==te.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===te.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==te.Identifier)return;a.add(i.property.name)}if(i.parent.type===te.CallExpression&&o)return}for(let[s,i]of r)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function Jr(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):[]}import{AST_NODE_TYPES as Y,ESLintUtils as Xr}from"@typescript-eslint/utils";var qr=U({selectors:X(U({name:z(),selectorProp:M(z()),selectorArgPos:M(ce()),returnProp:M(z())}))}),Kr=Xr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),en="no-unused-selected-values",pt={name:en,rule:Kr({name:en,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[qr]},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===Y.CallExpression&&(a=o.init),!a)return;let s=Zr(a);if(!s)return;let i=n.get(s);if(!i)return;let l=Gr(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=Qr(l);if(!c)return;let p=tn(c.properties,void 0);if(!p)return;if(o.id.type===Y.ObjectPattern){let h=tn(o.id.properties,i.returnProp);if(!h)return;for(let[x,b]of p)h.has(x)||e.report({node:b,messageId:"unusedSelectedValue",data:{name:x}});return}if(o.id.type!==Y.Identifier||i.returnProp)return;let u=ei(o,e.sourceCode);if(u.length===0)return;let S=new Set;for(let h of u){if(h.identifier.parent.type!==Y.MemberExpression)return;let x=h.identifier.parent.property;if(x.type!==Y.Identifier)return;S.add(x.name)}for(let[h,x]of p)S.has(h)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:h}})}}}})};function Gr(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===Y.ArrowFunctionExpression||n.type===Y.FunctionExpression)return n;if(r&&n.type===Y.ObjectExpression){let o=n.properties.find(s=>s.type===Y.Property&&s.key.type===Y.Identifier&&s.key.name===r);if(o?.type!==Y.Property)return null;let a=o.value;if(a.type===Y.ArrowFunctionExpression||a.type===Y.FunctionExpression)return a}return null}function Zr(e){return e.callee.type===Y.Identifier?e.callee.name:e.callee.type===Y.MemberExpression&&e.callee.property.type===Y.Identifier?e.callee.property.name:null}function Qr(e){if(e.body.type===Y.ObjectExpression)return e.body;if(e.body.type===Y.BlockStatement){let t=e.body.body.filter(r=>r.type===Y.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==Y.ObjectExpression?null:t[0].argument}return null}function tn(e,t){let r=e;if(t){let o=e.find(a=>a.type===Y.Property&&a.key.type===Y.Identifier&&a.key.name===t);if(o?.type!==Y.Property||o.value.type!==Y.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==Y.Property||o.key.type!==Y.Identifier)return null;n.set(o.key.name,o)}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(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as W}from"@typescript-eslint/utils";var ut=re({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===W.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let i=ti(a);i&&(n=i);return}let s=ni(a,e.sourceCode);if(s){o=!0;for(let i of s)n.delete(i);if(n.size!==0)for(let[i,l]of n)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function ti(e){if(!(e.callee.type===W.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==W.ObjectExpression)return null;let n=tt(r.properties,a=>a.type!==W.Property||a.key.type!==W.Identifier||a.key.name!=="initialConfig"?null:a.value.type===W.ObjectExpression?a.value:a.value.type===W.ArrowFunctionExpression||a.value.type===W.FunctionExpression?ri(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===W.Property&&a.key.type===W.Identifier&&o.set(a.key.name,a);return o}function ni(e,t){if(!(e.callee.type===W.Identifier&&e.callee.name==="useFormState")||e.parent.type!==W.VariableDeclarator||e.parent.id.type!==W.ObjectPattern||!tt(e.parent.id.properties,s=>s.type===W.Property&&s.key.type===W.Identifier&&s.key.name==="formFields"&&s))return null;let o=qt(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==W.Identifier||s.parent.type===W.Property&&s.parent.parent.type===W.ObjectExpression&&s.parent.parent.parent.type===W.ReturnStatement||s.parent.type===W.ReturnStatement)return null;if(s.parent.type===W.MemberExpression){if(s.parent.object.type!==W.Identifier||s.parent.property.type!==W.Identifier)return null;a.add(s.parent.property.name)}}return a}function ri(e){if(e.body.type===W.ObjectExpression)return e.body;if(e.body.type===W.BlockStatement){let t=e.body.body.filter(r=>r.type===W.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==W.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as $,ESLintUtils as ii}from"@typescript-eslint/utils";var si=ii.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function nn(e){let t=[];for(let r of e.members)r.type===$.TSPropertySignature&&r.key.type===$.Identifier&&t.push([r.key.name,r]);return t}function rn(e,...t){for(let r of t)e.set(...r);return e}var oi=U({forceCheckOnFCPropTypesWithName:M(X(z()))}),sn="no-unused-type-props-in-args",ft=null,ai=si({name:sn,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[oi],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!ft&&(ft=r.map(i=>new RegExp(i)));function n(i,l,c,p,u=!0){let S=c.name,h=e.sourceCode.getScope(l).references.find(k=>k.identifier.name===S)?.resolved,x=i&&ft?.some(k=>k.test(S));if(!h||!x&&h.references.filter(k=>k.isTypeReference).length>1)return;let b=h?.defs[0]?.node;if(!(u&&b?.parent?.type===$.ExportNamedDeclaration)){if(b?.type===$.TSTypeAliasDeclaration){o(i,l,p,b.typeAnnotation,!0);return}if(b?.type===$.TSInterfaceDeclaration){o(i,l,p,b.body,!0);return}}}function o(i,l,c,p,u){if(p.type===$.TSInterfaceBody){for(let S of p.body)S.type===$.TSPropertySignature&&S.key.type===$.Identifier&&c.set(S.key.name,S);return}if(p.type===$.TSTypeLiteral){rn(c,...nn(p));return}if(p.type===$.TSIntersectionType){for(let S of p.types)o(i,l,c,S,!0);return}u||p.type===$.TSTypeReference&&p.typeName.type===$.Identifier&&n(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let u=new Map;if(o(i,l,u,p.typeAnnotation.typeAnnotation,!1),u.size===0)continue;s(p,u)}else p.type===$.AssignmentPattern&&p.left.type===$.ObjectPattern&&a(i,l,[p.left])}function s(i,l){let c=[];if(i.properties.at(-1)?.type===$.RestElement)return;for(let h of i.properties)h.type===$.Property&&h.key.type===$.Identifier&&c.push(h.key.name);let u=[],S=[];for(let[h,x]of l)c.includes(h)||(S.push(h),u.push({node:x,messageId:"unusedObjectTypeProperty",data:{propertyName:h}}));for(let[h,x]of u.entries())e.report({...x,fix:h===u.length-1?b=>{let k=i.properties.at(-1),w=S.join(", ");return k?k?.type===$.RestElement?null:b.insertTextAfter(k,`, ${w}`):b.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${w}`)}:void 0})}return{VariableDeclaration(i){let l=i.declarations[0];if(!l)return;let c=new Map,p=l.id.type===$.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===$.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===$.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(p){if(p.type===$.TSTypeReference&&p.typeName.type===$.Identifier)n(!0,i,p.typeName,c,!1);else if(p.type===$.TSTypeLiteral)rn(c,...nn(p));else if(p.type===$.TSIntersectionType)for(let u of p.types)u.type===$.TSTypeReference&&u.typeName.type===$.Identifier?n(!0,i,u.typeName,c,!1):o(!0,i,c,u,!0);if(c.size!==0&&l.init?.type===$.ArrowFunctionExpression){let u=l.init.params[0];if(!u){e.report({node:l.init,messageId:"missingComponentParam"});return}u.type===$.ObjectPattern&&s(u,c)}}},FunctionDeclaration:function(i){a(!1,i,i.params)},ArrowFunctionExpression(i){a(!1,i,i.params)}}}}),mt={name:sn,rule:ai};import{AST_NODE_TYPES as dt,ESLintUtils as li}from"@typescript-eslint/utils";var ci=li.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="prefer-named-functions",on=new Map,pi=ci({name:an,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let r=null;if(t.ignoreRegex){let n=on.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),on.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===dt.ArrowFunctionExpression&&n.id.type===dt.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==dt.BlockStatement)return;let a=n.parent,s=n.init.params,i=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:c=>c.replaceText(a,`${l.async?"async ":""}function ${o}(${s.map(p=>e.sourceCode.getText(p)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),yt={name:an,rule:pi};import{AST_NODE_TYPES as D}from"@typescript-eslint/utils";var ui=U({disallowedFunctions:X(U({name:z(),allowUsingWithArgs:M(Te()),hookAlternative:M(z()),message:M(z()),allowUseInside:M(X(z()))}))});function je(e){return/^use[A-Z]/.test(e)}function ln(e){return/^[A-Z]/.test(e)}function fi(e){return e.type===D.Identifier?je(e.name):e.type===D.MemberExpression&&e.property.type===D.Identifier?je(e.property.name):!1}function cn(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 pn(e){return!!(e.parent&&e.parent.type===D.CallExpression&&cn(e.parent.callee,"forwardRef"))}function un(e){return!!(e.parent&&e.parent.type===D.CallExpression&&cn(e.parent.callee,"memo"))}function gt(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 mi(e){let t=e.parent,r=!1;for(;t;){if(t.type===D.FunctionDeclaration||t.type===D.FunctionExpression||t.type===D.ArrowFunctionExpression){let n=gt(t);if(n&&n.type===D.Identifier){if(ln(n.name)||je(n.name))return!r;r=!0}else{if(pn(t)||un(t))return!r;if(t.parent.type===D.CallExpression){let o=t.parent;fi(o.callee)||(r=!0)}else t.parent.type===D.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function fn(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 di(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===D.FunctionDeclaration||r.type===D.FunctionExpression||r.type===D.ArrowFunctionExpression){let n=gt(r);if(n&&n.type===D.Identifier&&t.includes(n.name))return!0}else if(r.type===D.CallExpression){let n=fn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function yi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===D.Identifier&&t.name==="undefined")}function gi(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===D.FunctionDeclaration||n.type===D.FunctionExpression||n.type===D.ArrowFunctionExpression){let o=gt(n);if(o&&o.type===D.Identifier){if(ln(o.name)||je(o.name)){r=!0;break}}else if(pn(n)||un(n)){r=!0;break}}n=n.parent}return r?t.length===0?mi(e):!di(e,t):!1}var St=re({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:[ui],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=fn(o);if(!a)return;let s=n.get(a);if(!s||s.allowUsingWithArgs&&yi(o))return;let i=s.allowUseInside||[];gi(o,i)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:s.message?` ${s.message}`:` use ${s.hookAlternative} instead`},suggest:s.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${s.hookAlternative}`,hookAlternative:s.hookAlternative},fix:l=>{let c=s.hookAlternative;return o.callee.type===D.Identifier?l.replaceText(o.callee,c):o.callee.type===D.MemberExpression&&o.callee.property.type===D.Identifier?l.replaceText(o.callee.property,c):null}}]:[]})}}}});import{AST_NODE_TYPES as J,AST_TOKEN_TYPES as mn,ESLintUtils as Si}from"@typescript-eslint/utils";var Ti=Si.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yn="prefer-single-line-if",hi=U({maxLineLength:M(ce()),maxNonSimpleConditionLength:M(ce())}),Ei=Ti({name:yn,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:[hi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==J.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.ReturnStatement){if(!Sn(a))return}else if(!(a.type===J.ContinueStatement||a.type===J.BreakStatement))return;if(n.test.type===J.LogicalExpression||n.test.type===J.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=dn(n.test);if(!u&&n.test.type===J.UnaryExpression&&n.test.operator==="!"){let S=n.test.argument;dn(S)&&(u=!0)}if(u&&(s=r.getText(n.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=r.getText(n.test));let i=r.getText(a);if(s.includes(`
|
|
16
|
+
`))return;let l=r.getTokenAfter(n);if(l&&l.type===mn.Punctuator&&l.value==="}"){let u=r.getTokenAfter(l);if(u&&u.type===mn.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=bi(r,n),p=`if (${s}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:u=>u.replaceText(n,p)})}}}});function dn(e){return e.type===J.CallExpression||e.type===J.BinaryExpression||e.type===J.MemberExpression&&gn(e)}function gn(e){return e.object.type===J.MemberExpression?gn(e.object):e.object.type!==J.Identifier}function bi(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Sn(e){if(!e.argument)return!0;let t=e.argument;return t.type===J.ArrayExpression&&t.elements.length===0||t.type===J.ObjectExpression&&t.properties.length===0||t.type===J.Literal||t.type===J.Identifier||t.type===J.TemplateLiteral||t.type===J.TaggedTemplateExpression?!0:t.type===J.CallExpression?t.arguments.length===0:t.type===J.UnaryExpression?Sn(t):!1}var Tt={name:yn,rule:Ei};import{AST_NODE_TYPES as se,ESLintUtils as xi}from"@typescript-eslint/utils";var wi=xi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tn="react-compiler-migration",Ii=U({disallowHooks:M(X(U({name:z(),replacement:z()}))),disallowMethods:M(X(U({name:z(),replacement:M(z()),requireTrueProp:M(z())})))}),Ci=/eslint +react-compiler\/react-compiler: +\["error/;function Ri(e){return e.type===se.Identifier?e.name.startsWith("use"):e.type===se.MemberExpression&&e.property.type===se.Identifier?e.property.name.startsWith("use"):!1}var Ai=wi({name:Tn,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:[Ii]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Ci.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===se.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===se.MemberExpression&&n.callee.property.type===se.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let s=t.disallowHooks.find(i=>i.name===o);s&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:i=>i.replaceText(a,s.replacement)}]})}}if(t.disallowMethods?.length&&Ri(n.callee)){for(let o of n.arguments)if(o.type===se.ObjectExpression){for(let a of o.properties)if(a.type===se.Property&&a.key.type===se.Identifier){let s=a.key.name,i=t.disallowMethods.find(l=>l.name===s);if(i){if(i.requireTrueProp){let l=i.requireTrueProp,c=!1;for(let p of o.properties)if(p.type===se.Property&&p.key.type===se.Identifier&&p.key.name===l&&p.value.type===se.Literal&&p.value.value===!0){c=!0;break}if(!c){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:l}});continue}}i.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:l=>l.replaceText(a.key,i.replacement)}]})}}}}}}:{}}}),ht={name:Tn,rule:Ai};import{ESLintUtils as ki,TSESTree as vi}from"@typescript-eslint/utils";var Oi=ki.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hn="require-description",Pi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Fi=/^eslint-disable-(next-)?line$/u,Ni=Oi({name:hn,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=Di(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Li(o.loc),messageId:"missingDescription"}))}}}}}),En={name:hn,rule:Ni};function Di(e){let{text:t,description:r}=ji(e.value);if(!t)return null;let n=Pi.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=Fi.test(o);if(e.type===vi.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let s=t.slice(n.index+o.length);return{kind:o,value:s.trim(),description:r}}function ji(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Li(e){return{start:{line:e.start.line,column:-1},end:e.end}}function wn(e){return/^use[A-Z0-9]/.test(e)}function Le(e){return e.type==="Identifier"?wn(e.name):e.type==="MemberExpression"&&!e.computed&&Le(e.property)?e.object.type==="Identifier":!1}function In(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Cn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Rn(e){return!!(e.parent&&e.parent.callee&&Cn(e.parent.callee,"forwardRef"))}function An(e){return!!(e.parent&&e.parent.callee&&Cn(e.parent.callee,"memo"))}function Et(e){for(;e;){let t=vn(e);if(t&&(In(t)||Le(t))||Rn(e)||An(e))return!0;e=e.parent}return!1}function bn(e){return!1}function bt(e){return!1}var Mi=/eslint +react-compiler\/react-compiler: +\["error/,kn={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(Mi.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,o=[],a=[],s=new WeakSet;function i(l){for(let c of l.references){let p=c.identifier.parent;if(p.type==="VariableDeclarator"&&p.init&&p.init.type==="CallExpression"&&p.init.callee&&bn(p.init.callee))for(let u of c.resolved.references)u!==c&&s.add(u.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,c){let p=o.pop();if(p.size===0)return;let u=new Set;function S(T,m){let{cache:y}=S,R=y.get(T.id),C=new Set(m);if(C.has(T.id)){let E=[...C],F=E.slice(E.indexOf(T.id)+1);for(let H of F)u.add(H);return BigInt("0")}if(C.add(T.id),R!==void 0)return R;if(l.thrownSegments.includes(T))R=BigInt("0");else if(T.prevSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let E of T.prevSegments)R+=S(E,C)}return T.reachable&&R===BigInt("0")?y.delete(T.id):y.set(T.id,R),R}function h(T,m){let{cache:y}=h,R=y.get(T.id),C=new Set(m);if(C.has(T.id)){let E=Array.from(C),F=E.slice(E.indexOf(T.id)+1);for(let H of F)u.add(H);return BigInt("0")}if(C.add(T.id),R!==void 0)return R;if(l.thrownSegments.includes(T))R=BigInt("0");else if(T.nextSegments.length===0)R=BigInt("1");else{R=BigInt("0");for(let E of T.nextSegments)R+=h(E,C)}return y.set(T.id,R),R}function x(T){let{cache:m}=x,y=m.get(T.id);if(y===null)return 1/0;if(y!==void 0)return y;if(m.set(T.id,null),T.prevSegments.length===0)y=1;else{y=1/0;for(let R of T.prevSegments){let C=x(R);C<y&&(y=C)}y+=1}return m.set(T.id,y),y}S.cache=new Map,h.cache=new Map,x.cache=new Map;let b=h(l.initialSegment),k=vn(c),w=Et(c),L=k?In(k)||Le(k):Rn(c)||An(c),P=1/0;for(let T of l.finalSegments){if(!T.reachable)continue;let m=x(T);m<P&&(P=m)}for(let[T,m]of p){if(!T.reachable)continue;let y=T.nextSegments.length===0?P<=x(T):P<x(T),R=S(T)*h(T),C=u.has(T.id);for(let E of m)if(C&&!bt(E)&&e.report({node:E,message:`React Hook "${t(E)}" 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(c.async&&e.report({node:E,message:`React Hook "${t(E)}" cannot be called in an async function.`}),!C&&R!==b&&!bt(E)){let H=`React Hook "${t(E)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(y?" Did you accidentally call a React Hook after an early return?":"");e.report({node:E,message:H})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let F=`React Hook "${t(E)}" 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:E,message:F})}else if(k){let F=`React Hook "${t(E)}" is called in function "${t(k)}" 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:E,message:F})}else if(c.type==="Program"){let F=`React Hook "${t(E)}" 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:E,message:F})}else if(w&&!bt(E)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let H=c.parent;if(H.parent.type==="VariableDeclarator"&&wn(H.parent.id.name))return}let F=`React Hook "${t(E)}" 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:E,message:F})}}},CallExpression(l){if(Le(l.callee)){let c=xn(o),p=xn(a),u=c.get(p);u||(u=[],c.set(p,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||bn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&s.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){Et(l)&&i(r(l))},ArrowFunctionExpression(l){Et(l)&&i(r(l))}}}};function vn(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 xn(e){return e[e.length-1]}var On={[mt.name]:mt.rule,[Ke.name]:Ke.rule,[qe.name]:qe.rule,"rules-of-hooks":kn,"exhaustive-deps":Dt,"require-description":En.rule,[Ge.name]:Ge.rule,[Qe.name]:Qe.rule,[yt.name]:yt.rule,[Ue.name]:Ue.rule,[Xe.name]:Xe.rule,[it.name]:it.rule,[Tt.name]:Tt.rule,[nt.name]:nt.rule,[Ze.name]:Ze.rule,[We.name]:We.rule,[ht.name]:ht.rule,[ze.name]:ze.rule,[Je.name]:Je.rule,[at.name]:at.rule,[lt.name]:lt.rule,[pt.name]:pt.rule,[ut.name]:ut.rule,[ct.name]:ct.rule,[St.name]:St.rule,[st.name]:st.rule};var Zo={rules:On};export{Zo as extendedLintPlugin};
|