@ls-stack/extended-lint 0.50.0 → 0.52.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 Jn=Object.create;var Me=Object.defineProperty;var Bn=Object.getOwnPropertyDescriptor;var Xn=Object.getOwnPropertyNames;var qn=Object.getPrototypeOf,Gn=Object.prototype.hasOwnProperty;var Kn=(e,t)=>{for(var n in t)Me(e,n,{get:t[n],enumerable:!0})},jt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xn(t))!Gn.call(e,o)&&o!==n&&Me(e,o,{get:()=>t[o],enumerable:!(r=Bn(t,o))||r.enumerable});return e};var he=(e,t,n)=>(n=e!=null?Jn(qn(e)):{},jt(t||!e||!e.__esModule?Me(n,"default",{value:e,enumerable:!0}):n,e)),Zn=e=>jt(Me({},"__esModule",{value:!0}),e);var Wi={};Kn(Wi,{extendedLintPlugin:()=>Ui});module.exports=Zn(Wi);var X=require("@typescript-eslint/utils");var qe=Symbol.for("optional");function L(e){return{...e,[qe]:!0}}function Mt(e,t){return{enum:e,...t}}function Ce(e){return{...e,type:"boolean"}}function W(e){return{...e,type:"string"}}function ce(e){return{...e,type:"number"}}function q(e,t){return{...t,type:"array",items:e}}function V(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,o=[];for(r in e)e[r][qe]?e[r][qe]=void 0:o.push(r);o.length>0&&(n.required=o)}return n}var Qn=X.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="react-compiler-extra",er=V({runOnlyWithEnableCompilerDirective:L(Ce())}),tr=/eslint +react-compiler\/react-compiler: +\["error/;function nr(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 rr=/\bthis[.[]/;function _t(e){return rr.test(e)}var ir=Qn({name:Lt,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:[er]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(tr.test(a.value)){n=!0;break}if(!n)return{}}function r(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(_t(p))e.report({node:s,messageId:"thisKeywordInMethod"});else{let u=c.params.map(h=>i.getText(h)).join(", "),g="";c.generator?g=`${l}: function* (${u}) ${p}`:g=`${l}: (${u}) => ${p}`,e.report({node:s,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(s,g)})}}}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);_t(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(nr(a.callee))for(let s of a.arguments){if(s.type===X.AST_NODE_TYPES.ObjectExpression&&(r(s),o(s)),s.type===X.AST_NODE_TYPES.ArrowFunctionExpression&&(s.body.type===X.AST_NODE_TYPES.ObjectExpression&&(r(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&&(r(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&&(r(i.argument),o(i.argument))}}}}}),Ge={name:Lt,rule:ir};var G=require("@typescript-eslint/utils"),S=he(require("zod/v4"));var $t=require("@typescript-eslint/utils"),zt=he(require("zod/v4"));function ne(e){let n=$t.ESLintUtils.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}function _e(e){return zt.toJSONSchema(e)}var sr=S.object({disallow:S.array(S.object({selector:S.string(),message:S.string(),replace:S.optional(S.union([S.string(),S.object({regex:S.string(),with:S.string()})])),replaceType:S.optional(S.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:S.optional(S.array(S.object({fn:S.string(),withArgs:S.optional(S.array(S.object({atIndex:S.number(),value:S.union([S.string(),S.number(),S.boolean()])}))),message:S.string(),replaceWith:S.optional(S.string()),ignoreRegex:S.optional(S.string())}))),__dev_simulateFileName:S.optional(S.string()),mustMatchSyntax:S.optional(S.array(S.object({includeRegex:S.string(),mustCallFn:S.optional(S.array(S.object({anyCall:S.array(S.object({fn:S.string(),withArgs:S.array(S.object({atIndex:S.number(),literal:S.union([S.string(),S.number(),S.boolean()])}))})),message:S.optional(S.string())}))),mustMatchSelector:S.optional(S.array(S.object({selector:S.string(),message:S.string()}))),mustHaveExport:S.optional(S.array(S.object({name:S.string(),type:S.enum(["function","variable","any"]).default("any"),message:S.string()})))})))}),Ke=ne({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[_e(sr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:o,disallow:a,disallowFnCalls:s}=t,i=o??e.filename,l=[],c=new Map,p=new Set,u=new Map,g=new Set,h=new Map;function x(m){for(let y of m.specifiers)y.type===G.AST_NODE_TYPES.ImportSpecifier&&y.imported.type===G.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===G.AST_NODE_TYPES.FunctionDeclaration&&m.declaration.id){let y=m.declaration.id.name;for(let A of Array.from(g)){let[C,E]=A.split(":");C===y&&(E==="function"||E==="any")&&g.delete(A)}}else if(m.declaration.type===G.AST_NODE_TYPES.VariableDeclaration){for(let y of m.declaration.declarations)if(y.id.type===G.AST_NODE_TYPES.Identifier){let A=y.id.name;for(let C of Array.from(g)){let[E,P]=C.split(":");E===A&&(P==="variable"||P==="any")&&g.delete(C)}}}}for(let y of m.specifiers)if(y.exported.type===G.AST_NODE_TYPES.Identifier){let A=y.exported.name;for(let C of Array.from(g)){let[E,P]=C.split(":");E===A&&P==="any"&&g.delete(C)}}}function k(m){m.id.type===G.AST_NODE_TYPES.Identifier&&m.init?.type===G.AST_NODE_TYPES.Identifier&&h.set(m.id.name,m.init.name)}function w(m){return h.get(m)??m}function M(m,y){return w(m)===y||m===y}for(let{includeRegex:m,mustCallFn:y,mustMatchSelector:A,mustHaveExport:C}of r??[]){let E=or(i,new RegExp(m));if(!E)continue;let P=Y=>{let B=Y;for(let{name:Q,value:K}of E)B=B.replaceAll(Q,K);return B};for(let{anyCall:Y,message:B}of y??[]){let Q=`Expected file to call the function: ${Y.map(({fn:K})=>K).join(" or ")}`;p.add(Q),l.push(K=>{let{callee:we}=K;if(we.type===G.AST_NODE_TYPES.Identifier){for(let{fn:te,withArgs:ve}of Y)if(we.name===te){p.delete(Q);for(let pe of ve){let le=K.arguments[pe.atIndex],ue=typeof pe.literal=="string"?P(pe.literal):pe.literal;if(!le){e.report({node:K,messageId:"default",data:{message:`Missing argument with value "${ue}" at index ${pe.atIndex}${B?`: ${P(B)}`:""}`}});continue}if(le.type!==G.AST_NODE_TYPES.Literal){e.report({node:le,messageId:"default",data:{message:`Argument at position ${pe.atIndex} should the literal "${ue}"${B?`: ${P(B)}`:""}`}});continue}le.value!==ue&&e.report({node:le,messageId:"default",data:{message:`Argument should have the value "${ue}"${B?`: ${P(B)}`:""}`},fix:Ie=>Ie.replaceText(le,typeof ue=="string"?`'${ue}'`:String(ue))})}break}}})}for(let{selector:Y,message:B}of A??[])u.set(Y,P(B)),c.set(P(Y),()=>{u.delete(Y)});for(let{name:Y,type:B,message:Q}of C??[]){let K=P(Y),we=P(Q);g.add(`${K}:${B}:${we}`)}}for(let{fn:m,withArgs:y,message:A,replaceWith:C,ignoreRegex:E}of s??[])E&&new RegExp(E).test(i)||l.push(P=>{let{callee:Y}=P;if(Y.type!==G.AST_NODE_TYPES.Identifier||!M(Y.name,m))return;if(y)for(let Q of y){let K=P.arguments[Q.atIndex];if(!K){e.report({node:P,messageId:"default",data:{message:`Missing argument with value "${Q.value}" at index ${Q.atIndex}: ${A}`}});return}if(K.type!==G.AST_NODE_TYPES.Literal||K.value!==Q.value)return}let B=Q=>C?Q.replaceText(P,C):null;e.report({node:P,messageId:"default",data:{message:A},suggest:C?[{messageId:"default",data:{message:`Replace with "${C}"`},fix:B}]:void 0})});function F(m,y){let A=n[m];A?n[m]=C=>{A(C),y(C)}:n[m]=y}for(let{selector:m,message:y,replace:A,replaceType:C="suggestion"}of a??[]){if(m==="CallExpression"){l.push(E=>{T(A,E,y,C)});continue}n[m]=E=>{T(A,E,y,C)}}if(c.size>0)for(let[m,y]of c)F(m,y);return l.length>0&&(n.CallExpression=m=>{if(m.type===G.AST_NODE_TYPES.CallExpression)for(let y of l)y(m)}),n.ImportDeclaration=m=>{m.type===G.AST_NODE_TYPES.ImportDeclaration&&x(m)},n.ExportNamedDeclaration=m=>{m.type===G.AST_NODE_TYPES.ExportNamedDeclaration&&b(m)},n.VariableDeclarator=m=>{m.type===G.AST_NODE_TYPES.VariableDeclarator&&k(m)},n["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 g){let[A,C,E]=y.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${A}" of type ${C}: ${E}`}})}},n;function T(m,y,A,C){let E=P=>{if(!m)return null;if(typeof m=="string")return P.replaceText(y,m);{let Y=new RegExp(m.regex),B=e.sourceCode.getText(y);return P.replaceText(y,B.replace(Y,m.with))}};e.report({node:y,messageId:"default",data:{message:A},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 or(e,t){let n=[],r=t.exec(e);if(!r)return null;let[o,...a]=r;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:Ut(o)}),n.push({name:"$0_uncapitalize",value:Wt(o)}),n.push({name:"$0",value:o});for(let s=0;s<a.length;s++){let i=`$${s+1}`,l=a[s];n.push({name:`${i}_lowercase`,value:l.toLowerCase()}),n.push({name:`${i}_capitalize`,value:Ut(l)}),n.push({name:`${i}_uncapitalize`,value:Wt(l)}),n.push({name:i,value:l})}return n}function Ut(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Wt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var _=require("@typescript-eslint/utils");var ar=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="collapse-simple-objs-in-one-line",lr=V({maxLineLength:L(ce()),maxProperties:L(ce()),nestedObjMaxLineLength:L(ce()),nestedObjMaxProperties:L(ce()),ignoreTypesWithSuffix:L(q(W()))}),cr=ar({name:Ht,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[lr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=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 x=c.properties[0];return x.type===_.AST_NODE_TYPES.Property&&x.value.type===_.AST_NODE_TYPES.ObjectExpression||x.type===_.AST_NODE_TYPES.Property&&x.value.type===_.AST_NODE_TYPES.ArrayExpression&&!x.value.elements.every(k=>k&&Ze(k))?!1:{text:n.getText(x),isNested:p,propsSize:g}}let h=[];for(let x of c.properties){if(x.type===_.AST_NODE_TYPES.Property&&!Ze(x.value))return!1;h.push(n.getText(x))}return{text:h.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(r.length>0&&c.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let x=c.parent.id.name;if(r.some(b=>x.endsWith(b)))return!1}if(g===1){let x=c.members[0];return x.type===_.AST_NODE_TYPES.TSPropertySignature&&x.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(x),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 h=[];for(let x of c.members){if(x.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let b=x.typeAnnotation?.typeAnnotation;if(!b||b.type===_.AST_NODE_TYPES.TSTypeLiteral||!Vt(b))return!1;if(b.type===_.AST_NODE_TYPES.TSTypeReference&&b.typeArguments){if(b.typeArguments.params.length>1)return!1;let w=b.typeArguments.params[0];if(!Vt(w))return!1}let k=n.getText(x).trim();(k.endsWith(";")||k.endsWith(","))&&(k=k.slice(0,-1)),h.push(k)}return{text:h.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 b=0,k=!1,w=n.getTokenAfter(c,{filter:F=>F.type!==_.AST_TOKEN_TYPES.Punctuator||k?!0:F.value===","?(b++,!1):F.value===";"?(b++,k=!0,!1):F.value===")"||F.value==="}"?(b++,!1):!0});if(b>4)return;let M=w?.type===_.AST_TOKEN_TYPES.Template&&w.value.startsWith(`}
|
|
2
|
-
`);if(w?.loc.start.line===c.loc.end.line&&!
|
|
3
|
-
`)||n.getCommentsInside(c).length>0)return;u.endsWith(";")&&(u=u.slice(0,-1));let g=`{ ${u} }`,h=
|
|
4
|
-
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function
|
|
1
|
+
"use strict";var Xn=Object.create;var _e=Object.defineProperty;var Gn=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames;var Zn=Object.getPrototypeOf,Qn=Object.prototype.hasOwnProperty;var er=(e,t)=>{for(var n in t)_e(e,n,{get:t[n],enumerable:!0})},_t=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Kn(t))!Qn.call(e,o)&&o!==n&&_e(e,o,{get:()=>t[o],enumerable:!(r=Gn(t,o))||r.enumerable});return e};var xe=(e,t,n)=>(n=e!=null?Xn(Zn(e)):{},_t(t||!e||!e.__esModule?_e(n,"default",{value:e,enumerable:!0}):n,e)),tr=e=>_t(_e({},"__esModule",{value:!0}),e);var qi={};er(qi,{extendedLintPlugin:()=>Ji});module.exports=tr(qi);var X=require("@typescript-eslint/utils");var Ke=Symbol.for("optional");function _(e){return{...e,[Ke]:!0}}function $t(e,t){return{enum:e,...t}}function Re(e){return{...e,type:"boolean"}}function W(e){return{...e,type:"string"}}function pe(e){return{...e,type:"number"}}function G(e,t){return{...t,type:"array",items:e}}function V(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,o=[];for(r in e)e[r][Ke]?e[r][Ke]=void 0:o.push(r);o.length>0&&(n.required=o)}return n}var nr=X.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="react-compiler-extra",rr=V({runOnlyWithEnableCompilerDirective:_(Re())}),ir=/eslint +react-compiler\/react-compiler: +\["error/;function sr(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 or=/\bthis[.[]/;function zt(e){return or.test(e)}var ar=nr({name:Ut,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:[rr]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(ir.test(a.value)){n=!0;break}if(!n)return{}}function r(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(zt(p))e.report({node:s,messageId:"thisKeywordInMethod"});else{let u=c.params.map(h=>i.getText(h)).join(", "),g="";c.generator?g=`${l}: function* (${u}) ${p}`:g=`${l}: (${u}) => ${p}`,e.report({node:s,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(s,g)})}}}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);zt(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(sr(a.callee))for(let s of a.arguments){if(s.type===X.AST_NODE_TYPES.ObjectExpression&&(r(s),o(s)),s.type===X.AST_NODE_TYPES.ArrowFunctionExpression&&(s.body.type===X.AST_NODE_TYPES.ObjectExpression&&(r(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&&(r(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&&(r(i.argument),o(i.argument))}}}}}),Ze={name:Ut,rule:ar};var K=require("@typescript-eslint/utils"),S=xe(require("zod/v4"));var Wt=require("@typescript-eslint/utils"),Vt=xe(require("zod/v4"));function Q(e){let n=Wt.ESLintUtils.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}function $e(e){return Vt.toJSONSchema(e)}var lr=S.object({disallow:S.array(S.object({selector:S.string(),message:S.string(),replace:S.optional(S.union([S.string(),S.object({regex:S.string(),with:S.string()})])),replaceType:S.optional(S.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:S.optional(S.array(S.object({fn:S.string(),withArgs:S.optional(S.array(S.object({atIndex:S.number(),value:S.union([S.string(),S.number(),S.boolean()])}))),message:S.string(),replaceWith:S.optional(S.string()),ignoreRegex:S.optional(S.string())}))),__dev_simulateFileName:S.optional(S.string()),mustMatchSyntax:S.optional(S.array(S.object({includeRegex:S.string(),mustCallFn:S.optional(S.array(S.object({anyCall:S.array(S.object({fn:S.string(),withArgs:S.array(S.object({atIndex:S.number(),literal:S.union([S.string(),S.number(),S.boolean()])}))})),message:S.optional(S.string())}))),mustMatchSelector:S.optional(S.array(S.object({selector:S.string(),message:S.string()}))),mustHaveExport:S.optional(S.array(S.object({name:S.string(),type:S.enum(["function","variable","any"]).default("any"),message:S.string()})))})))}),Qe=Q({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[$e(lr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:o,disallow:a,disallowFnCalls:s}=t,i=o??e.filename,l=[],c=new Map,p=new Set,u=new Map,g=new Set,h=new Map;function b(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 x(m){if(m.declaration){if(m.declaration.type===K.AST_NODE_TYPES.FunctionDeclaration&&m.declaration.id){let y=m.declaration.id.name;for(let A of Array.from(g)){let[C,E]=A.split(":");C===y&&(E==="function"||E==="any")&&g.delete(A)}}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 A=y.id.name;for(let C of Array.from(g)){let[E,F]=C.split(":");E===A&&(F==="variable"||F==="any")&&g.delete(C)}}}}for(let y of m.specifiers)if(y.exported.type===K.AST_NODE_TYPES.Identifier){let A=y.exported.name;for(let C of Array.from(g)){let[E,F]=C.split(":");E===A&&F==="any"&&g.delete(C)}}}function v(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:A,mustHaveExport:C}of r??[]){let E=cr(i,new RegExp(m));if(!E)continue;let F=Y=>{let q=Y;for(let{name:te,value:Z}of E)q=q.replaceAll(te,Z);return q};for(let{anyCall:Y,message:q}of y??[]){let te=`Expected file to call the function: ${Y.map(({fn:Z})=>Z).join(" or ")}`;p.add(te),l.push(Z=>{let{callee:Ce}=Z;if(Ce.type===K.AST_NODE_TYPES.Identifier){for(let{fn:re,withArgs:Pe}of Y)if(Ce.name===re){p.delete(te);for(let ue of Pe){let ce=Z.arguments[ue.atIndex],fe=typeof ue.literal=="string"?F(ue.literal):ue.literal;if(!ce){e.report({node:Z,messageId:"default",data:{message:`Missing argument with value "${fe}" at index ${ue.atIndex}${q?`: ${F(q)}`:""}`}});continue}if(ce.type!==K.AST_NODE_TYPES.Literal){e.report({node:ce,messageId:"default",data:{message:`Argument at position ${ue.atIndex} should the literal "${fe}"${q?`: ${F(q)}`:""}`}});continue}ce.value!==fe&&e.report({node:ce,messageId:"default",data:{message:`Argument should have the value "${fe}"${q?`: ${F(q)}`:""}`},fix:Ae=>Ae.replaceText(ce,typeof fe=="string"?`'${fe}'`:String(fe))})}break}}})}for(let{selector:Y,message:q}of A??[])u.set(Y,F(q)),c.set(F(Y),()=>{u.delete(Y)});for(let{name:Y,type:q,message:te}of C??[]){let Z=F(Y),Ce=F(te);g.add(`${Z}:${q}:${Ce}`)}}for(let{fn:m,withArgs:y,message:A,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 te of y){let Z=F.arguments[te.atIndex];if(!Z){e.report({node:F,messageId:"default",data:{message:`Missing argument with value "${te.value}" at index ${te.atIndex}: ${A}`}});return}if(Z.type!==K.AST_NODE_TYPES.Literal||Z.value!==te.value)return}let q=te=>C?te.replaceText(F,C):null;e.report({node:F,messageId:"default",data:{message:A},suggest:C?[{messageId:"default",data:{message:`Replace with "${C}"`},fix:q}]:void 0})});function P(m,y){let A=n[m];A?n[m]=C=>{A(C),y(C)}:n[m]=y}for(let{selector:m,message:y,replace:A,replaceType:C="suggestion"}of a??[]){if(m==="CallExpression"){l.push(E=>{T(A,E,y,C)});continue}n[m]=E=>{T(A,E,y,C)}}if(c.size>0)for(let[m,y]of c)P(m,y);return l.length>0&&(n.CallExpression=m=>{if(m.type===K.AST_NODE_TYPES.CallExpression)for(let y of l)y(m)}),n.ImportDeclaration=m=>{m.type===K.AST_NODE_TYPES.ImportDeclaration&&b(m)},n.ExportNamedDeclaration=m=>{m.type===K.AST_NODE_TYPES.ExportNamedDeclaration&&x(m)},n.VariableDeclarator=m=>{m.type===K.AST_NODE_TYPES.VariableDeclarator&&v(m)},n["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 g){let[A,C,E]=y.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${A}" of type ${C}: ${E}`}})}},n;function T(m,y,A,C){let E=F=>{if(!m)return null;if(typeof m=="string")return F.replaceText(y,m);{let Y=new RegExp(m.regex),q=e.sourceCode.getText(y);return F.replaceText(y,q.replace(Y,m.with))}};e.report({node:y,messageId:"default",data:{message:A},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 cr(e,t){let n=[],r=t.exec(e);if(!r)return null;let[o,...a]=r;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:Ht(o)}),n.push({name:"$0_uncapitalize",value:Yt(o)}),n.push({name:"$0",value:o});for(let s=0;s<a.length;s++){let i=`$${s+1}`,l=a[s];n.push({name:`${i}_lowercase`,value:l.toLowerCase()}),n.push({name:`${i}_capitalize`,value:Ht(l)}),n.push({name:`${i}_uncapitalize`,value:Yt(l)}),n.push({name:i,value:l})}return n}function Ht(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Yt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var M=require("@typescript-eslint/utils");var pr=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="collapse-simple-objs-in-one-line",ur=V({maxLineLength:_(pe()),maxProperties:_(pe()),nestedObjMaxLineLength:_(pe()),nestedObjMaxProperties:_(pe()),ignoreTypesWithSuffix:_(G(W()))}),fr=pr({name:Jt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[ur]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=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,g=c.properties.length;if(g>u)return!1;if(g===1){let b=c.properties[0];return b.type===M.AST_NODE_TYPES.Property&&b.value.type===M.AST_NODE_TYPES.ObjectExpression||b.type===M.AST_NODE_TYPES.Property&&b.value.type===M.AST_NODE_TYPES.ArrayExpression&&!b.value.elements.every(v=>v&&et(v))?!1:{text:n.getText(b),isNested:p,propsSize:g}}let h=[];for(let b of c.properties){if(b.type===M.AST_NODE_TYPES.Property&&!et(b.value))return!1;h.push(n.getText(b))}return{text:h.join(", "),isNested:p,propsSize:g}}else{let p=c.parent.parent?.type===M.AST_NODE_TYPES.TSPropertySignature,u=p?s:o,g=c.members.length;if(g>u)return!1;if(r.length>0&&c.parent.type===M.AST_NODE_TYPES.TSTypeAliasDeclaration){let b=c.parent.id.name;if(r.some(x=>b.endsWith(x)))return!1}if(g===1){let b=c.members[0];return b.type===M.AST_NODE_TYPES.TSPropertySignature&&b.typeAnnotation?.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(b),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 b of c.members){if(b.type!==M.AST_NODE_TYPES.TSPropertySignature)return!1;let x=b.typeAnnotation?.typeAnnotation;if(!x||x.type===M.AST_NODE_TYPES.TSTypeLiteral||!Bt(x))return!1;if(x.type===M.AST_NODE_TYPES.TSTypeReference&&x.typeArguments){if(x.typeArguments.params.length>1)return!1;let w=x.typeArguments.params[0];if(!Bt(w))return!1}let v=n.getText(b).trim();(v.endsWith(";")||v.endsWith(","))&&(v=v.slice(0,-1)),h.push(v)}return{text:h.join("; "),isNested:p,propsSize:g}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==M.AST_NODE_TYPES.JSXExpressionContainer){let x=0,v=!1,w=n.getTokenAfter(c,{filter:P=>P.type!==M.AST_TOKEN_TYPES.Punctuator||v?!0:P.value===","?(x++,!1):P.value===";"?(x++,v=!0,!1):P.value===")"||P.value==="}"?(x++,!1):!0});if(x>4)return;let 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
|
+
`)||n.getCommentsInside(c).length>0)return;u.endsWith(";")&&(u=u.slice(0,-1));let g=`{ ${u} }`,h=dr(n,c),b=p.isNested&&p.propsSize>2?a:t.maxLineLength;b&&g.length+h.length+mr(c,n)>b||e.report({node:c,messageId:"singleLineProp",fix:x=>x.replaceText(c,g)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function Bt(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 et(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(n=>n&&et(n,!0)))}function mr(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
|
|
4
|
+
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function dr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var tt={name:Jt,rule:fr};var yr=/eslint +react-compiler\/react-compiler: +\["error/,Xt={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?w=>n(w):w=>e.sourceCode.getText(w),r=typeof e.getScope=="function"?()=>r():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,g=new WeakMap,h=new WeakSet;function b(w,L){return function(P){if(L.has(P))return L.get(P);let T=w(P);return L.set(P,T),T}}function x(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 y=l.acquire(w),A=new Set,C=null;{let f=y.upper;for(;f&&(A.add(f),f.type!=="function");)f=f.upper;if(!f)return;C=f}let E=Array.isArray;function P(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 R=d.node.parent;if(R==null&&(nt(C.block,d.node.id),R=d.node.parent,R==null))return!1;if(R.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(Sr(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,ie=0;for(let fe=0;fe<j.length;fe++){if(j[fe].isWrite()&&ie++,ie>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 ie=0;ie<j.length;ie++)p.add(j[ie].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,R=C.childScopes,O=null,v;for(v=0;v<R.length;v++){let D=R[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&&A.has(D.resolved.scope)&&!B(D.resolved))return!1}return!0}let B=x(P,u),Q=x(Y,g),K=new Map;function we(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,ve=new Map;pe(y);function pe(f){for(let d of f.references){if(!d.resolved||!A.has(d.resolved.scope))continue;let I=nt(w,d.identifier),R=Bt(I),O=me(R,ve);if(m&&R.type==="Identifier"&&(R.parent.type==="MemberExpression"||R.parent.type==="OptionalMemberExpression")&&!R.parent.computed&&R.parent.property.type==="Identifier"&&R.parent.property.name==="current"&&we(d)&&K.set(O,{reference:d,dependencyNode:R}),R.parent.type==="TSTypeQuery"||R.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=B(D)||Q(D);te.set(O,{isStable:j,references:[d]})}}for(let d of f.childScopes)pe(d)}K.forEach(({reference:f,dependencyNode:d},I)=>{let R=f.resolved.references,O=!1;for(let v=0;v<R.length;v++){let{identifier:D}=R[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 ${n(F)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${n(F)}.`}))}let Ie=new Set;if(te.forEach(({isStable:f,references:d},I)=>{f&&Ie.add(I),d.forEach(R=>{R.writeExpr&&ue(R.writeExpr,I)})}),le.size>0)return;if(!M){let f=null;if(te.forEach(({isStable:d,references:I},R)=>{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=R)})}),f){let{suggestedDependencies:d}=et({dependencies:te,declaredDependencies:[],stableDependencies:Ie,externalDependencies:new Set,isEffect:!0});i({node:F,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 Oe=[],Fe=new Set;M.type!=="ArrayExpression"?i({node:M,message:`React Hook ${n(F)} 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 ${n(F)} 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 \`${n(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(f)}\``,fix(O){return O.removeRange(f.range)}}]});let d;try{d=me(f,ve)}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 ${n(F)} 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 R=!C.through.some(O=>O.identifier===I);Oe.push({key:d,node:f}),R||Fe.add(d)});let{suggestedDependencies:Wn,unnecessaryDependencies:De,missingDependencies:ye,duplicateDependencies:Pt}=et({dependencies:te,declaredDependencies:Oe,stableDependencies:Ie,externalDependencies:Fe,isEffect:m}),je=Wn;if(Pt.size+ye.size+De.size===0){if(t)return;mr({declaredDependencies:Oe,declaredDependenciesNode:M,componentScope:C,scope:y}).forEach(({construction:d,isUsedOutsideOfHook:I,depType:R})=>{let O=R==="function"?"useCallback":"useMemo",v=R==="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}`,ie=R==="conditional"||R==="logical expression"?"could make":"makes",fe=`The '${d.name.name}' ${R} ${ie} the dependencies of ${T} Hook (at line ${M.loc.start.line}) change on every render. ${j}`,Nt;I&&d.type==="Variable"&&R==="function"&&(Nt=[{desc:`Wrap the ${v} of '${d.name.name}' in its own ${O}() Hook.`,fix(Dt){let[Hn,Yn]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Dt.insertTextBefore(d.node.init,Hn),Dt.insertTextAfter(d.node.init,Yn)]}}]),i({node:d.node,message:fe,suggest:Nt})});return}!m&&ye.size>0&&(je=et({dependencies:te,declaredDependencies:[],stableDependencies:Ie,externalDependencies:Fe,isEffect:m}).suggestedDependencies);function Vn(){if(Oe.length===0)return!0;let f=Oe.map(I=>I.key),d=f.slice().sort();return f.join(",")===d.join(",")}Vn()&&je.sort();function Be(f){let d=f.split("."),I="";for(let R=0;R<d.length;R++){if(R!==0){let O=d.slice(0,R+1).join("."),v=ve.get(O)===!0;I+=v?"?.":"."}I+=d[R]}return I}function Xe(f,d,I,R){return f.size===0?null:(f.size>1?"":d+" ")+I+" "+(f.size>1?"dependencies":"dependency")+": "+yr(Array.from(f).sort().map(O=>"'"+Be(O)+"'"))+`. Either ${R} ${f.size>1?"them":"it"} or remove the dependency array.`}let oe="";if(De.size>0){let f=null;if(Array.from(De.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(Fe.size>0){let d=Array.from(Fe)[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 R=0;R<d.length;R++){let O=d[R],v=nt(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 ${n(F)}.`)}if(!oe&&ye.size>0){let f=null;ye.forEach(d=>{if(f)return;let I=C.set.get(d),R=te.get(d);if(R.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<R.references.length;j++)if(D=R.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 R=te.get(d).references,O,v;for(let D=0;D<R.length;D++){for(O=R[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 ie=R[D].resolved;if(ie!=null){let fe=ie.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:M,message:`React Hook ${n(F)} has `+(Xe(ye,"a","missing","include")||Xe(De,"an","unnecessary","exclude")||Xe(Pt,"a","duplicate","omit"))+oe,suggest:[{desc:`Update the dependencies array to be: [${je.map(Be).join(", ")}]`,fix(f){return f.replaceText(M,`[${je.map(Be).join(", ")}]`)}}]})}function k(w){let M=dr(w.callee,s);if(M===-1)return;let F=w.arguments[M],T=w.callee,m=Xt(T).name,y=w.arguments[M+1],A=/Effect($|[^a-z])/g.test(m);if(!F){i({node:T,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!A)){if(!y&&!A){(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(F.type){case"FunctionExpression":case"ArrowFunctionExpression":b(F,y,T,m,A);return;case"Identifier":if(!y||y.elements&&y.elements.some(P=>P&&P.type==="Identifier"&&P.name===F.name))return;let C=r(w).set.get(F.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,A);return;case"VariableDeclarator":let P=E.node.init;if(!P)break;switch(P.type){case"ArrowFunctionExpression":case"FunctionExpression":b(P,y,T,m,A);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: '${F.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${F.name}]`,fix(C){return C.replaceText(y,`[${F.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let w of e.sourceCode.getAllComments())if(fr.test(w.value))return t=!0,{CallExpression:M=>k(M,!0)}}return{CallExpression:w=>k(w)}}};function et({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,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,M=>{M.isSubtreeUsed=!0})}),t.forEach(({key:b})=>{let k=i(a,b);k.isSatisfiedRecursively=!0}),n.forEach(b=>{let k=i(a,b);k.isSatisfiedRecursively=!0});function i(b,k){let w=k.split("."),M=b;for(let F of w){let T=M.children.get(F);T||(T=s(),M.children.set(F,T)),M=T}return M}function l(b,k,w){let M=k.split("."),F=b;for(let T of M){let m=F.children.get(T);if(!m)return;w(m),F=m}}let c=new Set,p=new Set;u(a,c,p,b=>b);function u(b,k,w,M){b.children.forEach((F,T)=>{let m=M(T);if(F.isSatisfiedRecursively){F.isSubtreeUsed&&w.add(m);return}if(F.isUsed){k.add(m);return}u(F,k,w,y=>m+"."+y)})}let g=[],h=new Set,x=new Set;return t.forEach(({key:b})=>{p.has(b)?g.indexOf(b)===-1?g.push(b):x.add(b):h.add(b)}),c.forEach(b=>{g.push(b)}),{suggestedDependencies:g,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 mr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let o=e.map(({key:s})=>{let i=n.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!==r&&p!=null;)p=p.upper;if(p!==r&&!qt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}function Bt(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?Bt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function tt(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function me(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=me(e.object,t),r=me(e.property,null),o=`${n}.${r}`;return tt(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=me(e.object,t),r=me(e.property,null),o=`${n}.${r}`;return tt(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=me(n.object,t),o=me(n.property,null),a=`${r}.${o}`;return tt(n,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Xt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function dr(e,t){let n=Xt(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=me(n,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(r)?0:-1}else return-1}}function nt(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),gr(r,t))return r;if(qt(r,t))for(let[o,a]of Object.entries(r))o!=="parent"&&(Yt(a)?(a.parent=r,n.push(a)):Array.isArray(a)&&a.forEach(s=>{Yt(s)&&(s.parent=r,n.push(s))}))}return null}function yr(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function gr(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 qt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Sr(e){return!1}var Se=require("@typescript-eslint/utils");var Z=he(require("typescript")),Tr=Se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="improved-no-unnecessary-condition",hr=V({}),Er=["string","number","bigint","boolean","symbol","undefined","object","function","never"],br=new Set(Er),rt={name:Gt,rule:Tr({name:Gt,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[hr]},defaultOptions:[{}],create(e){let t=Se.ESLintUtils.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===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(!n)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=n.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 g of c.types){let h=o(g);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(r(i.left)?(c=i.left,p=i.right.type===Se.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):r(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||!xr(p,br))return;let u=a(c);if(!u)return;let g=i.operator==="!==",h=u.includes(p);u.length===1?h&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Ae(c,e),type:p}}):!h&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Ae(c,e),type:Array.from(u)[0]}}):!h&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Ae(c,e),actualType:Le(u),conditionType:p}}):h&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Ae(c,e),actualType:Le(u),conditionType:p}}):!h&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Ae(c,e),actualType:Le(u),conditionType:p}}):!h&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Ae(c,e),type:Le(u)}})}return{BinaryExpression:s}}})};function Le(e){return Array.from(new Set(e)).join(" | ")||"never"}function Ae(e,t){let n=e.argument;return n.type===Se.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function xr(e,t){return t.has(e)}var $e=require("@typescript-eslint/utils");var wr=$e.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="no-call-with-explicit-generics",Ir=V({functions:q(W())}),Cr=wr({name:Kt,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Ir]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:o}=r;o.type===$e.AST_NODE_TYPES.Identifier&&n.has(o.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),it={name:Kt,rule:Cr};var Ee=require("@typescript-eslint/utils"),Ar=Ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-call-with-inferred-generics",Rr=Ar({name:Zt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:o}=r;if(o.type!==Ee.AST_NODE_TYPES.Identifier)return;let a=n.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(r.typeArguments?.params.length||0)<(s||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&r.typeArguments?.params?.some(p=>!i&&p.type===Ee.AST_NODE_TYPES.TSAnyKeyword||l&&p.type===Ee.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===Ee.AST_NODE_TYPES.Identifier&&l.includes(p.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),st={name:Zt,rule:Rr};var en=require("@typescript-eslint/utils"),kr=en.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-commented-out-code",vr=["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:"],Or=[") {","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*:/],Fr=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Qt=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Pr=kr({name:tn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(r,o){if(r.startsWith("/"))return!1;let a=r.trimStart();if(r.startsWith("*")||a.startsWith("eslint-disable")||r.includes("@deprecated")||r.includes("@example")||r.includes("@param")||r.includes("@returns")||r.includes("@throws")||r.includes("typescript-eslint")||r.includes("@ts-")||r.includes("prettier-ignore")||/^\s*[*\s]*$/.test(r))return!1;for(let s of Qt)if(a.startsWith(s))return!1;if(r.includes("https://"))return!1;if(o==="Block"){for(let s of Fr)if(typeof s=="string"){if(r.includes(s))return{wrongPattern:s}}else if(s.test(r))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of vr)if(a.startsWith(s))return{wrongPattern:s};for(let s of Or)if(typeof s=="string"){if(r.includes(s))return{wrongPattern:s}}else if(s.test(r))return{wrongPattern:`regex(${s.toString()})`};return!1}function n(r,o){let a=r,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=n(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Qt.join(", ")}})}}}}}),ot={name:tn,rule:Pr};var ze=require("@typescript-eslint/utils"),Nr=ze.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nn="no-default-export",Dr=Nr({name:nn,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===ze.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),at={name:nn,rule:Dr};var rn=require("@typescript-eslint/utils"),jr=rn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="no-leaked-text-in-jsx",Mr=[",",";","[","]","(",")"],_r=jr({name:sn,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let r="";Mr.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),lt={name:sn,rule:_r};var Te=require("@typescript-eslint/utils"),Lr=Te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="no-non-camel-case-functions",$r=/^(\$?[a-z][a-zA-Z0-9]*)$/;function on(e){if(e.typeName.type!==Te.AST_NODE_TYPES.TSQualifiedName)return!1;let{left:t,right:n}=e.typeName;return t.type===Te.AST_NODE_TYPES.Identifier&&t.name==="JSX"&&n.name==="Element"}var zr=Lr({name:an,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&&!$r.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===Te.AST_NODE_TYPES.TSTypeReference?on(n):n.type===Te.AST_NODE_TYPES.TSUnionType&&n.types.some(o=>o.type===Te.AST_NODE_TYPES.TSTypeReference&&on(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ct={name:an,rule:zr};var z=require("@typescript-eslint/utils");var pt=require("@typescript-eslint/utils");function Re(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:Re(e.parent,t,n===1/0?n:n-1)}function*ut(e){yield e,e.parent&&(yield*ut(e.parent))}function ft(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function ln(e,t,n){let o=n.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===pt.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===pt.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Ur=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cn="no-optional-root-props",Wr=Ur({name:cn,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let a=e.sourceCode.getDeclaredVariables(r)[0];if(!a||a.references.length!==1)return!1;let s=a.references[0];if(!s)return!1;for(let i of ut(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=Re(l.parent.parent,z.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=Ue(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=Re(l,z.TSESTree.AST_NODE_TYPES.VariableDeclaration);return c?!!Ue(c,e.sourceCode):!1}if(l.type===z.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Ue(l,e.sourceCode)}return!1}function n(r){r.key.type!==z.TSESTree.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Re(r,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(r){if(r.typeAnnotation.type===z.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(We(r)||!t(r)))for(let o of r.typeAnnotation.members)o.type===z.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSInterfaceDeclaration(r){if(!(We(r)||!t(r)))for(let o of r.body.body)o.type===z.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSTypeReference(r){if(r.typeName.type!==z.TSESTree.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let o=r.typeArguments.params[0];if(o.type!==z.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=Re(r.parent,z.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=Ue(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&&n(l)}}}});function We(e){return e?e.parent?.type===z.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===z.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ue(e,t){if(We(e))return;let n;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&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===z.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let o=r.variables.find(s=>s.identifiers.includes(n));if(!o)return;let a=o.references.filter(s=>s.identifier!==n);if(!(a.length!==1||!a[0])&&!We(a[0].identifier.parent.parent))return a[0].identifier}var mt={name:cn,rule:Wr};var pn=require("@typescript-eslint/utils"),Ve=he(require("path"));var Vr=pn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),un="no-relative-imports",Hr=V({find:W(),replacement:W()}),Yr=V({aliases:q(Hr),rootDir:L(W()),allowNotFoundAliases:L(Ce()),_dev_simulateFileName:L(W())}),Jr=Vr({name:un,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:[Yr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=Ve.default.dirname(i);return Ve.default.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=Ve.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(!r(i))return;let l=o(i,n),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})}}}}),dt={name:un,rule:Jr};var Pe=require("@typescript-eslint/utils"),be=he(require("zod/v4"));var Br="no-type-guards",Xr=be.object({alternativeMsgs:be.object({inArrayFind:be.string().optional(),inArrayFilter:be.string().optional()}).optional(),__dev_simulateFileName:be.string().optional()});function qr(e){return e.typeAnnotation.type!==Pe.AST_NODE_TYPES.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function Gr(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function Kr(e){let t=e.parent;for(;t;){if(t.type===Pe.AST_NODE_TYPES.CallExpression&&t.callee.type===Pe.AST_NODE_TYPES.MemberExpression&&t.callee.property.type===Pe.AST_NODE_TYPES.Identifier){let n=t.callee.property.name;if(n==="filter"||n==="find")return{method:n}}t=t.parent}return null}var yt=ne({name:Br,meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[_e(Xr)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let n=t.__dev_simulateFileName??e.filename;if(Gr(n))return{};function r(o){if(!qr(o))return;let a=Kr(o),s=[];if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let l=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:l,data:{message:i}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":r,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":r,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":r}}});var xe=require("@typescript-eslint/utils");var Zr="no-unnecessary-async-on-jsx-props";function Qr(e){if(e.body.type!==xe.AST_NODE_TYPES.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let n=t[0];return!n||n.type!==xe.AST_NODE_TYPES.ExpressionStatement?!1:n.expression.type===xe.AST_NODE_TYPES.AwaitExpression}var gt=ne({name:Zr,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(n){Qr(n)&&e.report({node:n,messageId:"unnecessaryAsyncInJsxProp",fix(r){let o=e.sourceCode,a=[],s=o.getFirstToken(n,l=>l.value==="async");if(s){let l=o.getTokenAfter(s);l?a.push(r.replaceTextRange([s.range[0],l.range[0]],"")):a.push(r.remove(s))}function i(l){if(l.type===xe.AST_NODE_TYPES.AwaitExpression){let c=o.getFirstToken(l);if(c&&c.value==="await"){let p=o.getTokenAfter(c);p?a.push(r.replaceTextRange([c.range[0],p.range[0]],"")):a.push(r.remove(c))}}if(l.type===xe.AST_NODE_TYPES.BlockStatement)for(let c of l.body)i(c);else l.type===xe.AST_NODE_TYPES.ExpressionStatement&&i(l.expression)}return i(n.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});var de=require("@typescript-eslint/utils");var St=he(require("typescript")),ei=de.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="no-unnecessary-casting",ti=V({additionalCastFunctions:L(q(V({name:W(),expectedType:Mt(["string","number"])})))}),Tt={name:fn,rule:ei({name:fn,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:[ti],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],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&St.TypeFlags.NumberLike):!!(p.flags&St.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===de.AST_NODE_TYPES.SpreadElement)return;let{callee:g}=p;if(g.type!==de.AST_NODE_TYPES.Identifier)return;let h=g.name,x=r.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 Ne=require("@typescript-eslint/utils"),se=he(require("zod/v4"));var ni=se.object({methods:se.union([se.array(se.string()),se.literal("array")])}),ht=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:[se.toJSONSchema(ni)]},defaultOptions:[{methods:"array"}],create(e,[t]){let n=t.methods,r=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(n)?n.includes(i):r.has(i)}function a(i){let{callee:l}=i;if(l.type===Ne.AST_NODE_TYPES.MemberExpression){let c=l.property;if(c.type===Ne.AST_NODE_TYPES.Identifier)return c.name}return null}function s(i,l){if(i.type!==Ne.AST_NODE_TYPES.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===Ne.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 re=require("@typescript-eslint/utils");var Et=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===re.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==re.AST_NODE_TYPES.ObjectExpression||t.id.type===re.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===re.AST_NODE_TYPES.ExportNamedDeclaration)return;let n=new Map;for(let s of t.init.properties)s.type===re.AST_NODE_TYPES.Property&&s.key.type===re.AST_NODE_TYPES.Identifier&&n.set(s.key.name,s);if(n.size===0||t.id.type!==re.AST_NODE_TYPES.Identifier)return;let r=ri(t,e.sourceCode);if(r.length===0)return;let o=t.init.properties.some(s=>s.type!==re.AST_NODE_TYPES.Property?!1:s.value.type===re.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let s of r){if(s.identifier.parent.type!==re.AST_NODE_TYPES.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===re.AST_NODE_TYPES.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==re.AST_NODE_TYPES.Identifier)return;a.add(i.property.name)}if(i.parent.type===re.AST_NODE_TYPES.CallExpression&&o)return}for(let[s,i]of n)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function ri(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}var U=require("@typescript-eslint/utils");var ii=V({selectors:q(V({name:W(),selectorProp:L(W()),selectorArgPos:L(ce()),returnProp:L(W())}))}),si=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-unused-selected-values",bt={name:mn,rule:si({name:mn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[ii]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.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=ai(a);if(!s)return;let i=r.get(s);if(!i)return;let l=oi(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=li(l);if(!c)return;let p=dn(c.properties,void 0);if(!p)return;if(o.id.type===U.AST_NODE_TYPES.ObjectPattern){let h=dn(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=ci(o,e.sourceCode);if(u.length===0)return;let g=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;g.add(x.name)}for(let[h,x]of p)g.has(h)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:h}})}}}})};function oi(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===U.AST_NODE_TYPES.ArrowFunctionExpression||r.type===U.AST_NODE_TYPES.FunctionExpression)return r;if(n&&r.type===U.AST_NODE_TYPES.ObjectExpression){let o=r.properties.find(s=>s.type===U.AST_NODE_TYPES.Property&&s.key.type===U.AST_NODE_TYPES.Identifier&&s.key.name===n);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 ai(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 li(e){if(e.body.type===U.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===U.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===U.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==U.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function dn(e,t){let n=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;n=o.value.properties}let r=new Map;for(let o of n){if(o.type!==U.AST_NODE_TYPES.Property||o.key.type!==U.AST_NODE_TYPES.Identifier)return null;r.set(o.key.name,o)}return r.size>0?r:null}function ci(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}var H=require("@typescript-eslint/utils");var xt=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 r=null,o=!1;return{CallExpression(a){if(o)return;if(!r){let i=pi(a);i&&(r=i);return}let s=ui(a,e.sourceCode);if(s){o=!0;for(let i of s)r.delete(i);if(r.size!==0)for(let[i,l]of r)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function pi(e){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==H.AST_NODE_TYPES.ObjectExpression)return null;let r=ft(n.properties,a=>a.type!==H.AST_NODE_TYPES.Property||a.key.type!==H.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===H.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===H.AST_NODE_TYPES.FunctionExpression?fi(a.value):null);if(!r)return null;let o=new Map;for(let a of r.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 ui(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||!ft(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=ln(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 fi(e){if(e.body.type===H.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===H.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===H.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var $=require("@typescript-eslint/utils");var mi=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function yn(e){let t=[];for(let n of e.members)n.type===$.AST_NODE_TYPES.TSPropertySignature&&n.key.type===$.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function gn(e,...t){for(let n of t)e.set(...n);return e}var di=V({forceCheckOnFCPropTypesWithName:L(q(W()))}),Sn="no-unused-type-props-in-args",wt=null,yi=mi({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:[di],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!wt&&(wt=n.map(i=>new RegExp(i)));function r(i,l,c,p,u=!0){let g=c.name,h=e.sourceCode.getScope(l).references.find(k=>k.identifier.name===g)?.resolved,x=i&&wt?.some(k=>k.test(g));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 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){gn(c,...yn(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&&r(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=[],g=[];for(let[h,x]of l)c.includes(h)||(g.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=g.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)r(!0,i,p.typeName,c,!1);else if(p.type===$.AST_NODE_TYPES.TSTypeLiteral)gn(c,...yn(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?r(!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)}}}}),It={name:Sn,rule:yi};var ke=require("@typescript-eslint/utils"),gi=ke.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hn="prefer-named-functions",Tn=new Map,Si=gi({name:hn,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=Tn.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),Tn.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===ke.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===ke.AST_NODE_TYPES.Identifier){let o=r.id.name;if(r.id.typeAnnotation||n&&n.test(o)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==ke.AST_NODE_TYPES.BlockStatement)return;let a=r.parent,s=r.init.params,i=r.init.body,l=r.init;e.report({node:r.id,messageId:n?"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)}`)}]})}}}}}),Ct={name:hn,rule:Si};var N=require("@typescript-eslint/utils");var Ti=V({disallowedFunctions:q(V({name:W(),allowUsingWithArgs:L(Ce()),hookAlternative:L(W()),message:L(W()),allowUseInside:L(q(W()))}))});function He(e){return/^use[A-Z]/.test(e)}function En(e){return/^[A-Z]/.test(e)}function hi(e){return e.type===N.AST_NODE_TYPES.Identifier?He(e.name):e.type===N.AST_NODE_TYPES.MemberExpression&&e.property.type===N.AST_NODE_TYPES.Identifier?He(e.property.name):!1}function bn(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 xn(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&bn(e.parent.callee,"forwardRef"))}function wn(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&bn(e.parent.callee,"memo"))}function At(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 Ei(e){let t=e.parent,n=!1;for(;t;){if(t.type===N.AST_NODE_TYPES.FunctionDeclaration||t.type===N.AST_NODE_TYPES.FunctionExpression||t.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let r=At(t);if(r&&r.type===N.AST_NODE_TYPES.Identifier){if(En(r.name)||He(r.name))return!n;n=!0}else{if(xn(t)||wn(t))return!n;if(t.parent.type===N.AST_NODE_TYPES.CallExpression){let o=t.parent;hi(o.callee)||(n=!0)}else t.parent.type===N.AST_NODE_TYPES.JSXExpressionContainer||(n=!0)}}t=t.parent}return!1}function In(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 bi(e,t){if(!t.length)return!1;let n=e.parent;for(;n;){if(n.type===N.AST_NODE_TYPES.FunctionDeclaration||n.type===N.AST_NODE_TYPES.FunctionExpression||n.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let r=At(n);if(r&&r.type===N.AST_NODE_TYPES.Identifier&&t.includes(r.name))return!0}else if(n.type===N.AST_NODE_TYPES.CallExpression){let r=In(n);if(r&&t.includes(r))return!0}n=n.parent}return!1}function xi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===N.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function wi(e,t){let n=!1,r=e.parent;for(;r;){if(r.type===N.AST_NODE_TYPES.FunctionDeclaration||r.type===N.AST_NODE_TYPES.FunctionExpression||r.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let o=At(r);if(o&&o.type===N.AST_NODE_TYPES.Identifier){if(En(o.name)||He(o.name)){n=!0;break}}else if(xn(r)||wn(r)){n=!0;break}}r=r.parent}return n?t.length===0?Ei(e):!bi(e,t):!1}var Rt=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:[Ti],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:n}=t,r=new Map(n.map(o=>[o.name,o]));return{CallExpression(o){let a=In(o);if(!a)return;let s=r.get(a);if(!s||s.allowUsingWithArgs&&xi(o))return;let i=s.allowUseInside||[];wi(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 J=require("@typescript-eslint/utils");var Ii=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),An="prefer-single-line-if",Ci=V({maxLineLength:L(ce()),maxNonSimpleConditionLength:L(ce())}),Ai=Ii({name:An,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[Ci]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==J.AST_NODE_TYPES.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let a=r.consequent.body[0];if(a.type===J.AST_NODE_TYPES.ReturnStatement){if(!kn(a))return}else if(!(a.type===J.AST_NODE_TYPES.ContinueStatement||a.type===J.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===J.AST_NODE_TYPES.LogicalExpression||r.test.type===J.AST_NODE_TYPES.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=Cn(r.test);if(!u&&r.test.type===J.AST_NODE_TYPES.UnaryExpression&&r.test.operator==="!"){let g=r.test.argument;Cn(g)&&(u=!0)}if(u&&(s=n.getText(r.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=n.getText(r.test));let i=n.getText(a);if(s.includes(`
|
|
16
|
-
`))return;let l=n.getTokenAfter(r);if(l&&l.type===J.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let u=n.getTokenAfter(l);if(u&&u.type===J.AST_TOKEN_TYPES.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=Ri(n,r),p=`if (${s}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:u=>u.replaceText(r,p)})}}}});function Cn(e){return e.type===J.AST_NODE_TYPES.CallExpression||e.type===J.AST_NODE_TYPES.BinaryExpression||e.type===J.AST_NODE_TYPES.MemberExpression&&Rn(e)}function Rn(e){return e.object.type===J.AST_NODE_TYPES.MemberExpression?Rn(e.object):e.object.type!==J.AST_NODE_TYPES.Identifier}function Ri(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function kn(e){if(!e.argument)return!0;let t=e.argument;return t.type===J.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===J.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===J.AST_NODE_TYPES.Literal||t.type===J.AST_NODE_TYPES.Identifier||t.type===J.AST_NODE_TYPES.TemplateLiteral||t.type===J.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===J.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===J.AST_NODE_TYPES.UnaryExpression?kn(t):!1}var kt={name:An,rule:Ai};var ee=require("@typescript-eslint/utils");var ki=ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vn="react-compiler-migration",vi=V({disallowHooks:L(q(V({name:W(),replacement:W()}))),disallowMethods:L(q(V({name:W(),replacement:L(W()),requireTrueProp:L(W())})))}),Oi=/eslint +react-compiler\/react-compiler: +\["error/;function Fi(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 Pi=ki({name:vn,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:[vi]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(Oi.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let o=null,a=null;if(r.callee.type===ee.AST_NODE_TYPES.Identifier?(o=r.callee.name,a=r.callee):r.callee.type===ee.AST_NODE_TYPES.MemberExpression&&r.callee.property.type===ee.AST_NODE_TYPES.Identifier&&(o=r.callee.property.name,a=r.callee.property),o){let s=t.disallowHooks.find(i=>i.name===o);s&&a&&e.report({node:r,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&&Fi(r.callee)){for(let o of r.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)}]})}}}}}}:{}}}),vt={name:vn,rule:Pi};var Ye=require("@typescript-eslint/utils"),Ni=Ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),On="require-description",Di=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ji=/^eslint-disable-(next-)?line$/u,Mi=Ni({name:On,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let o of n.getAllComments()){let a=_i(o);a!=null&&(r.has(a.kind)||a.description||e.report({loc:$i(o.loc),messageId:"missingDescription"}))}}}}}),Fn={name:On,rule:Mi};function _i(e){let{text:t,description:n}=Li(e.value);if(!t)return null;let r=Di.exec(t);if(!r)return null;let o=r[1];if(!o)return null;let a=ji.test(o);if(e.type===Ye.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let s=t.slice(r.index+o.length);return{kind:o,value:s.trim(),description:n}}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 $i(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Dn(e){return/^use[A-Z0-9]/.test(e)}function Je(e){return e.type==="Identifier"?Dn(e.name):e.type==="MemberExpression"&&!e.computed&&Je(e.property)?e.object.type==="Identifier":!1}function jn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Mn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function _n(e){return!!(e.parent&&e.parent.callee&&Mn(e.parent.callee,"forwardRef"))}function Ln(e){return!!(e.parent&&e.parent.callee&&Mn(e.parent.callee,"memo"))}function Ot(e){for(;e;){let t=zn(e);if(t&&(jn(t)||Je(t))||_n(e)||Ln(e))return!0;e=e.parent}return!1}function Pn(e){return!1}function Ft(e){return!1}var zi=/eslint +react-compiler\/react-compiler: +\["error/,$n={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(zi.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),n=typeof e.getScope=="function"?()=>n():l=>e.sourceCode.getScope(l),r=null,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&&Pn(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(T,m){let{cache:y}=g,A=y.get(T.id),C=new Set(m);if(C.has(T.id)){let E=[...C],P=E.slice(E.indexOf(T.id)+1);for(let Y of P)u.add(Y);return BigInt("0")}if(C.add(T.id),A!==void 0)return A;if(l.thrownSegments.includes(T))A=BigInt("0");else if(T.prevSegments.length===0)A=BigInt("1");else{A=BigInt("0");for(let E of T.prevSegments)A+=g(E,C)}return T.reachable&&A===BigInt("0")?y.delete(T.id):y.set(T.id,A),A}function h(T,m){let{cache:y}=h,A=y.get(T.id),C=new Set(m);if(C.has(T.id)){let E=Array.from(C),P=E.slice(E.indexOf(T.id)+1);for(let Y of P)u.add(Y);return BigInt("0")}if(C.add(T.id),A!==void 0)return A;if(l.thrownSegments.includes(T))A=BigInt("0");else if(T.nextSegments.length===0)A=BigInt("1");else{A=BigInt("0");for(let E of T.nextSegments)A+=h(E,C)}return y.set(T.id,A),A}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 A of T.prevSegments){let C=x(A);C<y&&(y=C)}y+=1}return m.set(T.id,y),y}g.cache=new Map,h.cache=new Map,x.cache=new Map;let b=h(l.initialSegment),k=zn(c),w=Ot(c),M=k?jn(k)||Je(k):_n(c)||Ln(c),F=1/0;for(let T of l.finalSegments){if(!T.reachable)continue;let m=x(T);m<F&&(F=m)}for(let[T,m]of p){if(!T.reachable)continue;let y=T.nextSegments.length===0?F<=x(T):F<x(T),A=g(T)*h(T),C=u.has(T.id);for(let E of m)if(C&&!Ft(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.`}),M){if(c.async&&e.report({node:E,message:`React Hook "${t(E)}" cannot be called in an async function.`}),!C&&A!==b&&!Ft(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 P=`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:P})}else if(k){let P=`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:P})}else if(c.type==="Program"){let P=`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:P})}else if(w&&!Ft(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"&&Dn(Y.parent.id.name))return}let P=`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:P})}}},CallExpression(l){if(Je(l.callee)){let c=Nn(o),p=Nn(a),u=c.get(p);u||(u=[],c.set(p,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Pn(l.callee))&&l.arguments.length>0&&(r=l)},Identifier(l){r==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===r&&(r=null)},FunctionDeclaration(l){Ot(l)&&i(n(l))},ArrowFunctionExpression(l){Ot(l)&&i(n(l))}}}};function zn(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function Nn(e){return e[e.length-1]}var Un={[It.name]:It.rule,[ot.name]:ot.rule,[st.name]:st.rule,"rules-of-hooks":$n,"exhaustive-deps":Jt,"require-description":Fn.rule,[at.name]:at.rule,[ct.name]:ct.rule,[Ct.name]:Ct.rule,[Ke.name]:Ke.rule,[it.name]:it.rule,[dt.name]:dt.rule,[kt.name]:kt.rule,[mt.name]:mt.rule,[lt.name]:lt.rule,[Qe.name]:Qe.rule,[vt.name]:vt.rule,[Ge.name]:Ge.rule,[rt.name]:rt.rule,[Tt.name]:Tt.rule,[ht.name]:ht.rule,[bt.name]:bt.rule,[xt.name]:xt.rule,[Et.name]:Et.rule,[Rt.name]:Rt.rule,[gt.name]:gt.rule,[yt.name]:yt.rule};var Ui={rules:Un};0&&(module.exports={extendedLintPlugin});
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let y=l.acquire(w),A=new Set,C=null;{let f=y.upper;for(;f&&(A.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 R=d.node.parent;if(R==null&&(it(C.block,d.node.id),R=d.node.parent,R==null))return!1;if(R.kind==="const"&&I.type==="Literal"&&(typeof I.value=="string"||typeof I.value=="number"||I.value===null))return!0;if(I.type!=="CallExpression")return!1;let O=I.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let k=d.node.id,{name:j}=O;if(j==="useRef"&&k.type==="Identifier")return!0;if(Er(O)&&k.type==="Identifier"){for(let D of f.references)D!==k&&h.add(D.identifier);return!0}else if(j==="useState"||j==="useReducer"){if(k.type==="ArrayPattern"&&k.elements.length===2&&E(f.identifiers)){if(k.elements[1]===f.identifiers[0]){if(j==="useState"){let D=f.references,se=0;for(let me=0;me<D.length;me++){if(D[me].isWrite()&&se++,se>1)return!1;c.set(D[me].identifier,k.elements[0])}}return!0}else if(k.elements[0]===f.identifiers[0]){if(j==="useState"){let D=f.references;for(let se=0;se<D.length;se++)p.add(D[se].identifier)}return!1}}}else if(j==="useTransition"&&k.type==="ArrayPattern"&&k.elements.length===2&&Array.isArray(f.identifiers)&&k.elements[1]===f.identifiers[0])return!0;return!1}function Y(f){if(!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,R=C.childScopes,O=null,k;for(k=0;k<R.length;k++){let j=R[k],D=j.block;if(I.type==="FunctionDeclaration"&&D===I||I.type==="VariableDeclarator"&&D.parent===I){O=j;break}}if(O==null)return!1;for(k=0;k<O.through.length;k++){let j=O.through[k];if(j.resolved!=null&&A.has(j.resolved.scope)&&!q(j.resolved))return!1}return!0}let q=b(F,u),te=b(Y,g),Z=new Map;function Ce(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 re=new Map,Pe=new Map;ue(y);function ue(f){for(let d of f.references){if(!d.resolved||!A.has(d.resolved.scope))continue;let I=it(w,d.identifier),R=Gt(I),O=de(R,Pe);if(m&&R.type==="Identifier"&&(R.parent.type==="MemberExpression"||R.parent.type==="OptionalMemberExpression")&&!R.parent.computed&&R.parent.property.type==="Identifier"&&R.parent.property.name==="current"&&Ce(d)&&Z.set(O,{reference:d,dependencyNode:R}),R.parent.type==="TSTypeQuery"||R.parent.type==="TSTypeReference")continue;let k=d.resolved.defs[0];if(k!=null&&!(k.node!=null&&k.node.init===w.parent)&&k.type!=="TypeParameter")if(re.has(O))re.get(O).references.push(d);else{let j=d.resolved,D=q(j)||te(j);re.set(O,{isStable:D,references:[d]})}}for(let d of f.childScopes)ue(d)}Z.forEach(({reference:f,dependencyNode:d},I)=>{let R=f.resolved.references,O=!1;for(let k=0;k<R.length;k++){let{identifier:j}=R[k],{parent:D}=j;if(D!=null&&D.type==="MemberExpression"&&!D.computed&&D.property.type==="Identifier"&&D.property.name==="current"&&D.parent.type==="AssignmentExpression"&&D.parent.left===D){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 ce=new Set;function fe(f,d){ce.has(d)||(ce.add(d),i({node:f,message:`Assignments to the '${d}' variable from inside React Hook ${n(P)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${n(P)}.`}))}let Ae=new Set;if(re.forEach(({isStable:f,references:d},I)=>{f&&Ae.add(I),d.forEach(R=>{R.writeExpr&&fe(R.writeExpr,I)})}),ce.size>0)return;if(!L){let f=null;if(re.forEach(({isStable:d,references:I},R)=>{f||I.forEach(O=>{if(f)return;let k=O.identifier;if(!c.has(k))return;let D=O.from;for(;D.type!=="function";)D=D.upper;D.block===w&&(f=R)})}),f){let{suggestedDependencies:d}=nt({dependencies:re,declaredDependencies:[],stableDependencies:Ae,externalDependencies:new Set,isEffect:!0});i({node:P,message:`React Hook ${T} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+d.join(", ")+`] as a second argument to the ${T} Hook.`,suggest:[{desc:`Add dependencies array: [${d.join(", ")}]`,fix(I){return I.insertTextAfter(w,`, [${d.join(", ")}]`)}}]})}return}let Fe=[],Ne=new Set;L.type!=="ArrayExpression"?i({node:L,message:`React Hook ${n(P)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):L.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${n(P)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}h.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(f)}\``,fix(O){return O.removeRange(f.range)}}]});let d;try{d=de(f,Pe)}catch(O){if(/Unsupported node type/.test(O.message)){f.type==="Literal"?re.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${n(P)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw O}let I=f;for(;I.type==="MemberExpression"||I.type==="OptionalMemberExpression"||I.type==="ChainExpression";)I=I.object||I.expression.object;let R=!C.through.some(O=>O.identifier===I);Fe.push({key:d,node:f}),R||Ne.add(d)});let{suggestedDependencies:Yn,unnecessaryDependencies:Le,missingDependencies:ge,duplicateDependencies:Dt}=nt({dependencies:re,declaredDependencies:Fe,stableDependencies:Ae,externalDependencies:Ne,isEffect:m}),Me=Yn;if(Dt.size+ge.size+Le.size===0){if(t)return;gr({declaredDependencies:Fe,declaredDependenciesNode:L,componentScope:C,scope:y}).forEach(({construction:d,isUsedOutsideOfHook:I,depType:R})=>{let O=R==="function"?"useCallback":"useMemo",k=R==="function"?"definition":"initialization",j=`wrap the ${k} of '${d.name.name}' in its own ${O}() Hook.`,D=I?`To fix this, ${j}`:`Move it inside the ${T} callback. Alternatively, ${j}`,se=R==="conditional"||R==="logical expression"?"could make":"makes",me=`The '${d.name.name}' ${R} ${se} the dependencies of ${T} Hook (at line ${L.loc.start.line}) change on every render. ${D}`,Lt;I&&d.type==="Variable"&&R==="function"&&(Lt=[{desc:`Wrap the ${k} of '${d.name.name}' in its own ${O}() Hook.`,fix(Mt){let[Jn,qn]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Mt.insertTextBefore(d.node.init,Jn),Mt.insertTextAfter(d.node.init,qn)]}}]),i({node:d.node,message:me,suggest:Lt})});return}!m&&ge.size>0&&(Me=nt({dependencies:re,declaredDependencies:[],stableDependencies:Ae,externalDependencies:Ne,isEffect:m}).suggestedDependencies);function Bn(){if(Fe.length===0)return!0;let f=Fe.map(I=>I.key),d=f.slice().sort();return f.join(",")===d.join(",")}Bn()&&Me.sort();function Xe(f){let d=f.split("."),I="";for(let R=0;R<d.length;R++){if(R!==0){let O=d.slice(0,R+1).join("."),k=Pe.get(O)===!0;I+=k?"?.":"."}I+=d[R]}return I}function Ge(f,d,I,R){return f.size===0?null:(f.size>1?"":d+" ")+I+" "+(f.size>1?"dependencies":"dependency")+": "+Tr(Array.from(f).sort().map(O=>"'"+Xe(O)+"'"))+`. Either ${R} ${f.size>1?"them":"it"} or remove the dependency array.`}let ae="";if(Le.size>0){let f=null;if(Array.from(Le.keys()).forEach(d=>{f===null&&d.endsWith(".current")&&(f=d)}),f!==null)ae=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Ne.size>0){let d=Array.from(Ne)[0];y.set.has(d)||(ae=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ae&&ge.has("props")){let f=re.get("props");if(f==null)return;let d=f.references;if(!Array.isArray(d))return;let I=!0;for(let R=0;R<d.length;R++){let O=d[R],k=it(C.block,O.identifier);if(!k){I=!1;break}let j=k.parent;if(j==null){I=!1;break}if(j.type!=="MemberExpression"&&j.type!=="OptionalMemberExpression"){I=!1;break}}I&&(ae=` 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 ${n(P)}.`)}if(!ae&&ge.size>0){let f=null;ge.forEach(d=>{if(f)return;let I=C.set.get(d),R=re.get(d);if(R.references[0].resolved!==I)return;let O=I.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let k=!1,j;for(let D=0;D<R.references.length;D++)if(j=R.references[D].identifier,j!=null&&j.parent!=null&&(j.parent.type==="CallExpression"||j.parent.type==="OptionalCallExpression")&&j.parent.callee===j){k=!0;break}k&&(f=d)}),f!==null&&(ae=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ae&&ge.size>0){let f=null;if(ge.forEach(d=>{if(f!==null)return;let R=re.get(d).references,O,k;for(let j=0;j<R.length;j++){for(O=R[j].identifier,k=O.parent;k!=null&&k!==C.block;){if(k.type==="CallExpression"){let D=c.get(k.callee);if(D!=null){if(D.name===d)f={missingDep:d,setter:k.callee.name,form:"updater"};else if(p.has(O))f={missingDep:d,setter:k.callee.name,form:"reducer"};else{let se=R[j].resolved;if(se!=null){let me=se.defs[0];me!=null&&me.type==="Parameter"&&(f={missingDep:d,setter:k.callee.name,form:"inlineReducer"})}}break}}k=k.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":ae=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":ae=` 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":ae=` 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 ${n(P)} has `+(Ge(ge,"a","missing","include")||Ge(Le,"an","unnecessary","exclude")||Ge(Dt,"a","duplicate","omit"))+ae,suggest:[{desc:`Update the dependencies array to be: [${Me.map(Xe).join(", ")}]`,fix(f){return f.replaceText(L,`[${Me.map(Xe).join(", ")}]`)}}]})}function v(w){let L=Sr(w.callee,s);if(L===-1)return;let P=w.arguments[L],T=w.callee,m=Kt(T).name,y=w.arguments[L+1],A=/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&&!A)){if(!y&&!A){(m==="useMemo"||m==="useCallback")&&i({node:T,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(P.type){case"FunctionExpression":case"ArrowFunctionExpression":x(P,y,T,m,A);return;case"Identifier":if(!y||y.elements&&y.elements.some(F=>F&&F.type==="Identifier"&&F.name===P.name))return;let C=r(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":x(E.node,y,T,m,A);return;case"VariableDeclarator":let F=E.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":x(F,y,T,m,A);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(yr.test(w.value))return t=!0,{CallExpression:L=>v(L,!0)}}return{CallExpression:w=>v(w)}}};function nt({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((x,v)=>{let w=i(a,v);w.isUsed=!0,l(a,v,L=>{L.isSubtreeUsed=!0})}),t.forEach(({key:x})=>{let v=i(a,x);v.isSatisfiedRecursively=!0}),n.forEach(x=>{let v=i(a,x);v.isSatisfiedRecursively=!0});function i(x,v){let w=v.split("."),L=x;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(x,v,w){let L=v.split("."),P=x;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,x=>x);function u(x,v,w,L){x.children.forEach((P,T)=>{let m=L(T);if(P.isSatisfiedRecursively){P.isSubtreeUsed&&w.add(m);return}if(P.isUsed){v.add(m);return}u(P,v,w,y=>m+"."+y)})}let g=[],h=new Set,b=new Set;return t.forEach(({key:x})=>{p.has(x)?g.indexOf(x)===-1?g.push(x):b.add(x):h.add(x)}),c.forEach(x=>{g.push(x)}),{suggestedDependencies:g,unnecessaryDependencies:h,duplicateDependencies:b,missingDependencies:c}}function Se(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return Se(e.consequent)!=null||Se(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Se(e.left)!=null||Se(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Se(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Se(e.expression);case"TSAsExpression":return Se(e.expression)}return null}function gr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let o=e.map(({key:s})=>{let i=n.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=Se(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!==r&&p!=null;)p=p.upper;if(p!==r&&!Zt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}function Gt(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?Gt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function rt(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function de(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=de(e.object,t),r=de(e.property,null),o=`${n}.${r}`;return rt(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=de(e.object,t),r=de(e.property,null),o=`${n}.${r}`;return rt(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=de(n.object,t),o=de(n.property,null),a=`${r}.${o}`;return rt(n,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Kt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Sr(e,t){let n=Kt(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=de(n,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(r)?0:-1}else return-1}}function it(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),hr(r,t))return r;if(Zt(r,t))for(let[o,a]of Object.entries(r))o!=="parent"&&(qt(a)?(a.parent=r,n.push(a)):Array.isArray(a)&&a.forEach(s=>{qt(s)&&(s.parent=r,n.push(s))}))}return null}function Tr(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function qt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function hr(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function Zt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Er(e){return!1}var Te=require("@typescript-eslint/utils");var ee=xe(require("typescript")),xr=Te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="improved-no-unnecessary-condition",br=V({}),wr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Ir=new Set(wr),st={name:Qt,rule:xr({name:Qt,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[br]},defaultOptions:[{}],create(e){let t=Te.ESLintUtils.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===Te.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&ee.default.TypeFlags.Any||i.flags&ee.default.TypeFlags.Unknown?null:i.flags&ee.default.TypeFlags.StringLike?["string"]:i.flags&ee.default.TypeFlags.NumberLike?["number"]:i.flags&ee.default.TypeFlags.BigIntLike?["bigint"]:i.flags&ee.default.TypeFlags.BooleanLike?["boolean"]:i.flags&ee.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&ee.default.TypeFlags.Undefined||i.flags&ee.default.TypeFlags.Void?["undefined"]:i.flags&ee.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&ee.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&ee.default.TypeFlags.NonPrimitive?["object"]:i.flags&ee.default.TypeFlags.Never?["never"]:null}function a(i){if(!n)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=n.getTypeAtLocation(l.expression);if(c.flags&ee.default.TypeFlags.Any||c.flags&ee.default.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let g of c.types){let h=o(g);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(r(i.left)?(c=i.left,p=i.right.type===Te.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(c=i.right,p=i.left.type===Te.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!Cr(p,Ir))return;let u=a(c);if(!u)return;let g=i.operator==="!==",h=u.includes(p);u.length===1?h&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ve(c,e),type:p}}):!h&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ve(c,e),type:Array.from(u)[0]}}):!h&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ve(c,e),actualType:ze(u),conditionType:p}}):h&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ve(c,e),actualType:ze(u),conditionType:p}}):!h&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ve(c,e),actualType:ze(u),conditionType:p}}):!h&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ve(c,e),type:ze(u)}})}return{BinaryExpression:s}}})};function ze(e){return Array.from(new Set(e)).join(" | ")||"never"}function ve(e,t){let n=e.argument;return n.type===Te.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function Cr(e,t){return t.has(e)}var Ue=require("@typescript-eslint/utils");var Ar=Ue.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),en="no-call-with-explicit-generics",Rr=V({functions:G(W())}),vr=Ar({name:en,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Rr]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:o}=r;o.type===Ue.AST_NODE_TYPES.Identifier&&n.has(o.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),ot={name:en,rule:vr};var be=require("@typescript-eslint/utils"),kr=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-call-with-inferred-generics",Or=kr({name:tn,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:o}=r;if(o.type!==be.AST_NODE_TYPES.Identifier)return;let a=n.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(r.typeArguments?.params.length||0)<(s||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&r.typeArguments?.params?.some(p=>!i&&p.type===be.AST_NODE_TYPES.TSAnyKeyword||l&&p.type===be.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===be.AST_NODE_TYPES.Identifier&&l.includes(p.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),at={name:tn,rule:Or};var rn=require("@typescript-eslint/utils"),Pr=rn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="no-commented-out-code",Fr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],J={returnStatement:/^\s*return\s+/,stringAssignment:/\w=("|'|`)/,objectPropertyWithQuotes:/\w+:\s*('|"|`)/,computedPropertyAssignment:/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,kebabCaseProperty:/\w+-\w+:/,snakeCaseProperty:/\w+_\w+:/,ternaryOperator:/\?\s+\w/,colonWithWord:/:\s+\w/,quotedString:/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,numberWithComma:/^\s*\d+[,}]/,arrayWithComma:/^\s*\[[^\]]*\][,}]/,objectWithComma:/^\s*\{[^}]*\}[,}]/,methodCall:/\.\w+\(/,arrayAccess:/\[\w+\]/,quotedPropertyKey:/^\s*(['"`]).+?\1\s*:/,jsxSelfClosing:/^<[A-Z]\w*(\s|>|\/)/,jsxElement:/^<[a-z]+(\s|>|\/)/,jsxOpeningTag:/<[A-Z]\w*(\s.*)?>/,jsxClosingTag:/<\/[A-Z]\w*>/,htmlOpeningTag:/<[a-z]+(\s.*)?>/,htmlClosingTag:/<\/[a-z]+>/,colonDescriptiveComment:/^[a-zA-Z]+(\s+[a-zA-Z]+)*:\s+[a-zA-Z]+\s+[a-zA-Z][^{=,'"]*$/,jsdocComment:/^\s*[*\s]*$/},Nr=[") {","return;",J.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",J.stringAssignment,");",J.objectPropertyWithQuotes,J.computedPropertyAssignment,J.kebabCaseProperty,J.snakeCaseProperty,"&&","||","()",J.ternaryOperator,J.colonWithWord,J.quotedString,J.numberWithComma,J.arrayWithComma,J.objectWithComma,J.methodCall,J.arrayAccess,"?.(","??","=>",J.quotedPropertyKey],jr=["/>","</",J.jsxSelfClosing,J.jsxElement,J.jsxOpeningTag,J.jsxClosingTag,J.htmlOpeningTag,J.htmlClosingTag],nn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Dr=Pr({name:sn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(r,o){if(r.startsWith("/"))return!1;let a=r.trimStart();if(r.startsWith("*")||a.startsWith("eslint-disable")||r.includes("@deprecated")||r.includes("@example")||r.includes("@param")||r.includes("@returns")||r.includes("@throws")||r.includes("typescript-eslint")||r.includes("@ts-")||r.includes("prettier-ignore")||J.jsdocComment.test(r))return!1;for(let s of nn)if(a.startsWith(s))return!1;if(r.includes("https://")||a.includes(":")&&J.colonDescriptiveComment.test(a.trim()))return!1;if(o==="Block"){for(let s of jr)if(typeof s=="string"){if(r.includes(s))return{wrongPattern:s}}else if(s.test(r))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of Fr)if(a.startsWith(s))return{wrongPattern:s};for(let s of Nr)if(typeof s=="string"){if(r.includes(s))return{wrongPattern:s}}else if(s.test(r))return{wrongPattern:`regex(${s.toString()})`};return!1}function n(r,o){let a=r,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=n(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:nn.join(", ")}})}}}}}),lt={name:sn,rule:Dr};var We=require("@typescript-eslint/utils"),Lr=We.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-default-export",Mr=Lr({name:on,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===We.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ct={name:on,rule:Mr};var an=require("@typescript-eslint/utils"),_r=an.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ln="no-leaked-text-in-jsx",$r=[",",";","[","]","(",")"],zr=_r({name:ln,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let r="";$r.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),pt={name:ln,rule:zr};var he=require("@typescript-eslint/utils"),Ur=he.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-non-camel-case-functions",Wr=/^(\$?[a-z][a-zA-Z0-9]*)$/;function cn(e){if(e.typeName.type!==he.AST_NODE_TYPES.TSQualifiedName)return!1;let{left:t,right:n}=e.typeName;return t.type===he.AST_NODE_TYPES.Identifier&&t.name==="JSX"&&n.name==="Element"}var Vr=Ur({name:pn,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Wr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===he.AST_NODE_TYPES.TSTypeReference?cn(n):n.type===he.AST_NODE_TYPES.TSUnionType&&n.types.some(o=>o.type===he.AST_NODE_TYPES.TSTypeReference&&cn(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ut={name:pn,rule:Vr};var z=require("@typescript-eslint/utils");var ft=require("@typescript-eslint/utils");function ke(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:ke(e.parent,t,n===1/0?n:n-1)}function*mt(e){yield e,e.parent&&(yield*mt(e.parent))}function dt(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function un(e,t,n){let o=n.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===ft.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===ft.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Hr=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="no-optional-root-props",Yr=Hr({name:fn,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let a=e.sourceCode.getDeclaredVariables(r)[0];if(!a||a.references.length!==1)return!1;let s=a.references[0];if(!s)return!1;for(let i of mt(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=ke(l.parent.parent,z.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=Ve(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=ke(l,z.TSESTree.AST_NODE_TYPES.VariableDeclaration);return c?!!Ve(c,e.sourceCode):!1}if(l.type===z.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Ve(l,e.sourceCode)}return!1}function n(r){r.key.type!==z.TSESTree.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=ke(r,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(r){if(r.typeAnnotation.type===z.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(He(r)||!t(r)))for(let o of r.typeAnnotation.members)o.type===z.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSInterfaceDeclaration(r){if(!(He(r)||!t(r)))for(let o of r.body.body)o.type===z.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSTypeReference(r){if(r.typeName.type!==z.TSESTree.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let o=r.typeArguments.params[0];if(o.type!==z.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=ke(r.parent,z.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=Ve(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&&n(l)}}}});function He(e){return e?e.parent?.type===z.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===z.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ve(e,t){if(He(e))return;let n;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&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===z.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let o=r.variables.find(s=>s.identifiers.includes(n));if(!o)return;let a=o.references.filter(s=>s.identifier!==n);if(!(a.length!==1||!a[0])&&!He(a[0].identifier.parent.parent))return a[0].identifier}var yt={name:fn,rule:Yr};var mn=require("@typescript-eslint/utils"),Ye=xe(require("path"));var Br=mn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="no-relative-imports",Jr=V({find:W(),replacement:W()}),qr=V({aliases:G(Jr),rootDir:_(W()),allowNotFoundAliases:_(Re()),_dev_simulateFileName:_(W())}),Xr=Br({name:dn,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[qr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=Ye.default.dirname(i);return Ye.default.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=Ye.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(!r(i))return;let l=o(i,n),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})}}}}),gt={name:dn,rule:Xr};var je=require("@typescript-eslint/utils"),we=xe(require("zod/v4"));var Gr=we.object({alternativeMsgs:we.object({inArrayFind:we.string().optional(),inArrayFilter:we.string().optional()}).optional(),__dev_simulateFileName:we.string().optional()});function Kr(e){return e.typeAnnotation.type!==je.AST_NODE_TYPES.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function Zr(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function Qr(e){let t=e.parent;for(;t;){if(t.type===je.AST_NODE_TYPES.CallExpression&&t.callee.type===je.AST_NODE_TYPES.MemberExpression&&t.callee.property.type===je.AST_NODE_TYPES.Identifier){let n=t.callee.property.name;if(n==="filter"||n==="find")return{method:n}}t=t.parent}return null}var St=Q({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[$e(Gr)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let n=t.__dev_simulateFileName??e.filename;if(Zr(n))return{};function r(o){if(!Kr(o))return;let a=Qr(o),s=[];if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let l=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:l,data:{message:i}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":r,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":r,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":r}}});var Ie=require("@typescript-eslint/utils");var ei="no-unnecessary-async-on-jsx-props";function ti(e){if(e.body.type!==Ie.AST_NODE_TYPES.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let n=t[0];return!n||n.type!==Ie.AST_NODE_TYPES.ExpressionStatement?!1:n.expression.type===Ie.AST_NODE_TYPES.AwaitExpression}var Tt=Q({name:ei,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(n){ti(n)&&e.report({node:n,messageId:"unnecessaryAsyncInJsxProp",fix(r){let o=e.sourceCode,a=[],s=o.getFirstToken(n,l=>l.value==="async");if(s){let l=o.getTokenAfter(s);l?a.push(r.replaceTextRange([s.range[0],l.range[0]],"")):a.push(r.remove(s))}function i(l){if(l.type===Ie.AST_NODE_TYPES.AwaitExpression){let c=o.getFirstToken(l);if(c&&c.value==="await"){let p=o.getTokenAfter(c);p?a.push(r.replaceTextRange([c.range[0],p.range[0]],"")):a.push(r.remove(c))}}if(l.type===Ie.AST_NODE_TYPES.BlockStatement)for(let c of l.body)i(c);else l.type===Ie.AST_NODE_TYPES.ExpressionStatement&&i(l.expression)}return i(n.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});var ye=require("@typescript-eslint/utils");var ht=xe(require("typescript")),ni=ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yn="no-unnecessary-casting",ri=V({additionalCastFunctions:_(G(V({name:W(),expectedType:$t(["string","number"])})))}),Et={name:yn,rule:ni({name:yn,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:[ri],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],o=ye.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 ye.AST_NODE_TYPES.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case ye.AST_NODE_TYPES.TemplateLiteral:return u==="string";case ye.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&ht.TypeFlags.NumberLike):!!(p.flags&ht.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===ye.AST_NODE_TYPES.SpreadElement)return;let{callee:g}=p;if(g.type!==ye.AST_NODE_TYPES.Identifier)return;let h=g.name,b=r.find(v=>v.name===h);if(!b)return;if(s(u,b.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),b.expectedType)){let v,w;h==="Number"?v="unnecessaryNumberCasting":h==="String"?v="unnecessaryStringCasting":(v="unnecessaryCustomCasting",w={name:b.name,type:b.expectedType}),e.report({node:p,messageId:v,...w?{data:w}:{},fix:l(p,u)})}}return{CallExpression:c}}})};var De=require("@typescript-eslint/utils"),oe=xe(require("zod/v4"));var ii=oe.object({methods:oe.union([oe.array(oe.string()),oe.literal("array")])}),xt=Q({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[oe.toJSONSchema(ii)]},defaultOptions:[{methods:"array"}],create(e,[t]){let n=t.methods,r=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(n)?n.includes(i):r.has(i)}function a(i){let{callee:l}=i;if(l.type===De.AST_NODE_TYPES.MemberExpression){let c=l.property;if(c.type===De.AST_NODE_TYPES.Identifier)return c.name}return null}function s(i,l){if(i.type!==De.AST_NODE_TYPES.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===De.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 ie=require("@typescript-eslint/utils");var bt=Q({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(t){if(t.id.type===ie.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==ie.AST_NODE_TYPES.ObjectExpression||t.id.type===ie.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ie.AST_NODE_TYPES.ExportNamedDeclaration)return;let n=new Map;for(let s of t.init.properties)s.type===ie.AST_NODE_TYPES.Property&&s.key.type===ie.AST_NODE_TYPES.Identifier&&n.set(s.key.name,s);if(n.size===0||t.id.type!==ie.AST_NODE_TYPES.Identifier)return;let r=si(t,e.sourceCode);if(r.length===0)return;let o=t.init.properties.some(s=>s.type!==ie.AST_NODE_TYPES.Property?!1:s.value.type===ie.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let s of r){if(s.identifier.parent.type!==ie.AST_NODE_TYPES.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===ie.AST_NODE_TYPES.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==ie.AST_NODE_TYPES.Identifier)return;a.add(i.property.name)}if(i.parent.type===ie.AST_NODE_TYPES.CallExpression&&o)return}for(let[s,i]of n)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function si(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}var U=require("@typescript-eslint/utils");var oi=V({selectors:G(V({name:W(),selectorProp:_(W()),selectorArgPos:_(pe()),returnProp:_(W())}))}),ai=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn="no-unused-selected-values",wt={name:gn,rule:ai({name:gn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[oi]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.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=ci(a);if(!s)return;let i=r.get(s);if(!i)return;let l=li(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=pi(l);if(!c)return;let p=Sn(c.properties,void 0);if(!p)return;if(o.id.type===U.AST_NODE_TYPES.ObjectPattern){let h=Sn(o.id.properties,i.returnProp);if(!h)return;for(let[b,x]of p)h.has(b)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:b}});return}if(o.id.type!==U.AST_NODE_TYPES.Identifier||i.returnProp)return;let u=ui(o,e.sourceCode);if(u.length===0)return;let g=new Set;for(let h of u){if(h.identifier.parent.type!==U.AST_NODE_TYPES.MemberExpression)return;let b=h.identifier.parent.property;if(b.type!==U.AST_NODE_TYPES.Identifier)return;g.add(b.name)}for(let[h,b]of p)g.has(h)||e.report({node:b,messageId:"unusedSelectedValue",data:{name:h}})}}}})};function li(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===U.AST_NODE_TYPES.ArrowFunctionExpression||r.type===U.AST_NODE_TYPES.FunctionExpression)return r;if(n&&r.type===U.AST_NODE_TYPES.ObjectExpression){let o=r.properties.find(s=>s.type===U.AST_NODE_TYPES.Property&&s.key.type===U.AST_NODE_TYPES.Identifier&&s.key.name===n);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 ci(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 pi(e){if(e.body.type===U.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===U.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===U.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==U.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function Sn(e,t){let n=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;n=o.value.properties}let r=new Map;for(let o of n){if(o.type!==U.AST_NODE_TYPES.Property||o.key.type!==U.AST_NODE_TYPES.Identifier)return null;r.set(o.key.name,o)}return r.size>0?r:null}function ui(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}var H=require("@typescript-eslint/utils");var It=Q({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===H.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let r=null,o=!1;return{CallExpression(a){if(o)return;if(!r){let i=fi(a);i&&(r=i);return}let s=mi(a,e.sourceCode);if(s){o=!0;for(let i of s)r.delete(i);if(r.size!==0)for(let[i,l]of r)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function fi(e){if(!(e.callee.type===H.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==H.AST_NODE_TYPES.ObjectExpression)return null;let r=dt(n.properties,a=>a.type!==H.AST_NODE_TYPES.Property||a.key.type!==H.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===H.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===H.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===H.AST_NODE_TYPES.FunctionExpression?di(a.value):null);if(!r)return null;let o=new Map;for(let a of r.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 mi(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||!dt(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=un(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 di(e){if(e.body.type===H.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===H.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===H.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==H.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var $=require("@typescript-eslint/utils");var yi=$.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Tn(e){let t=[];for(let n of e.members)n.type===$.AST_NODE_TYPES.TSPropertySignature&&n.key.type===$.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function hn(e,...t){for(let n of t)e.set(...n);return e}var gi=V({forceCheckOnFCPropTypesWithName:_(G(W()))}),En="no-unused-type-props-in-args",Ct=null,Si=yi({name:En,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[gi],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Ct&&(Ct=n.map(i=>new RegExp(i)));function r(i,l,c,p,u=!0){let g=c.name,h=e.sourceCode.getScope(l).references.find(v=>v.identifier.name===g)?.resolved,b=i&&Ct?.some(v=>v.test(g));if(!h||!b&&h.references.filter(v=>v.isTypeReference).length>1)return;let x=h?.defs[0]?.node;if(!(u&&x?.parent?.type===$.AST_NODE_TYPES.ExportNamedDeclaration)){if(x?.type===$.AST_NODE_TYPES.TSTypeAliasDeclaration){o(i,l,p,x.typeAnnotation,!0);return}if(x?.type===$.AST_NODE_TYPES.TSInterfaceDeclaration){o(i,l,p,x.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){hn(c,...Tn(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&&r(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=[],g=[];for(let[h,b]of l)c.includes(h)||(g.push(h),u.push({node:b,messageId:"unusedObjectTypeProperty",data:{propertyName:h}}));for(let[h,b]of u.entries())e.report({...b,fix:h===u.length-1?x=>{let v=i.properties.at(-1),w=g.join(", ");return v?v?.type===$.AST_NODE_TYPES.RestElement?null:x.insertTextAfter(v,`, ${w}`):x.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)r(!0,i,p.typeName,c,!1);else if(p.type===$.AST_NODE_TYPES.TSTypeLiteral)hn(c,...Tn(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?r(!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)}}}}),At={name:En,rule:Si};var Oe=require("@typescript-eslint/utils"),Ti=Oe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bn="prefer-named-functions",xn=new Map,hi=Ti({name:bn,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=xn.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),xn.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===Oe.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===Oe.AST_NODE_TYPES.Identifier){let o=r.id.name;if(r.id.typeAnnotation||n&&n.test(o)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==Oe.AST_NODE_TYPES.BlockStatement)return;let a=r.parent,s=r.init.params,i=r.init.body,l=r.init;e.report({node:r.id,messageId:n?"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)}`)}]})}}}}}),Rt={name:bn,rule:hi};var N=require("@typescript-eslint/utils");var Ei=V({disallowedFunctions:G(V({name:W(),allowUsingWithArgs:_(Re()),hookAlternative:_(W()),message:_(W()),allowUseInside:_(G(W()))}))});function Be(e){return/^use[A-Z]/.test(e)}function wn(e){return/^[A-Z]/.test(e)}function xi(e){return e.type===N.AST_NODE_TYPES.Identifier?Be(e.name):e.type===N.AST_NODE_TYPES.MemberExpression&&e.property.type===N.AST_NODE_TYPES.Identifier?Be(e.property.name):!1}function In(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 Cn(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&In(e.parent.callee,"forwardRef"))}function An(e){return!!(e.parent&&e.parent.type===N.AST_NODE_TYPES.CallExpression&&In(e.parent.callee,"memo"))}function vt(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 bi(e){let t=e.parent,n=!1;for(;t;){if(t.type===N.AST_NODE_TYPES.FunctionDeclaration||t.type===N.AST_NODE_TYPES.FunctionExpression||t.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let r=vt(t);if(r&&r.type===N.AST_NODE_TYPES.Identifier){if(wn(r.name)||Be(r.name))return!n;n=!0}else{if(Cn(t)||An(t))return!n;if(t.parent.type===N.AST_NODE_TYPES.CallExpression){let o=t.parent;xi(o.callee)||(n=!0)}else t.parent.type===N.AST_NODE_TYPES.JSXExpressionContainer||(n=!0)}}t=t.parent}return!1}function Rn(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 wi(e,t){if(!t.length)return!1;let n=e.parent;for(;n;){if(n.type===N.AST_NODE_TYPES.FunctionDeclaration||n.type===N.AST_NODE_TYPES.FunctionExpression||n.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let r=vt(n);if(r&&r.type===N.AST_NODE_TYPES.Identifier&&t.includes(r.name))return!0}else if(n.type===N.AST_NODE_TYPES.CallExpression){let r=Rn(n);if(r&&t.includes(r))return!0}n=n.parent}return!1}function Ii(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===N.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function Ci(e,t){let n=!1,r=e.parent;for(;r;){if(r.type===N.AST_NODE_TYPES.FunctionDeclaration||r.type===N.AST_NODE_TYPES.FunctionExpression||r.type===N.AST_NODE_TYPES.ArrowFunctionExpression){let o=vt(r);if(o&&o.type===N.AST_NODE_TYPES.Identifier){if(wn(o.name)||Be(o.name)){n=!0;break}}else if(Cn(r)||An(r)){n=!0;break}}r=r.parent}return n?t.length===0?bi(e):!wi(e,t):!1}var kt=Q({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react{{message}}."},schema:[Ei],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:n}=t,r=new Map(n.map(o=>[o.name,o]));return{CallExpression(o){let a=Rn(o);if(!a)return;let s=r.get(a);if(!s||s.allowUsingWithArgs&&Ii(o))return;let i=s.allowUseInside||[];Ci(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 Ai=B.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kn="prefer-single-line-if",Ri=V({maxLineLength:_(pe()),maxNonSimpleConditionLength:_(pe())}),vi=Ai({name:kn,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[Ri]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==B.AST_NODE_TYPES.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let a=r.consequent.body[0];if(a.type===B.AST_NODE_TYPES.ReturnStatement){if(!Pn(a))return}else if(!(a.type===B.AST_NODE_TYPES.ContinueStatement||a.type===B.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===B.AST_NODE_TYPES.LogicalExpression||r.test.type===B.AST_NODE_TYPES.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=vn(r.test);if(!u&&r.test.type===B.AST_NODE_TYPES.UnaryExpression&&r.test.operator==="!"){let g=r.test.argument;vn(g)&&(u=!0)}if(u&&(s=n.getText(r.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=n.getText(r.test));let i=n.getText(a);if(s.includes(`
|
|
16
|
+
`))return;let l=n.getTokenAfter(r);if(l&&l.type===B.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let u=n.getTokenAfter(l);if(u&&u.type===B.AST_TOKEN_TYPES.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=ki(n,r),p=`if (${s}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:u=>u.replaceText(r,p)})}}}});function vn(e){return e.type===B.AST_NODE_TYPES.CallExpression||e.type===B.AST_NODE_TYPES.BinaryExpression||e.type===B.AST_NODE_TYPES.MemberExpression&&On(e)}function On(e){return e.object.type===B.AST_NODE_TYPES.MemberExpression?On(e.object):e.object.type!==B.AST_NODE_TYPES.Identifier}function ki(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Pn(e){if(!e.argument)return!0;let t=e.argument;return t.type===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?Pn(t):!1}var Ot={name:kn,rule:vi};var ne=require("@typescript-eslint/utils");var Oi=ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Fn="react-compiler-migration",Pi=V({disallowHooks:_(G(V({name:W(),replacement:W()}))),disallowMethods:_(G(V({name:W(),replacement:_(W()),requireTrueProp:_(W())})))}),Fi=/eslint +react-compiler\/react-compiler: +\["error/;function Ni(e){return e.type===ne.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===ne.AST_NODE_TYPES.MemberExpression&&e.property.type===ne.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var ji=Oi({name:Fn,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:[Pi]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(Fi.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let o=null,a=null;if(r.callee.type===ne.AST_NODE_TYPES.Identifier?(o=r.callee.name,a=r.callee):r.callee.type===ne.AST_NODE_TYPES.MemberExpression&&r.callee.property.type===ne.AST_NODE_TYPES.Identifier&&(o=r.callee.property.name,a=r.callee.property),o){let s=t.disallowHooks.find(i=>i.name===o);s&&a&&e.report({node:r,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&&Ni(r.callee)){for(let o of r.arguments)if(o.type===ne.AST_NODE_TYPES.ObjectExpression){for(let a of o.properties)if(a.type===ne.AST_NODE_TYPES.Property&&a.key.type===ne.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===ne.AST_NODE_TYPES.Property&&p.key.type===ne.AST_NODE_TYPES.Identifier&&p.key.name===l&&p.value.type===ne.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)}]})}}}}}}:{}}}),Pt={name:Fn,rule:ji};var Je=require("@typescript-eslint/utils"),Di=Je.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nn="require-description",Li=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Mi=/^eslint-disable-(next-)?line$/u,_i=Di({name:Nn,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let o of n.getAllComments()){let a=$i(o);a!=null&&(r.has(a.kind)||a.description||e.report({loc:Ui(o.loc),messageId:"missingDescription"}))}}}}}),jn={name:Nn,rule:_i};function $i(e){let{text:t,description:n}=zi(e.value);if(!t)return null;let r=Li.exec(t);if(!r)return null;let o=r[1];if(!o)return null;let a=Mi.test(o);if(e.type===Je.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let s=t.slice(r.index+o.length);return{kind:o,value:s.trim(),description:n}}function zi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Ui(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Mn(e){return/^use[A-Z0-9]/.test(e)}function qe(e){return e.type==="Identifier"?Mn(e.name):e.type==="MemberExpression"&&!e.computed&&qe(e.property)?e.object.type==="Identifier":!1}function _n(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function $n(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function zn(e){return!!(e.parent&&e.parent.callee&&$n(e.parent.callee,"forwardRef"))}function Un(e){return!!(e.parent&&e.parent.callee&&$n(e.parent.callee,"memo"))}function Ft(e){for(;e;){let t=Vn(e);if(t&&(_n(t)||qe(t))||zn(e)||Un(e))return!0;e=e.parent}return!1}function Dn(e){return!1}function Nt(e){return!1}var Wi=/eslint +react-compiler\/react-compiler: +\["error/,Wn={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(Wi.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),n=typeof e.getScope=="function"?()=>n():l=>e.sourceCode.getScope(l),r=null,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&&Dn(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(T,m){let{cache:y}=g,A=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),A!==void 0)return A;if(l.thrownSegments.includes(T))A=BigInt("0");else if(T.prevSegments.length===0)A=BigInt("1");else{A=BigInt("0");for(let E of T.prevSegments)A+=g(E,C)}return T.reachable&&A===BigInt("0")?y.delete(T.id):y.set(T.id,A),A}function h(T,m){let{cache:y}=h,A=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),A!==void 0)return A;if(l.thrownSegments.includes(T))A=BigInt("0");else if(T.nextSegments.length===0)A=BigInt("1");else{A=BigInt("0");for(let E of T.nextSegments)A+=h(E,C)}return y.set(T.id,A),A}function b(T){let{cache:m}=b,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 A of T.prevSegments){let C=b(A);C<y&&(y=C)}y+=1}return m.set(T.id,y),y}g.cache=new Map,h.cache=new Map,b.cache=new Map;let x=h(l.initialSegment),v=Vn(c),w=Ft(c),L=v?_n(v)||qe(v):zn(c)||Un(c),P=1/0;for(let T of l.finalSegments){if(!T.reachable)continue;let m=b(T);m<P&&(P=m)}for(let[T,m]of p){if(!T.reachable)continue;let y=T.nextSegments.length===0?P<=b(T):P<b(T),A=g(T)*h(T),C=u.has(T.id);for(let E of m)if(C&&!Nt(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&&A!==x&&!Nt(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(v){let F=`React Hook "${t(E)}" is called in function "${t(v)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node: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&&!Nt(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"&&Mn(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(qe(l.callee)){let c=Ln(o),p=Ln(a),u=c.get(p);u||(u=[],c.set(p,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Dn(l.callee))&&l.arguments.length>0&&(r=l)},Identifier(l){r==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===r&&(r=null)},FunctionDeclaration(l){Ft(l)&&i(n(l))},ArrowFunctionExpression(l){Ft(l)&&i(n(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 Ln(e){return e[e.length-1]}var Ee=require("@typescript-eslint/utils");function Vi(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function Hi(e){return e.type===Ee.AST_NODE_TYPES.Literal&&"regex"in e&&!!e.regex}function Yi(e){let t=e.parent;for(;t;){if(t.type===Ee.AST_NODE_TYPES.FunctionDeclaration||t.type===Ee.AST_NODE_TYPES.FunctionExpression||t.type===Ee.AST_NODE_TYPES.ArrowFunctionExpression||t.type===Ee.AST_NODE_TYPES.MethodDefinition)return!1;t=t.parent}return!0}function Bi(e){let t=e.parent;return t?.type===Ee.AST_NODE_TYPES.NewExpression&&t.callee.type===Ee.AST_NODE_TYPES.Identifier&&t.callee.name==="RegExp"}var jt=Q({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function t(n){Hi(n)&&(Vi(n)||Yi(n)||Bi(n)||e.report({node:n,messageId:"regexShouldBeTopLevel"}))}return{Literal:t}}});var Hn={[At.name]:At.rule,[lt.name]:lt.rule,[at.name]:at.rule,"rules-of-hooks":Wn,"exhaustive-deps":Xt,"require-description":jn.rule,[ct.name]:ct.rule,[ut.name]:ut.rule,[Rt.name]:Rt.rule,[Qe.name]:Qe.rule,[ot.name]:ot.rule,[gt.name]:gt.rule,[Ot.name]:Ot.rule,[yt.name]:yt.rule,[pt.name]:pt.rule,[tt.name]:tt.rule,[Pt.name]:Pt.rule,[Ze.name]:Ze.rule,[st.name]:st.rule,[Et.name]:Et.rule,[xt.name]:xt.rule,[wt.name]:wt.rule,[It.name]:It.rule,[bt.name]:bt.rule,[kt.name]:kt.rule,[Tt.name]:Tt.rule,[St.name]:St.rule,[jt.name]:jt.rule};var Ji={rules:Hn};0&&(module.exports={extendedLintPlugin});
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{AST_NODE_TYPES as q,ESLintUtils as zn}from"@typescript-eslint/utils";var We=Symbol.for("optional");function _(e){return{...e,[We]:!0}}function vt(e,t){return{enum:e,...t}}function he(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][We]?e[n][We]=void 0:o.push(n);o.length>0&&(r.required=o)}return r}var Un=zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="react-compiler-extra",Wn=U({runOnlyWithEnableCompilerDirective:_(he())}),Vn=/eslint +react-compiler\/react-compiler: +\["error/;function Hn(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 Yn=/\bthis[.[]/;function Ot(e){return Yn.test(e)}var Jn=Un({name:Ft,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:[Wn]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(Vn.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(Ot(p))e.report({node:s,messageId:"thisKeywordInMethod"});else{let u=c.params.map(h=>i.getText(h)).join(", "),g="";c.generator?g=`${l}: function* (${u}) ${p}`:g=`${l}: (${u}) => ${p}`,e.report({node:s,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(s,g)})}}}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);Ot(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Hn(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))}}}}}),Ve={name:Ft,rule:Jn};import{AST_NODE_TYPES as K}from"@typescript-eslint/utils";import*as S from"zod/v4";import{ESLintUtils as Bn}from"@typescript-eslint/utils";import*as Pt from"zod/v4";function te(e){let r=Bn.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function Oe(e){return Pt.toJSONSchema(e)}var Xn=S.object({disallow:S.array(S.object({selector:S.string(),message:S.string(),replace:S.optional(S.union([S.string(),S.object({regex:S.string(),with:S.string()})])),replaceType:S.optional(S.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:S.optional(S.array(S.object({fn:S.string(),withArgs:S.optional(S.array(S.object({atIndex:S.number(),value:S.union([S.string(),S.number(),S.boolean()])}))),message:S.string(),replaceWith:S.optional(S.string()),ignoreRegex:S.optional(S.string())}))),__dev_simulateFileName:S.optional(S.string()),mustMatchSyntax:S.optional(S.array(S.object({includeRegex:S.string(),mustCallFn:S.optional(S.array(S.object({anyCall:S.array(S.object({fn:S.string(),withArgs:S.array(S.object({atIndex:S.number(),literal:S.union([S.string(),S.number(),S.boolean()])}))})),message:S.optional(S.string())}))),mustMatchSelector:S.optional(S.array(S.object({selector:S.string(),message:S.string()}))),mustHaveExport:S.optional(S.array(S.object({name:S.string(),type:S.enum(["function","variable","any"]).default("any"),message:S.string()})))})))}),He=te({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Oe(Xn)],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 Set,h=new Map;function x(m){for(let y of m.specifiers)y.type===K.ImportSpecifier&&y.imported.type===K.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.FunctionDeclaration&&m.declaration.id){let y=m.declaration.id.name;for(let A of Array.from(g)){let[C,E]=A.split(":");C===y&&(E==="function"||E==="any")&&g.delete(A)}}else if(m.declaration.type===K.VariableDeclaration){for(let y of m.declaration.declarations)if(y.id.type===K.Identifier){let A=y.id.name;for(let C of Array.from(g)){let[E,P]=C.split(":");E===A&&(P==="variable"||P==="any")&&g.delete(C)}}}}for(let y of m.specifiers)if(y.exported.type===K.Identifier){let A=y.exported.name;for(let C of Array.from(g)){let[E,P]=C.split(":");E===A&&P==="any"&&g.delete(C)}}}function k(m){m.id.type===K.Identifier&&m.init?.type===K.Identifier&&h.set(m.id.name,m.init.name)}function w(m){return h.get(m)??m}function M(m,y){return w(m)===y||m===y}for(let{includeRegex:m,mustCallFn:y,mustMatchSelector:A,mustHaveExport:C}of n??[]){let E=qn(i,new RegExp(m));if(!E)continue;let P=H=>{let J=H;for(let{name:Z,value:G}of E)J=J.replaceAll(Z,G);return J};for(let{anyCall:H,message:J}of y??[]){let Z=`Expected file to call the function: ${H.map(({fn:G})=>G).join(" or ")}`;p.add(Z),l.push(G=>{let{callee:Se}=G;if(Se.type===K.Identifier){for(let{fn:ee,withArgs:we}of H)if(Se.name===ee){p.delete(Z);for(let pe of we){let le=G.arguments[pe.atIndex],ue=typeof pe.literal=="string"?P(pe.literal):pe.literal;if(!le){e.report({node:G,messageId:"default",data:{message:`Missing argument with value "${ue}" at index ${pe.atIndex}${J?`: ${P(J)}`:""}`}});continue}if(le.type!==K.Literal){e.report({node:le,messageId:"default",data:{message:`Argument at position ${pe.atIndex} should the literal "${ue}"${J?`: ${P(J)}`:""}`}});continue}le.value!==ue&&e.report({node:le,messageId:"default",data:{message:`Argument should have the value "${ue}"${J?`: ${P(J)}`:""}`},fix:Te=>Te.replaceText(le,typeof ue=="string"?`'${ue}'`:String(ue))})}break}}})}for(let{selector:H,message:J}of A??[])u.set(H,P(J)),c.set(P(H),()=>{u.delete(H)});for(let{name:H,type:J,message:Z}of C??[]){let G=P(H),Se=P(Z);g.add(`${G}:${J}:${Se}`)}}for(let{fn:m,withArgs:y,message:A,replaceWith:C,ignoreRegex:E}of s??[])E&&new RegExp(E).test(i)||l.push(P=>{let{callee:H}=P;if(H.type!==K.Identifier||!M(H.name,m))return;if(y)for(let Z of y){let G=P.arguments[Z.atIndex];if(!G){e.report({node:P,messageId:"default",data:{message:`Missing argument with value "${Z.value}" at index ${Z.atIndex}: ${A}`}});return}if(G.type!==K.Literal||G.value!==Z.value)return}let J=Z=>C?Z.replaceText(P,C):null;e.report({node:P,messageId:"default",data:{message:A},suggest:C?[{messageId:"default",data:{message:`Replace with "${C}"`},fix:J}]:void 0})});function F(m,y){let A=r[m];A?r[m]=C=>{A(C),y(C)}:r[m]=y}for(let{selector:m,message:y,replace:A,replaceType:C="suggestion"}of a??[]){if(m==="CallExpression"){l.push(E=>{T(A,E,y,C)});continue}r[m]=E=>{T(A,E,y,C)}}if(c.size>0)for(let[m,y]of c)F(m,y);return l.length>0&&(r.CallExpression=m=>{if(m.type===K.CallExpression)for(let y of l)y(m)}),r.ImportDeclaration=m=>{m.type===K.ImportDeclaration&&x(m)},r.ExportNamedDeclaration=m=>{m.type===K.ExportNamedDeclaration&&b(m)},r.VariableDeclarator=m=>{m.type===K.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 g){let[A,C,E]=y.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${A}" of type ${C}: ${E}`}})}},r;function T(m,y,A,C){let E=P=>{if(!m)return null;if(typeof m=="string")return P.replaceText(y,m);{let H=new RegExp(m.regex),J=e.sourceCode.getText(y);return P.replaceText(y,J.replace(H,m.with))}};e.report({node:y,messageId:"default",data:{message:A},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 qn(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:Nt(o)}),r.push({name:"$0_uncapitalize",value:Dt(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:Nt(l)}),r.push({name:`${i}_uncapitalize`,value:Dt(l)}),r.push({name:i,value:l})}return r}function Nt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Dt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as L,AST_TOKEN_TYPES as jt,ESLintUtils as Gn}from"@typescript-eslint/utils";var Kn=Gn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="collapse-simple-objs-in-one-line",Zn=U({maxLineLength:_(ce()),maxProperties:_(ce()),nestedObjMaxLineLength:_(ce()),nestedObjMaxProperties:_(ce()),ignoreTypesWithSuffix:_(X(z()))}),Qn=Kn({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:[Zn]},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===L.ObjectExpression){let p=c.parent.type===L.Property,u=p?s:o,g=c.properties.length;if(g>u)return!1;if(g===1){let x=c.properties[0];return x.type===L.Property&&x.value.type===L.ObjectExpression||x.type===L.Property&&x.value.type===L.ArrayExpression&&!x.value.elements.every(k=>k&&Ye(k))?!1:{text:r.getText(x),isNested:p,propsSize:g}}let h=[];for(let x of c.properties){if(x.type===L.Property&&!Ye(x.value))return!1;h.push(r.getText(x))}return{text:h.join(", "),isNested:p,propsSize:g}}else{let p=c.parent.parent?.type===L.TSPropertySignature,u=p?s:o,g=c.members.length;if(g>u)return!1;if(n.length>0&&c.parent.type===L.TSTypeAliasDeclaration){let x=c.parent.id.name;if(n.some(b=>x.endsWith(b)))return!1}if(g===1){let x=c.members[0];return x.type===L.TSPropertySignature&&x.typeAnnotation?.typeAnnotation.type===L.TSTypeLiteral?!1:{text:r.getText(x),isNested:p,propsSize:1}}if(c.parent.type===L.TSIntersectionType||c.parent.type===L.TSUnionType&&c.parent.types[0]!==c)return!1;let h=[];for(let x of c.members){if(x.type!==L.TSPropertySignature)return!1;let b=x.typeAnnotation?.typeAnnotation;if(!b||b.type===L.TSTypeLiteral||!Mt(b))return!1;if(b.type===L.TSTypeReference&&b.typeArguments){if(b.typeArguments.params.length>1)return!1;let w=b.typeArguments.params[0];if(!Mt(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:g}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==L.JSXExpressionContainer){let b=0,k=!1,w=r.getTokenAfter(c,{filter:F=>F.type!==jt.Punctuator||k?!0:F.value===","?(b++,!1):F.value===";"?(b++,k=!0,!1):F.value===")"||F.value==="}"?(b++,!1):!0});if(b>4)return;let M=w?.type===jt.Template&&w.value.startsWith(`}
|
|
2
|
-
`);if(w?.loc.start.line===c.loc.end.line&&!
|
|
3
|
-
`)||
|
|
4
|
-
`,
|
|
1
|
+
import{AST_NODE_TYPES as G,ESLintUtils as Vn}from"@typescript-eslint/utils";var He=Symbol.for("optional");function M(e){return{...e,[He]:!0}}function Ft(e,t){return{enum:e,...t}}function xe(e){return{...e,type:"boolean"}}function z(e){return{...e,type:"string"}}function pe(e){return{...e,type:"number"}}function X(e,t){return{...t,type:"array",items:e}}function U(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,o=[];for(r in e)e[r][He]?e[r][He]=void 0:o.push(r);o.length>0&&(n.required=o)}return n}var Hn=Vn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jt="react-compiler-extra",Yn=U({runOnlyWithEnableCompilerDirective:M(xe())}),Bn=/eslint +react-compiler\/react-compiler: +\["error/;function Jn(e){return e.type===G.Identifier?e.name.startsWith("use"):e.type===G.MemberExpression&&e.property.type===G.Identifier?e.property.name.startsWith("use"):!1}var qn=/\bthis[.[]/;function Nt(e){return qn.test(e)}var Xn=Hn({name:jt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[Yn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(Bn.test(a.value)){n=!0;break}if(!n)return{}}function r(a){for(let s of a.properties)if(s.type===G.Property&&s.method&&s.value.type===G.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(", "),g="";c.generator?g=`${l}: function* (${u}) ${p}`:g=`${l}: (${u}) => ${p}`,e.report({node:s,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(s,g)})}}}function o(a){for(let s of a.properties)if(s.type===G.Property&&s.value.type===G.ObjectExpression){for(let i of s.value.properties)if(i.type===G.Property&&i.method&&i.value.type===G.FunctionExpression){let c=e.sourceCode.getText(i.value.body);Nt(c)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(Jn(a.callee))for(let s of a.arguments){if(s.type===G.ObjectExpression&&(r(s),o(s)),s.type===G.ArrowFunctionExpression&&(s.body.type===G.ObjectExpression&&(r(s.body),o(s.body)),s.body.type===G.BlockStatement))for(let i of s.body.body)i.type===G.ReturnStatement&&i.argument?.type===G.ObjectExpression&&(r(i.argument),o(i.argument));if(s.type===G.FunctionExpression)for(let i of s.body.body)i.type===G.ReturnStatement&&i.argument?.type===G.ObjectExpression&&(r(i.argument),o(i.argument))}}}}}),Ye={name:jt,rule:Xn};import{AST_NODE_TYPES as Q}from"@typescript-eslint/utils";import*as S from"zod/v4";import{ESLintUtils as Gn}from"@typescript-eslint/utils";import*as Dt from"zod/v4";function Z(e){let n=Gn.RuleCreator(r=>`https://github.com/lucasols/extended-lint#${r}`)(e);return{name:e.name,rule:n}}function Fe(e){return Dt.toJSONSchema(e)}var Kn=S.object({disallow:S.array(S.object({selector:S.string(),message:S.string(),replace:S.optional(S.union([S.string(),S.object({regex:S.string(),with:S.string()})])),replaceType:S.optional(S.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:S.optional(S.array(S.object({fn:S.string(),withArgs:S.optional(S.array(S.object({atIndex:S.number(),value:S.union([S.string(),S.number(),S.boolean()])}))),message:S.string(),replaceWith:S.optional(S.string()),ignoreRegex:S.optional(S.string())}))),__dev_simulateFileName:S.optional(S.string()),mustMatchSyntax:S.optional(S.array(S.object({includeRegex:S.string(),mustCallFn:S.optional(S.array(S.object({anyCall:S.array(S.object({fn:S.string(),withArgs:S.array(S.object({atIndex:S.number(),literal:S.union([S.string(),S.number(),S.boolean()])}))})),message:S.optional(S.string())}))),mustMatchSelector:S.optional(S.array(S.object({selector:S.string(),message:S.string()}))),mustHaveExport:S.optional(S.array(S.object({name:S.string(),type:S.enum(["function","variable","any"]).default("any"),message:S.string()})))})))}),Be=Z({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Fe(Kn)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:o,disallow:a,disallowFnCalls:s}=t,i=o??e.filename,l=[],c=new Map,p=new Set,u=new Map,g=new Set,h=new Map;function b(m){for(let y of m.specifiers)y.type===Q.ImportSpecifier&&y.imported.type===Q.Identifier&&y.imported.name!==y.local.name&&h.set(y.local.name,y.imported.name)}function x(m){if(m.declaration){if(m.declaration.type===Q.FunctionDeclaration&&m.declaration.id){let y=m.declaration.id.name;for(let A of Array.from(g)){let[C,E]=A.split(":");C===y&&(E==="function"||E==="any")&&g.delete(A)}}else if(m.declaration.type===Q.VariableDeclaration){for(let y of m.declaration.declarations)if(y.id.type===Q.Identifier){let A=y.id.name;for(let C of Array.from(g)){let[E,F]=C.split(":");E===A&&(F==="variable"||F==="any")&&g.delete(C)}}}}for(let y of m.specifiers)if(y.exported.type===Q.Identifier){let A=y.exported.name;for(let C of Array.from(g)){let[E,F]=C.split(":");E===A&&F==="any"&&g.delete(C)}}}function v(m){m.id.type===Q.Identifier&&m.init?.type===Q.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:A,mustHaveExport:C}of r??[]){let E=Zn(i,new RegExp(m));if(!E)continue;let F=H=>{let J=H;for(let{name:ee,value:K}of E)J=J.replaceAll(ee,K);return J};for(let{anyCall:H,message:J}of y??[]){let ee=`Expected file to call the function: ${H.map(({fn:K})=>K).join(" or ")}`;p.add(ee),l.push(K=>{let{callee:he}=K;if(he.type===Q.Identifier){for(let{fn:ne,withArgs:Ce}of H)if(he.name===ne){p.delete(ee);for(let ue of Ce){let ce=K.arguments[ue.atIndex],fe=typeof ue.literal=="string"?F(ue.literal):ue.literal;if(!ce){e.report({node:K,messageId:"default",data:{message:`Missing argument with value "${fe}" at index ${ue.atIndex}${J?`: ${F(J)}`:""}`}});continue}if(ce.type!==Q.Literal){e.report({node:ce,messageId:"default",data:{message:`Argument at position ${ue.atIndex} should the literal "${fe}"${J?`: ${F(J)}`:""}`}});continue}ce.value!==fe&&e.report({node:ce,messageId:"default",data:{message:`Argument should have the value "${fe}"${J?`: ${F(J)}`:""}`},fix:Ee=>Ee.replaceText(ce,typeof fe=="string"?`'${fe}'`:String(fe))})}break}}})}for(let{selector:H,message:J}of A??[])u.set(H,F(J)),c.set(F(H),()=>{u.delete(H)});for(let{name:H,type:J,message:ee}of C??[]){let K=F(H),he=F(ee);g.add(`${K}:${J}:${he}`)}}for(let{fn:m,withArgs:y,message:A,replaceWith:C,ignoreRegex:E}of s??[])E&&new RegExp(E).test(i)||l.push(F=>{let{callee:H}=F;if(H.type!==Q.Identifier||!L(H.name,m))return;if(y)for(let ee of y){let K=F.arguments[ee.atIndex];if(!K){e.report({node:F,messageId:"default",data:{message:`Missing argument with value "${ee.value}" at index ${ee.atIndex}: ${A}`}});return}if(K.type!==Q.Literal||K.value!==ee.value)return}let J=ee=>C?ee.replaceText(F,C):null;e.report({node:F,messageId:"default",data:{message:A},suggest:C?[{messageId:"default",data:{message:`Replace with "${C}"`},fix:J}]:void 0})});function P(m,y){let A=n[m];A?n[m]=C=>{A(C),y(C)}:n[m]=y}for(let{selector:m,message:y,replace:A,replaceType:C="suggestion"}of a??[]){if(m==="CallExpression"){l.push(E=>{T(A,E,y,C)});continue}n[m]=E=>{T(A,E,y,C)}}if(c.size>0)for(let[m,y]of c)P(m,y);return l.length>0&&(n.CallExpression=m=>{if(m.type===Q.CallExpression)for(let y of l)y(m)}),n.ImportDeclaration=m=>{m.type===Q.ImportDeclaration&&b(m)},n.ExportNamedDeclaration=m=>{m.type===Q.ExportNamedDeclaration&&x(m)},n.VariableDeclarator=m=>{m.type===Q.VariableDeclarator&&v(m)},n["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 g){let[A,C,E]=y.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${A}" of type ${C}: ${E}`}})}},n;function T(m,y,A,C){let E=F=>{if(!m)return null;if(typeof m=="string")return F.replaceText(y,m);{let H=new RegExp(m.regex),J=e.sourceCode.getText(y);return F.replaceText(y,J.replace(H,m.with))}};e.report({node:y,messageId:"default",data:{message:A},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 Zn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[o,...a]=r;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:Lt(o)}),n.push({name:"$0_uncapitalize",value:Mt(o)}),n.push({name:"$0",value:o});for(let s=0;s<a.length;s++){let i=`$${s+1}`,l=a[s];n.push({name:`${i}_lowercase`,value:l.toLowerCase()}),n.push({name:`${i}_capitalize`,value:Lt(l)}),n.push({name:`${i}_uncapitalize`,value:Mt(l)}),n.push({name:i,value:l})}return n}function Lt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Mt(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as _,AST_TOKEN_TYPES as _t,ESLintUtils as Qn}from"@typescript-eslint/utils";var er=Qn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="collapse-simple-objs-in-one-line",tr=U({maxLineLength:M(pe()),maxProperties:M(pe()),nestedObjMaxLineLength:M(pe()),nestedObjMaxProperties:M(pe()),ignoreTypesWithSuffix:M(X(z()))}),nr=er({name:zt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[tr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=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 b=c.properties[0];return b.type===_.Property&&b.value.type===_.ObjectExpression||b.type===_.Property&&b.value.type===_.ArrayExpression&&!b.value.elements.every(v=>v&&Je(v))?!1:{text:n.getText(b),isNested:p,propsSize:g}}let h=[];for(let b of c.properties){if(b.type===_.Property&&!Je(b.value))return!1;h.push(n.getText(b))}return{text:h.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(r.length>0&&c.parent.type===_.TSTypeAliasDeclaration){let b=c.parent.id.name;if(r.some(x=>b.endsWith(x)))return!1}if(g===1){let b=c.members[0];return b.type===_.TSPropertySignature&&b.typeAnnotation?.typeAnnotation.type===_.TSTypeLiteral?!1:{text:n.getText(b),isNested:p,propsSize:1}}if(c.parent.type===_.TSIntersectionType||c.parent.type===_.TSUnionType&&c.parent.types[0]!==c)return!1;let h=[];for(let b of c.members){if(b.type!==_.TSPropertySignature)return!1;let x=b.typeAnnotation?.typeAnnotation;if(!x||x.type===_.TSTypeLiteral||!$t(x))return!1;if(x.type===_.TSTypeReference&&x.typeArguments){if(x.typeArguments.params.length>1)return!1;let w=x.typeArguments.params[0];if(!$t(w))return!1}let v=n.getText(b).trim();(v.endsWith(";")||v.endsWith(","))&&(v=v.slice(0,-1)),h.push(v)}return{text:h.join("; "),isNested:p,propsSize:g}}}function l(c){if(c.loc.start.line===c.loc.end.line)return;if(c.parent.type!==_.JSXExpressionContainer){let x=0,v=!1,w=n.getTokenAfter(c,{filter:P=>P.type!==_t.Punctuator||v?!0:P.value===","?(x++,!1):P.value===";"?(x++,v=!0,!1):P.value===")"||P.value==="}"?(x++,!1):!0});if(x>4)return;let L=w?.type===_t.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
|
+
`)||n.getCommentsInside(c).length>0)return;u.endsWith(";")&&(u=u.slice(0,-1));let g=`{ ${u} }`,h=ir(n,c),b=p.isNested&&p.propsSize>2?a:t.maxLineLength;b&&g.length+h.length+rr(c,n)>b||e.report({node:c,messageId:"singleLineProp",fix:x=>x.replaceText(c,g)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function $t(e){return e.type===_.TSLiteralType||e.type===_.TSTypeReference||e.type===_.TSNumberKeyword||e.type===_.TSStringKeyword||e.type===_.TSBooleanKeyword||e.type===_.TSNullKeyword||e.type===_.TSUndefinedKeyword}function Je(e,t){return!!(e.type===_.Literal||e.type===_.Identifier||e.type===_.TemplateLiteral||e.type===_.TaggedTemplateExpression||!t&&e.type===_.ArrayExpression&&e.elements.every(n=>n&&Je(n,!0)))}function rr(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
|
|
4
|
+
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function ir(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var qe={name:zt,rule:nr};var sr=/eslint +react-compiler\/react-compiler: +\["error/,Wt={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?w=>n(w):w=>e.sourceCode.getText(w),r=typeof e.getScope=="function"?()=>r():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,g=new WeakMap,h=new WeakSet;function b(w,L){return function(P){if(L.has(P))return L.get(P);let T=w(P);return L.set(P,T),T}}function x(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 y=l.acquire(w),A=new Set,C=null;{let f=y.upper;for(;f&&(A.add(f),f.type!=="function");)f=f.upper;if(!f)return;C=f}let E=Array.isArray;function P(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 R=d.node.parent;if(R==null&&(qe(C.block,d.node.id),R=d.node.parent,R==null))return!1;if(R.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(ar(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,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(N==="useState"){let j=f.references;for(let re=0;re<j.length;re++)p.add(j[re].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,R=C.childScopes,O=null,v;for(v=0;v<R.length;v++){let N=R[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&&A.has(N.resolved.scope)&&!J(N.resolved))return!1}return!0}let J=x(P,u),Z=x(H,g),G=new Map;function Se(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,we=new Map;pe(y);function pe(f){for(let d of f.references){if(!d.resolved||!A.has(d.resolved.scope))continue;let I=qe(w,d.identifier),R=zt(I),O=me(R,we);if(m&&R.type==="Identifier"&&(R.parent.type==="MemberExpression"||R.parent.type==="OptionalMemberExpression")&&!R.parent.computed&&R.parent.property.type==="Identifier"&&R.parent.property.name==="current"&&Se(d)&&G.set(O,{reference:d,dependencyNode:R}),R.parent.type==="TSTypeQuery"||R.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=J(N)||Z(N);ee.set(O,{isStable:j,references:[d]})}}for(let d of f.childScopes)pe(d)}G.forEach(({reference:f,dependencyNode:d},I)=>{let R=f.resolved.references,O=!1;for(let v=0;v<R.length;v++){let{identifier:N}=R[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(F)} 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(F)}.`}))}let Te=new Set;if(ee.forEach(({isStable:f,references:d},I)=>{f&&Te.add(I),d.forEach(R=>{R.writeExpr&&ue(R.writeExpr,I)})}),le.size>0)return;if(!M){let f=null;if(ee.forEach(({isStable:d,references:I},R)=>{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=R)})}),f){let{suggestedDependencies:d}=Be({dependencies:ee,declaredDependencies:[],stableDependencies:Te,externalDependencies:new Set,isEffect:!0});i({node:F,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 Ie=[],Ce=new Set;M.type!=="ArrayExpression"?i({node:M,message:`React Hook ${r(F)} 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(F)} 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,we)}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(F)} 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 R=!C.through.some(O=>O.identifier===I);Ie.push({key:d,node:f}),R||Ce.add(d)});let{suggestedDependencies:Mn,unnecessaryDependencies:ke,missingDependencies:de,duplicateDependencies:At}=Be({dependencies:ee,declaredDependencies:Ie,stableDependencies:Te,externalDependencies:Ce,isEffect:m}),ve=Mn;if(At.size+de.size+ke.size===0){if(t)return;rr({declaredDependencies:Ie,declaredDependenciesNode:M,componentScope:C,scope:y}).forEach(({construction:d,isUsedOutsideOfHook:I,depType:R})=>{let O=R==="function"?"useCallback":"useMemo",v=R==="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}`,re=R==="conditional"||R==="logical expression"?"could make":"makes",fe=`The '${d.name.name}' ${R} ${re} the dependencies of ${T} Hook (at line ${M.loc.start.line}) change on every render. ${j}`,Rt;I&&d.type==="Variable"&&R==="function"&&(Rt=[{desc:`Wrap the ${v} of '${d.name.name}' in its own ${O}() Hook.`,fix(kt){let[Ln,$n]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[kt.insertTextBefore(d.node.init,Ln),kt.insertTextAfter(d.node.init,$n)]}}]),i({node:d.node,message:fe,suggest:Rt})});return}!m&&de.size>0&&(ve=Be({dependencies:ee,declaredDependencies:[],stableDependencies:Te,externalDependencies:Ce,isEffect:m}).suggestedDependencies);function _n(){if(Ie.length===0)return!0;let f=Ie.map(I=>I.key),d=f.slice().sort();return f.join(",")===d.join(",")}_n()&&ve.sort();function ze(f){let d=f.split("."),I="";for(let R=0;R<d.length;R++){if(R!==0){let O=d.slice(0,R+1).join("."),v=we.get(O)===!0;I+=v?"?.":"."}I+=d[R]}return I}function Ue(f,d,I,R){return f.size===0?null:(f.size>1?"":d+" ")+I+" "+(f.size>1?"dependencies":"dependency")+": "+sr(Array.from(f).sort().map(O=>"'"+ze(O)+"'"))+`. Either ${R} ${f.size>1?"them":"it"} or remove the dependency array.`}let oe="";if(ke.size>0){let f=null;if(Array.from(ke.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(Ce.size>0){let d=Array.from(Ce)[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 R=0;R<d.length;R++){let O=d[R],v=qe(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(F)}.`)}if(!oe&&de.size>0){let f=null;de.forEach(d=>{if(f)return;let I=C.set.get(d),R=ee.get(d);if(R.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<R.references.length;j++)if(N=R.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 R=ee.get(d).references,O,v;for(let N=0;N<R.length;N++){for(O=R[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 re=R[N].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:M,message:`React Hook ${r(F)} has `+(Ue(de,"a","missing","include")||Ue(ke,"an","unnecessary","exclude")||Ue(At,"a","duplicate","omit"))+oe,suggest:[{desc:`Update the dependencies array to be: [${ve.map(ze).join(", ")}]`,fix(f){return f.replaceText(M,`[${ve.map(ze).join(", ")}]`)}}]})}function k(w){let M=ir(w.callee,s);if(M===-1)return;let F=w.arguments[M],T=w.callee,m=Ut(T).name,y=w.arguments[M+1],A=/Effect($|[^a-z])/g.test(m);if(!F){i({node:T,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!A)){if(!y&&!A){(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(F.type){case"FunctionExpression":case"ArrowFunctionExpression":b(F,y,T,m,A);return;case"Identifier":if(!y||y.elements&&y.elements.some(P=>P&&P.type==="Identifier"&&P.name===F.name))return;let C=n(w).set.get(F.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,A);return;case"VariableDeclarator":let P=E.node.init;if(!P)break;switch(P.type){case"ArrowFunctionExpression":case"FunctionExpression":b(P,y,T,m,A);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: '${F.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${F.name}]`,fix(C){return C.replaceText(y,`[${F.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let w of e.sourceCode.getAllComments())if(nr.test(w.value))return t=!0,{CallExpression:M=>k(M,!0)}}return{CallExpression:w=>k(w)}}};function Be({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,M=>{M.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("."),M=b;for(let F of w){let T=M.children.get(F);T||(T=s(),M.children.set(F,T)),M=T}return M}function l(b,k,w){let M=k.split("."),F=b;for(let T of M){let m=F.children.get(T);if(!m)return;w(m),F=m}}let c=new Set,p=new Set;u(a,c,p,b=>b);function u(b,k,w,M){b.children.forEach((F,T)=>{let m=M(T);if(F.isSatisfiedRecursively){F.isSubtreeUsed&&w.add(m);return}if(F.isUsed){k.add(m);return}u(F,k,w,y=>m+"."+y)})}let g=[],h=new Set,x=new Set;return t.forEach(({key:b})=>{p.has(b)?g.indexOf(b)===-1?g.push(b):x.add(b):h.add(b)}),c.forEach(b=>{g.push(b)}),{suggestedDependencies:g,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 rr({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&&!Wt(t,c.identifier))return!0}return!1}return o.map(([s,i])=>({construction:s.defs[0],depType:i,isUsedOutsideOfHook:a(s)}))}function zt(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)?zt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Xe(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 Xe(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 Xe(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 Xe(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function Ut(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function ir(e,t){let r=Ut(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(),or(n,t))return n;if(Wt(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(Lt(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(s=>{Lt(s)&&(s.parent=n,r.push(s))}))}return null}function sr(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 Lt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function or(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 Wt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function ar(e){return!1}import{AST_NODE_TYPES as Pe,ESLintUtils as Ht}from"@typescript-eslint/utils";import Q from"typescript";var lr=Ht.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vt="improved-no-unnecessary-condition",cr=U({}),pr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],ur=new Set(pr),Ge={name:Vt,rule:lr({name:Vt,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:[cr]},defaultOptions:[{}],create(e){let t=Ht.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===Pe.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 h=o(g);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===Pe.Literal&&typeof i.right.value=="string"?i.right.value:null):n(i.right)&&(c=i.right,p=i.left.type===Pe.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!fr(p,ur))return;let u=a(c);if(!u)return;let g=i.operator==="!==",h=u.includes(p);u.length===1?h&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Ee(c,e),type:p}}):!h&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Ee(c,e),type:Array.from(u)[0]}}):!h&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Ee(c,e),actualType:Fe(u),conditionType:p}}):h&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Ee(c,e),actualType:Fe(u),conditionType:p}}):!h&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:Ee(c,e),actualType:Fe(u),conditionType:p}}):!h&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:Ee(c,e),type:Fe(u)}})}return{BinaryExpression:s}}})};function Fe(e){return Array.from(new Set(e)).join(" | ")||"never"}function Ee(e,t){let r=e.argument;return r.type===Pe.Identifier?r.name:t.sourceCode.getText(r)}function fr(e,t){return t.has(e)}import{AST_NODE_TYPES as mr,ESLintUtils as dr}from"@typescript-eslint/utils";var yr=dr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="no-call-with-explicit-generics",gr=U({functions:X(z())}),Sr=yr({name:Yt,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:[gr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===mr.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),Ke={name:Yt,rule:Sr};import{AST_NODE_TYPES as Ne,ESLintUtils as Tr}from"@typescript-eslint/utils";var hr=Tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="no-call-with-inferred-generics",Er=hr({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!==Ne.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===Ne.TSAnyKeyword||l&&p.type===Ne.TSTypeReference&&p.typeName.type===Ne.Identifier&&l.includes(p.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),Ze={name:Jt,rule:Er};import{ESLintUtils as br}from"@typescript-eslint/utils";var xr=br.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xt="no-commented-out-code",wr=["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:"],Ir=[") {","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*:/],Cr=["/>","</",/^<[A-Z]\w*(\s|>|\/)/,/^<[a-z]+(\s|>|\/)/,/<[A-Z]\w*(\s.*)?>/,/<\/[A-Z]\w*>/,/<[a-z]+(\s.*)?>/,/<\/[a-z]+>/],Bt=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Ar=xr({name:Xt,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 Bt)if(a.startsWith(s))return!1;if(n.includes("https://"))return!1;if(o==="Block"){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}for(let s of wr)if(a.startsWith(s))return{wrongPattern:s};for(let s of Ir)if(typeof s=="string"){if(n.includes(s))return{wrongPattern:s}}else if(s.test(n))return{wrongPattern:`regex(${s.toString()})`};return!1}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:Bt.join(", ")}})}}}}}),Qe={name:Xt,rule:Ar};import{ESLintUtils as Rr,TSESTree as kr}from"@typescript-eslint/utils";var vr=Rr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="no-default-export",Or=vr({name:qt,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===kr.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),et={name:qt,rule:Or};import{ESLintUtils as Fr}from"@typescript-eslint/utils";var Pr=Fr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Gt="no-leaked-text-in-jsx",Nr=[",",";","[","]","(",")"],Dr=Pr({name:Gt,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="";Nr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),tt={name:Gt,rule:Dr};import{AST_NODE_TYPES as Ae,ESLintUtils as jr}from"@typescript-eslint/utils";var Mr=jr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-non-camel-case-functions",_r=/^(\$?[a-z][a-zA-Z0-9]*)$/;function Kt(e){if(e.typeName.type!==Ae.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Ae.Identifier&&t.name==="JSX"&&r.name==="Element"}var Lr=Mr({name:Zt,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&&!_r.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Ae.TSTypeReference?Kt(r):r.type===Ae.TSUnionType&&r.types.some(o=>o.type===Ae.TSTypeReference&&Kt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),nt={name:Zt,rule:Lr};import{ESLintUtils as $r,TSESTree as W}from"@typescript-eslint/utils";import{AST_NODE_TYPES as Qt}from"@typescript-eslint/utils";function be(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:be(e.parent,t,r===1/0?r:r-1)}function*rt(e){yield e,e.parent&&(yield*rt(e.parent))}function it(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function en(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===Qt.Property&&a.identifiers[0]?.parent.key.type===Qt.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var zr=$r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-optional-root-props",Ur=zr({name:tn,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 rt(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=be(l.parent.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=De(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=be(l,W.AST_NODE_TYPES.VariableDeclaration);return c?!!De(c,e.sourceCode):!1}if(l.type===W.AST_NODE_TYPES.FunctionDeclaration)return!!De(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=be(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&&!(je(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===W.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(je(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=be(n.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=De(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 je(e){return e?e.parent?.type===W.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===W.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function De(e,t){if(je(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])&&!je(a[0].identifier.parent.parent))return a[0].identifier}var st={name:tn,rule:Ur};import{ESLintUtils as Wr}from"@typescript-eslint/utils";import ot from"node:path";var Vr=Wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nn="no-relative-imports",Hr=U({find:z(),replacement:z()}),Yr=U({aliases:X(Hr),rootDir:_(z()),allowNotFoundAliases:_(he()),_dev_simulateFileName:_(z())}),Jr=Vr({name:nn,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:[Yr]},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=ot.dirname(i);return ot.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=ot.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})}}}}),at={name:nn,rule:Jr};import{AST_NODE_TYPES as Me}from"@typescript-eslint/utils";import*as ge from"zod/v4";var Br="no-type-guards",Xr=ge.object({alternativeMsgs:ge.object({inArrayFind:ge.string().optional(),inArrayFilter:ge.string().optional()}).optional(),__dev_simulateFileName:ge.string().optional()});function qr(e){return e.typeAnnotation.type!==Me.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function Gr(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function Kr(e){let t=e.parent;for(;t;){if(t.type===Me.CallExpression&&t.callee.type===Me.MemberExpression&&t.callee.property.type===Me.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var lt=te({name:Br,meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[Oe(Xr)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(Gr(r))return{};function n(o){if(!qr(o))return;let a=Kr(o),s=[];if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let l=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:l,data:{message:i}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as xe}from"@typescript-eslint/utils";var Zr="no-unnecessary-async-on-jsx-props";function Qr(e){if(e.body.type!==xe.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==xe.ExpressionStatement?!1:r.expression.type===xe.AwaitExpression}var ct=te({name:Zr,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){Qr(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===xe.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===xe.BlockStatement)for(let c of l.body)i(c);else l.type===xe.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 sn}from"@typescript-eslint/utils";import*as pt from"typescript";var ei=sn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),rn="no-unnecessary-casting",ti=U({additionalCastFunctions:_(X(U({name:z(),expectedType:vt(["string","number"])})))}),ut={name:rn,rule:ei({name:rn,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:[ti],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=sn.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&pt.TypeFlags.NumberLike):!!(p.flags&pt.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===Re.SpreadElement)return;let{callee:g}=p;if(g.type!==Re.Identifier)return;let h=g.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 _e}from"@typescript-eslint/utils";import*as ie from"zod/v4";var ni=ie.object({methods:ie.union([ie.array(ie.string()),ie.literal("array")])}),ft=te({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(ni)]},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===_e.MemberExpression){let c=l.property;if(c.type===_e.Identifier)return c.name}return null}function s(i,l){if(i.type!==_e.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===_e.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 ne}from"@typescript-eslint/utils";var mt=te({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.ObjectPattern||!t.init||t.init.type!==ne.ObjectExpression||t.id.type===ne.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ne.ExportNamedDeclaration)return;let r=new Map;for(let s of t.init.properties)s.type===ne.Property&&s.key.type===ne.Identifier&&r.set(s.key.name,s);if(r.size===0||t.id.type!==ne.Identifier)return;let n=ri(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(s=>s.type!==ne.Property?!1:s.value.type===ne.FunctionExpression),a=new Set;for(let s of n){if(s.identifier.parent.type!==ne.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===ne.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==ne.Identifier)return;a.add(i.property.name)}if(i.parent.type===ne.CallExpression&&o)return}for(let[s,i]of r)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function ri(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 ii}from"@typescript-eslint/utils";var si=U({selectors:X(U({name:z(),selectorProp:_(z()),selectorArgPos:_(ce()),returnProp:_(z())}))}),oi=ii.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-unused-selected-values",dt={name:on,rule:oi({name:on,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[si]},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=li(a);if(!s)return;let i=n.get(s);if(!i)return;let l=ai(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=ci(l);if(!c)return;let p=an(c.properties,void 0);if(!p)return;if(o.id.type===Y.ObjectPattern){let h=an(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=pi(o,e.sourceCode);if(u.length===0)return;let g=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;g.add(x.name)}for(let[h,x]of p)g.has(h)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:h}})}}}})};function ai(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 li(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 ci(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 an(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 pi(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 V}from"@typescript-eslint/utils";var yt=te({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===V.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let i=ui(a);i&&(n=i);return}let s=fi(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 ui(e){if(!(e.callee.type===V.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==V.ObjectExpression)return null;let n=it(r.properties,a=>a.type!==V.Property||a.key.type!==V.Identifier||a.key.name!=="initialConfig"?null:a.value.type===V.ObjectExpression?a.value:a.value.type===V.ArrowFunctionExpression||a.value.type===V.FunctionExpression?mi(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===V.Property&&a.key.type===V.Identifier&&o.set(a.key.name,a);return o}function fi(e,t){if(!(e.callee.type===V.Identifier&&e.callee.name==="useFormState")||e.parent.type!==V.VariableDeclarator||e.parent.id.type!==V.ObjectPattern||!it(e.parent.id.properties,s=>s.type===V.Property&&s.key.type===V.Identifier&&s.key.name==="formFields"&&s))return null;let o=en(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==V.Identifier||s.parent.type===V.Property&&s.parent.parent.type===V.ObjectExpression&&s.parent.parent.parent.type===V.ReturnStatement||s.parent.type===V.ReturnStatement)return null;if(s.parent.type===V.MemberExpression){if(s.parent.object.type!==V.Identifier||s.parent.property.type!==V.Identifier)return null;a.add(s.parent.property.name)}}return a}function mi(e){if(e.body.type===V.ObjectExpression)return e.body;if(e.body.type===V.BlockStatement){let t=e.body.body.filter(r=>r.type===V.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==V.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as $,ESLintUtils as di}from"@typescript-eslint/utils";var yi=di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function ln(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 cn(e,...t){for(let r of t)e.set(...r);return e}var gi=U({forceCheckOnFCPropTypesWithName:_(X(z()))}),pn="no-unused-type-props-in-args",gt=null,Si=yi({name:pn,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:[gi],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!gt&&(gt=r.map(i=>new RegExp(i)));function n(i,l,c,p,u=!0){let g=c.name,h=e.sourceCode.getScope(l).references.find(k=>k.identifier.name===g)?.resolved,x=i&>?.some(k=>k.test(g));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 g of p.body)g.type===$.TSPropertySignature&&g.key.type===$.Identifier&&c.set(g.key.name,g);return}if(p.type===$.TSTypeLiteral){cn(c,...ln(p));return}if(p.type===$.TSIntersectionType){for(let g of p.types)o(i,l,c,g,!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=[],g=[];for(let[h,x]of l)c.includes(h)||(g.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=g.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)cn(c,...ln(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)}}}}),St={name:pn,rule:Si};import{AST_NODE_TYPES as Tt,ESLintUtils as Ti}from"@typescript-eslint/utils";var hi=Ti.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="prefer-named-functions",un=new Map,Ei=hi({name:fn,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=un.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),un.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===Tt.ArrowFunctionExpression&&n.id.type===Tt.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==Tt.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)}`)}]})}}}}}),ht={name:fn,rule:Ei};import{AST_NODE_TYPES as D}from"@typescript-eslint/utils";var bi=U({disallowedFunctions:X(U({name:z(),allowUsingWithArgs:_(he()),hookAlternative:_(z()),message:_(z()),allowUseInside:_(X(z()))}))});function Le(e){return/^use[A-Z]/.test(e)}function mn(e){return/^[A-Z]/.test(e)}function xi(e){return e.type===D.Identifier?Le(e.name):e.type===D.MemberExpression&&e.property.type===D.Identifier?Le(e.property.name):!1}function dn(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 yn(e){return!!(e.parent&&e.parent.type===D.CallExpression&&dn(e.parent.callee,"forwardRef"))}function gn(e){return!!(e.parent&&e.parent.type===D.CallExpression&&dn(e.parent.callee,"memo"))}function Et(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 wi(e){let t=e.parent,r=!1;for(;t;){if(t.type===D.FunctionDeclaration||t.type===D.FunctionExpression||t.type===D.ArrowFunctionExpression){let n=Et(t);if(n&&n.type===D.Identifier){if(mn(n.name)||Le(n.name))return!r;r=!0}else{if(yn(t)||gn(t))return!r;if(t.parent.type===D.CallExpression){let o=t.parent;xi(o.callee)||(r=!0)}else t.parent.type===D.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Sn(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 Ii(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=Et(r);if(n&&n.type===D.Identifier&&t.includes(n.name))return!0}else if(r.type===D.CallExpression){let n=Sn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Ci(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===D.Identifier&&t.name==="undefined")}function Ai(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=Et(n);if(o&&o.type===D.Identifier){if(mn(o.name)||Le(o.name)){r=!0;break}}else if(yn(n)||gn(n)){r=!0;break}}n=n.parent}return r?t.length===0?wi(e):!Ii(e,t):!1}var bt=te({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:[bi],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=Sn(o);if(!a)return;let s=n.get(a);if(!s||s.allowUsingWithArgs&&Ci(o))return;let i=s.allowUseInside||[];Ai(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 B,AST_TOKEN_TYPES as Tn,ESLintUtils as Ri}from"@typescript-eslint/utils";var ki=Ri.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),En="prefer-single-line-if",vi=U({maxLineLength:_(ce()),maxNonSimpleConditionLength:_(ce())}),Oi=ki({name:En,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:[vi]},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(!xn(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=hn(n.test);if(!u&&n.test.type===B.UnaryExpression&&n.test.operator==="!"){let g=n.test.argument;hn(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===Tn.Punctuator&&l.value==="}"){let u=r.getTokenAfter(l);if(u&&u.type===Tn.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=Fi(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 hn(e){return e.type===B.CallExpression||e.type===B.BinaryExpression||e.type===B.MemberExpression&&bn(e)}function bn(e){return e.object.type===B.MemberExpression?bn(e.object):e.object.type!==B.Identifier}function Fi(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function xn(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?xn(t):!1}var xt={name:En,rule:Oi};import{AST_NODE_TYPES as se,ESLintUtils as Pi}from"@typescript-eslint/utils";var Ni=Pi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wn="react-compiler-migration",Di=U({disallowHooks:_(X(U({name:z(),replacement:z()}))),disallowMethods:_(X(U({name:z(),replacement:_(z()),requireTrueProp:_(z())})))}),ji=/eslint +react-compiler\/react-compiler: +\["error/;function Mi(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 _i=Ni({name:wn,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:[Di]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(ji.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&&Mi(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)}]})}}}}}}:{}}}),wt={name:wn,rule:_i};import{ESLintUtils as Li,TSESTree as $i}from"@typescript-eslint/utils";var zi=Li.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),In="require-description",Ui=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Wi=/^eslint-disable-(next-)?line$/u,Vi=zi({name:In,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=Hi(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Ji(o.loc),messageId:"missingDescription"}))}}}}}),Cn={name:In,rule:Vi};function Hi(e){let{text:t,description:r}=Yi(e.value);if(!t)return null;let n=Ui.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=Wi.test(o);if(e.type===$i.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 Yi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Ji(e){return{start:{line:e.start.line,column:-1},end:e.end}}function kn(e){return/^use[A-Z0-9]/.test(e)}function $e(e){return e.type==="Identifier"?kn(e.name):e.type==="MemberExpression"&&!e.computed&&$e(e.property)?e.object.type==="Identifier":!1}function vn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function On(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Fn(e){return!!(e.parent&&e.parent.callee&&On(e.parent.callee,"forwardRef"))}function Pn(e){return!!(e.parent&&e.parent.callee&&On(e.parent.callee,"memo"))}function It(e){for(;e;){let t=Dn(e);if(t&&(vn(t)||$e(t))||Fn(e)||Pn(e))return!0;e=e.parent}return!1}function An(e){return!1}function Ct(e){return!1}var Bi=/eslint +react-compiler\/react-compiler: +\["error/,Nn={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(Bi.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(T,m){let{cache:y}=g,A=y.get(T.id),C=new Set(m);if(C.has(T.id)){let E=[...C],P=E.slice(E.indexOf(T.id)+1);for(let H of P)u.add(H);return BigInt("0")}if(C.add(T.id),A!==void 0)return A;if(l.thrownSegments.includes(T))A=BigInt("0");else if(T.prevSegments.length===0)A=BigInt("1");else{A=BigInt("0");for(let E of T.prevSegments)A+=g(E,C)}return T.reachable&&A===BigInt("0")?y.delete(T.id):y.set(T.id,A),A}function h(T,m){let{cache:y}=h,A=y.get(T.id),C=new Set(m);if(C.has(T.id)){let E=Array.from(C),P=E.slice(E.indexOf(T.id)+1);for(let H of P)u.add(H);return BigInt("0")}if(C.add(T.id),A!==void 0)return A;if(l.thrownSegments.includes(T))A=BigInt("0");else if(T.nextSegments.length===0)A=BigInt("1");else{A=BigInt("0");for(let E of T.nextSegments)A+=h(E,C)}return y.set(T.id,A),A}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 A of T.prevSegments){let C=x(A);C<y&&(y=C)}y+=1}return m.set(T.id,y),y}g.cache=new Map,h.cache=new Map,x.cache=new Map;let b=h(l.initialSegment),k=Dn(c),w=It(c),M=k?vn(k)||$e(k):Fn(c)||Pn(c),F=1/0;for(let T of l.finalSegments){if(!T.reachable)continue;let m=x(T);m<F&&(F=m)}for(let[T,m]of p){if(!T.reachable)continue;let y=T.nextSegments.length===0?F<=x(T):F<x(T),A=g(T)*h(T),C=u.has(T.id);for(let E of m)if(C&&!Ct(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.`}),M){if(c.async&&e.report({node:E,message:`React Hook "${t(E)}" cannot be called in an async function.`}),!C&&A!==b&&!Ct(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 P=`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:P})}else if(k){let P=`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:P})}else if(c.type==="Program"){let P=`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:P})}else if(w&&!Ct(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"&&kn(H.parent.id.name))return}let P=`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:P})}}},CallExpression(l){if($e(l.callee)){let c=Rn(o),p=Rn(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){It(l)&&i(r(l))},ArrowFunctionExpression(l){It(l)&&i(r(l))}}}};function Dn(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function Rn(e){return e[e.length-1]}var jn={[St.name]:St.rule,[Qe.name]:Qe.rule,[Ze.name]:Ze.rule,"rules-of-hooks":Nn,"exhaustive-deps":$t,"require-description":Cn.rule,[et.name]:et.rule,[nt.name]:nt.rule,[ht.name]:ht.rule,[He.name]:He.rule,[Ke.name]:Ke.rule,[at.name]:at.rule,[xt.name]:xt.rule,[st.name]:st.rule,[tt.name]:tt.rule,[Je.name]:Je.rule,[wt.name]:wt.rule,[Ve.name]:Ve.rule,[Ge.name]:Ge.rule,[ut.name]:ut.rule,[ft.name]:ft.rule,[dt.name]:dt.rule,[yt.name]:yt.rule,[mt.name]:mt.rule,[bt.name]:bt.rule,[ct.name]:ct.rule,[lt.name]:lt.rule};var ma={rules:jn};export{ma as extendedLintPlugin};
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let y=l.acquire(w),A=new Set,C=null;{let f=y.upper;for(;f&&(A.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 R=d.node.parent;if(R==null&&(Ke(C.block,d.node.id),R=d.node.parent,R==null))return!1;if(R.kind==="const"&&I.type==="Literal"&&(typeof I.value=="string"||typeof I.value=="number"||I.value===null))return!0;if(I.type!=="CallExpression")return!1;let O=I.callee;if(O.type==="MemberExpression"&&O.object.name==="React"&&O.property!=null&&!O.computed&&(O=O.property),O.type!=="Identifier")return!1;let k=d.node.id,{name:N}=O;if(N==="useRef"&&k.type==="Identifier")return!0;if(pr(O)&&k.type==="Identifier"){for(let D of f.references)D!==k&&h.add(D.identifier);return!0}else if(N==="useState"||N==="useReducer"){if(k.type==="ArrayPattern"&&k.elements.length===2&&E(f.identifiers)){if(k.elements[1]===f.identifiers[0]){if(N==="useState"){let D=f.references,ie=0;for(let me=0;me<D.length;me++){if(D[me].isWrite()&&ie++,ie>1)return!1;c.set(D[me].identifier,k.elements[0])}}return!0}else if(k.elements[0]===f.identifiers[0]){if(N==="useState"){let D=f.references;for(let ie=0;ie<D.length;ie++)p.add(D[ie].identifier)}return!1}}}else if(N==="useTransition"&&k.type==="ArrayPattern"&&k.elements.length===2&&Array.isArray(f.identifiers)&&k.elements[1]===f.identifiers[0])return!0;return!1}function 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,R=C.childScopes,O=null,k;for(k=0;k<R.length;k++){let N=R[k],D=N.block;if(I.type==="FunctionDeclaration"&&D===I||I.type==="VariableDeclarator"&&D.parent===I){O=N;break}}if(O==null)return!1;for(k=0;k<O.through.length;k++){let N=O.through[k];if(N.resolved!=null&&A.has(N.resolved.scope)&&!J(N.resolved))return!1}return!0}let J=b(F,u),ee=b(H,g),K=new Map;function he(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 ne=new Map,Ce=new Map;ue(y);function ue(f){for(let d of f.references){if(!d.resolved||!A.has(d.resolved.scope))continue;let I=Ke(w,d.identifier),R=Vt(I),O=de(R,Ce);if(m&&R.type==="Identifier"&&(R.parent.type==="MemberExpression"||R.parent.type==="OptionalMemberExpression")&&!R.parent.computed&&R.parent.property.type==="Identifier"&&R.parent.property.name==="current"&&he(d)&&K.set(O,{reference:d,dependencyNode:R}),R.parent.type==="TSTypeQuery"||R.parent.type==="TSTypeReference")continue;let k=d.resolved.defs[0];if(k!=null&&!(k.node!=null&&k.node.init===w.parent)&&k.type!=="TypeParameter")if(ne.has(O))ne.get(O).references.push(d);else{let N=d.resolved,D=J(N)||ee(N);ne.set(O,{isStable:D,references:[d]})}}for(let d of f.childScopes)ue(d)}K.forEach(({reference:f,dependencyNode:d},I)=>{let R=f.resolved.references,O=!1;for(let k=0;k<R.length;k++){let{identifier:N}=R[k],{parent:D}=N;if(D!=null&&D.type==="MemberExpression"&&!D.computed&&D.property.type==="Identifier"&&D.property.name==="current"&&D.parent.type==="AssignmentExpression"&&D.parent.left===D){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 ce=new Set;function fe(f,d){ce.has(d)||(ce.add(d),i({node:f,message:`Assignments to the '${d}' variable from inside React Hook ${n(P)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${n(P)}.`}))}let Ee=new Set;if(ne.forEach(({isStable:f,references:d},I)=>{f&&Ee.add(I),d.forEach(R=>{R.writeExpr&&fe(R.writeExpr,I)})}),ce.size>0)return;if(!L){let f=null;if(ne.forEach(({isStable:d,references:I},R)=>{f||I.forEach(O=>{if(f)return;let k=O.identifier;if(!c.has(k))return;let D=O.from;for(;D.type!=="function";)D=D.upper;D.block===w&&(f=R)})}),f){let{suggestedDependencies:d}=Xe({dependencies:ne,declaredDependencies:[],stableDependencies:Ee,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 Ae=[],Re=new Set;L.type!=="ArrayExpression"?i({node:L,message:`React Hook ${n(P)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):L.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,message:`React Hook ${n(P)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}h.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(f)}\``,fix(O){return O.removeRange(f.range)}}]});let d;try{d=de(f,Ce)}catch(O){if(/Unsupported node type/.test(O.message)){f.type==="Literal"?ne.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${n(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 R=!C.through.some(O=>O.identifier===I);Ae.push({key:d,node:f}),R||Re.add(d)});let{suggestedDependencies:$n,unnecessaryDependencies:Oe,missingDependencies:ye,duplicateDependencies:kt}=Xe({dependencies:ne,declaredDependencies:Ae,stableDependencies:Ee,externalDependencies:Re,isEffect:m}),Pe=$n;if(kt.size+ye.size+Oe.size===0){if(t)return;or({declaredDependencies:Ae,declaredDependenciesNode:L,componentScope:C,scope:y}).forEach(({construction:d,isUsedOutsideOfHook:I,depType:R})=>{let O=R==="function"?"useCallback":"useMemo",k=R==="function"?"definition":"initialization",N=`wrap the ${k} of '${d.name.name}' in its own ${O}() Hook.`,D=I?`To fix this, ${N}`:`Move it inside the ${T} callback. Alternatively, ${N}`,ie=R==="conditional"||R==="logical expression"?"could make":"makes",me=`The '${d.name.name}' ${R} ${ie} the dependencies of ${T} Hook (at line ${L.loc.start.line}) change on every render. ${D}`,Ot;I&&d.type==="Variable"&&R==="function"&&(Ot=[{desc:`Wrap the ${k} of '${d.name.name}' in its own ${O}() Hook.`,fix(Pt){let[Un,Wn]=O==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Pt.insertTextBefore(d.node.init,Un),Pt.insertTextAfter(d.node.init,Wn)]}}]),i({node:d.node,message:me,suggest:Ot})});return}!m&&ye.size>0&&(Pe=Xe({dependencies:ne,declaredDependencies:[],stableDependencies:Ee,externalDependencies:Re,isEffect:m}).suggestedDependencies);function zn(){if(Ae.length===0)return!0;let f=Ae.map(I=>I.key),d=f.slice().sort();return f.join(",")===d.join(",")}zn()&&Pe.sort();function We(f){let d=f.split("."),I="";for(let R=0;R<d.length;R++){if(R!==0){let O=d.slice(0,R+1).join("."),k=Ce.get(O)===!0;I+=k?"?.":"."}I+=d[R]}return I}function Ve(f,d,I,R){return f.size===0?null:(f.size>1?"":d+" ")+I+" "+(f.size>1?"dependencies":"dependency")+": "+lr(Array.from(f).sort().map(O=>"'"+We(O)+"'"))+`. Either ${R} ${f.size>1?"them":"it"} or remove the dependency array.`}let ae="";if(Oe.size>0){let f=null;if(Array.from(Oe.keys()).forEach(d=>{f===null&&d.endsWith(".current")&&(f=d)}),f!==null)ae=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Re.size>0){let d=Array.from(Re)[0];y.set.has(d)||(ae=` Outer scope values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ae&&ye.has("props")){let f=ne.get("props");if(f==null)return;let d=f.references;if(!Array.isArray(d))return;let I=!0;for(let R=0;R<d.length;R++){let O=d[R],k=Ke(C.block,O.identifier);if(!k){I=!1;break}let N=k.parent;if(N==null){I=!1;break}if(N.type!=="MemberExpression"&&N.type!=="OptionalMemberExpression"){I=!1;break}}I&&(ae=` 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 ${n(P)}.`)}if(!ae&&ye.size>0){let f=null;ye.forEach(d=>{if(f)return;let I=C.set.get(d),R=ne.get(d);if(R.references[0].resolved!==I)return;let O=I.defs[0];if(O==null||O.name==null||O.type!=="Parameter")return;let k=!1,N;for(let D=0;D<R.references.length;D++)if(N=R.references[D].identifier,N!=null&&N.parent!=null&&(N.parent.type==="CallExpression"||N.parent.type==="OptionalCallExpression")&&N.parent.callee===N){k=!0;break}k&&(f=d)}),f!==null&&(ae=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ae&&ye.size>0){let f=null;if(ye.forEach(d=>{if(f!==null)return;let R=ne.get(d).references,O,k;for(let N=0;N<R.length;N++){for(O=R[N].identifier,k=O.parent;k!=null&&k!==C.block;){if(k.type==="CallExpression"){let D=c.get(k.callee);if(D!=null){if(D.name===d)f={missingDep:d,setter:k.callee.name,form:"updater"};else if(p.has(O))f={missingDep:d,setter:k.callee.name,form:"reducer"};else{let ie=R[N].resolved;if(ie!=null){let me=ie.defs[0];me!=null&&me.type==="Parameter"&&(f={missingDep:d,setter:k.callee.name,form:"inlineReducer"})}}break}}k=k.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":ae=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":ae=` 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":ae=` 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 ${n(P)} has `+(Ve(ye,"a","missing","include")||Ve(Oe,"an","unnecessary","exclude")||Ve(kt,"a","duplicate","omit"))+ae,suggest:[{desc:`Update the dependencies array to be: [${Pe.map(We).join(", ")}]`,fix(f){return f.replaceText(L,`[${Pe.map(We).join(", ")}]`)}}]})}function v(w){let L=ar(w.callee,s);if(L===-1)return;let P=w.arguments[L],T=w.callee,m=Ht(T).name,y=w.arguments[L+1],A=/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&&!A)){if(!y&&!A){(m==="useMemo"||m==="useCallback")&&i({node:T,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(P.type){case"FunctionExpression":case"ArrowFunctionExpression":x(P,y,T,m,A);return;case"Identifier":if(!y||y.elements&&y.elements.some(F=>F&&F.type==="Identifier"&&F.name===P.name))return;let C=r(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":x(E.node,y,T,m,A);return;case"VariableDeclarator":let F=E.node.init;if(!F)break;switch(F.type){case"ArrowFunctionExpression":case"FunctionExpression":x(F,y,T,m,A);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(sr.test(w.value))return t=!0,{CallExpression:L=>v(L,!0)}}return{CallExpression:w=>v(w)}}};function Xe({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:o}){let a=s();function s(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((x,v)=>{let w=i(a,v);w.isUsed=!0,l(a,v,L=>{L.isSubtreeUsed=!0})}),t.forEach(({key:x})=>{let v=i(a,x);v.isSatisfiedRecursively=!0}),n.forEach(x=>{let v=i(a,x);v.isSatisfiedRecursively=!0});function i(x,v){let w=v.split("."),L=x;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(x,v,w){let L=v.split("."),P=x;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,x=>x);function u(x,v,w,L){x.children.forEach((P,T)=>{let m=L(T);if(P.isSatisfiedRecursively){P.isSubtreeUsed&&w.add(m);return}if(P.isUsed){v.add(m);return}u(P,v,w,y=>m+"."+y)})}let g=[],h=new Set,b=new Set;return t.forEach(({key:x})=>{p.has(x)?g.indexOf(x)===-1?g.push(x):b.add(x):h.add(x)}),c.forEach(x=>{g.push(x)}),{suggestedDependencies:g,unnecessaryDependencies:h,duplicateDependencies:b,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 or({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let o=e.map(({key:s})=>{let i=n.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!==r&&p!=null;)p=p.upper;if(p!==r&&!Yt(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 Ge(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function de(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=de(e.object,t),r=de(e.property,null),o=`${n}.${r}`;return Ge(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=de(e.object,t),r=de(e.property,null),o=`${n}.${r}`;return Ge(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=de(n.object,t),o=de(n.property,null),a=`${r}.${o}`;return Ge(n,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 ar(e,t){let n=Ht(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=de(n,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(r)?0:-1}else return-1}}function Ke(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),cr(r,t))return r;if(Yt(r,t))for(let[o,a]of Object.entries(r))o!=="parent"&&(Ut(a)?(a.parent=r,n.push(a)):Array.isArray(a)&&a.forEach(s=>{Ut(s)&&(s.parent=r,n.push(s))}))}return null}function lr(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function cr(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 pr(e){return!1}import{AST_NODE_TYPES as je,ESLintUtils as Jt}from"@typescript-eslint/utils";import te from"typescript";var ur=Jt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt="improved-no-unnecessary-condition",fr=U({}),mr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],dr=new Set(mr),Ze={name:Bt,rule:ur({name:Bt,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:[fr]},defaultOptions:[{}],create(e){let t=Jt.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===je.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&te.TypeFlags.Any||i.flags&te.TypeFlags.Unknown?null:i.flags&te.TypeFlags.StringLike?["string"]:i.flags&te.TypeFlags.NumberLike?["number"]:i.flags&te.TypeFlags.BigIntLike?["bigint"]:i.flags&te.TypeFlags.BooleanLike?["boolean"]:i.flags&te.TypeFlags.ESSymbolLike?["symbol"]:i.flags&te.TypeFlags.Undefined||i.flags&te.TypeFlags.Void?["undefined"]:i.flags&te.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&te.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&te.TypeFlags.NonPrimitive?["object"]:i.flags&te.TypeFlags.Never?["never"]:null}function a(i){if(!n)return null;let l=t.esTreeNodeToTSNodeMap.get(i),c=n.getTypeAtLocation(l.expression);if(c.flags&te.TypeFlags.Any||c.flags&te.TypeFlags.Unknown)return null;let p=[];if(c.isUnion()){for(let g of c.types){let h=o(g);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(r(i.left)?(c=i.left,p=i.right.type===je.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(c=i.right,p=i.left.type===je.Literal&&typeof i.left.value=="string"?i.left.value:null),!c||!p||!yr(p,dr))return;let u=a(c);if(!u)return;let g=i.operator==="!==",h=u.includes(p);u.length===1?h&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:be(c,e),type:p}}):!h&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:be(c,e),type:Array.from(u)[0]}}):!h&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:be(c,e),actualType:Ne(u),conditionType:p}}):h&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:be(c,e),actualType:Ne(u),conditionType:p}}):!h&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:be(c,e),actualType:Ne(u),conditionType:p}}):!h&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:be(c,e),type:Ne(u)}})}return{BinaryExpression:s}}})};function Ne(e){return Array.from(new Set(e)).join(" | ")||"never"}function be(e,t){let n=e.argument;return n.type===je.Identifier?n.name:t.sourceCode.getText(n)}function yr(e,t){return t.has(e)}import{AST_NODE_TYPES as gr,ESLintUtils as Sr}from"@typescript-eslint/utils";var Tr=Sr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="no-call-with-explicit-generics",hr=U({functions:X(z())}),Er=Tr({name:qt,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 n=new Set(t.functions);return{CallExpression(r){let{callee:o}=r;o.type===gr.Identifier&&n.has(o.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),Qe={name:qt,rule:Er};import{AST_NODE_TYPES as De,ESLintUtils as xr}from"@typescript-eslint/utils";var br=xr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xt="no-call-with-inferred-generics",wr=br({name:Xt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:o}=r;if(o.type!==De.Identifier)return;let a=n.get(o.name);if(!a)return;let{minGenerics:s=1,allowAny:i,disallowTypes:l=t.disallowTypes}=a;(r.typeArguments?.params.length||0)<(s||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:s||0}}),!(i&&!l)&&r.typeArguments?.params?.some(p=>!i&&p.type===De.TSAnyKeyword||l&&p.type===De.TSTypeReference&&p.typeName.type===De.Identifier&&l.includes(p.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),et={name:Xt,rule:wr};import{ESLintUtils as Ir}from"@typescript-eslint/utils";var Cr=Ir.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="no-commented-out-code",Ar=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],B={returnStatement:/^\s*return\s+/,stringAssignment:/\w=("|'|`)/,objectPropertyWithQuotes:/\w+:\s*('|"|`)/,computedPropertyAssignment:/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,kebabCaseProperty:/\w+-\w+:/,snakeCaseProperty:/\w+_\w+:/,ternaryOperator:/\?\s+\w/,colonWithWord:/:\s+\w/,quotedString:/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,numberWithComma:/^\s*\d+[,}]/,arrayWithComma:/^\s*\[[^\]]*\][,}]/,objectWithComma:/^\s*\{[^}]*\}[,}]/,methodCall:/\.\w+\(/,arrayAccess:/\[\w+\]/,quotedPropertyKey:/^\s*(['"`]).+?\1\s*:/,jsxSelfClosing:/^<[A-Z]\w*(\s|>|\/)/,jsxElement:/^<[a-z]+(\s|>|\/)/,jsxOpeningTag:/<[A-Z]\w*(\s.*)?>/,jsxClosingTag:/<\/[A-Z]\w*>/,htmlOpeningTag:/<[a-z]+(\s.*)?>/,htmlClosingTag:/<\/[a-z]+>/,colonDescriptiveComment:/^[a-zA-Z]+(\s+[a-zA-Z]+)*:\s+[a-zA-Z]+\s+[a-zA-Z][^{=,'"]*$/,jsdocComment:/^\s*[*\s]*$/},Rr=[") {","return;",B.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",B.stringAssignment,");",B.objectPropertyWithQuotes,B.computedPropertyAssignment,B.kebabCaseProperty,B.snakeCaseProperty,"&&","||","()",B.ternaryOperator,B.colonWithWord,B.quotedString,B.numberWithComma,B.arrayWithComma,B.objectWithComma,B.methodCall,B.arrayAccess,"?.(","??","=>",B.quotedPropertyKey],vr=["/>","</",B.jsxSelfClosing,B.jsxElement,B.jsxOpeningTag,B.jsxClosingTag,B.htmlOpeningTag,B.htmlClosingTag],Gt=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],kr=Cr({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(r,o){if(r.startsWith("/"))return!1;let a=r.trimStart();if(r.startsWith("*")||a.startsWith("eslint-disable")||r.includes("@deprecated")||r.includes("@example")||r.includes("@param")||r.includes("@returns")||r.includes("@throws")||r.includes("typescript-eslint")||r.includes("@ts-")||r.includes("prettier-ignore")||B.jsdocComment.test(r))return!1;for(let s of Gt)if(a.startsWith(s))return!1;if(r.includes("https://")||a.includes(":")&&B.colonDescriptiveComment.test(a.trim()))return!1;if(o==="Block"){for(let s of vr)if(typeof s=="string"){if(r.includes(s))return{wrongPattern:s}}else if(s.test(r))return{wrongPattern:`regex(${s.toString()})`};return!1}for(let s of Ar)if(a.startsWith(s))return{wrongPattern:s};for(let s of Rr)if(typeof s=="string"){if(r.includes(s))return{wrongPattern:s}}else if(s.test(r))return{wrongPattern:`regex(${s.toString()})`};return!1}function n(r,o){let a=r,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=n(a.value,a.type),i=t(s,a.type);i&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:i.wrongPattern,allowedPrefixes:Gt.join(", ")}})}}}}}),tt={name:Kt,rule:kr};import{ESLintUtils as Or,TSESTree as Pr}from"@typescript-eslint/utils";var Fr=Or.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="no-default-export",Nr=Fr({name:Zt,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===Pr.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),nt={name:Zt,rule:Nr};import{ESLintUtils as jr}from"@typescript-eslint/utils";var Dr=jr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="no-leaked-text-in-jsx",Lr=[",",";","[","]","(",")"],Mr=Dr({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 n=t.value.trim();if(!n)return;let r="";Lr.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),rt={name:Qt,rule:Mr};import{AST_NODE_TYPES as ve,ESLintUtils as _r}from"@typescript-eslint/utils";var $r=_r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-non-camel-case-functions",zr=/^(\$?[a-z][a-zA-Z0-9]*)$/;function en(e){if(e.typeName.type!==ve.TSQualifiedName)return!1;let{left:t,right:n}=e.typeName;return t.type===ve.Identifier&&t.name==="JSX"&&n.name==="Element"}var Ur=$r({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&&!zr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ve.TSTypeReference?en(n):n.type===ve.TSUnionType&&n.types.some(o=>o.type===ve.TSTypeReference&&en(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),it={name:tn,rule:Ur};import{ESLintUtils as Wr,TSESTree as W}from"@typescript-eslint/utils";import{AST_NODE_TYPES as nn}from"@typescript-eslint/utils";function we(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:we(e.parent,t,n===1/0?n:n-1)}function*st(e){yield e,e.parent&&(yield*st(e.parent))}function ot(e,t){for(let n of e){let r=t(n);if(r!=null&&r!==!1)return r}}function rn(e,t,n){let o=n.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===nn.Property&&a.identifiers[0]?.parent.key.type===nn.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Vr=Wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="no-optional-root-props",Hr=Vr({name:sn,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let a=e.sourceCode.getDeclaredVariables(r)[0];if(!a||a.references.length!==1)return!1;let s=a.references[0];if(!s)return!1;for(let i of st(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=we(l.parent.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!p)return!1;let u=Le(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=we(l,W.AST_NODE_TYPES.VariableDeclaration);return c?!!Le(c,e.sourceCode):!1}if(l.type===W.AST_NODE_TYPES.FunctionDeclaration)return!!Le(l,e.sourceCode)}return!1}function n(r){r.key.type!==W.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=we(r,W.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let s=e.sourceCode.getText(a);return o.replaceText(a,s.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===W.AST_NODE_TYPES.TSTypeLiteral&&!(Me(r)||!t(r)))for(let o of r.typeAnnotation.members)o.type===W.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSInterfaceDeclaration(r){if(!(Me(r)||!t(r)))for(let o of r.body.body)o.type===W.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSTypeReference(r){if(r.typeName.type!==W.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let o=r.typeArguments.params[0];if(o.type!==W.AST_NODE_TYPES.TSTypeLiteral)return;let a=we(r.parent,W.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let s=Le(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&&n(l)}}}});function Me(e){return e?e.parent?.type===W.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===W.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Le(e,t){if(Me(e))return;let n;if(e.type===W.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===W.AST_NODE_TYPES.Identifier&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===W.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let o=r.variables.find(s=>s.identifiers.includes(n));if(!o)return;let a=o.references.filter(s=>s.identifier!==n);if(!(a.length!==1||!a[0])&&!Me(a[0].identifier.parent.parent))return a[0].identifier}var at={name:sn,rule:Hr};import{ESLintUtils as Yr}from"@typescript-eslint/utils";import lt from"node:path";var Br=Yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-relative-imports",Jr=U({find:z(),replacement:z()}),qr=U({aliases:X(Jr),rootDir:M(z()),allowNotFoundAliases:M(xe()),_dev_simulateFileName:M(z())}),Xr=Br({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:[qr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(s){return s.startsWith(".")||s.startsWith("..")}function o(s,i){let l=lt.dirname(i);return lt.resolve(l,s)}function a(s){let i=t.rootDir??process.cwd(),l=lt.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(!r(i))return;let l=o(i,n),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})}}}}),ct={name:on,rule:Xr};import{AST_NODE_TYPES as _e}from"@typescript-eslint/utils";import*as Se from"zod/v4";var Gr=Se.object({alternativeMsgs:Se.object({inArrayFind:Se.string().optional(),inArrayFilter:Se.string().optional()}).optional(),__dev_simulateFileName:Se.string().optional()});function Kr(e){return e.typeAnnotation.type!==_e.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function Zr(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function Qr(e){let t=e.parent;for(;t;){if(t.type===_e.CallExpression&&t.callee.type===_e.MemberExpression&&t.callee.property.type===_e.Identifier){let n=t.callee.property.name;if(n==="filter"||n==="find")return{method:n}}t=t.parent}return null}var pt=Z({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[Fe(Gr)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let n=t.__dev_simulateFileName??e.filename;if(Zr(n))return{};function r(o){if(!Kr(o))return;let a=Qr(o),s=[];if(t.alternativeMsgs&&a){let i=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(i){let l=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:l,data:{message:i}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":r,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":r,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":r}}});import{AST_NODE_TYPES as Ie}from"@typescript-eslint/utils";var ei="no-unnecessary-async-on-jsx-props";function ti(e){if(e.body.type!==Ie.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let n=t[0];return!n||n.type!==Ie.ExpressionStatement?!1:n.expression.type===Ie.AwaitExpression}var ut=Z({name:ei,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(n){ti(n)&&e.report({node:n,messageId:"unnecessaryAsyncInJsxProp",fix(r){let o=e.sourceCode,a=[],s=o.getFirstToken(n,l=>l.value==="async");if(s){let l=o.getTokenAfter(s);l?a.push(r.replaceTextRange([s.range[0],l.range[0]],"")):a.push(r.remove(s))}function i(l){if(l.type===Ie.AwaitExpression){let c=o.getFirstToken(l);if(c&&c.value==="await"){let p=o.getTokenAfter(c);p?a.push(r.replaceTextRange([c.range[0],p.range[0]],"")):a.push(r.remove(c))}}if(l.type===Ie.BlockStatement)for(let c of l.body)i(c);else l.type===Ie.ExpressionStatement&&i(l.expression)}return i(n.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as ke,ESLintUtils as ln}from"@typescript-eslint/utils";import*as ft from"typescript";var ni=ln.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="no-unnecessary-casting",ri=U({additionalCastFunctions:M(X(U({name:z(),expectedType:Ft(["string","number"])})))}),mt={name:an,rule:ni({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:[ri],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],o=ln.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 ke.Literal:return u==="number"?typeof p.value=="number":typeof p.value=="string";case ke.TemplateLiteral:return u==="string";case ke.UnaryExpression:return u==="number"?p.operator==="+"||p.operator==="-"||p.operator==="~":!1;default:return!1}}function i(p,u){return u==="number"?!!(p.flags&ft.TypeFlags.NumberLike):!!(p.flags&ft.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===ke.SpreadElement)return;let{callee:g}=p;if(g.type!==ke.Identifier)return;let h=g.name,b=r.find(v=>v.name===h);if(!b)return;if(s(u,b.expectedType)||i(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(u)),b.expectedType)){let v,w;h==="Number"?v="unnecessaryNumberCasting":h==="String"?v="unnecessaryStringCasting":(v="unnecessaryCustomCasting",w={name:b.name,type:b.expectedType}),e.report({node:p,messageId:v,...w?{data:w}:{},fix:l(p,u)})}}return{CallExpression:c}}})};import{AST_NODE_TYPES as $e}from"@typescript-eslint/utils";import*as se from"zod/v4";var ii=se.object({methods:se.union([se.array(se.string()),se.literal("array")])}),dt=Z({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(ii)]},defaultOptions:[{methods:"array"}],create(e,[t]){let n=t.methods,r=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(i){return Array.isArray(n)?n.includes(i):r.has(i)}function a(i){let{callee:l}=i;if(l.type===$e.MemberExpression){let c=l.property;if(c.type===$e.Identifier)return c.name}return null}function s(i,l){if(i.type!==$e.Identifier||!i.typeAnnotation)return;let c=l.parent;if(c.type===$e.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 re}from"@typescript-eslint/utils";var yt=Z({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===re.ObjectPattern||!t.init||t.init.type!==re.ObjectExpression||t.id.type===re.Identifier&&t.id.typeAnnotation||t.parent.parent.type===re.ExportNamedDeclaration)return;let n=new Map;for(let s of t.init.properties)s.type===re.Property&&s.key.type===re.Identifier&&n.set(s.key.name,s);if(n.size===0||t.id.type!==re.Identifier)return;let r=si(t,e.sourceCode);if(r.length===0)return;let o=t.init.properties.some(s=>s.type!==re.Property?!1:s.value.type===re.FunctionExpression),a=new Set;for(let s of r){if(s.identifier.parent.type!==re.MemberExpression)return;let i=s.identifier.parent;if(i.object!==s.identifier)return;if(i.computed)if(i.property.type===re.Literal&&typeof i.property.value=="string")a.add(i.property.value);else return;else{if(i.property.type!==re.Identifier)return;a.add(i.property.name)}if(i.parent.type===re.CallExpression&&o)return}for(let[s,i]of n)a.has(s)||e.report({node:i,messageId:"unusedObjectProperty",data:{name:s}})}}}});function si(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as Y,ESLintUtils as oi}from"@typescript-eslint/utils";var ai=U({selectors:X(U({name:z(),selectorProp:M(z()),selectorArgPos:M(pe()),returnProp:M(z())}))}),li=oi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cn="no-unused-selected-values",gt={name:cn,rule:li({name:cn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[ai]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===Y.CallExpression&&(a=o.init),!a)return;let s=pi(a);if(!s)return;let i=r.get(s);if(!i)return;let l=ci(a,i.selectorArgPos??0,i.selectorProp);if(!l)return;let c=ui(l);if(!c)return;let p=pn(c.properties,void 0);if(!p)return;if(o.id.type===Y.ObjectPattern){let h=pn(o.id.properties,i.returnProp);if(!h)return;for(let[b,x]of p)h.has(b)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:b}});return}if(o.id.type!==Y.Identifier||i.returnProp)return;let u=fi(o,e.sourceCode);if(u.length===0)return;let g=new Set;for(let h of u){if(h.identifier.parent.type!==Y.MemberExpression)return;let b=h.identifier.parent.property;if(b.type!==Y.Identifier)return;g.add(b.name)}for(let[h,b]of p)g.has(h)||e.report({node:b,messageId:"unusedSelectedValue",data:{name:h}})}}}})};function ci(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===Y.ArrowFunctionExpression||r.type===Y.FunctionExpression)return r;if(n&&r.type===Y.ObjectExpression){let o=r.properties.find(s=>s.type===Y.Property&&s.key.type===Y.Identifier&&s.key.name===n);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 pi(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 ui(e){if(e.body.type===Y.ObjectExpression)return e.body;if(e.body.type===Y.BlockStatement){let t=e.body.body.filter(n=>n.type===Y.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==Y.ObjectExpression?null:t[0].argument}return null}function pn(e,t){let n=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;n=o.value.properties}let r=new Map;for(let o of n){if(o.type!==Y.Property||o.key.type!==Y.Identifier)return null;r.set(o.key.name,o)}return r.size>0?r:null}function fi(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}import{AST_NODE_TYPES as V}from"@typescript-eslint/utils";var St=Z({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===V.ImportDeclaration&&a.source.value==="t-state-form"))return{};let r=null,o=!1;return{CallExpression(a){if(o)return;if(!r){let i=mi(a);i&&(r=i);return}let s=di(a,e.sourceCode);if(s){o=!0;for(let i of s)r.delete(i);if(r.size!==0)for(let[i,l]of r)e.report({node:l,messageId:"unusedField",data:{name:i}})}}}}});function mi(e){if(!(e.callee.type===V.Identifier&&e.callee.name==="useForm"))return null;let n=e.arguments[0];if(!n||n.type!==V.ObjectExpression)return null;let r=ot(n.properties,a=>a.type!==V.Property||a.key.type!==V.Identifier||a.key.name!=="initialConfig"?null:a.value.type===V.ObjectExpression?a.value:a.value.type===V.ArrowFunctionExpression||a.value.type===V.FunctionExpression?yi(a.value):null);if(!r)return null;let o=new Map;for(let a of r.properties)a.type===V.Property&&a.key.type===V.Identifier&&o.set(a.key.name,a);return o}function di(e,t){if(!(e.callee.type===V.Identifier&&e.callee.name==="useFormState")||e.parent.type!==V.VariableDeclarator||e.parent.id.type!==V.ObjectPattern||!ot(e.parent.id.properties,s=>s.type===V.Property&&s.key.type===V.Identifier&&s.key.name==="formFields"&&s))return null;let o=rn(e.parent,"formFields",t),a=new Set;for(let{identifier:s}of o){if(s.type!==V.Identifier||s.parent.type===V.Property&&s.parent.parent.type===V.ObjectExpression&&s.parent.parent.parent.type===V.ReturnStatement||s.parent.type===V.ReturnStatement)return null;if(s.parent.type===V.MemberExpression){if(s.parent.object.type!==V.Identifier||s.parent.property.type!==V.Identifier)return null;a.add(s.parent.property.name)}}return a}function yi(e){if(e.body.type===V.ObjectExpression)return e.body;if(e.body.type===V.BlockStatement){let t=e.body.body.filter(n=>n.type===V.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==V.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as $,ESLintUtils as gi}from"@typescript-eslint/utils";var Si=gi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function un(e){let t=[];for(let n of e.members)n.type===$.TSPropertySignature&&n.key.type===$.Identifier&&t.push([n.key.name,n]);return t}function fn(e,...t){for(let n of t)e.set(...n);return e}var Ti=U({forceCheckOnFCPropTypesWithName:M(X(z()))}),mn="no-unused-type-props-in-args",Tt=null,hi=Si({name:mn,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:[Ti],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Tt&&(Tt=n.map(i=>new RegExp(i)));function r(i,l,c,p,u=!0){let g=c.name,h=e.sourceCode.getScope(l).references.find(v=>v.identifier.name===g)?.resolved,b=i&&Tt?.some(v=>v.test(g));if(!h||!b&&h.references.filter(v=>v.isTypeReference).length>1)return;let x=h?.defs[0]?.node;if(!(u&&x?.parent?.type===$.ExportNamedDeclaration)){if(x?.type===$.TSTypeAliasDeclaration){o(i,l,p,x.typeAnnotation,!0);return}if(x?.type===$.TSInterfaceDeclaration){o(i,l,p,x.body,!0);return}}}function o(i,l,c,p,u){if(p.type===$.TSInterfaceBody){for(let g of p.body)g.type===$.TSPropertySignature&&g.key.type===$.Identifier&&c.set(g.key.name,g);return}if(p.type===$.TSTypeLiteral){fn(c,...un(p));return}if(p.type===$.TSIntersectionType){for(let g of p.types)o(i,l,c,g,!0);return}u||p.type===$.TSTypeReference&&p.typeName.type===$.Identifier&&r(i,l,p.typeName,c)}function a(i,l,c){for(let p of c)if(p.type==="ObjectPattern"&&p.typeAnnotation){let 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=[],g=[];for(let[h,b]of l)c.includes(h)||(g.push(h),u.push({node:b,messageId:"unusedObjectTypeProperty",data:{propertyName:h}}));for(let[h,b]of u.entries())e.report({...b,fix:h===u.length-1?x=>{let v=i.properties.at(-1),w=g.join(", ");return v?v?.type===$.RestElement?null:x.insertTextAfter(v,`, ${w}`):x.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)r(!0,i,p.typeName,c,!1);else if(p.type===$.TSTypeLiteral)fn(c,...un(p));else if(p.type===$.TSIntersectionType)for(let u of p.types)u.type===$.TSTypeReference&&u.typeName.type===$.Identifier?r(!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)}}}}),ht={name:mn,rule:hi};import{AST_NODE_TYPES as Et,ESLintUtils as Ei}from"@typescript-eslint/utils";var xi=Ei.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yn="prefer-named-functions",dn=new Map,bi=xi({name:yn,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=dn.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),dn.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===Et.ArrowFunctionExpression&&r.id.type===Et.Identifier){let o=r.id.name;if(r.id.typeAnnotation||n&&n.test(o)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==Et.BlockStatement)return;let a=r.parent,s=r.init.params,i=r.init.body,l=r.init;e.report({node:r.id,messageId:n?"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:yn,rule:bi};import{AST_NODE_TYPES as j}from"@typescript-eslint/utils";var wi=U({disallowedFunctions:X(U({name:z(),allowUsingWithArgs:M(xe()),hookAlternative:M(z()),message:M(z()),allowUseInside:M(X(z()))}))});function ze(e){return/^use[A-Z]/.test(e)}function gn(e){return/^[A-Z]/.test(e)}function Ii(e){return e.type===j.Identifier?ze(e.name):e.type===j.MemberExpression&&e.property.type===j.Identifier?ze(e.property.name):!1}function Sn(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 Tn(e){return!!(e.parent&&e.parent.type===j.CallExpression&&Sn(e.parent.callee,"forwardRef"))}function hn(e){return!!(e.parent&&e.parent.type===j.CallExpression&&Sn(e.parent.callee,"memo"))}function bt(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 Ci(e){let t=e.parent,n=!1;for(;t;){if(t.type===j.FunctionDeclaration||t.type===j.FunctionExpression||t.type===j.ArrowFunctionExpression){let r=bt(t);if(r&&r.type===j.Identifier){if(gn(r.name)||ze(r.name))return!n;n=!0}else{if(Tn(t)||hn(t))return!n;if(t.parent.type===j.CallExpression){let o=t.parent;Ii(o.callee)||(n=!0)}else t.parent.type===j.JSXExpressionContainer||(n=!0)}}t=t.parent}return!1}function En(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 Ai(e,t){if(!t.length)return!1;let n=e.parent;for(;n;){if(n.type===j.FunctionDeclaration||n.type===j.FunctionExpression||n.type===j.ArrowFunctionExpression){let r=bt(n);if(r&&r.type===j.Identifier&&t.includes(r.name))return!0}else if(n.type===j.CallExpression){let r=En(n);if(r&&t.includes(r))return!0}n=n.parent}return!1}function Ri(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===j.Identifier&&t.name==="undefined")}function vi(e,t){let n=!1,r=e.parent;for(;r;){if(r.type===j.FunctionDeclaration||r.type===j.FunctionExpression||r.type===j.ArrowFunctionExpression){let o=bt(r);if(o&&o.type===j.Identifier){if(gn(o.name)||ze(o.name)){n=!0;break}}else if(Tn(r)||hn(r)){n=!0;break}}r=r.parent}return n?t.length===0?Ci(e):!Ai(e,t):!1}var wt=Z({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react{{message}}."},schema:[wi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:n}=t,r=new Map(n.map(o=>[o.name,o]));return{CallExpression(o){let a=En(o);if(!a)return;let s=r.get(a);if(!s||s.allowUsingWithArgs&&Ri(o))return;let i=s.allowUseInside||[];vi(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 q,AST_TOKEN_TYPES as xn,ESLintUtils as ki}from"@typescript-eslint/utils";var Oi=ki.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wn="prefer-single-line-if",Pi=U({maxLineLength:M(pe()),maxNonSimpleConditionLength:M(pe())}),Fi=Oi({name:wn,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:[Pi]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==q.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let a=r.consequent.body[0];if(a.type===q.ReturnStatement){if(!Cn(a))return}else if(!(a.type===q.ContinueStatement||a.type===q.BreakStatement))return;if(r.test.type===q.LogicalExpression||r.test.type===q.ConditionalExpression)return;let s;if(t.maxNonSimpleConditionLength){let u=bn(r.test);if(!u&&r.test.type===q.UnaryExpression&&r.test.operator==="!"){let g=r.test.argument;bn(g)&&(u=!0)}if(u&&(s=n.getText(r.test),s.length>t.maxNonSimpleConditionLength))return}s||(s=n.getText(r.test));let i=n.getText(a);if(s.includes(`
|
|
16
|
+
`))return;let l=n.getTokenAfter(r);if(l&&l.type===xn.Punctuator&&l.value==="}"){let u=n.getTokenAfter(l);if(u&&u.type===xn.Keyword&&(u.value==="else"||u.value==="catch"))return}let c=Ni(n,r),p=`if (${s}) ${i}`;t.maxLineLength&&p.length+c.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:u=>u.replaceText(r,p)})}}}});function bn(e){return e.type===q.CallExpression||e.type===q.BinaryExpression||e.type===q.MemberExpression&&In(e)}function In(e){return e.object.type===q.MemberExpression?In(e.object):e.object.type!==q.Identifier}function Ni(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Cn(e){if(!e.argument)return!0;let t=e.argument;return t.type===q.ArrayExpression&&t.elements.length===0||t.type===q.ObjectExpression&&t.properties.length===0||t.type===q.Literal||t.type===q.Identifier||t.type===q.TemplateLiteral||t.type===q.TaggedTemplateExpression?!0:t.type===q.CallExpression?t.arguments.length===0:t.type===q.UnaryExpression?Cn(t):!1}var It={name:wn,rule:Fi};import{AST_NODE_TYPES as oe,ESLintUtils as ji}from"@typescript-eslint/utils";var Di=ji.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),An="react-compiler-migration",Li=U({disallowHooks:M(X(U({name:z(),replacement:z()}))),disallowMethods:M(X(U({name:z(),replacement:M(z()),requireTrueProp:M(z())})))}),Mi=/eslint +react-compiler\/react-compiler: +\["error/;function _i(e){return e.type===oe.Identifier?e.name.startsWith("use"):e.type===oe.MemberExpression&&e.property.type===oe.Identifier?e.property.name.startsWith("use"):!1}var $i=Di({name:An,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:[Li]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(Mi.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let o=null,a=null;if(r.callee.type===oe.Identifier?(o=r.callee.name,a=r.callee):r.callee.type===oe.MemberExpression&&r.callee.property.type===oe.Identifier&&(o=r.callee.property.name,a=r.callee.property),o){let s=t.disallowHooks.find(i=>i.name===o);s&&a&&e.report({node:r,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&&_i(r.callee)){for(let o of r.arguments)if(o.type===oe.ObjectExpression){for(let a of o.properties)if(a.type===oe.Property&&a.key.type===oe.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===oe.Property&&p.key.type===oe.Identifier&&p.key.name===l&&p.value.type===oe.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:An,rule:$i};import{ESLintUtils as zi,TSESTree as Ui}from"@typescript-eslint/utils";var Wi=zi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rn="require-description",Vi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Hi=/^eslint-disable-(next-)?line$/u,Yi=Wi({name:Rn,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let o of n.getAllComments()){let a=Bi(o);a!=null&&(r.has(a.kind)||a.description||e.report({loc:qi(o.loc),messageId:"missingDescription"}))}}}}}),vn={name:Rn,rule:Yi};function Bi(e){let{text:t,description:n}=Ji(e.value);if(!t)return null;let r=Vi.exec(t);if(!r)return null;let o=r[1];if(!o)return null;let a=Hi.test(o);if(e.type===Ui.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let s=t.slice(r.index+o.length);return{kind:o,value:s.trim(),description:n}}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 qi(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Pn(e){return/^use[A-Z0-9]/.test(e)}function Ue(e){return e.type==="Identifier"?Pn(e.name):e.type==="MemberExpression"&&!e.computed&&Ue(e.property)?e.object.type==="Identifier":!1}function Fn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Nn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function jn(e){return!!(e.parent&&e.parent.callee&&Nn(e.parent.callee,"forwardRef"))}function Dn(e){return!!(e.parent&&e.parent.callee&&Nn(e.parent.callee,"memo"))}function At(e){for(;e;){let t=Mn(e);if(t&&(Fn(t)||Ue(t))||jn(e)||Dn(e))return!0;e=e.parent}return!1}function kn(e){return!1}function Rt(e){return!1}var Xi=/eslint +react-compiler\/react-compiler: +\["error/,Ln={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(Xi.test(l.value))return{CallExpression(c){let p=null;c.callee.name==="useMemo"?p="useMemo":c.callee.name==="useCallback"&&(p="useCallback"),p&&e.report({node:c,message:`"${p}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),n=typeof e.getScope=="function"?()=>n():l=>e.sourceCode.getScope(l),r=null,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&&kn(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(T,m){let{cache:y}=g,A=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),A!==void 0)return A;if(l.thrownSegments.includes(T))A=BigInt("0");else if(T.prevSegments.length===0)A=BigInt("1");else{A=BigInt("0");for(let E of T.prevSegments)A+=g(E,C)}return T.reachable&&A===BigInt("0")?y.delete(T.id):y.set(T.id,A),A}function h(T,m){let{cache:y}=h,A=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),A!==void 0)return A;if(l.thrownSegments.includes(T))A=BigInt("0");else if(T.nextSegments.length===0)A=BigInt("1");else{A=BigInt("0");for(let E of T.nextSegments)A+=h(E,C)}return y.set(T.id,A),A}function b(T){let{cache:m}=b,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 A of T.prevSegments){let C=b(A);C<y&&(y=C)}y+=1}return m.set(T.id,y),y}g.cache=new Map,h.cache=new Map,b.cache=new Map;let x=h(l.initialSegment),v=Mn(c),w=At(c),L=v?Fn(v)||Ue(v):jn(c)||Dn(c),P=1/0;for(let T of l.finalSegments){if(!T.reachable)continue;let m=b(T);m<P&&(P=m)}for(let[T,m]of p){if(!T.reachable)continue;let y=T.nextSegments.length===0?P<=b(T):P<b(T),A=g(T)*h(T),C=u.has(T.id);for(let E of m)if(C&&!Rt(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&&A!==x&&!Rt(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(v){let F=`React Hook "${t(E)}" is called in function "${t(v)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node: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&&!Rt(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"&&Pn(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(Ue(l.callee)){let c=On(o),p=On(a),u=c.get(p);u||(u=[],c.set(p,u)),u.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||kn(l.callee))&&l.arguments.length>0&&(r=l)},Identifier(l){r==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===r&&(r=null)},FunctionDeclaration(l){At(l)&&i(n(l))},ArrowFunctionExpression(l){At(l)&&i(n(l))}}}};function Mn(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 On(e){return e[e.length-1]}import{AST_NODE_TYPES as Te}from"@typescript-eslint/utils";function Gi(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function Ki(e){return e.type===Te.Literal&&"regex"in e&&!!e.regex}function Zi(e){let t=e.parent;for(;t;){if(t.type===Te.FunctionDeclaration||t.type===Te.FunctionExpression||t.type===Te.ArrowFunctionExpression||t.type===Te.MethodDefinition)return!1;t=t.parent}return!0}function Qi(e){let t=e.parent;return t?.type===Te.NewExpression&&t.callee.type===Te.Identifier&&t.callee.name==="RegExp"}var vt=Z({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function t(n){Ki(n)&&(Gi(n)||Zi(n)||Qi(n)||e.report({node:n,messageId:"regexShouldBeTopLevel"}))}return{Literal:t}}});var _n={[ht.name]:ht.rule,[tt.name]:tt.rule,[et.name]:et.rule,"rules-of-hooks":Ln,"exhaustive-deps":Wt,"require-description":vn.rule,[nt.name]:nt.rule,[it.name]:it.rule,[xt.name]:xt.rule,[Be.name]:Be.rule,[Qe.name]:Qe.rule,[ct.name]:ct.rule,[It.name]:It.rule,[at.name]:at.rule,[rt.name]:rt.rule,[qe.name]:qe.rule,[Ct.name]:Ct.rule,[Ye.name]:Ye.rule,[Ze.name]:Ze.rule,[mt.name]:mt.rule,[dt.name]:dt.rule,[gt.name]:gt.rule,[St.name]:St.rule,[yt.name]:yt.rule,[wt.name]:wt.rule,[ut.name]:ut.rule,[pt.name]:pt.rule,[vt.name]:vt.rule};var Ia={rules:_n};export{Ia as extendedLintPlugin};
|